diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java index e9534bb854a..6c248c9182d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,7 +27,7 @@ import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings; */ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { - private static final boolean PRINT_POSITIONS= false; + private static final boolean PRINT_POSITIONS= true; private static final Class THIS= SemanticHighlightingTest.class; @@ -35,17 +35,6 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { return new SemanticHighlightingTestSetup(new TestSuite(THIS), "/SHTest/src/SHTest.cpp"); } -// public void testStaticConstFieldHighlighting() throws Exception { -// setUpSemanticHighlighting(SemanticHighlightings.STATIC_CONST_FIELD); -// Position[] expected= new Position[] { -// createPosition(6, 18, 16), -// createPosition(35, 37, 16), -// }; -// Position[] actual= getSemanticHighlightingPositions(); -//// System.out.println(toString(actual)); -// assertEqualPositions(expected, actual); -// } - public void testStaticFieldHighlighting() throws Exception { setUpSemanticHighlighting(SemanticHighlightings.STATIC_FIELD); Position[] actual= getSemanticHighlightingPositions(); @@ -108,12 +97,9 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { createPosition(63, 8, 10), createPosition(77, 4, 13), createPosition(104, 4, 26), - createPosition(104, 20, 10), createPosition(108, 4, 25), - createPosition(108, 20, 9), createPosition(113, 4, 32), - createPosition(113, 20, 16), - }; + }; if (PRINT_POSITIONS) System.out.println(toString(actual)); assertEqualPositions(expected, actual); } @@ -129,50 +115,25 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { createPosition(63, 8, 10), createPosition(77, 4, 13), createPosition(104, 4, 26), - createPosition(104, 20, 10), createPosition(108, 4, 25), - createPosition(108, 20, 9), createPosition(113, 4, 32), - createPosition(113, 20, 16), createPosition(114, 23, 9), createPosition(118, 4, 15), - }; + }; Position[] actual= getSemanticHighlightingPositions(); if (PRINT_POSITIONS) System.out.println(toString(actual)); assertEqualPositions(expected, actual); } - // public void testStaticMethodInvocationHighlighting() throws Exception { -// setUpSemanticHighlighting(SemanticHighlightings.STATIC_METHOD_INVOCATION); -// Position[] expected= new Position[] { -// }; -// Position[] actual= getSemanticHighlightingPositions(); -// System.out.println(toString(actual)); -// assertEqualPositions(expected, actual); -// } - - /* - */ -// public void testVirtualMethodInvocationHighlighting() throws Exception { -// setUpSemanticHighlighting(SemanticHighlightings.VIRTUAL_METHOD_INVOCATION); -// Position[] expected= new Position[] { -// createPosition(11, 2, 14), -// }; -// Position[] actual= getSemanticHighlightingPositions(); -//// System.out.println(toString(actual)); -// assertEqualPositions(expected, actual); -// } - -// public void testInheritedMethodInvocationHighlighting() throws Exception { -// setUpSemanticHighlighting(SemanticHighlightings.INHERITED_METHOD_INVOCATION); -// Position[] expected= new Position[] { -// createPosition(12, 2, 8), -// createPosition(15, 17, 8), -// }; -// Position[] actual= getSemanticHighlightingPositions(); -//// System.out.println(toString(actual)); -// assertEqualPositions(expected, actual); -// } + public void testStaticMethodInvocationHighlighting() throws Exception { + setUpSemanticHighlighting(SemanticHighlightings.STATIC_METHOD_INVOCATION); + Position[] expected= new Position[] { + createPosition(118, 4, 15), + }; + Position[] actual= getSemanticHighlightingPositions(); + System.out.println(toString(actual)); + assertEqualPositions(expected, actual); + } public void testLocalVariableDeclarationHighlighting() throws Exception { setUpSemanticHighlighting(SemanticHighlightings.LOCAL_VARIABLE_DECLARATION); @@ -206,7 +167,6 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { Position[] expected= new Position[] { createPosition(11, 20, 1), createPosition(28, 35, 3), - createPosition(29, 8, 19), createPosition(30, 19, 3), createPosition(77, 21, 4), createPosition(77, 30, 4), @@ -234,16 +194,6 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { assertEqualPositions(expected, actual); } -// public void testTemplateArgumentHighlighting() throws Exception { -// setUpSemanticHighlighting(SemanticHighlightings.TEMPLATE_ARGUMENT); -// Position[] actual= getSemanticHighlightingPositions(); -// Position[] expected= new Position[] { -// createPosition(41, 8, 6), -// }; -//// System.out.println(toString(actual)); -// assertEqualPositions(expected, actual); -// } - public void testEnumHighlighting() throws Exception { setUpSemanticHighlighting(SemanticHighlightings.ENUM); Position[] actual= getSemanticHighlightingPositions(); @@ -282,11 +232,13 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { createPosition(74, 35, 13), createPosition(83, 25, 24), createPosition(83, 52, 13), - createPosition(83, 52, 24), createPosition(83, 70, 5), createPosition(86, 7, 9), createPosition(90, 6, 8), createPosition(94, 8, 8), + createPosition(104, 4, 14), + createPosition(108, 4, 14), + createPosition(113, 4, 14), createPosition(114, 4, 9), createPosition(116, 4, 8), }; @@ -314,11 +266,9 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { createPosition(11, 5, 10), createPosition(12, 12, 16), createPosition(19, 16, 10), - createPosition(29, 8, 19), createPosition(30, 8, 10), createPosition(98, 8, 13), createPosition(99, 1, 16), - createPosition(120, 4, 17), }; if (PRINT_POSITIONS) System.out.println(toString(actual)); assertEqualPositions(expected, actual); @@ -340,15 +290,26 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { assertEqualPositions(expected, actual); } - public void testMacroSubstitutionHighlighting() throws Exception { - setUpSemanticHighlighting(SemanticHighlightings.MACRO_SUBSTITUTION); + public void testMacroDefinitionHighlighting() throws Exception { + setUpSemanticHighlighting(SemanticHighlightings.MACRO_DEFINITION); Position[] actual= getSemanticHighlightingPositions(); Position[] expected= new Position[] { - createPosition(29, 8, 19), + createPosition(0, 8, 3), + createPosition(1, 8, 14), + }; + if (PRINT_POSITIONS) System.out.println(toString(actual)); + assertEqualPositions(expected, actual); + } + + public void testMacroReferencesHighlighting() throws Exception { + setUpSemanticHighlighting(SemanticHighlightings.MACRO_REFERENCE); + Position[] actual= getSemanticHighlightingPositions(); + Position[] expected= new Position[] { + createPosition(29, 8, 14), createPosition(104, 0, 3), createPosition(108, 0, 3), createPosition(113, 0, 3), - createPosition(120, 4, 17), + createPosition(120, 4, 14), }; if (PRINT_POSITIONS) System.out.println(toString(actual)); assertEqualPositions(expected, actual); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties index 789ac9c64c0..2b15774149e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties @@ -153,8 +153,6 @@ SemanticHighlighting_staticField= Static fields SemanticHighlighting_staticConstField= Constants SemanticHighlighting_methodDeclaration= Method declarations SemanticHighlighting_staticMethodInvocation= Static method invocations -SemanticHighlighting_virtualMethodInvocation= Virtual method invocations -SemanticHighlighting_inheritedMethodInvocation= Inherited method invocations SemanticHighlighting_localVariableDeclaration= Local variable declarations SemanticHighlighting_localVariable= Local variable references SemanticHighlighting_globalVariable= Global variables 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 74d27ce6f9f..67e42f4ec09 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -84,20 +84,4 @@ public abstract class SemanticHighlighting { * @return true iff the semantic highlighting consumes the semantic token */ public abstract boolean consumes(SemanticToken token); - - /** - * Returns true iff the semantic highlighting consumes the - * semantic token. - *

- * NOTE: Implementors are not allowed to keep a reference on the token or on - * any object retrieved from the token. - *

- * @param token the semantic token for a - * {@link org.eclipse.cdt.core.dom.ast.IASTLiteralExpression} - * @return true iff the semantic highlighting consumes the - * semantic token - */ - public boolean consumesLiteral(SemanticToken token) { - return false; - } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java index da232a4bf61..6a6224badcd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -39,6 +39,8 @@ import org.eclipse.cdt.core.dom.ast.IASTMacroExpansion; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNodeLocation; +import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition; +import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.ui.CUIPlugin; @@ -62,9 +64,11 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { */ private class PositionCollector extends ASTVisitor { { + shouldVisitTranslationUnit= true; shouldVisitNames= true; shouldVisitDeclarations= true; shouldVisitExpressions= true; + shouldVisitStatements= true; shouldVisitDeclSpecifiers= true; } @@ -82,6 +86,21 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { fPositionTracker= positionTracker; } + /* + * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit) + */ + public int visit(IASTTranslationUnit tu) { + // visit macro definitions + IASTPreprocessorMacroDefinition[] macroDefs= tu.getMacroDefinitions(); + for (int i= 0; i < macroDefs.length; i++) { + IASTPreprocessorMacroDefinition macroDef= macroDefs[i]; + if (fFilePath.equals(macroDef.getContainingFilename())) { + visit(macroDef.getName()); + } + } + return super.visit(tu); + } + /* * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclaration) */ @@ -115,29 +134,63 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { return PROCESS_CONTINUE; } + /* + * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTStatement) + */ + public int visit(IASTStatement statement) { + if (checkForMacro(statement)) { + return PROCESS_SKIP; + } + return PROCESS_CONTINUE; + } + /* * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTName) */ public int visit(IASTName node) { - visitNode(node); + if (visitNode(node)) { + return PROCESS_SKIP; + } return PROCESS_CONTINUE; } private boolean checkForMacro(IASTNode node) { IASTNodeLocation[] nodeLocations= node.getNodeLocations(); if (nodeLocations.length == 1 && nodeLocations[0] instanceof IASTMacroExpansion) { - return visitNode(node); + IASTNodeLocation useLocation= getMinFileLocation(nodeLocations); + if (useLocation != null) { + IASTPreprocessorMacroDefinition macroDef= ((IASTMacroExpansion)nodeLocations[0]).getMacroDefinition(); + IASTNodeLocation defLocation= macroDef.getName().getFileLocation(); + IASTNode macroNode= node.getTranslationUnit().selectNodeForLocation(fFilePath, useLocation.getNodeOffset(), defLocation.getNodeLength()); + if (macroNode != null && visitMacro(macroNode, defLocation.getNodeLength())) { + return true; + } + } } return false; } + private boolean visitMacro(IASTNode node, int macroLength) { + fToken.update(node); + for (int i= 0, n= fJobSemanticHighlightings.length; i < n; ++i) { + SemanticHighlighting semanticHighlighting= fJobSemanticHighlightings[i]; + if (fJobHighlightings[i].isEnabled() && semanticHighlighting.consumes(fToken)) { + addMacroLocation(node.getFileLocation(), macroLength, fJobHighlightings[i]); + break; + } + } + fToken.clear(); + // always consume this node + return true; + } + private boolean visitNode(IASTNode node) { boolean consumed= false; fToken.update(node); for (int i= 0, n= fJobSemanticHighlightings.length; i < n; ++i) { SemanticHighlighting semanticHighlighting= fJobSemanticHighlightings[i]; if (fJobHighlightings[i].isEnabled() && semanticHighlighting.consumes(fToken)) { - addNodeLocations(node.getNodeLocations(), fJobHighlightings[i]); + addNodeLocation(node.getFileLocation(), fJobHighlightings[i]); consumed= true; break; } @@ -149,20 +202,15 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { /** * Add the a location range for the given highlighting. * - * @param nodeLocations The node locations + * @param nodeLocation The node location * @param highlighting The highlighting */ - private void addNodeLocations(IASTNodeLocation[] nodeLocations, HighlightingStyle highlighting) { - final IASTFileLocation minLocation= getMinFileLocation(nodeLocations); - if (minLocation == null) { + private void addNodeLocation(IASTNodeLocation nodeLocation, HighlightingStyle highlighting) { + if (nodeLocation == null) { return; } - final IASTFileLocation maxLocation= getMaxFileLocation(nodeLocations); - if (maxLocation == null) { - return; - } - int offset= minLocation.getNodeOffset(); - int length= maxLocation.getNodeOffset() + maxLocation.getNodeLength() - offset; + int offset= nodeLocation.getNodeOffset(); + int length= nodeLocation.getNodeLength(); if (fPositionTracker != null) { IRegion actualPos= fPositionTracker.historicToActual(new Region(offset, length)); offset= actualPos.getOffset(); @@ -173,18 +221,27 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { } } - private IASTFileLocation getMaxFileLocation(IASTNodeLocation[] locations) { - if (locations == null || locations.length == 0) { - return null; + /** + * Add the a location range for the given macro highlighting. + * + * @param macroUseLocaton The location of the macro occurrence + * @param macroLength the length of the macro name + * @param highlighting The highlighting + */ + private void addMacroLocation(IASTNodeLocation macroUseLocation, int macroLength, HighlightingStyle highlighting) { + if (macroUseLocation == null) { + return; } - final IASTNodeLocation nodeLocation= locations[locations.length-1]; - if (nodeLocation instanceof IASTFileLocation) { - return (IASTFileLocation)nodeLocation; - } else if (nodeLocation instanceof IASTMacroExpansion) { - IASTNodeLocation[] macroLocations= ((IASTMacroExpansion)nodeLocation).getExpansionLocations(); - return getMaxFileLocation(macroLocations); + int offset= macroUseLocation.getNodeOffset(); + int length= macroLength; + if (fPositionTracker != null) { + IRegion actualPos= fPositionTracker.historicToActual(new Region(offset, length)); + offset= actualPos.getOffset(); + length= actualPos.getLength(); + } + if (offset > -1 && length > 0) { + addPosition(offset, length, highlighting); } - return null; } private IASTFileLocation getMinFileLocation(IASTNodeLocation[] locations) { @@ -298,14 +355,11 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { return; PositionCollector collector= new PositionCollector(ast.getFilePath(), positionTracker); - IASTNode[] subtrees= getAffectedSubtrees(ast); - if (subtrees.length == 0) - return; - + startReconcilingPositions(); if (!fJobPresenter.isCanceled()) - reconcilePositions(subtrees, collector); + reconcilePositions(ast, collector); TextPresentation textPresentation= null; if (!fJobPresenter.isCanceled()) @@ -325,14 +379,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { } } - /** - * @param node Root node - * @return Array of subtrees that may be affected by past document changes - */ - private IASTNode[] getAffectedSubtrees(IASTNode node) { - return new IASTNode[] { node }; - } - /** * Start reconciling positions. */ @@ -342,15 +388,13 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { } /** - * Reconcile positions based on the AST subtrees + * Reconcile positions based on the AST. * - * @param subtrees the AST subtrees + * @param ast the AST + * @param visitor the AST visitor */ - private void reconcilePositions(IASTNode[] subtrees, ASTVisitor visitor) { - // FIXME: remove positions not covered by subtrees - for (int i= 0, n= subtrees.length; i < n; i++) { - subtrees[i].accept(visitor); - } + private void reconcilePositions(IASTTranslationUnit ast, PositionCollector visitor) { + ast.accept(visitor); List oldPositions= fRemovedPositions; List newPositions= new ArrayList(fNOfRemovedPositions); for (int i= 0, n= oldPositions.size(); i < n; i ++) { 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 e2b7988ec75..a0817f6d53b 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,10 +21,8 @@ import org.eclipse.swt.graphics.RGB; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; -import org.eclipse.cdt.core.dom.ast.IASTMacroExpansion; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTNodeLocation; import org.eclipse.cdt.core.dom.ast.IASTProblem; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IEnumeration; @@ -32,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.ILabel; +import org.eclipse.cdt.core.dom.ast.IMacroBinding; import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IScope; @@ -41,6 +40,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope; @@ -60,11 +60,6 @@ public class SemanticHighlightings { private static final RGB RGB_BLACK = new RGB(0, 0, 0); - /** - * A named preference part that controls the highlighting of static const fields. - */ - public static final String STATIC_CONST_FIELD="staticConstField"; //$NON-NLS-1$ - /** * A named preference part that controls the highlighting of static fields. */ @@ -83,17 +78,7 @@ public class SemanticHighlightings { /** * A named preference part that controls the highlighting of static method invocations. */ - public static final String STATIC_METHOD_INVOCATION="staticMethodInvocation"; //$NON-NLS-1$ - - /** - * A named preference part that controls the highlighting of inherited method invocations. - */ - public static final String INHERITED_METHOD_INVOCATION="inheritedMethodInvocation"; //$NON-NLS-1$ - - /** - * A named preference part that controls the highlighting of virtual method invocations. - */ - public static final String VIRTUAL_METHOD_INVOCATION="virtualMethodInvocation"; //$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. @@ -146,15 +131,9 @@ public class SemanticHighlightings { public static final String ENUM="enum"; //$NON-NLS-1$ /** - * A named preference part that controls the highlighting of template arguments. + * A named preference part that controls the highlighting of macro references. */ - public static final String TEMPLATE_ARGUMENT="templateArgument"; //$NON-NLS-1$ - - /** - * A named preference part that controls the highlighting of macro substitutions - * (=references). - */ - public static final String MACRO_SUBSTITUTION="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. @@ -194,73 +173,6 @@ public class SemanticHighlightings { */ private static SemanticHighlighting[] fgSemanticHighlightings; - /** - * Semantic highlighting for static const fields. - */ -// private static final class StaticConstFieldHighlighting extends SemanticHighlighting { -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() -// */ -// public String getPreferenceKey() { -// return STATIC_CONST_FIELD; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() -// */ -// public RGB getDefaultTextColor() { -// return RGB_BLACK; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() -// */ -// public boolean isBoldByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() -// */ -// public boolean isItalicByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() -// */ -// public boolean isEnabledByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() -// */ -// public String getDisplayName() { -// return CEditorMessages.getString("SemanticHighlighting_staticConstField"); //$NON-NLS-1$ -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) -// */ -// public boolean consumes(SemanticToken token) { -// IBinding binding= token.getBinding(); -// if (binding instanceof ICPPField && !(binding instanceof IProblemBinding)) { -// ICPPField field= (ICPPField)binding; -// try { -// // TLETODO [semanticHighlighting] need access to const storage class -// return field.isStatic() /* && field.isConst() */; -// } catch (DOMException exc) { -// CUIPlugin.getDefault().log(exc.getStatus()); -// } catch (Error e) /* PDOMNotImplementedError */ { -// // ignore -// } -// } -// return false; -// } -// } - /** * Semantic highlighting for static fields. */ @@ -312,14 +224,21 @@ public class SemanticHighlightings { * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ public boolean consumes(SemanticToken token) { - IBinding binding= token.getBinding(); - if (binding instanceof IField && !(binding instanceof IProblemBinding)) { - try { - return ((IField)binding).isStatic(); - } catch (DOMException exc) { - CUIPlugin.getDefault().log(exc); - } catch (Error e) /* PDOMNotImplementedError */ { - // ignore + IASTNode node= token.getNode(); + if (node instanceof IASTName) { + IASTName name= (IASTName)node; + if (name instanceof ICPPASTQualifiedName && name.isReference()) { + return false; + } + IBinding binding= token.getBinding(); + if (binding instanceof IField && !(binding instanceof IProblemBinding)) { + try { + return ((IField)binding).isStatic(); + } catch (DOMException exc) { + CUIPlugin.getDefault().log(exc); + } catch (Error e) /* PDOMNotImplementedError */ { + // ignore + } } } return false; @@ -377,9 +296,16 @@ public class SemanticHighlightings { * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ public boolean consumes(SemanticToken token) { - IBinding binding= token.getBinding(); - if (binding instanceof IField) { - return true; + IASTNode node= token.getNode(); + if (node instanceof IASTName) { + IASTName name= (IASTName)node; + if (name instanceof ICPPASTQualifiedName && name.isReference()) { + return false; + } + IBinding binding= token.getBinding(); + if (binding instanceof IField) { + return true; + } } return false; } @@ -439,7 +365,7 @@ public class SemanticHighlightings { IASTNode node= token.getNode(); if (node instanceof IASTName) { IASTName name= (IASTName)node; - if (name.isDeclaration() || name.isDefinition()) { + if (!name.isReference()) { IBinding binding= token.getBinding(); if (binding instanceof ICPPMethod) { return true; @@ -477,198 +403,77 @@ 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() -// */ -// public String getPreferenceKey() { -// return STATIC_METHOD_INVOCATION; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() -// */ -// public RGB getDefaultTextColor() { -// return RGB_BLACK; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() -// */ -// public boolean isBoldByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() -// */ -// public boolean isItalicByDefault() { -// return true; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() -// */ -// public boolean isEnabledByDefault() { -// return true; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() -// */ -// public String getDisplayName() { -// return CEditorMessages.getString("SemanticHighlighting_staticMethodInvocation"); //$NON-NLS-1$ -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) -// */ -// public boolean consumes(SemanticToken token) { -// IASTNode node= token.getNode(); -// if (node instanceof IASTName) { -// IASTName name= (IASTName)node; -// if (name.isReference()) { -// IBinding binding= token.getBinding(); -// if (binding instanceof ICPPMethod) { -// try { -// return ((ICPPMethod)binding).isStatic(); -// } catch (DOMException exc) { -// CUIPlugin.getDefault().log(exc.getStatus()); -// } catch (Error e) /* PDOMNotImplementedError */ { -// // ignore -// } -// } -// } -// } -// return false; -// } -// } + private static final class StaticMethodInvocationHighlighting extends SemanticHighlighting { - /** - * Semantic highlighting for virtual method invocations. - */ -// private static final class VirtualMethodInvocationHighlighting extends SemanticHighlighting { -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() -// */ -// public String getPreferenceKey() { -// return VIRTUAL_METHOD_INVOCATION; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() -// */ -// public RGB getDefaultTextColor() { -// return RGB_BLACK; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() -// */ -// public boolean isBoldByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() -// */ -// public boolean isItalicByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() -// */ -// public boolean isEnabledByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() -// */ -// public String getDisplayName() { -// return CEditorMessages.getString("SemanticHighlighting_virtualMethodInvocation"); //$NON-NLS-1$ -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) -// */ -// public boolean consumes(SemanticToken token) { -// IASTName node= token.getNode(); -// if (node.isReference()) { -// IBinding binding= token.getBinding(); -// if (binding instanceof ICPPMethod) { -// try { -// // TLETODO [semanticHighlighting] need proper check for virtual method -// return ((ICPPMethod)binding).isVirtual(); -// } catch (DOMException exc) { -// CUIPlugin.getDefault().log(exc.getStatus()); -// } catch (Error e) /* PDOMNotImplementedError */ { -// // ignore -// } -// } -// } -// return false; -// } -// } + /* + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() + */ + public String getPreferenceKey() { + return STATIC_METHOD_INVOCATION; + } - /** - * Semantic highlighting for inherited method invocations. - */ -// private static final class InheritedMethodInvocationHighlighting extends SemanticHighlighting { -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() -// */ -// public String getPreferenceKey() { -// return INHERITED_METHOD_INVOCATION; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() -// */ -// public RGB getDefaultTextColor() { -// return RGB_BLACK; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() -// */ -// public boolean isBoldByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() -// */ -// public boolean isItalicByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() -// */ -// public boolean isEnabledByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() -// */ -// public String getDisplayName() { -// return CEditorMessages.getString("SemanticHighlighting_inheritedMethodInvocation"); //$NON-NLS-1$ -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) -// */ -// public boolean consumes(SemanticToken token) { -// // TLETODO [semanticHighlighting] inherited method invocation -// return false; -// } -// } + /* + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + */ + public RGB getDefaultTextColor() { + return RGB_BLACK; + } + + /* + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() + */ + public boolean isBoldByDefault() { + return false; + } + + /* + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() + */ + public boolean isItalicByDefault() { + return true; + } + + /* + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() + */ + public boolean isEnabledByDefault() { + return true; + } + + /* + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() + */ + public String getDisplayName() { + return CEditorMessages.getString("SemanticHighlighting_staticMethodInvocation"); //$NON-NLS-1$ + } + + /* + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) + */ + public boolean consumes(SemanticToken token) { + IASTNode node= token.getNode(); + if (node instanceof IASTName) { + IASTName name= (IASTName)node; + if (name instanceof ICPPASTQualifiedName) { + return false; + } + if (!name.isReference()) { + return false; + } + IBinding binding= token.getBinding(); + if (binding instanceof ICPPMethod) { + try { + return ((ICPPMethod)binding).isStatic(); + } catch (DOMException exc) { + CUIPlugin.getDefault().log(exc); + } catch (Error e) /* PDOMNotImplementedError */ { + // ignore + } + } + } + return false; + } + } /** * Semantic highlighting for methods. @@ -723,6 +528,10 @@ public class SemanticHighlightings { public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { + IASTName name= (IASTName)node; + if (name instanceof ICPPASTQualifiedName && name.isReference()) { + return false; + } IBinding binding= token.getBinding(); if (binding instanceof ICPPMethod) { return true; @@ -1296,22 +1105,13 @@ public class SemanticHighlightings { */ public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); + if (node instanceof ICPPASTQualifiedName || node instanceof ICPPASTTemplateId) { + return false; + } if (node instanceof IASTName) { IBinding binding= token.getBinding(); if (binding instanceof ICPPClassType) { - IASTName name= (IASTName)node; - if (name.isReference()) { - if (node.getParent() instanceof ICPPASTQualifiedName) { - ICPPASTQualifiedName qName= (ICPPASTQualifiedName)node.getParent(); - if (qName.getLastName() == name) { - return true; - } - } else { - return true; - } - } else { - return true; - } + return true; } } return false; @@ -1369,83 +1169,27 @@ public class SemanticHighlightings { * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ public boolean consumes(SemanticToken token) { - IBinding binding= token.getBinding(); - if (binding instanceof IEnumeration) { - return true; + IASTNode node= token.getNode(); + if (node instanceof IASTName) { + IBinding binding= token.getBinding(); + if (binding instanceof IEnumeration) { + return true; + } } return false; } } /** - * Semantic highlighting for template arguments. + * Semantic highlighting for macro references. */ -// private static final class TemplateArgumentHighlighting extends SemanticHighlighting { -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() -// */ -// public String getPreferenceKey() { -// return TEMPLATE_ARGUMENT; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() -// */ -// public RGB getDefaultTextColor() { -// return new RGB(13, 100, 0); -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() -// */ -// public boolean isBoldByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() -// */ -// public boolean isItalicByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() -// */ -// public boolean isEnabledByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() -// */ -// public String getDisplayName() { -// return CEditorMessages.getString("SemanticHighlighting_templateArguments"); //$NON-NLS-1$ -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) -// */ -// public boolean consumes(SemanticToken token) { -// IBinding binding= token.getBinding(); -// if (binding instanceof ICPPTemplateParameter) { -// return true; -// } -// return false; -// } -// } - - /** - * Semantic highlighting for macro substitutions (references). - */ - private static final class MacroSubstitutionHighlighting extends SemanticHighlighting { + private static final class MacroReferenceHighlighting extends SemanticHighlighting { /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ public String getPreferenceKey() { - return MACRO_SUBSTITUTION; + return MACRO_REFERENCE; } /* @@ -1487,10 +1231,12 @@ public class SemanticHighlightings { * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ public boolean consumes(SemanticToken token) { - IASTNode node= token.getNode(); - IASTNodeLocation[] nodeLocations= node.getNodeLocations(); - if (nodeLocations.length == 1 && nodeLocations[0] instanceof IASTMacroExpansion) { - return true; + IBinding binding= token.getBinding(); + if (binding instanceof IMacroBinding) { + IASTName name= (IASTName)token.getNode(); + if (name.isReference()) { + return true; + } } return false; } @@ -1499,61 +1245,64 @@ public class SemanticHighlightings { /** * Semantic highlighting for macro definitions. */ -// private static final class MacroDefinitionHighlighting extends SemanticHighlighting { -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() -// */ -// public String getPreferenceKey() { -// return MACRO_DEFINITION; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() -// */ -// public RGB getDefaultTextColor() { -// return RGB_BLACK; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() -// */ -// public boolean isBoldByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() -// */ -// public boolean isItalicByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() -// */ -// public boolean isEnabledByDefault() { -// return false; -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() -// */ -// public String getDisplayName() { -// return CEditorMessages.getString("SemanticHighlighting_macroDefinition"); //$NON-NLS-1$ -// } -// -// /* -// * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) -// */ -// public boolean consumes(SemanticToken token) { -// IASTNode node= token.getNode(); -// if (node instanceof IASTName && node.getParent() instanceof IASTPreprocessorMacroDefinition) { -// return true; -// } -// return false; -// } -// } + private static final class MacroDefinitionHighlighting extends SemanticHighlighting { + + /* + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() + */ + public String getPreferenceKey() { + return MACRO_DEFINITION; + } + + /* + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + */ + public RGB getDefaultTextColor() { + return RGB_BLACK; + } + + /* + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() + */ + public boolean isBoldByDefault() { + return false; + } + + /* + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() + */ + public boolean isItalicByDefault() { + return false; + } + + /* + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() + */ + public boolean isEnabledByDefault() { + return false; + } + + /* + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() + */ + public String getDisplayName() { + return CEditorMessages.getString("SemanticHighlighting_macroDefintion"); //$NON-NLS-1$ + } + + /* + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) + */ + public boolean consumes(SemanticToken token) { + IBinding binding= token.getBinding(); + if (binding instanceof IMacroBinding) { + IASTName name= (IASTName)token.getNode(); + if (!name.isReference()) { + return true; + } + } + return false; + } + } /** * Semantic highlighting for typedefs. @@ -1927,31 +1676,21 @@ public class SemanticHighlightings { public static SemanticHighlighting[] getSemanticHighlightings() { if (fgSemanticHighlightings == null) fgSemanticHighlightings= new SemanticHighlighting[] { - new MacroSubstitutionHighlighting(), // before all others! + new MacroReferenceHighlighting(), // before all others! new ProblemHighlighting(), new ClassHighlighting(), -// new StaticConstFieldHighlighting(), new StaticFieldHighlighting(), new FieldHighlighting(), // after all other fields new MethodDeclarationHighlighting(), -// TLETODO [semanticHighlighting] Static method invocations -// new StaticMethodInvocationHighlighting(), -// TLETODO [semanticHighlighting] Virtual method invocations -// new VirtualMethodInvocationHighlighting(), -// TLETODO [semanticHighlighting] Inherited method invocations -// new InheritedMethodInvocationHighlighting(), + new StaticMethodInvocationHighlighting(), new ParameterVariableHighlighting(), // before local variables new LocalVariableDeclarationHighlighting(), new LocalVariableHighlighting(), new GlobalVariableHighlighting(), -// TLETODO [semanticHighlighting] Template parameter highlighting new TemplateParameterHighlighting(), // before template arguments! new MethodHighlighting(), // before types to get ctors -// TLETODO [semanticHighlighting] Template argument highlighting -// new TemplateArgumentHighlighting(), // before other types new EnumHighlighting(), -// TLETODO [semanticHighlighting] Macro definition highlighting -// new MacroDefinitionHighlighting(), + new MacroDefinitionHighlighting(), new FunctionDeclarationHighlighting(), new FunctionHighlighting(), new TypedefHighlighting(), diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java index c31b935a746..06a1a800737 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -851,6 +851,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { */ private SemanticHighlightingManager.HighlightedRange[][] createPreviewerRanges() { return new SemanticHighlightingManager.HighlightedRange[][] { + { createHighlightedRange( 2, 8, 5, SemanticHighlightings.MACRO_DEFINITION) }, { createHighlightedRange( 3, 16, 3, SemanticHighlightings.NAMESPACE) }, { createHighlightedRange( 5, 21, 4, SemanticHighlightings.TYPEDEF) }, { createHighlightedRange( 6, 11, 6, SemanticHighlightings.FUNCTION_DECLARATION), createHighlightedRange( 6, 11, 6, SemanticHighlightings.FUNCTION) }, @@ -877,9 +878,11 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { { createHighlightedRange(18, 0, 5, SemanticHighlightings.LABEL) }, { createHighlightedRange(18, 7, 6, SemanticHighlightings.FUNCTION) }, { createHighlightedRange(18, 14, 5, SemanticHighlightings.LOCAL_VARIABLE) }, - { createHighlightedRange(18, 21, 11, SemanticHighlightings.MACRO_SUBSTITUTION) }, + { createHighlightedRange(18, 21, 5, SemanticHighlightings.MACRO_REFERENCE) }, { createHighlightedRange(19, 4, 7, SemanticHighlightings.METHOD) }, - { createHighlightedRange(20, 4, 7, SemanticHighlightings.PROBLEM) }, + { createHighlightedRange(20, 4, 12, SemanticHighlightings.STATIC_METHOD_INVOCATION), createHighlightedRange(20, 4, 12, SemanticHighlightings.METHOD) }, + { createHighlightedRange(21, 4, 7, SemanticHighlightings.PROBLEM) }, + { createHighlightedRange(23, 14, 12, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(23, 14, 12, SemanticHighlightings.METHOD) }, }; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt index ac0b26ef957..5cdae187531 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt @@ -18,6 +18,8 @@ public: int local= (int)n; label: myfunc(local, MACRO('\0')); vmethod(); + staticMethod(); problem(); } + static void staticMethod(); }; \ No newline at end of file