mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
Bug 416748 - Improve semantic highlighting for alias templates
Change-Id: Ic0d0110133a4732cace07d19e995e7c51b5538e3 Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
parent
60e390b0e4
commit
f82660f14c
2 changed files with 36 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2014 IBM Corporation and others.
|
* Copyright (c) 2000, 2015 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -30,10 +30,6 @@ import org.eclipse.jface.text.Position;
|
||||||
import org.eclipse.jface.text.source.SourceViewer;
|
import org.eclipse.jface.text.source.SourceViewer;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
|
||||||
import junit.framework.Test;
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import junit.framework.TestSuite;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
||||||
|
@ -55,9 +51,13 @@ import org.eclipse.cdt.ui.testplugin.ResourceTestHelper;
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.editor.SemanticHighlighting;
|
import org.eclipse.cdt.internal.ui.editor.SemanticHighlighting;
|
||||||
import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager;
|
import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager;
|
||||||
|
import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightedPosition;
|
||||||
import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingPresenter;
|
import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingPresenter;
|
||||||
import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings;
|
import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings;
|
||||||
import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightedPosition;
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Semantic highlighting tests.
|
* Semantic highlighting tests.
|
||||||
|
@ -447,4 +447,19 @@ public class SemanticHighlightingTest extends TestCase {
|
||||||
public void testUserDefinedLiteralSuffix_484617() throws Exception {
|
public void testUserDefinedLiteralSuffix_484617() throws Exception {
|
||||||
makeAssertions();
|
makeAssertions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename T, typename U> //$templateParameter,templateParameter
|
||||||
|
// struct Pair {}; //$class
|
||||||
|
//
|
||||||
|
// template<typename T> //$templateParameter
|
||||||
|
// using PairIntX = Pair<int, T>; //$typedef,class,templateParameter
|
||||||
|
//
|
||||||
|
// struct Waldo {}; //$class
|
||||||
|
//
|
||||||
|
// int main() { //$functionDeclaration
|
||||||
|
// PairIntX<Waldo> pair; //$typedef,class,localVariableDeclaration
|
||||||
|
// }
|
||||||
|
public void testAliasTemplates_416748() throws Exception {
|
||||||
|
makeAssertions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2011 IBM Corporation and others.
|
* Copyright (c) 2000, 2015 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -51,6 +51,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
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.ICPPASTTemplateId;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVirtSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVirtSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
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.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredFunction;
|
||||||
|
@ -1142,6 +1144,18 @@ public class SemanticHighlightings {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IBinding binding= token.getBinding();
|
IBinding binding= token.getBinding();
|
||||||
|
// Names that resolve to alias template instances are template-ids
|
||||||
|
// with the template-name naming the alias template. We don't want
|
||||||
|
// to color the entire template-id, but rather want to color its
|
||||||
|
// constituent names separately.
|
||||||
|
if (binding instanceof ICPPAliasTemplateInstance) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// This covers the name defining an alias template.
|
||||||
|
if (binding instanceof ICPPAliasTemplate) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// This covers regular typedefs.
|
||||||
if (binding instanceof ITypedef) {
|
if (binding instanceof ITypedef) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue