Slashdot Mirror


Programmer's Language-Aware Spell Checker?

Jerry Asher writes "Not all of my coworkers are careful about spelling errors. Sometimes this causes real embarrassment as spelling errors creep into software interfaces. Does anyone know of spell checkers for programming languages? I don't want a text spell checker, I want a programming-language-aware spell checker. A spell checker that I can pass all of my code through and will flag spelling errors in function names, variable names, and comments, but will ignore language keywords, language constructs and expressions, and various programming styles (camel code, or underscores, or...). I want a spell checker that knows that void *functionSigniture(char *myRoutine) contains one spelling error. Does anyone have such a thing for Java or C++? Are there any Eclipse plugins that do this?"

26 of 452 comments (clear)

  1. Eclipse WTP 3.3 Europa seems to do this.. almost. by pringlis · · Score: 5, Informative

    The version of Eclipse I run, Eclipse WTP 3.3, does spell checking on comments as standard. Not for variable, function names and the like though. It's a decent first attempt though. In truth, I turned it off within the first few hours. It underlines any mistakes in red which I find really annoying when scanning code as I keep thinking I've seen syntax errors. More often than not my eyes are drawn to a spelling mistake, which in many cases isn't even really a mistake, which distracts me from what I'm actually trying to look at.

  2. Visual Assist by Anonymous Coward · · Score: 3, Informative

    Visual Assist for Visual Studio does this.

    Next silly question, please.

    1. Re:Visual Assist by Anonymous Coward · · Score: 1, Informative

      No, it doesn't. See listed spelling features. It will spell check normal language (looks like only comments) and highlight *mistyped* symbols, not mispelled symbols.

      Next wrong answer, please.

    2. Re:Visual Assist by lanthar · · Score: 3, Informative

      It is important to note that with a large code base, Visual Assist is noticing any time you have a variable or function name that it can't find anywhere else, and highlighting it with the red underline. This is in addition to turning the various keywords, macros, #defines, class names, function names, member variable names, nonmember variable names, and other such things all into their own colors. Granted, if you misspell something everywhere, then it will highlight correctly, and not indicate a problem. It's still a simple thing to notice it and bulk find/replace a string in all files in your project/solution/directory/etc. If you are a walking spellchecker like me, you'll be glad you've made your whole group install it. Also the extra droplists it provides, the wonderful shift insert droplist of previous copy/paste entries, and a variety of other great features will all make you happy to pay the tiny registration fee for each programmer on your team. I'd say it saves me at least 30 minutes of digging through our 2 million lines of code to remember how someone capitalized something or which spelling or abbreviation to use. -A very satisfied VA customer who recommends it to every VS programmer he knows

    3. Re:Visual Assist by Jerry+Coffin · · Score: 2, Informative

      See listed spelling features. It will spell check normal language (looks like only comments) and highlight *mistyped* symbols, not mispelled symbols.

      Just FWIW, it checks typing in both comments and (perhaps more importantly) string literals. It's also "intelligent" enough to know (for example) that '%d' should not be treated as a problem in a string literal. It is true, however, that symbols that are misspelled don't get highlighted, provided the misspelling is consistent.

      --
      The universe is a figment of its own imagination.
  3. Editors with a spell checker by Peter_JS_Blue · · Score: 1, Informative
    On most Linux or BSD distros there is an editor called Kate. This has a spell checker built-in.

    This isn't quite what you want because you have to select the text to be checked but its better than nothing !

    Hope this helps

    --
    Art Makers Just an excuse to show photos of naked women !!
  4. FxCop by W3bbo · · Score: 2, Informative

    Okay, so it's only for Managed Assemblies (C#, VB.NET, J#, etc), but it does spell-checking, acronym-checking, and case-checking, which is nifty. Along with the other slew of introspection rules (some of which are a PITA to implement, even if it does increase the quality of the finished product).

    The $$$ version of Visual Studio (the Team Suite version) comes with an introspection engine for VC++ though, it's not as flexible as FxCop but does the basics.

    Then there's the countless "Spellchecker" plugins available for IDEs everywhere, VS, Eclipse, NetBeans, etc...

  5. Re:Keep text in dedicated files by Roofus · · Score: 2, Informative

    If you maintain a library that is used by customers, that would be a *very* big issue. You just broke backwards compatibility for a spelling fix.

    Overall, the answers to the submitters question are absolutely horrible so far. If the tool he's searching for doesn't exist, it damn well should.

  6. Re:It's a good question ... by Corporate+Troll · · Score: 5, Informative

    As a non-native English speaker, working in a non-native english speaking team (mainly french speaking people) it is a real problem. The biggest problem happens when you search something and don't find it because you wrote it right and your coworker wrote it wrong. (Or the inverse, I don't claim to be perfect in English)

    Sure, you might say, "Write your code in French", but that's not a solution. My mother tongue is Dutch, we have a German coworker, and you never know if the next guy will be Italian. There is also this team that has to maintain code written by Spanish people.... in Spanish.... and they don't know Spanish. Fun times, if you like to hear them curse....

    In multilingual environments this problem increases drastically.

  7. Re:Eclipse WTP 3.3 Europa seems to do this.. almos by iapetus · · Score: 2, Informative

    For the record, 'I' is a word. Also plenty of spellcheckers will ignore one or two letter words.

    The idea isn't anywhere near as nuts as you think it is, provided you make a habit of using meaningful variable/class names.

    --
    ++ Say to Elrond "Hello.".
    Elrond says "No.". Elrond gives you some lunch.
  8. Re:Eclipse WTP 3.3 Europa seems to do this.. almos by thetartanavenger · · Score: 2, Informative

    More like WTF are you on man?? If a compiler is able to work out what a variable is, what piece of code does what, which bit's of text are going to be displayed, then another spell checking program can be written to recognise this too!! It would be tricky, and there are many circumstances where it could be circumvented but why not still use it to prevent a possible spelling error, and the circumstances where it cannot tell what the word is, so what. Those circumstances you learn to spell but there's nothing wrong with another program to help prevent it!

    This is a good idea, and one that can be implemented. Just because it's hard to do it right, and would need to be done seperately for different languages doesn't change the fact it would still be useful and help prevent errors.

    --
    Who need's speling and grammar?
  9. FxCop by Koyaanisqatsi · · Score: 5, Informative

    For .net languages, FxCop does some of this checking, even understanding camel casing and underscores in tokens. And a bunch more, since it is a static code analysis tool.

    http://www.gotdotnet.com/Team/FxCop/

  10. Re:What is wrong with people? by Anonymous Coward · · Score: 1, Informative

    In English enumerations, you have a comma before the last and.


    No, you do. Fowler's asserts "no agreement" and advises your approach in cases of ambiguity. To be specific: the comma would have been obligatory had there been a possibility of reading "spelling and pretty much any other ability..." as two items that make up "programming". This misinterpretation is impossible by virtue of the implied "etc." in the final item.

    It is quite possible that your remark applies to the simplified version of English spoken across the pond ;-), the adherents of which have attempted to codify matters of style as law. But thank you for casting a critical eye on my use of language - I always appreciate educated human feedback! (and rarely appreciate dumb computer feedback, as you might have noticed :-)

    realize that everyone isn't perfect and that spelling isn't viewed as really important by that many, and that a spellchecker is a really useful tool.


    And they might carry on being misunderstood when the spellchecker ignores context or is not available. Every man has his own set of priorities, but only the most arrogant offloads the responsibility of making his language easily decipherable.
  11. Re:Eclipse WTP 3.3 Europa seems to do this.. almos by Anonymous Coward · · Score: 1, Informative

    For the record, 'I' is a word.

    Not exactly. I is a word. Lower case I should get a red line still.

  12. Re:Eclipse WTP 3.3 Europa seems to do this.. almos by bytesex · · Score: 2, Informative

    Yeah, not to nitpick but, you see; 'i', being a variable-name, would be a properly camel-cased 'I' from the point of view of the spellchecker.

    --
    Religion is what happens when nature strikes and groupthink goes wrong.
  13. Re:How about this by Ed+Avis · · Score: 2, Informative

    I should add that if you do use underscores to separate words, just put 'tr/_/ /' in the perl code instead of that [a-z][A-Z] stuff.

    --
    -- Ed Avis ed@membled.com
  14. Re:Eclipse WTP 3.3 Europa seems to do this.. almos by kristoferkarlsson · · Score: 2, Informative

    Sure, it's the halting problem. We all know that. But there are several common cases where you can deduce that there is an infinite loop in the code. It won't catch all infinite loops, but that doesn't make it useless.

    (Suns Java seems to be good at detecting some of those by default when it complains about unreachable return statement)

  15. Re:How about eyeball Mk 1? by SilentChasm · · Score: 2, Informative

    Opera does have a spell check in it. You right click on the text box and select "Check spelling". http://www.opera.com/support/tutorials/opera/spell check/index.dml

  16. linkers/loaders used to generate lists of names by AncientWarrior · · Score: 2, Informative

    how about hacking the linker map file to generate a list of function/variable names? ie, "ld -M". then run the resulting word list through a standard spell checker. the thing is, all you really need is a way ti generate a list of names...

  17. Re:Man Dies Waiting for Eclipse to Launch by ravenlock · · Score: 5, Informative

    Credit where credit is due -- this is an excerpt from Stevey's Tech News, Issue #1.

  18. Re:Man Dies Waiting for Eclipse to Launch by Jaffa · · Score: 1, Informative
    Moderators: this is blatant plaigarism of a Steve Yegge post.

    And it wasn't that funny or topical when he first posted it, earlier this week.

  19. Emacs - ispell-check-comments by SuperKendall · · Score: 2, Informative

    Still a great IDE after all these years...

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  20. Re:Man Dies Waiting for Eclipse to Launch by Anonymous Coward · · Score: 0, Informative
  21. Re:Eclipse WTP 3.3 Europa seems to do this.. almos by DimGeo · · Score: 2, Informative

    1. The stop-problem is undecidable only on a device with infinite RAM, if you put an upper bound on the RAM, you get a decidable problem (in theory only).
    2. There are some practical ways to construct proofs that a loop ends (remember the CS lectures). Sure, it's not a perfect solution, but if you can't construct a proof that the loop ends, you'd better rethink the loop, and possibly rewrite it.

  22. Re:Eclipse WTP 3.3 Europa seems to do this.. almos by DragonWriter · · Score: 2, Informative

    It's actually impossible for the computer to know whether you're creating an infinite loop.


    Its impossible for a computer program to be constructed which can do so for all cases (hence, the halting problem), but that doesn't mean that its impossible to detect some infinite loops, or to detect constructs which are particularly likely to be infinite loops, either of which could, in theory, be useful features in an IDE.

    Spelling/grammar checkers for human language aren't flawless, either, but they still have utility. The fact that perfection in a task is impractical or even provably impossible doesn't rule out useful applications.
  23. Re:Flyspell by dollargonzo · · Score: 2, Informative

    hate replying to myself, but it missed what they key part...

    (require 'flyspell)
    (require 'cc-subword)

    (defvar ps-flyspell-check-subwords nil
    "*Non-nil if Flyspell should check subwords separately.

    If this variable is set to non-nil, an identifier such
    MyLongFunctionName will be treated as four separate words (My,
    Long, Function, Name) for the purposes of Flyspell.")

    (defadvice flyspell-region (around subword-checking (beg end))
    "Check individual subwords if ps-flyspell-check-subwords is set."
    (if ps-flyspell-check-subwords
    ;; mostly copied from flyspell-small-region
    (save-excursion
    (if (> beg end)
    (let ((old beg))
    (setq beg end)
    (setq end old)))
    (goto-char beg)
    (let ((count 0))
    (while (< (point) end)
    (if (and flyspell-issue-message-flag (= count 100))
    (progn
    (message "Spell Checking...%d%%"
    (* 100 (/ (float (- (point) beg)) (- end beg))))
    (setq count 0))
    (setq count (+ 1 count)))
    (if (>= (length (car (save-excursion (flyspell-get-word nil)))) 5)
    (flyspell-word))
    ;; (flyspell-word)
    (sit-for 0)
    (let ((cur (point)))
    (c-forward-subword 1)
    (if (and (< (point) end) (> (point) (+ cur 1)))
    (backward-char 1)))))
    (backward-char 1)
    (if flyspell-issue-message-flag (message "Spell Checking completed."))
    (if (>= (length (car (save-excursion (flyspell-get-word nil)))) 5)
    (flyspell-word) 'nil))
    ad-do-it))

    (ad-activate 'flyspell-region)

    (defun flyspell-get-word (following &optional extra-otherchars)
    "Return the word for spell-checking according to Ispell syntax.
    If optional argument FOLLOWING is non-nil or if `flyspell-following-word'
    is non-nil when called interactively, then the following word
    \(rather than preceding\) is checked when the cursor is not over a word.
    Optional second argument contains otherchars that can be included in word
    many times.

    Word syntax described by `flyspell-dictionary-alist' (which see)."
    (let* ((flyspell-casechars (flyspell-get-casechars))
    (flyspell-casechars-non-initial (if ps-flyspell-check-subwords
    (downcase flyspell-casechars)
    flyspell-casechars))
    (flyspell-not-casechars (flyspell-get-not-casechars))
    (ispell-otherchars (ispell-get-otherchars))
    (ispell-many-otherchars-p (ispell-get-many-otherchars-p))
    (word-regexp (concat flyspell-casechars
    flyspell-casechars-non-initial
    "*\\("
    (if (not (string= "" ispell-otherchars))
    (concat ispell-otherchars "?"))
    (if extra-otherchars
    (concat extra-otherchars "?"))

    --
    BSD is for people who love UNIX. Linux is for those who hate Microsoft.