Community
Participate
Working Groups
Support spell check in C/C++ editor similar to Java.
I guess you haven't experienced a lot of Java development with that *!*#$ spell check turned on. I've eventually had to turn it off. But hey, others may like it.
I like it so far although my experience with it is limited.
I can see how a spell checker may be painful to use, but I have a member of staff who is dyslexic and he struggles to spell anything. With content assist and the compiler picking up syntax errors, misspelt code is usually picked up easily. However, comments are often a mess. It occurs to me that it should be possible for the spell checker to be enabled in comments only - after all content assist is turned off in comments. Having this available would be very useful.
JDT spell checks only comments and - optionally - string literals. I don't think it makes sense to spell check identifiers. Note that the default spellcheck engine is contributed by JDT and there is currently no common framework we could extend or build upon. See also bug 185695.
(In reply to comment #4) > I don't think it makes sense to spell check identifiers. I don't know about that. The new project model is littered with spelling errors :). The latest one: CConfigBasedDescriptorManager.reconsile. Shouldn't that be reconcile?
I'm working on porting JDT spell checker implementation to CDT. Stay tuned.
Created attachment 78526 [details] Implementation of the feature Tony or Markus, please review the patch and initiate the IP review process. Thanks.
Created attachment 78527 [details] Icons for the spelling checker
For the spelling checker to work, "Enable editor problem annotation" option has to be enabled. I've flipped the default for that option to true since it doesn't produce false positives any more. I couldn't figure out a way to access the spelling dictionaries used by JDT and had to create a separate copy of the dictionaries (org.eclipse.cdt.ui/dictionaries).
(In reply to comment #7) > Tony or Markus, please review the patch and initiate the IP review process. > Thanks. Sergey, I had a look at your patch. Basically it looks good. Most of the code is copied from JDT as expected. Some issues remain: - Are the changes in package org.eclipse.cdt.core.parser really necessary? Most of the code is obsolete and will probably be removed anyway. - The patch introduces an optional dependency to o.e.jdt.ui I.e. JDT is required to build CDT, I am not sure everyone is happy with that. - The spelling checker does not distinguish between comments and code - There are some compilation errors against Eclipse 3.3. I assume you coded against a 3.4 milestone. (In reply to comment #9) > I couldn't figure out a way to access the spelling dictionaries used by JDT and > had to create a separate copy of the dictionaries > (org.eclipse.cdt.ui/dictionaries). The following should work: public static URL getDictionaryLocation() throws MalformedURLException { Bundle jdtuiBundle= Platform.getBundle("org.eclipse.jdt.ui"); //$NON-NLS-1$ if (jdtuiBundle != null && (jdtuiBundle.getState() & Bundle.RESOLVED) != 0) { return jdtuiBundle.getEntry("/" + DICTIONARY_LOCATION); //$NON-NLS-1$ } return null; }
The following *does* work ;-) public static URL getDictionaryLocation() throws MalformedURLException { Bundle jdtuiBundle= Platform.getBundle("org.eclipse.jdt.ui"); //$NON-NLS-1$ if (jdtuiBundle != null && (jdtuiBundle.getState() & (Bundle.RESOLVED|Bundle.STARTING|Bundle.ACTIVE)) != 0) { return jdtuiBundle.getEntry("/" + DICTIONARY_LOCATION); //$NON-NLS-1$ } return null; }
The fact that this feature depends on the JDT points out that there's stuff they need to move down to the platform. There are many CDT-based IDEs that do not include the JDT. I'd prefer this functionality be applicable to all. At any rate, this would be a great feature for CDT Ganymede. We still have time to work out ways of removing the JDT dependencies. Let me know if you need help co-ordinating with the JDT team on this.
> - Are the changes in package org.eclipse.cdt.core.parser really necessary? > Most of the code is obsolete and will probably be removed anyway. Couple changes were needed to avoid compilation errors. The rest is just formatting. > - The patch introduces an optional dependency to o.e.jdt.ui > I.e. JDT is required to build CDT, I am not sure everyone is happy with that. Spell check support in Eclipse is weird. Even when you are editing a simple text file it is provided by JDT, not by the platform. I had a choice between reusing JDT provided preferences (General/Editors/Text Editors/Spelling) or providing an independent set of spelling preferences. Unfortunately, the second approach forces user to choose which of the two spelling engines to use for the whole platform, irrespective of the file type. I will soon file bugs against platform/JDT for this. org.eclipse.jdt.internal.ui.text.spelling.DefaultSpellingEngine class has to move to the platform and support an extension point allowing contribution of content type specific spelling engines. > - The spelling checker does not distinguish between comments and code Oops. I'll investigate. > - There are some compilation errors against Eclipse 3.3. I assume you coded > against a 3.4 milestone. Yes. > public static URL getDictionaryLocation() throws MalformedURLException { > Bundle jdtuiBundle= Platform.getBundle("org.eclipse.jdt.ui"); //$NON-NLS-1$ > if (jdtuiBundle != null && (jdtuiBundle.getState() & Bundle.RESOLVED) != 0) { > return jdtuiBundle.getEntry("/" + DICTIONARY_LOCATION); //$NON-NLS-1$ > } > return null; > } Thanks a lot!
(In reply to comment #12) > The fact that this feature depends on the JDT points out that there's stuff > they need to move down to the platform. > > There are many CDT-based IDEs that do not include the JDT. I'd prefer this > functionality be applicable to all. > > At any rate, this would be a great feature for CDT Ganymede. We still have time > to work out ways of removing the JDT dependencies. Let me know if you need help > co-ordinating with the JDT team on this. I'll try to formulate a proposal for moving core spelling checker functionality to the platform and file a bugzilla for it. I will definitely need all help I can get.
Created attachment 79036 [details] Addressed Tony's and Doug's concerns This patch fixes the problem of comments and code being treated the same way. To make it happen I had to completely depart from JDT. The dependency on it is now gone. Unfortunately, when both JDT and CDT are installed, user now has to choose between two spelling engines. Bug 204370 describes the problem. Formatting changes in Parser.java have been reverted.
Created attachment 79456 [details] Better coexistence of C/C++ and Java spell checkers Added CSpellingService class that calls the C/C++ spelling engine on C/C++ content types even when it is not selected in Preferences/General/Editors/Text Editors/Spelling. SpellingEngineDispatcher delegates to the default spelling engine (the JDT one) if it is called for a content type outside of C/C++ realm. This may happen when the C/C++ spelling engine is selected in Preferences/General/Editors/Text Editors/Spelling. Time to initiate an IP review process?
Created attachment 79852 [details] Fixed spell checking of preprocessor directives Unfortunately, there seem to be no general purpose utilities for parsing of preprocessor directives. As a result, CSpellingEngine has to do some low level parsing on its own.
The feature committed to HEAD. For the spelling checker to work, "Enable editor problem annotation" option has to be turned on. It is now enabled by default for new workspaces but has to be turned on for existing ones. Code duplication between CDT and JDT can be avoided when the core of the spell checker gets moved from JDT to the platform (see bug 185695).
(In reply to comment #18) > The feature committed to HEAD. For the spelling checker to work, "Enable editor > problem annotation" option has to be turned on. It is now enabled by default > for new workspaces but has to be turned on for existing ones. > > Code duplication between CDT and JDT can be avoided when the core of the spell > checker gets moved from JDT to the platform (see bug 185695). > Hi Sergey, Does this enhancement make use of the iSpell dictionaries? /org.eclipse.cdt.ui/dictionaries/en_GB.dictionary /org.eclipse.cdt.ui/dictionaries/en_US.dictionary (Are they the same as the ones in JDT?) If so, I'll need to add the third party code info in about.html. Thanks!
(In reply to comment #19) > Hi Sergey, > > Does this enhancement make use of the iSpell dictionaries? > > /org.eclipse.cdt.ui/dictionaries/en_GB.dictionary > /org.eclipse.cdt.ui/dictionaries/en_US.dictionary > > (Are they the same as the ones in JDT?) > > If so, I'll need to add the third party code info in about.html. > > Thanks! Yes, the dictionaries were borrowed from JDT.
(In reply to comment #20) > Yes, the dictionaries were borrowed from JDT. Thanks. I've opened a CQ for this (CQ 3223).