diff options
author | Sergey Prigogin | 2012-04-18 01:15:00 +0000 |
---|---|---|
committer | Sergey Prigogin | 2012-04-18 02:56:18 +0000 |
commit | 885f6f1b7e6a2e6902435d09bd80c0811d19ca04 (patch) | |
tree | 609f2a4336cd18b6addf70a6239748ed01e3c5bd | |
parent | f3f2671d487d66ebdcd48cc5ceb4c667c815f150 (diff) | |
download | org.eclipse.cdt-885f6f1b7e6a2e6902435d09bd80c0811d19ca04.tar.gz org.eclipse.cdt-885f6f1b7e6a2e6902435d09bd80c0811d19ca04.tar.xz org.eclipse.cdt-885f6f1b7e6a2e6902435d09bd80c0811d19ca04.zip |
Cosmetics.
4 files changed, 149 insertions, 790 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java index 1c24b726ce6..ada44c0f132 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java @@ -105,9 +105,9 @@ public class ASTProblem extends ASTNode implements IASTProblem { setOffset(startNumber); setLength(endNumber-startNumber); - this.isError= isError; this.id = id; this.arg = arg; + this.isError= isError; } public ASTProblem(int id, char[] arg, boolean isError) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java index 3d7b127d12f..55c519499b8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java @@ -104,7 +104,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { */ static protected class ProblemAnnotation extends Annotation implements ICAnnotation { private static final String INDEXER_ANNOTATION_TYPE= "org.eclipse.cdt.ui.indexmarker"; //$NON-NLS-1$ - + private final ITranslationUnit fTranslationUnit; private final int fId; private final boolean fIsProblem; @@ -120,65 +120,45 @@ public class CDocumentProvider extends TextFileDocumentProvider { fArguments= isProblem() ? problem.getArguments() : null; setType(problem instanceof CoreSpellingProblem ? SpellingAnnotation.TYPE : INDEXER_ANNOTATION_TYPE); - if (problem instanceof IPersistableProblem) + if (problem instanceof IPersistableProblem) { fMarkerType= ((IPersistableProblem) problem).getMarkerType(); - else + } else { fMarkerType= null; + } } - - /* - * @see ICAnnotation#getArguments() - */ + @Override public String[] getArguments() { return fArguments; } - - /* - * @see ICAnnotation#getId() - */ + @Override public int getId() { return fId; } - - /* - * @see ICAnnotation#isProblem() - */ + @Override public boolean isProblem() { return fIsProblem; } - - /* - * @see ICAnnotation#hasOverlay() - */ + @Override public boolean hasOverlay() { return false; } - - /* - * @see ICAnnotation#getOverlay() - */ + @Override public ICAnnotation getOverlay() { return null; } - - /* - * @see ICAnnotation#addOverlaid(ICAnnotation) - */ + @Override public void addOverlaid(ICAnnotation annotation) { if (fOverlaids == null) fOverlaids= new ArrayList<ICAnnotation>(1); fOverlaids.add(annotation); } - - /* - * @see ICAnnotation#removeOverlaid(ICAnnotation) - */ + @Override public void removeOverlaid(ICAnnotation annotation) { if (fOverlaids != null) { @@ -187,34 +167,25 @@ public class CDocumentProvider extends TextFileDocumentProvider { fOverlaids= null; } } - - /* - * @see ICAnnotation#getOverlaidIterator() - */ + @Override public Iterator<ICAnnotation> getOverlaidIterator() { if (fOverlaids != null) return fOverlaids.iterator(); return null; } - - /* - * @see org.eclipse.cdt.internal.ui.editor.ICAnnotation#getTranslationUnit() - */ + @Override public ITranslationUnit getTranslationUnit() { return fTranslationUnit; } - /* - * @see org.eclipsecjdt.internal.ui.editor.ICAnnotation#getMarkerType() - */ @Override public String getMarkerType() { return fMarkerType; } } - + /** * Internal structure for mapping positions to some value. * The reason for this specific structure is that positions can @@ -222,22 +193,21 @@ public class CDocumentProvider extends TextFileDocumentProvider { * on hash value. */ protected static class ReverseMap { - + static class Entry { Position fPosition; Object fValue; } - + private List<Entry> fList= new ArrayList<Entry>(2); private int fAnchor= 0; - + public ReverseMap() { } - + public Object get(Position position) { - Entry entry; - + // behind anchor int length= fList.size(); for (int i= fAnchor; i < length; i++) { @@ -247,7 +217,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { return entry.fValue; } } - + // before anchor for (int i= 0; i < fAnchor; i++) { entry= fList.get(i); @@ -256,10 +226,10 @@ public class CDocumentProvider extends TextFileDocumentProvider { return entry.fValue; } } - + return null; } - + private int getIndex(Position position) { Entry entry; int length= fList.size(); @@ -270,7 +240,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { } return -1; } - + public void put(Position position, Object value) { int index= getIndex(position); if (index == -1) { @@ -283,13 +253,13 @@ public class CDocumentProvider extends TextFileDocumentProvider { entry.fValue= value; } } - + public void remove(Position position) { int index= getIndex(position); if (index > -1) fList.remove(index); } - + public void clear() { fList.clear(); fAnchor= 0; @@ -300,32 +270,22 @@ public class CDocumentProvider extends TextFileDocumentProvider { * A marker updater which removes problems markers with length 0. */ public static class ProblemMarkerUpdater implements IMarkerUpdater { - /** * Default constructor (executable extension). */ public ProblemMarkerUpdater() { } - /* - * @see org.eclipse.ui.texteditor.IMarkerUpdater#getAttribute() - */ @Override public String[] getAttribute() { return null; } - /* - * @see org.eclipse.ui.texteditor.IMarkerUpdater#getMarkerType() - */ @Override public String getMarkerType() { return ICModelMarker.C_MODEL_PROBLEM_MARKER; } - /* - * @see org.eclipse.ui.texteditor.IMarkerUpdater#updateMarker(org.eclipse.core.resources.IMarker, org.eclipse.jface.text.IDocument, org.eclipse.jface.text.Position) - */ @Override public boolean updateMarker(IMarker marker, IDocument document, Position position) { if (position == null) { @@ -340,37 +300,37 @@ public class CDocumentProvider extends TextFileDocumentProvider { /** * Annotation model dealing with c marker annotations and temporary problems. - * Also acts as a problem requestor for its translation unit. Initially inactive. Must be explicitly - * activated. + * Also acts as a problem requestor for its translation unit. Initially inactive. + * Must be explicitly activated. */ - protected static class TranslationUnitAnnotationModel extends ResourceMarkerAnnotationModel implements IProblemRequestor, IProblemRequestorExtension { - + protected static class TranslationUnitAnnotationModel extends ResourceMarkerAnnotationModel + implements IProblemRequestor, IProblemRequestorExtension { + private static class ProblemRequestorState { - boolean fInsideReportingSequence= false; + boolean fInsideReportingSequence; List<IProblem> fReportedProblems; } - + private ThreadLocal<ProblemRequestorState> fProblemRequestorState= new ThreadLocal<ProblemRequestorState>(); private int fStateCount= 0; - + private ITranslationUnit fTranslationUnit; private List<ProblemAnnotation> fGeneratedAnnotations; private IProgressMonitor fProgressMonitor; - private boolean fIsActive= false; - + private boolean fIsActive; + private ReverseMap fReverseMap= new ReverseMap(); - private List<CMarkerAnnotation> fPreviouslyOverlaid= null; + private List<CMarkerAnnotation> fPreviouslyOverlaid; private List<CMarkerAnnotation> fCurrentlyOverlaid= new ArrayList<CMarkerAnnotation>(); - - + public TranslationUnitAnnotationModel(IResource resource) { super(resource); } - + public void setTranslationUnit(ITranslationUnit unit) { fTranslationUnit= unit; } - + @Override protected MarkerAnnotation createMarkerAnnotation(IMarker marker) { String markerType= MarkerUtilities.getMarkerType(marker); @@ -379,22 +339,18 @@ public class CDocumentProvider extends TextFileDocumentProvider { } return super.createMarkerAnnotation(marker); } - - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#createPositionFromMarker(org.eclipse.core.resources.IMarker) - */ + @Override protected Position createPositionFromMarker(IMarker marker) { int start= MarkerUtilities.getCharStart(marker); int end= MarkerUtilities.getCharEnd(marker); - + if (start > end) { end= start + end; start= end - start; end= end - start; } - + if (start == -1 && end == -1) { // marker line number is 1-based int line= MarkerUtilities.getLineNumber(marker); @@ -414,56 +370,48 @@ public class CDocumentProvider extends TextFileDocumentProvider { } } } - + if (start > -1 && end > -1) return new Position(start, end - start); - + return null; } - /* - * @see org.eclipse.jface.text.source.AnnotationModel#createAnnotationModelEvent() - */ + @Override protected AnnotationModelEvent createAnnotationModelEvent() { return new TranslationUnitAnnotationModelEvent(this, getResource()); } - + protected Position createPositionFromProblem(IProblem problem) { int start= problem.getSourceStart(); if (start < 0) return null; - + int length= problem.getSourceEnd() - problem.getSourceStart() + 1; if (length < 0) return null; return new Position(start, length); } - - /* - * @see IProblemRequestor#beginReporting() - */ + @Override public void beginReporting() { ProblemRequestorState state= fProblemRequestorState.get(); if (state == null) internalBeginReporting(false); } - - /* - * @see org.eclipse.cdt.internal.ui.text.java.IProblemRequestorExtension#beginReportingSequence() - */ + @Override public void beginReportingSequence() { ProblemRequestorState state= fProblemRequestorState.get(); if (state == null) internalBeginReporting(true); } - + /** * Sets up the infrastructure necessary for problem reporting. - * + * * @param insideReportingSequence <code>true</code> if this method - * call is issued from inside a reporting sequence + * call is issued from inside a reporting sequence */ private void internalBeginReporting(boolean insideReportingSequence) { if (fTranslationUnit != null) { @@ -476,10 +424,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { } } } - - /* - * @see IProblemRequestor#acceptProblem(IProblem) - */ + @Override public void acceptProblem(IProblem problem) { if (isActive()) { @@ -488,95 +433,85 @@ public class CDocumentProvider extends TextFileDocumentProvider { state.fReportedProblems.add(problem); } } - - /* - * @see IProblemRequestor#endReporting() - */ + @Override public void endReporting() { ProblemRequestorState state= fProblemRequestorState.get(); if (state != null && !state.fInsideReportingSequence) internalEndReporting(state); } - - /* - * @see org.eclipse.cdt.internal.ui.text.java.IProblemRequestorExtension#endReportingSequence() - */ + @Override public void endReportingSequence() { ProblemRequestorState state= fProblemRequestorState.get(); if (state != null && state.fInsideReportingSequence) internalEndReporting(state); } - + private void internalEndReporting(ProblemRequestorState state) { int stateCount= 0; - synchronized(getLockObject()) { - -- fStateCount; + synchronized (getLockObject()) { + --fStateCount; stateCount= fStateCount; fProblemRequestorState.set(null); } - + if (stateCount == 0 && isActive()) reportProblems(state.fReportedProblems); } - + /** * Signals the end of problem reporting. */ private void reportProblems(List<IProblem> reportedProblems) { if (fProgressMonitor != null && fProgressMonitor.isCanceled()) return; - + boolean temporaryProblemsChanged= false; - + synchronized (getLockObject()) { boolean isCanceled= false; - + fPreviouslyOverlaid= fCurrentlyOverlaid; fCurrentlyOverlaid= new ArrayList<CMarkerAnnotation>(); - + if (fGeneratedAnnotations.size() > 0) { temporaryProblemsChanged= true; removeAnnotations(fGeneratedAnnotations, false, true); fGeneratedAnnotations.clear(); } - - if (reportedProblems != null && reportedProblems.size() > 0) { - Iterator<IProblem> e= reportedProblems.iterator(); - while (e.hasNext()) { - + + if (reportedProblems != null) { + for (IProblem problem : reportedProblems) { if (fProgressMonitor != null && fProgressMonitor.isCanceled()) { isCanceled= true; break; } - - IProblem problem= e.next(); + Position position= createPositionFromProblem(problem); if (position != null) { - try { ProblemAnnotation annotation= new ProblemAnnotation(problem, fTranslationUnit); overlayMarkers(position, annotation); addAnnotation(annotation, position, false); fGeneratedAnnotations.add(annotation); - + temporaryProblemsChanged= true; } catch (BadLocationException x) { - // ignore invalid position + // Ignore invalid position } } } } - + removeMarkerOverlays(isCanceled); fPreviouslyOverlaid= null; } - + if (temporaryProblemsChanged) fireModelChanged(); } - + private void removeMarkerOverlays(boolean isCanceled) { if (isCanceled) { fCurrentlyOverlaid.addAll(fPreviouslyOverlaid); @@ -588,7 +523,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { } } } - + /** * Overlays value with problem annotation. * @param problemAnnotation @@ -601,28 +536,28 @@ public class CDocumentProvider extends TextFileDocumentProvider { fPreviouslyOverlaid.remove(annotation); fCurrentlyOverlaid.add(annotation); } - } else { } } - + private void overlayMarkers(Position position, ProblemAnnotation problemAnnotation) { Object value= getAnnotations(position); if (value instanceof List<?>) { List<?> list= (List<?>) value; - for (Object element : list) + for (Object element : list) { setOverlay(element, problemAnnotation); + } } else { setOverlay(value, problemAnnotation); } } - + /** * Tells this annotation model to collect temporary problems from now on. */ private void startCollectingProblems() { fGeneratedAnnotations= new ArrayList<ProblemAnnotation>(); } - + /** * Tells this annotation model to no longer collect temporary problems. */ @@ -631,26 +566,17 @@ public class CDocumentProvider extends TextFileDocumentProvider { removeAnnotations(fGeneratedAnnotations, true, true); fGeneratedAnnotations= null; } - - /* - * @see IProblemRequestor#isActive() - */ + @Override public boolean isActive() { return fIsActive; } - - /* - * @see IProblemRequestorExtension#setProgressMonitor(IProgressMonitor) - */ + @Override public void setProgressMonitor(IProgressMonitor monitor) { fProgressMonitor= monitor; } - - /* - * @see IProblemRequestorExtension#setIsActive(boolean) - */ + @Override public void setIsActive(boolean isActive) { if (fIsActive != isActive) { @@ -661,21 +587,18 @@ public class CDocumentProvider extends TextFileDocumentProvider { stopCollectingProblems(); } } - + private Object getAnnotations(Position position) { synchronized (getLockObject()) { return fReverseMap.get(position); } } - - /* - * @see AnnotationModel#addAnnotation(Annotation, Position, boolean) - */ + @Override @SuppressWarnings({ "unchecked" }) protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException { super.addAnnotation(annotation, position, fireModelChanged); - + synchronized (getLockObject()) { Object cached= fReverseMap.get(position); if (cached == null) { @@ -691,10 +614,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { } } } - - /* - * @see AnnotationModel#removeAllAnnotations(boolean) - */ + @Override protected void removeAllAnnotations(boolean fireModelChanged) { super.removeAllAnnotations(fireModelChanged); @@ -702,10 +622,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { fReverseMap.clear(); } } - - /* - * @see AnnotationModel#removeAnnotation(Annotation, boolean) - */ + @Override protected void removeAnnotation(Annotation annotation, boolean fireModelChanged) { Position position= getPosition(annotation); @@ -727,16 +644,12 @@ public class CDocumentProvider extends TextFileDocumentProvider { } protected static class GlobalAnnotationModelListener implements IAnnotationModelListener, IAnnotationModelListenerExtension { - private ListenerList fListenerList; - + public GlobalAnnotationModelListener() { fListenerList= new ListenerList(ListenerList.IDENTITY); } - - /** - * @see IAnnotationModelListener#modelChanged(IAnnotationModel) - */ + @Override public void modelChanged(IAnnotationModel model) { Object[] listeners= fListenerList.getListeners(); @@ -745,9 +658,6 @@ public class CDocumentProvider extends TextFileDocumentProvider { } } - /** - * @see IAnnotationModelListenerExtension#modelChanged(AnnotationModelEvent) - */ @Override public void modelChanged(AnnotationModelEvent event) { Object[] listeners= fListenerList.getListeners(); @@ -757,16 +667,16 @@ public class CDocumentProvider extends TextFileDocumentProvider { } } } - + public void addListener(IAnnotationModelListener listener) { fListenerList.add(listener); } - + public void removeListener(IAnnotationModelListener listener) { fListenerList.remove(listener); } } - + /** Preference key for temporary problems */ private final static String HANDLE_TEMPORARY_PROBLEMS= PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS; @@ -775,9 +685,6 @@ public class CDocumentProvider extends TextFileDocumentProvider { /** Annotation model listener added to all created CU annotation models */ private GlobalAnnotationModelListener fGlobalAnnotationModelListener; - /** - * - */ public CDocumentProvider() { super(); IDocumentProvider parentProvider= new ExternalSearchDocumentProvider(); @@ -794,9 +701,6 @@ public class CDocumentProvider extends TextFileDocumentProvider { CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyListener); } - /* - * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#connect(java.lang.Object) - */ @Override public void connect(Object element) throws CoreException { super.connect(element); @@ -810,9 +714,8 @@ public class CDocumentProvider extends TextFileDocumentProvider { /** * Creates a translation unit from the given file. - * - * @param file - * the file from which to create the translation unit + * + * @param file the file from which to create the translation unit */ protected ITranslationUnit createTranslationUnit(IFile file) { Object element = CoreModel.getDefault().create(file); @@ -820,7 +723,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { return (ITranslationUnit) element; } if (element == null) { - // not in a source folder? + // Not in a source folder? ICProject cproject= CoreModel.getDefault().create(file.getProject()); if (cproject != null) { String contentTypeId= CoreModel.getRegistedContentTypeId(file.getProject(), file.getName()); @@ -832,25 +735,16 @@ public class CDocumentProvider extends TextFileDocumentProvider { return null; } - /* - * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createEmptyFileInfo() - */ @Override protected FileInfo createEmptyFileInfo() { return new TranslationUnitInfo(); } - /* - * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createAnnotationModel(org.eclipse.core.resources.IFile) - */ @Override protected IAnnotationModel createAnnotationModel(IFile file) { return new TranslationUnitAnnotationModel(file); } - /* - * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createFileInfo(java.lang.Object) - */ @Override protected FileInfo createFileInfo(Object element) throws CoreException { ITranslationUnit original = null; @@ -876,7 +770,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { if (original == null) { return null; } - + FileInfo info = super.createFileInfo(element); if (!(info instanceof TranslationUnitInfo)) return null; @@ -915,7 +809,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { } /** - * Try to synthesize an ITranslationUnit out of thin air. + * Tries to synthesize an ITranslationUnit out of thin air. * @param location the file system location of the file in question * @return a translation unit or <code>null</code> */ @@ -931,7 +825,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { } /** - * Try to synthesize an ITranslationUnit out of thin air. + * Tries to synthesize an ITranslationUnit out of thin air. * @param uri the URU of the file in question * @return a translation unit or <code>null</code> */ @@ -946,10 +840,6 @@ public class CDocumentProvider extends TextFileDocumentProvider { return null; } - /* - * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#disposeFileInfo(java.lang.Object, - * org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo) - */ @Override protected void disposeFileInfo(Object element, FileInfo info) { if (info instanceof TranslationUnitInfo) { @@ -1020,25 +910,17 @@ public class CDocumentProvider extends TextFileDocumentProvider { } } - /* - * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createSaveOperation(java.lang.Object, org.eclipse.jface.text.IDocument, boolean) - */ @Override protected DocumentProviderOperation createSaveOperation(final Object element, final IDocument document, final boolean overwrite) throws CoreException { final FileInfo info= getFileInfo(element); if (info instanceof TranslationUnitInfo) { return new DocumentProviderOperation() { - /* - * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor) - */ @Override protected void execute(IProgressMonitor monitor) throws CoreException { commitWorkingCopy(monitor, element, (TranslationUnitInfo) info, overwrite); } - /* - * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#getSchedulingRule() - */ + @Override public ISchedulingRule getSchedulingRule() { if (info.fElement instanceof IFileEditorInput) { @@ -1055,7 +937,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { /** * Removes trailing whitespaces from changed lines and adds newline at the end of the file, * if the last line of the file was changed. - * @throws BadLocationException + * @throws BadLocationException */ private void performSaveActions(ITextFileBuffer buffer, IProgressMonitor monitor) throws CoreException { if (shouldRemoveTrailingWhitespace() || shouldAddNewlineAtEof()) { @@ -1099,7 +981,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { return PreferenceConstants.getPreferenceStore().getBoolean( PreferenceConstants.REMOVE_TRAILING_WHITESPACE_LIMIT_TO_EDITED_LINES); } - + private static boolean needsChangedRegions() { return shouldRemoveTrailingWhitespace() && isLimitedRemoveTrailingWhitespace(); } @@ -1182,7 +1064,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { // } // return true; // } - + /** * Returns the preference whether handling temporary problems is enabled. */ @@ -1190,7 +1072,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); return store.getBoolean(HANDLE_TEMPORARY_PROBLEMS); } - + /** * Switches the state of problem acceptance according to the value in the preference store. */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java index 570a59fd135..a58b7463bc6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java @@ -10,7 +10,6 @@ * Anton Leherbauer (Wind River Systems) - Adapted for CDT * Markus Schorn (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.ui.editor; import org.eclipse.jface.resource.ColorRegistry; @@ -26,7 +25,6 @@ import org.eclipse.cdt.ui.CUIPlugin; * @since 4.0 */ public abstract class SemanticHighlighting { - /** * @return the preference key, will be augmented by a prefix and a suffix for each preference */ @@ -126,5 +124,4 @@ public abstract class SemanticHighlighting { return rgb; return defaultRGB; } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java index 73f17530039..9f199957714 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java @@ -9,7 +9,6 @@ * IBM Corporation - initial API and implementation * Anton Leherbauer (Wind River Systems) - Adapted for CDT *******************************************************************************/ - package org.eclipse.cdt.internal.ui.editor; import org.eclipse.core.runtime.CoreException; @@ -74,117 +73,117 @@ public class SemanticHighlightings { /** * A named preference part that controls the highlighting of static fields. */ - public static final String STATIC_FIELD="staticField"; //$NON-NLS-1$ + public static final String STATIC_FIELD= "staticField"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of fields. */ - public static final String FIELD="field"; //$NON-NLS-1$ + public static final String FIELD= "field"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of method declarations. */ - public static final String METHOD_DECLARATION="methodDeclaration"; //$NON-NLS-1$ + public static final String METHOD_DECLARATION= "methodDeclaration"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of static method invocations. */ - public static final String STATIC_METHOD_INVOCATION="staticMethod"; //$NON-NLS-1$ + public static final String STATIC_METHOD_INVOCATION= "staticMethod"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of function declarations. */ - public static final String FUNCTION_DECLARATION="functionDeclaration"; //$NON-NLS-1$ + public static final String FUNCTION_DECLARATION= "functionDeclaration"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of functions. */ - public static final String FUNCTION="function"; //$NON-NLS-1$ + public static final String FUNCTION= "function"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of local variables. */ - public static final String LOCAL_VARIABLE_DECLARATION="localVariableDeclaration"; //$NON-NLS-1$ + public static final String LOCAL_VARIABLE_DECLARATION= "localVariableDeclaration"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of local variable references. */ - public static final String LOCAL_VARIABLE="localVariable"; //$NON-NLS-1$ + public static final String LOCAL_VARIABLE= "localVariable"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of global variables. */ - public static final String GLOBAL_VARIABLE="globalVariable"; //$NON-NLS-1$ + public static final String GLOBAL_VARIABLE= "globalVariable"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of parameter variables. */ - public static final String PARAMETER_VARIABLE="parameterVariable"; //$NON-NLS-1$ + public static final String PARAMETER_VARIABLE= "parameterVariable"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of template parameters. */ - public static final String TEMPLATE_PARAMETER="templateParameter"; //$NON-NLS-1$ + public static final String TEMPLATE_PARAMETER= "templateParameter"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of methods. */ - public static final String METHOD="method"; //$NON-NLS-1$ + public static final String METHOD= "method"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of classes. */ - public static final String CLASS="class"; //$NON-NLS-1$ + public static final String CLASS= "class"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of enums. */ - public static final String ENUM="enum"; //$NON-NLS-1$ + public static final String ENUM= "enum"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of macro references. */ - public static final String MACRO_REFERENCE="macroSubstitution"; //$NON-NLS-1$ + public static final String MACRO_REFERENCE= "macroSubstitution"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of macro definitions. */ - public static final String MACRO_DEFINITION="macroDefinition"; //$NON-NLS-1$ + public static final String MACRO_DEFINITION= "macroDefinition"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of typedefs. */ - public static final String TYPEDEF="typedef"; //$NON-NLS-1$ + public static final String TYPEDEF= "typedef"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of namespaces. */ - public static final String NAMESPACE="namespace"; //$NON-NLS-1$ + public static final String NAMESPACE= "namespace"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of labels. */ - public static final String LABEL="label"; //$NON-NLS-1$ + public static final String LABEL= "label"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of enumerators. */ - public static final String ENUMERATOR="enumerator"; //$NON-NLS-1$ + public static final String ENUMERATOR= "enumerator"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of problems. */ - public static final String PROBLEM="problem"; //$NON-NLS-1$ + public static final String PROBLEM= "problem"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of external SDK. */ - public static final String EXTERNAL_SDK="externalSDK"; //$NON-NLS-1$ + public static final String EXTERNAL_SDK= "externalSDK"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of operators that have been overloaded. */ - public static final String OVERLOADED_OPERATOR="overloadedOperator"; //$NON-NLS-1$ + public static final String OVERLOADED_OPERATOR= "overloadedOperator"; //$NON-NLS-1$ /** Init debugging mode */ @@ -199,63 +198,41 @@ public class SemanticHighlightings { * Semantic highlighting for static fields. */ private static final class StaticFieldHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return STATIC_FIELD; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return new RGB(0, 0, 192); } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_staticField; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { - IASTName name= (IASTName)node; + IASTName name= (IASTName) node; if (name instanceof ICPPASTQualifiedName && name.isReference()) { return false; } @@ -272,63 +249,41 @@ public class SemanticHighlightings { * Semantic highlighting for fields. */ private static final class FieldHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return FIELD; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return new RGB(0, 0, 192); } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_field; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { - IASTName name= (IASTName)node; + IASTName name= (IASTName) node; if (name instanceof ICPPASTQualifiedName && name.isReference()) { return false; } @@ -345,58 +300,36 @@ public class SemanticHighlightings { * Semantic highlighting for method declarations. */ private static final class MethodDeclarationHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return METHOD_DECLARATION; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_methodDeclaration; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); @@ -404,7 +337,7 @@ public class SemanticHighlightings { return false; if (node instanceof IASTName) { - IASTName name= (IASTName)node; + IASTName name= (IASTName) node; if (!name.isReference()) { IBinding binding= token.getBinding(); if (binding instanceof ICPPMethod) { @@ -417,7 +350,7 @@ public class SemanticHighlightings { } if (node instanceof ICPPASTFunctionDeclarator) { if (name instanceof ICPPASTQualifiedName) { - ICPPASTQualifiedName qName= (ICPPASTQualifiedName)name; + ICPPASTQualifiedName qName= (ICPPASTQualifiedName) name; IASTName[] names= qName.getNames(); if (names.length > 1) { if (names[names.length - 2].getBinding() instanceof ICPPClassType) { @@ -444,63 +377,41 @@ public class SemanticHighlightings { * Semantic highlighting for static method invocations. */ private static final class StaticMethodInvocationHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return STATIC_METHOD_INVOCATION; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_staticMethodInvocation; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { - IASTName name= (IASTName)node; + IASTName name= (IASTName) node; if (name instanceof ICPPASTQualifiedName) { return false; } @@ -509,7 +420,7 @@ public class SemanticHighlightings { } IBinding binding= token.getBinding(); if (binding instanceof ICPPMethod && !(binding instanceof IProblemBinding)) { - return ((ICPPMethod)binding).isStatic(); + return ((ICPPMethod) binding).isStatic(); } } return false; @@ -520,65 +431,43 @@ public class SemanticHighlightings { * Semantic highlighting for methods. */ private static final class MethodHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return METHOD; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_method; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTImplicitName) return false; if (node instanceof IASTName) { - IASTName name= (IASTName)node; + IASTName name= (IASTName) node; if (name instanceof ICPPASTQualifiedName && name.isReference()) { return false; } @@ -589,65 +478,42 @@ public class SemanticHighlightings { } return false; } - } /** * Semantic highlighting for function declarations. */ private static final class FunctionDeclarationHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return FUNCTION_DECLARATION; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_functionDeclaration; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); @@ -655,11 +521,10 @@ public class SemanticHighlightings { return false; if (node instanceof IASTName) { - IASTName name= (IASTName)node; + IASTName name= (IASTName) node; if (name.isDeclaration()) { IBinding binding= token.getBinding(); - if (binding instanceof IFunction - && !(binding instanceof ICPPMethod)) { + if (binding instanceof IFunction && !(binding instanceof ICPPMethod)) { return true; } else if (binding instanceof IProblemBinding) { // try to derive from AST @@ -690,65 +555,43 @@ public class SemanticHighlightings { * Semantic highlighting for functions. */ private static final class FunctionHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return FUNCTION; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_function; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTImplicitName) return false; if (node instanceof IASTName) { - IASTName name= (IASTName)node; + IASTName name= (IASTName) node; if (name instanceof ICPPASTQualifiedName && name.isReference()) { return false; } @@ -765,63 +608,41 @@ public class SemanticHighlightings { * Semantic highlighting for local variable declarations. */ private static final class LocalVariableDeclarationHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return LOCAL_VARIABLE_DECLARATION; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return new RGB(128, 0, 0); } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_localVariableDeclaration; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { - IASTName name= (IASTName)node; + IASTName name= (IASTName) node; if (name.isDeclaration()) { IBinding binding= token.getBinding(); if (binding instanceof IVariable @@ -841,70 +662,47 @@ public class SemanticHighlightings { } return false; } - -} + } /** * Semantic highlighting for local variables. */ private static final class LocalVariableHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return LOCAL_VARIABLE; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_localVariable; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { - IASTName name= (IASTName)node; + IASTName name= (IASTName) node; if (name.isReference()) { IBinding binding= token.getBinding(); if (binding instanceof IVariable @@ -940,69 +738,47 @@ public class SemanticHighlightings { } return false; } -} + } /** * Semantic highlighting for global variables. */ private static final class GlobalVariableHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return GLOBAL_VARIABLE; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_globalVariable; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { - IASTName name= (IASTName)node; + IASTName name= (IASTName) node; if (name instanceof ICPPASTQualifiedName) { return false; } @@ -1024,65 +800,42 @@ public class SemanticHighlightings { } return false; } - } /** * Semantic highlighting for parameter variables. */ private static final class ParameterVariableHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return PARAMETER_VARIABLE; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_parameterVariable; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IBinding binding= token.getBinding(); @@ -1097,58 +850,36 @@ public class SemanticHighlightings { * Semantic highlighting for template parameters. */ private static final class TemplateParameterHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return TEMPLATE_PARAMETER; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return new RGB(100, 70, 50); } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_templateParameter; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); @@ -1166,58 +897,36 @@ public class SemanticHighlightings { * Semantic highlighting for classes. */ private static final class ClassHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return CLASS; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return new RGB(0, 80, 50); } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_classes; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); @@ -1238,58 +947,36 @@ public class SemanticHighlightings { * Semantic highlighting for enums. */ private static final class EnumHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return ENUM; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return new RGB(100, 70, 50); } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_enums; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); @@ -1307,58 +994,36 @@ public class SemanticHighlightings { * Semantic highlighting for macro references. */ private static final class MacroReferenceHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return MACRO_REFERENCE; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_macroSubstitution; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IBinding binding= token.getBinding(); @@ -1376,58 +1041,36 @@ public class SemanticHighlightings { * Semantic highlighting for macro definitions. */ private static final class MacroDefinitionHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return MACRO_DEFINITION; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_macroDefintion; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IBinding binding= token.getBinding(); @@ -1445,63 +1088,41 @@ public class SemanticHighlightings { * Semantic highlighting for typedefs. */ private static final class TypedefHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return TYPEDEF; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return new RGB(0, 80, 50); } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_typeDef; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { - IASTName name= (IASTName)node; + IASTName name= (IASTName) node; if (name instanceof ICPPASTQualifiedName) { return false; } @@ -1518,58 +1139,36 @@ public class SemanticHighlightings { * Semantic highlighting for namespaces. */ private static final class NamespaceHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return NAMESPACE; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_namespace; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IBinding binding= token.getBinding(); @@ -1584,58 +1183,36 @@ public class SemanticHighlightings { * Semantic highlighting for labels. */ private static final class LabelHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return LABEL; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_label; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IBinding binding= token.getBinding(); @@ -1650,63 +1227,41 @@ public class SemanticHighlightings { * Semantic highlighting for enumerators. */ private static final class EnumeratorHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return ENUMERATOR; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return new RGB(0, 0, 192); } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_enumerator; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { - IASTName name= (IASTName)node; + IASTName name= (IASTName) node; if (name instanceof ICPPASTQualifiedName) { return false; } @@ -1723,66 +1278,41 @@ public class SemanticHighlightings { * Semantic highlighting for problems. */ private static final class ProblemHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return PROBLEM; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return new RGB(224, 0, 0); } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isStrikethroughByDefault() - */ @Override public boolean isStrikethroughByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_problem; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); @@ -1801,71 +1331,46 @@ public class SemanticHighlightings { * Semantic highlighting for external SDK references. */ private static final class ExternalSDKHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return EXTERNAL_SDK; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return new RGB(100, 40, 128); } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isStrikethroughByDefault() - */ @Override public boolean isStrikethroughByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return true; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_externalSDK; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { - IASTName name= (IASTName)node; + IASTName name= (IASTName) node; if (name instanceof ICPPASTQualifiedName) { return false; } @@ -1915,69 +1420,46 @@ public class SemanticHighlightings { * Semantic highlighting for functions. */ private static final class OverloadedOperatorHighlighting extends SemanticHighlighting { - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() - */ @Override public String getPreferenceKey() { return OVERLOADED_OPERATOR; } - @Override public boolean requiresImplicitNames() { return true; } - - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() - */ @Override public RGB getDefaultDefaultTextColor() { return new RGB(200, 100, 0); // orange } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() - */ @Override public boolean isBoldByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() - */ @Override public boolean isItalicByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() - */ @Override public boolean isEnabledByDefault() { return false; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() - */ @Override public String getDisplayName() { return CEditorMessages.SemanticHighlighting_overloadedOperators; } - /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) - */ @Override public boolean consumes(SemanticToken token) { IASTNode node = token.getNode(); - // so far we only have implicit names for overloaded operators and destructors, so this works + // So far we only have implicit names for overloaded operators and destructors, + // so this works. if (node instanceof IASTImplicitName) { IASTImplicitName name = (IASTImplicitName) node; if (name.isReference() && name.isOperator()) { @@ -2159,16 +1641,14 @@ public class SemanticHighlightings { return false; } SemanticHighlighting[] highlightings= getSemanticHighlightings(); - boolean enable= false; for (SemanticHighlighting highlighting : highlightings) { String enabledKey= getEnabledPreferenceKey(highlighting); if (store.getBoolean(enabledKey)) { - enable= true; - break; + return true; } } - return enable; + return false; } /** |