From dd919f8f93ffde4419771134648821d6b1c55b16 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Sun, 26 Oct 2014 02:44:29 -0400 Subject: [PATCH] Bug 379626 - Incorrect syntax coloring of dependent method call Change-Id: Id1b327a814d91ff88984362402666a9e640248f5 Signed-off-by: Nathan Ridge Reviewed-on: https://git.eclipse.org/r/35519 Reviewed-by: Sergey Prigogin Tested-by: Sergey Prigogin --- .../core/dom/parser/cpp/semantics/CPPSemantics.java | 10 +++------- .../cdt/ui/tests/text/SemanticHighlightingTest.java | 12 ++++++++++++ .../internal/ui/editor/SemanticHighlightings.java | 8 ++++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 19d90ff64d9..067f308ded2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -475,14 +475,10 @@ public class CPPSemantics { // binding. final ASTNodeProperty namePropertyInParent = name.getPropertyInParent(); if (binding == null && data.skippedScope != null) { - if (data.hasFunctionArguments()) { - binding= new CPPDeferredFunction(data.skippedScope, name.getSimpleID(), null); + if (namePropertyInParent == IASTNamedTypeSpecifier.NAME) { + binding= new CPPUnknownMemberClass(data.skippedScope, name.getSimpleID()); } else { - if (namePropertyInParent == IASTNamedTypeSpecifier.NAME) { - binding= new CPPUnknownMemberClass(data.skippedScope, name.getSimpleID()); - } else { - binding= new CPPUnknownMethod(data.skippedScope, name.getSimpleID()); - } + binding= new CPPUnknownMethod(data.skippedScope, name.getSimpleID()); } } 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 4471fbc942e..02e728ac3e9 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 @@ -381,4 +381,16 @@ public class SemanticHighlightingTest extends TestCase { public void testVariousHighlightings() throws Exception { makeAssertions(); } + + // class C { //$class + // template void bar(T); //$templateParameter,methodDeclaration,templateParameter + // }; + // + // template //$templateParameter + // void foo(U u) { //$functionDeclaration,templateParameter,parameterVariable + // C().bar(u); //$class,method,parameterVariable + // } + public void testDependentMethodCall_379626() throws Exception { + makeAssertions(); + } } 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 c0bdc67a782..c7cdc84d96b 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 @@ -52,6 +52,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVirtSpecifier; 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.ICPPDeferredFunction; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; @@ -482,6 +484,12 @@ public class SemanticHighlightings { IBinding binding= token.getBinding(); if (binding instanceof ICPPMethod) { return true; + } else if (binding instanceof ICPPDeferredFunction) { + for (ICPPFunction candidate : ((ICPPDeferredFunction) binding).getCandidates()) { + if (candidate instanceof ICPPMethod) { + return true; + } + } } } return false;