mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Merge remote-tracking branch 'cdt/master' into sd90
This commit is contained in:
commit
d63769fe1f
129 changed files with 2663 additions and 853 deletions
|
@ -10,8 +10,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.managedbuilder.core.tests;
|
package org.eclipse.cdt.managedbuilder.core.tests;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
@ -24,7 +22,6 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
|
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||||
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsScannerInfoProvider;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||||
|
@ -201,26 +198,6 @@ public class ManagedBuildCoreTests20 extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert path to OS specific representation
|
|
||||||
*/
|
|
||||||
private String toOSLocation(String path) {
|
|
||||||
File file = new File(path);
|
|
||||||
try {
|
|
||||||
path = file.getCanonicalPath();
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert path to OS specific representation
|
|
||||||
*/
|
|
||||||
private String toOSString(String path) {
|
|
||||||
return new Path(path).toOSString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The purpose of this test is to exercise the build path info interface.
|
* The purpose of this test is to exercise the build path info interface.
|
||||||
* To get to that point, a new project/config has to be created in the test
|
* To get to that point, a new project/config has to be created in the test
|
||||||
|
@ -241,38 +218,18 @@ public class ManagedBuildCoreTests20 extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
//These are the expected path settings
|
//These are the expected path settings
|
||||||
IPath buildCWD = project.getLocation().append("Sub Config");
|
final String[] expectedPaths = new String[5];
|
||||||
|
|
||||||
final String[] expectedPaths;
|
// This first path is a built-in, so it will not be manipulated by build manager
|
||||||
if (new Path("C:\\home\\tester/include").isAbsolute()) {
|
expectedPaths[0] = (new Path("/usr/include")).toOSString();
|
||||||
// Windows
|
expectedPaths[1] = (new Path("/opt/gnome/include")).toOSString();
|
||||||
expectedPaths = new String[] {
|
IPath path = new Path("C:\\home\\tester/include");
|
||||||
toOSLocation("/usr/include"),
|
if(path.isAbsolute()) // for win32 path is treated as absolute
|
||||||
toOSLocation("/opt/gnome/include"),
|
expectedPaths[2] = path.toOSString();
|
||||||
toOSLocation("C:\\home\\tester/include"),
|
else // for Linux path is relative
|
||||||
// relative paths from MBS will make 3 entries
|
expectedPaths[2] = project.getLocation().append("Sub Config").append(path).toOSString();
|
||||||
project.getLocation().append("includes").toOSString(),
|
expectedPaths[3] = project.getLocation().append( "includes" ).toOSString();
|
||||||
buildCWD.append("includes").toOSString(),
|
expectedPaths[4] = (new Path("/usr/gnu/include")).toOSString();
|
||||||
toOSString("includes"),
|
|
||||||
"/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
// Unix
|
|
||||||
expectedPaths = new String[] {
|
|
||||||
toOSLocation("/usr/include"),
|
|
||||||
toOSLocation("/opt/gnome/include"),
|
|
||||||
// on unix "C:\\home\\tester/include" is relative path
|
|
||||||
// looks like nonsense but has to be this way as MBS converts entry to keep "Sub Config/C:\\home\\tester/include" in its storage
|
|
||||||
project.getLocation().append("Sub Config/C:\\home\\tester/include").toOSString(),
|
|
||||||
buildCWD.append("Sub Config/C:\\home\\tester/include").toOSString(),
|
|
||||||
toOSString("Sub Config/C:\\home\\tester/include"),
|
|
||||||
// relative paths from MBS will make 3 entries
|
|
||||||
project.getLocation().append("includes").toOSString(),
|
|
||||||
buildCWD.append("includes").toOSString(),
|
|
||||||
toOSString("includes"),
|
|
||||||
"/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new managed project based on the sub project type
|
// Create a new managed project based on the sub project type
|
||||||
IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.sub");
|
IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.sub");
|
||||||
|
@ -324,7 +281,6 @@ public class ManagedBuildCoreTests20 extends TestCase {
|
||||||
// Find the first IScannerInfoProvider that supplies build info for the project
|
// Find the first IScannerInfoProvider that supplies build info for the project
|
||||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
|
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
|
||||||
assertNotNull(provider);
|
assertNotNull(provider);
|
||||||
assertTrue(provider instanceof LanguageSettingsScannerInfoProvider);
|
|
||||||
|
|
||||||
// Now subscribe (note that the method will be called after a change
|
// Now subscribe (note that the method will be called after a change
|
||||||
provider.subscribe(project, new IScannerInfoChangeListener () {
|
provider.subscribe(project, new IScannerInfoChangeListener () {
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<!-- Need UI harness for quick fix tests -->
|
<!-- Need UI harness for quick fix tests -->
|
||||||
<useUIHarness>true</useUIHarness>
|
<useUIHarness>true</useUIHarness>
|
||||||
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
|
<argLine>-ea -Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/AutomatedIntegrationSuite.*</include>
|
<include>**/AutomatedIntegrationSuite.*</include>
|
||||||
</includes>
|
</includes>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
* Copyright (c) 2005, 2013 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
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* Devin Steffler (IBM Corporation) - initial API and implementation
|
* Devin Steffler (IBM Corporation) - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
|
* Nathan Ridge
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
|
||||||
|
@ -6060,14 +6061,14 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
|
||||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||||
ICPPTemplateInstance inst;
|
ICPPTemplateInstance inst;
|
||||||
inst= bh.assertNonProblem("f1(v)", 2);
|
inst= bh.assertNonProblem("f1(v)", 2);
|
||||||
assertEquals("<20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
assertEquals("<int20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||||
inst= bh.assertNonProblem("f1<20>(v)", -3);
|
inst= bh.assertNonProblem("f1<20>(v)", -3);
|
||||||
assertEquals("<20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
assertEquals("<int20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||||
bh.assertProblem("f2(v)", 2);
|
bh.assertProblem("f2(v)", 2);
|
||||||
inst= bh.assertNonProblem("f2<10>(v)", -3);
|
inst= bh.assertNonProblem("f2<10>(v)", -3);
|
||||||
assertEquals("<10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
assertEquals("<int10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||||
inst= bh.assertNonProblem("f3(v)", 2);
|
inst= bh.assertNonProblem("f3(v)", 2);
|
||||||
assertEquals("<10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
assertEquals("<int10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
// template <int i> class A { };
|
// template <int i> class A { };
|
||||||
|
@ -6086,9 +6087,9 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
|
||||||
ICPPTemplateInstance inst;
|
ICPPTemplateInstance inst;
|
||||||
bh.assertProblem("g(a1)", 1);
|
bh.assertProblem("g(a1)", 1);
|
||||||
inst= bh.assertNonProblem("g<0>(a1)", -4);
|
inst= bh.assertNonProblem("g<0>(a1)", -4);
|
||||||
assertEquals("<0>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
assertEquals("<int0>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||||
inst= bh.assertNonProblem("f(a1, a2)", 1);
|
inst= bh.assertNonProblem("f(a1, a2)", 1);
|
||||||
assertEquals("<1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
assertEquals("<int1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<typename T> class A {
|
// template<typename T> class A {
|
||||||
|
@ -6134,9 +6135,9 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
|
||||||
ICPPTemplateInstance inst;
|
ICPPTemplateInstance inst;
|
||||||
bh.assertProblem("f(a)", 1);
|
bh.assertProblem("f(a)", 1);
|
||||||
inst= bh.assertNonProblem("f<1>(a)", -3);
|
inst= bh.assertNonProblem("f<1>(a)", -3);
|
||||||
assertEquals("<1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
assertEquals("<short int1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||||
inst= bh.assertNonProblem("g(b)", 1);
|
inst= bh.assertNonProblem("g(b)", 1);
|
||||||
assertEquals("<1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
assertEquals("<short int1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<class T> void f(void(*)(T,int));
|
// template<class T> void f(void(*)(T,int));
|
||||||
|
|
|
@ -7051,7 +7051,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
// void test() {
|
// void test() {
|
||||||
// int x = C<bool>::id;
|
// int x = C<bool>::id;
|
||||||
// }
|
// }
|
||||||
public void _testDependentEnumValue_389009() throws Exception {
|
public void testDependentEnumValue_389009() throws Exception {
|
||||||
BindingAssertionHelper ah = getAssertionHelper();
|
BindingAssertionHelper ah = getAssertionHelper();
|
||||||
IEnumerator binding = ah.assertNonProblem("C<bool>::id", "id");
|
IEnumerator binding = ah.assertNonProblem("C<bool>::id", "id");
|
||||||
IValue value = binding.getValue();
|
IValue value = binding.getValue();
|
||||||
|
@ -7125,4 +7125,44 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
public void testClassTemplateSpecializationPartialOrdering_398044b() throws Exception {
|
public void testClassTemplateSpecializationPartialOrdering_398044b() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <typename>
|
||||||
|
// struct meta {
|
||||||
|
// static const bool value = 1;
|
||||||
|
// };
|
||||||
|
// template <bool>
|
||||||
|
// struct enable_if {};
|
||||||
|
// template <>
|
||||||
|
// struct enable_if<true> {
|
||||||
|
// typedef void type;
|
||||||
|
// };
|
||||||
|
// template <class T>
|
||||||
|
// struct pair {
|
||||||
|
// template <typename = typename enable_if<meta<T>::value>::type>
|
||||||
|
// pair(int);
|
||||||
|
// };
|
||||||
|
// void push_back(pair<long>&&);
|
||||||
|
// void push_back(const pair<long>&);
|
||||||
|
// void test() {
|
||||||
|
// push_back(0);
|
||||||
|
// }
|
||||||
|
public void testRegression_399142() throws Exception {
|
||||||
|
parseAndCheckBindings();
|
||||||
|
}
|
||||||
|
|
||||||
|
// template <class T>
|
||||||
|
// struct A {
|
||||||
|
// struct impl {
|
||||||
|
// static T x;
|
||||||
|
// };
|
||||||
|
// static const int value = sizeof(impl::x);
|
||||||
|
// };
|
||||||
|
// template <int> struct W {};
|
||||||
|
// template <> struct W<1> { typedef int type; };
|
||||||
|
// int main() {
|
||||||
|
// W<A<char>::value>::type w;
|
||||||
|
// }
|
||||||
|
public void testDependentExpressionInvolvingFieldInNestedClass_399362() throws Exception {
|
||||||
|
parseAndCheckBindings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,14 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IField;
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||||
|
@ -2063,6 +2065,27 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
||||||
checkBindings();
|
checkBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <typename T>
|
||||||
|
// struct B {
|
||||||
|
// enum { value = 1 };
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template <typename T>
|
||||||
|
// struct C {
|
||||||
|
// enum { id = B<T>::value };
|
||||||
|
// };
|
||||||
|
|
||||||
|
// void test() {
|
||||||
|
// int x = C<bool>::id;
|
||||||
|
// }
|
||||||
|
public void testDependentEnumValue_389009() throws Exception {
|
||||||
|
IEnumerator binding = getBindingFromASTName("id;", 2, IEnumerator.class);
|
||||||
|
IValue value = binding.getValue();
|
||||||
|
Long num = value.numericalValue();
|
||||||
|
assertNotNull(num);
|
||||||
|
assertEquals(1, num.longValue());
|
||||||
|
}
|
||||||
|
|
||||||
// template<typename U>
|
// template<typename U>
|
||||||
// struct A {
|
// struct A {
|
||||||
// typedef U type1;
|
// typedef U type1;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2012 Symbian Software Systems and others.
|
* Copyright (c) 2007, 2013 Symbian Software Systems 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
|
||||||
|
@ -7,13 +7,13 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.index.tests;
|
package org.eclipse.cdt.internal.index.tests;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -46,6 +46,56 @@ import org.eclipse.core.runtime.Path;
|
||||||
* Tests the behavior of the IIndex API when dealing with multiple projects
|
* Tests the behavior of the IIndex API when dealing with multiple projects
|
||||||
*/
|
*/
|
||||||
public class IndexCompositeTests extends BaseTestCase {
|
public class IndexCompositeTests extends BaseTestCase {
|
||||||
|
/*
|
||||||
|
* Convenience class for setting up projects.
|
||||||
|
*/
|
||||||
|
private static class ProjectBuilder {
|
||||||
|
private final String name;
|
||||||
|
private final boolean cpp;
|
||||||
|
private List<IProject> dependencies = new ArrayList<IProject>();
|
||||||
|
private Map<String, String> path2content = new HashMap<String, String>();
|
||||||
|
|
||||||
|
ProjectBuilder(String name, boolean cpp) {
|
||||||
|
this.name = name;
|
||||||
|
this.cpp = cpp;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProjectBuilder addDependency(IProject project) {
|
||||||
|
dependencies.add(project);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProjectBuilder addFile(String relativePath, CharSequence content) {
|
||||||
|
path2content.put(relativePath, content.toString());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICProject create() throws Exception {
|
||||||
|
ICProject result = cpp ?
|
||||||
|
CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER) :
|
||||||
|
CProjectHelper.createCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
|
||||||
|
|
||||||
|
IFile lastFile= null;
|
||||||
|
for (Map.Entry<String, String> entry : path2content.entrySet()) {
|
||||||
|
lastFile= TestSourceReader.createFile(result.getProject(), new Path(entry.getKey()), entry.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
IProjectDescription desc = result.getProject().getDescription();
|
||||||
|
desc.setReferencedProjects(dependencies.toArray(new IProject[dependencies.size()]));
|
||||||
|
result.getProject().setDescription(desc, new NullProgressMonitor());
|
||||||
|
|
||||||
|
IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
|
indexManager.setIndexerId(result, IPDOMManager.ID_FAST_INDEXER);
|
||||||
|
if (lastFile != null) {
|
||||||
|
// Call reindex explicitly since setting indexer ID doesn't trigger reindexing.
|
||||||
|
indexManager.reindex(result);
|
||||||
|
IIndex index= indexManager.getIndex(result);
|
||||||
|
TestSourceReader.waitUntilFileIsIndexed(index, lastFile, INDEXER_TIMEOUT_SEC * 1000);
|
||||||
|
}
|
||||||
|
BaseTestCase.waitForIndexer(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return suite(IndexCompositeTests.class);
|
return suite(IndexCompositeTests.class);
|
||||||
|
@ -101,8 +151,9 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
setIndex(cprojA, REFD); assertBCount(1, 1);
|
setIndex(cprojA, REFD); assertBCount(1, 1);
|
||||||
setIndex(cprojA, BOTH); assertBCount(2, 2);
|
setIndex(cprojA, BOTH); assertBCount(2, 2);
|
||||||
} finally {
|
} finally {
|
||||||
for (ICProject project : projects)
|
for (ICProject project : projects) {
|
||||||
project.getProject().delete(true, true, new NullProgressMonitor());
|
project.getProject().delete(true, true, new NullProgressMonitor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +226,6 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
assertNamespaceXMemberCount(5);
|
assertNamespaceXMemberCount(5);
|
||||||
assertFieldCount("C1", 1);
|
assertFieldCount("C1", 1);
|
||||||
|
|
||||||
|
|
||||||
setIndex(cprojB, NONE);
|
setIndex(cprojB, NONE);
|
||||||
assertBCount(gBC, aBC);
|
assertBCount(gBC, aBC);
|
||||||
assertNamespaceXMemberCount(2);
|
assertNamespaceXMemberCount(2);
|
||||||
|
@ -195,7 +245,6 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
assertBCount(gABC, aABC);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(5);
|
assertNamespaceXMemberCount(5);
|
||||||
assertFieldCount("C1", 1);
|
assertFieldCount("C1", 1);
|
||||||
|
|
||||||
|
|
||||||
setIndex(cprojA, NONE);
|
setIndex(cprojA, NONE);
|
||||||
assertBCount(gABC, aABC);
|
assertBCount(gABC, aABC);
|
||||||
|
@ -217,8 +266,9 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
assertNamespaceXMemberCount(5);
|
assertNamespaceXMemberCount(5);
|
||||||
assertFieldCount("C1", 1);
|
assertFieldCount("C1", 1);
|
||||||
} finally {
|
} finally {
|
||||||
for (ICProject project : projects)
|
for (ICProject project : projects) {
|
||||||
project.getProject().delete(true, true, new NullProgressMonitor());
|
project.getProject().delete(true, true, new NullProgressMonitor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +309,6 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
ICProject cprojC = pb.create();
|
ICProject cprojC = pb.create();
|
||||||
projects.add(cprojC);
|
projects.add(cprojC);
|
||||||
|
|
||||||
|
|
||||||
/* A C |
|
/* A C |
|
||||||
* \ / | Depends On / References
|
* \ / | Depends On / References
|
||||||
* B V
|
* B V
|
||||||
|
@ -278,7 +327,6 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
final int gAB= gA + gB - 1, aAB= aA + aB - 1;
|
final int gAB= gA + gB - 1, aAB= aA + aB - 1;
|
||||||
final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
|
final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
|
||||||
|
|
||||||
|
|
||||||
setIndex(cprojC, NONE);
|
setIndex(cprojC, NONE);
|
||||||
assertBCount(gBC, aBC);
|
assertBCount(gBC, aBC);
|
||||||
assertNamespaceXMemberCount(3);
|
assertNamespaceXMemberCount(3);
|
||||||
|
@ -318,8 +366,9 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
assertBCount(gABC, aABC);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(4);
|
assertNamespaceXMemberCount(4);
|
||||||
} finally {
|
} finally {
|
||||||
for (ICProject project : projects)
|
for (ICProject project : projects) {
|
||||||
project.getProject().delete(true, true, new NullProgressMonitor());
|
project.getProject().delete(true, true, new NullProgressMonitor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,8 +464,9 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
assertBCount(gABC, aABC);
|
assertBCount(gABC, aABC);
|
||||||
assertNamespaceXMemberCount(4);
|
assertNamespaceXMemberCount(4);
|
||||||
} finally {
|
} finally {
|
||||||
for (ICProject project : projects)
|
for (ICProject project : projects) {
|
||||||
project.getProject().delete(true, true, new NullProgressMonitor());
|
project.getProject().delete(true, true, new NullProgressMonitor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,13 +488,13 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
private void assertNamespaceXMemberCount(int count) throws CoreException, DOMException {
|
private void assertNamespaceXMemberCount(int count) throws CoreException, DOMException {
|
||||||
IBinding[] bindings = index.findBindings(Pattern.compile("X"), true, FILTER, new NullProgressMonitor());
|
IBinding[] bindings = index.findBindings(Pattern.compile("X"), true, FILTER, new NullProgressMonitor());
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
assertEquals(count, ((ICPPNamespace)bindings[0]).getMemberBindings().length);
|
assertEquals(count, ((ICPPNamespace) bindings[0]).getMemberBindings().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertFieldCount(String qnPattern, int count) throws CoreException, DOMException {
|
private void assertFieldCount(String qnPattern, int count) throws CoreException, DOMException {
|
||||||
IBinding[] bindings = index.findBindings(Pattern.compile(qnPattern), true, FILTER, new NullProgressMonitor());
|
IBinding[] bindings = index.findBindings(Pattern.compile(qnPattern), true, FILTER, new NullProgressMonitor());
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
assertEquals(count, ((ICompositeType)bindings[0]).getFields().length);
|
assertEquals(count, ((ICompositeType) bindings[0]).getFields().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setIndex(ICProject project, int options) throws CoreException, InterruptedException {
|
private void setIndex(ICProject project, int options) throws CoreException, InterruptedException {
|
||||||
|
@ -463,53 +513,3 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Convenience class for setting up projects.
|
|
||||||
*/
|
|
||||||
class ProjectBuilder {
|
|
||||||
private static final int INDEXER_TIMEOUT_SEC = 10;
|
|
||||||
private final String name;
|
|
||||||
private final boolean cpp;
|
|
||||||
private List dependencies = new ArrayList();
|
|
||||||
private Map path2content = new HashMap();
|
|
||||||
|
|
||||||
ProjectBuilder(String name, boolean cpp) {
|
|
||||||
this.name = name;
|
|
||||||
this.cpp = cpp;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectBuilder addDependency(IProject project) {
|
|
||||||
dependencies.add(project);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectBuilder addFile(String relativePath, CharSequence content) {
|
|
||||||
path2content.put(relativePath, content.toString());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
ICProject create() throws Exception {
|
|
||||||
ICProject result = cpp ?
|
|
||||||
CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER) :
|
|
||||||
CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
|
|
||||||
|
|
||||||
IFile lastFile= null;
|
|
||||||
for (Iterator i = path2content.entrySet().iterator(); i.hasNext();) {
|
|
||||||
Map.Entry entry = (Map.Entry) i.next();
|
|
||||||
lastFile= TestSourceReader.createFile(result.getProject(), new Path((String)entry.getKey()), (String) entry.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
IProjectDescription desc = result.getProject().getDescription();
|
|
||||||
desc.setReferencedProjects((IProject[]) dependencies.toArray(new IProject[dependencies.size()]));
|
|
||||||
result.getProject().setDescription(desc, new NullProgressMonitor());
|
|
||||||
|
|
||||||
CCorePlugin.getIndexManager().setIndexerId(result, IPDOMManager.ID_FAST_INDEXER);
|
|
||||||
if (lastFile != null) {
|
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(result);
|
|
||||||
TestSourceReader.waitUntilFileIsIndexed(index, lastFile, INDEXER_TIMEOUT_SEC * 1000);
|
|
||||||
}
|
|
||||||
BaseTestCase.waitForIndexer(result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -240,7 +240,8 @@ public class IndexUpdateTests extends IndexTestBase {
|
||||||
for (int i = 0; i < nchars.length; i++) {
|
for (int i = 0; i < nchars.length; i++) {
|
||||||
nchars[i]= names[i].toCharArray();
|
nchars[i]= names[i].toCharArray();
|
||||||
}
|
}
|
||||||
return fIndex.findBindings(nchars, IndexFilter.ALL_DECLARED, npm())[0];
|
IIndexBinding[] bindings = fIndex.findBindings(nchars, IndexFilter.ALL_DECLARED, npm());
|
||||||
|
return bindings.length > 0 ? bindings[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String msg() {
|
private String msg() {
|
||||||
|
@ -256,7 +257,6 @@ public class IndexUpdateTests extends IndexTestBase {
|
||||||
// short globalVar;
|
// short globalVar;
|
||||||
|
|
||||||
// register int globalVar;
|
// register int globalVar;
|
||||||
|
|
||||||
public void testGlobalCppVariable() throws Exception {
|
public void testGlobalCppVariable() throws Exception {
|
||||||
setupFile(3, true);
|
setupFile(3, true);
|
||||||
checkCppVariable("globalVar", INT, new String[]{});
|
checkCppVariable("globalVar", INT, new String[]{});
|
||||||
|
@ -345,7 +345,6 @@ public class IndexUpdateTests extends IndexTestBase {
|
||||||
// struct my_struct {int fField;};
|
// struct my_struct {int fField;};
|
||||||
|
|
||||||
// struct my_struct {short fField;};
|
// struct my_struct {short fField;};
|
||||||
|
|
||||||
public void testCField() throws Exception {
|
public void testCField() throws Exception {
|
||||||
setupFile(2, false);
|
setupFile(2, false);
|
||||||
checkVariable("my_struct::fField", INT, new String[]{});
|
checkVariable("my_struct::fField", INT, new String[]{});
|
||||||
|
@ -402,7 +401,6 @@ public class IndexUpdateTests extends IndexTestBase {
|
||||||
checkModifier(modifiers, PRIVATE, visibility == ICPPMember.v_private);
|
checkModifier(modifiers, PRIVATE, visibility == ICPPMember.v_private);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// class MyClass {int method(int a, int b);};
|
// class MyClass {int method(int a, int b);};
|
||||||
|
|
||||||
// class MyClass {short method(int a, int b);};
|
// class MyClass {short method(int a, int b);};
|
||||||
|
@ -422,7 +420,6 @@ public class IndexUpdateTests extends IndexTestBase {
|
||||||
// class MyClass {int method(char a){};};
|
// class MyClass {int method(char a){};};
|
||||||
|
|
||||||
// class MyClass {virtual int method(char a) = 0;};
|
// class MyClass {virtual int method(char a) = 0;};
|
||||||
|
|
||||||
public void testCppMethod() throws Exception {
|
public void testCppMethod() throws Exception {
|
||||||
setupFile(10, true);
|
setupFile(10, true);
|
||||||
checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PRIVATE});
|
checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PRIVATE});
|
||||||
|
@ -453,7 +450,6 @@ public class IndexUpdateTests extends IndexTestBase {
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// char MyClass::method(int a, int b);
|
// char MyClass::method(int a, int b);
|
||||||
|
|
||||||
public void testFixedCppMethod() throws Exception {
|
public void testFixedCppMethod() throws Exception {
|
||||||
setupHeader(3, true);
|
setupHeader(3, true);
|
||||||
checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PROTECTED});
|
checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PROTECTED});
|
||||||
|
@ -493,7 +489,6 @@ public class IndexUpdateTests extends IndexTestBase {
|
||||||
// class MyClass {protected: MyClass(char a, int b);};
|
// class MyClass {protected: MyClass(char a, int b);};
|
||||||
|
|
||||||
// class MyClass {private: MyClass(char a, int b);};
|
// class MyClass {private: MyClass(char a, int b);};
|
||||||
|
|
||||||
public void testCppConstructor() throws Exception {
|
public void testCppConstructor() throws Exception {
|
||||||
setupFile(6, true);
|
setupFile(6, true);
|
||||||
checkCppConstructor("MyClass::MyClass", new String[] {"", INT, INT}, new String[]{PRIVATE});
|
checkCppConstructor("MyClass::MyClass", new String[] {"", INT, INT}, new String[]{PRIVATE});
|
||||||
|
@ -587,7 +582,8 @@ public class IndexUpdateTests extends IndexTestBase {
|
||||||
}
|
}
|
||||||
checkCppConstructor((ICPPConstructor) ctors[0], new String[]{"", constRefType}, m2);
|
checkCppConstructor((ICPPConstructor) ctors[0], new String[]{"", constRefType}, m2);
|
||||||
|
|
||||||
IIndexBinding[] assignmentOps= fIndex.findBindings(new char[][]{nchars, "operator =".toCharArray()}, IndexFilter.ALL_DECLARED_OR_IMPLICIT, npm());
|
IIndexBinding[] assignmentOps= fIndex.findBindings(
|
||||||
|
new char[][] {nchars, "operator =".toCharArray() }, IndexFilter.ALL_DECLARED_OR_IMPLICIT, npm());
|
||||||
count= 0;
|
count= 0;
|
||||||
for (int i = 0; i < assignmentOps.length; i++) {
|
for (int i = 0; i < assignmentOps.length; i++) {
|
||||||
IIndexBinding assignmentOp= assignmentOps[i];
|
IIndexBinding assignmentOp= assignmentOps[i];
|
||||||
|
@ -717,7 +713,6 @@ public class IndexUpdateTests extends IndexTestBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// class myType {
|
// class myType {
|
||||||
// int a;
|
// int a;
|
||||||
// };
|
// };
|
||||||
|
@ -1183,7 +1178,6 @@ public class IndexUpdateTests extends IndexTestBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// void funcTypeDeletion(int);
|
// void funcTypeDeletion(int);
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<version>${tycho-version}</version>
|
<version>${tycho-version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<useUIHarness>false</useUIHarness>
|
<useUIHarness>false</useUIHarness>
|
||||||
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
|
<argLine>-ea -Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/AutomatedIntegrationSuite.*</include>
|
<include>**/AutomatedIntegrationSuite.*</include>
|
||||||
</includes>
|
</includes>
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
* Copyright (c) 2005, 2010 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Norbert Ploett (Siemens AG)
|
* Norbert Ploett (Siemens AG)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.suite;
|
package org.eclipse.cdt.core.suite;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2011 Andrew Gvozdev and others.
|
* Copyright (c) 2009, 2013 Andrew Gvozdev 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
|
||||||
|
@ -23,6 +23,8 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
import org.eclipse.cdt.internal.core.LocalProjectScope;
|
import org.eclipse.cdt.internal.core.LocalProjectScope;
|
||||||
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsExtensionManager;
|
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsExtensionManager;
|
||||||
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
|
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
|
||||||
|
import org.eclipse.cdt.internal.core.language.settings.providers.ScannerInfoExtensionLanguageSettingsProvider;
|
||||||
|
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||||
import org.osgi.service.prefs.BackingStoreException;
|
import org.osgi.service.prefs.BackingStoreException;
|
||||||
|
@ -42,6 +44,8 @@ public class ScannerDiscoveryLegacySupport {
|
||||||
public static final String USER_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.ui.UserLanguageSettingsProvider"; //$NON-NLS-1$
|
public static final String USER_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.ui.UserLanguageSettingsProvider"; //$NON-NLS-1$
|
||||||
/** ID of MBS language settings provider (from org.eclipse.cdt.managedbuilder.core) */
|
/** ID of MBS language settings provider (from org.eclipse.cdt.managedbuilder.core) */
|
||||||
public static final String MBS_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider"; //$NON-NLS-1$
|
public static final String MBS_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider"; //$NON-NLS-1$
|
||||||
|
/** ID of ScannerInfo language settings provider wrapping ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider extension point */
|
||||||
|
private static final String SI_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.core.LegacyScannerInfoLanguageSettingsProvider"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static String DISABLE_LSP_PREFERENCE = "language.settings.providers.disabled"; //$NON-NLS-1$
|
private static String DISABLE_LSP_PREFERENCE = "language.settings.providers.disabled"; //$NON-NLS-1$
|
||||||
// the default for project needs to be "disabled" - for legacy projects to be open with old SD enabled for MBS provider
|
// the default for project needs to be "disabled" - for legacy projects to be open with old SD enabled for MBS provider
|
||||||
|
@ -156,15 +160,60 @@ public class ScannerDiscoveryLegacySupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return list containing MBS and User provider. Used to initialize for unaware tool-chains (backward compatibility).
|
* Return list containing User provider and one of wrapper providers to support legacy projects (backward compatibility).
|
||||||
|
*
|
||||||
|
* @noreference This is internal helper method to support compatibility with previous versions
|
||||||
|
* which is not intended to be referenced by clients.
|
||||||
|
* @since 5.5
|
||||||
|
*/
|
||||||
|
public static String[] getDefaultProviderIdsLegacy(ICConfigurationDescription cfgDescription) {
|
||||||
|
boolean useScannerInfoProviderExtension = new ScannerInfoExtensionLanguageSettingsProvider().getScannerInfoProvider(cfgDescription) != null;
|
||||||
|
if (useScannerInfoProviderExtension) {
|
||||||
|
return new String[] {USER_LANGUAGE_SETTINGS_PROVIDER_ID, SI_LANGUAGE_SETTINGS_PROVIDER_ID};
|
||||||
|
}
|
||||||
|
if (CProjectDescriptionManager.getInstance().isNewStyleCfg(cfgDescription)) {
|
||||||
|
return new String[] {USER_LANGUAGE_SETTINGS_PROVIDER_ID, MBS_LANGUAGE_SETTINGS_PROVIDER_ID};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the provider is applicable for configuration from backward compatibility point of view
|
||||||
|
*
|
||||||
|
* @noreference This is internal helper method to support compatibility with previous versions
|
||||||
|
* which is not intended to be referenced by clients.
|
||||||
|
* @since 5.5
|
||||||
|
*/
|
||||||
|
public static boolean isProviderCompatible(String providerId, ICConfigurationDescription cfgDescription) {
|
||||||
|
if (cfgDescription != null) {
|
||||||
|
boolean useScannerInfoProviderExtension = new ScannerInfoExtensionLanguageSettingsProvider().getScannerInfoProvider(cfgDescription) != null;
|
||||||
|
if (SI_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) {
|
||||||
|
return useScannerInfoProviderExtension;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) {
|
||||||
|
boolean isNewStyleCfg = CProjectDescriptionManager.getInstance().isNewStyleCfg(cfgDescription);
|
||||||
|
return !useScannerInfoProviderExtension && isNewStyleCfg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return list containing User and MBS providers. Used to initialize older MBS tool-chains (backward compatibility).
|
||||||
|
*
|
||||||
|
* @noreference This is internal helper method to support compatibility with previous versions
|
||||||
|
* which is not intended to be referenced by clients.
|
||||||
*/
|
*/
|
||||||
public static List<ILanguageSettingsProvider> getDefaultProvidersLegacy() {
|
public static List<ILanguageSettingsProvider> getDefaultProvidersLegacy() {
|
||||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(2);
|
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(2);
|
||||||
ILanguageSettingsProvider provider = LanguageSettingsExtensionManager.getExtensionProviderCopy((ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID), false);
|
ILanguageSettingsProvider provider = LanguageSettingsExtensionManager.getExtensionProviderCopy((USER_LANGUAGE_SETTINGS_PROVIDER_ID), false);
|
||||||
if (provider != null) {
|
if (provider != null) {
|
||||||
providers.add(provider);
|
providers.add(provider);
|
||||||
}
|
}
|
||||||
providers.add(LanguageSettingsProvidersSerializer.getWorkspaceProvider(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID));
|
providers.add(LanguageSettingsProvidersSerializer.getWorkspaceProvider(MBS_LANGUAGE_SETTINGS_PROVIDER_ID));
|
||||||
return providers;
|
return providers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
|
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
|
||||||
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
|
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
|
||||||
|
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
|
||||||
import org.eclipse.cdt.core.resources.IPathEntryStore;
|
import org.eclipse.cdt.core.resources.IPathEntryStore;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
|
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
|
||||||
|
@ -1253,11 +1254,12 @@ public class CoreModel {
|
||||||
if(des != null){
|
if(des != null){
|
||||||
ICConfigurationDescription indexCfg = des.getDefaultSettingConfiguration();
|
ICConfigurationDescription indexCfg = des.getDefaultSettingConfiguration();
|
||||||
if(indexCfg != null){
|
if(indexCfg != null){
|
||||||
if(!mngr.isNewStyleCfg(indexCfg)){
|
if (!mngr.isNewStyleCfg(indexCfg)) {
|
||||||
return oldIsScannerInformationEmpty(resource);
|
return oldIsScannerInformationEmpty(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indexCfg instanceof ILanguageSettingsProvidersKeeper) {
|
if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project) &&
|
||||||
|
indexCfg instanceof ILanguageSettingsProvidersKeeper) {
|
||||||
List<String> languageIds = LanguageSettingsManager.getLanguages(resource, indexCfg);
|
List<String> languageIds = LanguageSettingsManager.getLanguages(resource, indexCfg);
|
||||||
for (String langId : languageIds) {
|
for (String langId : languageIds) {
|
||||||
List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(indexCfg, resource, langId,
|
List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(indexCfg, resource, langId,
|
||||||
|
|
|
@ -38,7 +38,8 @@ public interface ICSettingEntry {
|
||||||
/**
|
/**
|
||||||
* Flag {@code LOCAL} is used during creation of {@link IIncludeEntry}
|
* Flag {@code LOCAL} is used during creation of {@link IIncludeEntry}
|
||||||
* to indicate that an include path is not a system path.
|
* to indicate that an include path is not a system path.
|
||||||
* It does not appear it is used anywhere else.
|
* "System" path is denoted by angle brackets as in #include <x.h>
|
||||||
|
* "Local" path is denoted by quotes as in #include "x.h"
|
||||||
*/
|
*/
|
||||||
int LOCAL = 1 << 2;
|
int LOCAL = 1 << 2;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2011 Andrew Gvozdev and others.
|
* Copyright (c) 2009, 2013 Andrew Gvozdev 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
|
||||||
|
@ -82,7 +82,7 @@ public class LanguageSettingsProvidersSerializer {
|
||||||
public static final String JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE = "CDT_JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE"; //$NON-NLS-1$
|
public static final String JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE = "CDT_JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String PREFERENCE_WORSPACE_PROVIDERS_SET = "language.settings.providers.workspace.prefs.toggle"; //$NON-NLS-1$
|
private static final String PREFERENCE_WORSPACE_PROVIDERS_SET = "language.settings.providers.workspace.prefs.toggle"; //$NON-NLS-1$
|
||||||
private static final String CPROJECT_STORAGE_MODULE = "org.eclipse.cdt.core.LanguageSettingsProviders"; //$NON-NLS-1$
|
private static final String CPROJECT_STORAGE_MODULE_LANGUAGE_SETTINGS_PROVIDERS = "org.eclipse.cdt.core.LanguageSettingsProviders"; //$NON-NLS-1$
|
||||||
private static final String STORAGE_WORKSPACE_LANGUAGE_SETTINGS = "language.settings.xml"; //$NON-NLS-1$
|
private static final String STORAGE_WORKSPACE_LANGUAGE_SETTINGS = "language.settings.xml"; //$NON-NLS-1$
|
||||||
private static final String STORAGE_PROJECT_PATH = ".settings/language.settings.xml"; //$NON-NLS-1$
|
private static final String STORAGE_PROJECT_PATH = ".settings/language.settings.xml"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -833,8 +833,13 @@ public class LanguageSettingsProvidersSerializer {
|
||||||
LanguageSettingsLogger.logWarning("LanguageSettingsProvidersSerializer.serializeLanguageSettings() for " + project);
|
LanguageSettingsLogger.logWarning("LanguageSettingsProvidersSerializer.serializeLanguageSettings() for " + project);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Using side effect of adding the module to the storage
|
// Add the storage module to .cpoject and persist on disk as a side effect of adding
|
||||||
prjDescription.getStorage(CPROJECT_STORAGE_MODULE, true);
|
prjDescription.getStorage(CPROJECT_STORAGE_MODULE_LANGUAGE_SETTINGS_PROVIDERS, true);
|
||||||
|
if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) {
|
||||||
|
// set the flag if was not previously set by the user - to the default value
|
||||||
|
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project,
|
||||||
|
ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project));
|
||||||
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log("Internal error while trying to serialize language settings", e); //$NON-NLS-1$
|
CCorePlugin.log("Internal error while trying to serialize language settings", e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -1131,7 +1136,9 @@ public class LanguageSettingsProvidersSerializer {
|
||||||
public static void loadLanguageSettings(ICProjectDescription prjDescription) {
|
public static void loadLanguageSettings(ICProjectDescription prjDescription) {
|
||||||
IProject project = prjDescription.getProject();
|
IProject project = prjDescription.getProject();
|
||||||
IFile storeInPrjArea = getStoreInProjectArea(project);
|
IFile storeInPrjArea = getStoreInProjectArea(project);
|
||||||
if (storeInPrjArea.exists()) {
|
boolean isStoreInProjectAreaExist = storeInPrjArea.exists();
|
||||||
|
boolean enableLSP = isStoreInProjectAreaExist;
|
||||||
|
if (isStoreInProjectAreaExist) {
|
||||||
Document doc = null;
|
Document doc = null;
|
||||||
try {
|
try {
|
||||||
doc = XmlUtil.loadXml(storeInPrjArea);
|
doc = XmlUtil.loadXml(storeInPrjArea);
|
||||||
|
@ -1156,19 +1163,18 @@ public class LanguageSettingsProvidersSerializer {
|
||||||
CCorePlugin.log("Can't load preferences from file " + storeInPrjArea.getLocation(), e); //$NON-NLS-1$
|
CCorePlugin.log("Can't load preferences from file " + storeInPrjArea.getLocation(), e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else { // Storage in project area does not exist
|
||||||
// Storage in project area does not exist
|
ICStorageElement lspStorageModule = null;
|
||||||
ICStorageElement storageElement = null;
|
|
||||||
try {
|
try {
|
||||||
storageElement = prjDescription.getStorage(CPROJECT_STORAGE_MODULE, false);
|
lspStorageModule = prjDescription.getStorage(CPROJECT_STORAGE_MODULE_LANGUAGE_SETTINGS_PROVIDERS, false);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
String msg = "Internal error while trying to load language settings"; //$NON-NLS-1$
|
String msg = "Internal error while trying to load language settings"; //$NON-NLS-1$
|
||||||
CCorePlugin.log(msg, e);
|
CCorePlugin.log(msg, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (storageElement != null) {
|
// set default providers defined in the tool-chain
|
||||||
// set default providers defined in the tool-chain
|
for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) {
|
||||||
for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) {
|
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
|
||||||
String[] ids = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
|
String[] ids = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
|
||||||
if (ids != null) {
|
if (ids != null) {
|
||||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(ids.length);
|
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(ids.length);
|
||||||
|
@ -1182,23 +1188,16 @@ public class LanguageSettingsProvidersSerializer {
|
||||||
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
|
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
// Older existing legacy projects unaware of Language Settings Providers and their persistence store
|
|
||||||
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
|
|
||||||
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
|
|
||||||
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
|
|
||||||
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(ScannerDiscoveryLegacySupport.getDefaultProvidersLegacy());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) {
|
|
||||||
// if not yet defined by user - set preference to tell if this is legacy .cproject (i.e. no LSP storageElement)
|
|
||||||
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, storageElement != null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enableLSP = lspStorageModule != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) {
|
||||||
|
// set the flag if was not previously set by the user
|
||||||
|
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, enableLSP);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,158 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2013, 2013 Andrew Gvozdev 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Gvozdev - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.language.settings.providers;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.AbstractCExtension;
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider;
|
||||||
|
import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
|
||||||
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
|
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||||
|
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||||
|
import org.eclipse.cdt.core.settings.model.util.CExtensionUtil;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper class intended to provide backward compatibility with ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider extension point
|
||||||
|
*/
|
||||||
|
public class ScannerInfoExtensionLanguageSettingsProvider extends LanguageSettingsBaseProvider {
|
||||||
|
@Override
|
||||||
|
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
|
||||||
|
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
|
||||||
|
IScannerInfoProvider scannerInfoProvider = getScannerInfoProvider(cfgDescription);
|
||||||
|
if (scannerInfoProvider != null) {
|
||||||
|
IScannerInfo si = scannerInfoProvider.getScannerInformation(rc);
|
||||||
|
if (si != null) {
|
||||||
|
if (si instanceof IExtendedScannerInfo) {
|
||||||
|
addLocalIncludePaths(entries, (IExtendedScannerInfo) si);
|
||||||
|
}
|
||||||
|
|
||||||
|
addSystemIncludePaths(entries, si);
|
||||||
|
addDefinedSymbols(entries, si);
|
||||||
|
|
||||||
|
if (si instanceof IExtendedScannerInfo) {
|
||||||
|
addIncludeFiles(entries, (IExtendedScannerInfo) si);
|
||||||
|
addMacroFiles(entries, (IExtendedScannerInfo) si);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entries.isEmpty()) {
|
||||||
|
return LanguageSettingsSerializableStorage.getPooledList(entries);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return ScannerInfoProvider defined in configuration metadata in .cproject.
|
||||||
|
*
|
||||||
|
* @param cfgDescription - configuration description.
|
||||||
|
* @return an instance of ScannerInfoProvider or {@code null}.
|
||||||
|
*/
|
||||||
|
public IScannerInfoProvider getScannerInfoProvider(ICConfigurationDescription cfgDescription) {
|
||||||
|
if (cfgDescription == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
IScannerInfoProvider scannerInfoProvider = null;
|
||||||
|
ICConfigExtensionReference[] refs = cfgDescription.get(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
|
||||||
|
if (refs != null && refs.length > 0) {
|
||||||
|
ICConfigExtensionReference ref = refs[0];
|
||||||
|
try {
|
||||||
|
AbstractCExtension cExtension = null;
|
||||||
|
IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(ref, "cextension", false); //$NON-NLS-1$
|
||||||
|
cExtension = (AbstractCExtension)el.createExecutableExtension("run"); //$NON-NLS-1$
|
||||||
|
cExtension.setExtensionReference(ref);
|
||||||
|
cExtension.setProject(ref.getConfiguration().getProjectDescription().getProject());
|
||||||
|
if (cExtension instanceof IScannerInfoProvider) {
|
||||||
|
scannerInfoProvider = (IScannerInfoProvider) cExtension;
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return scannerInfoProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add local include paths to the list of entries.
|
||||||
|
*/
|
||||||
|
private void addLocalIncludePaths(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
|
||||||
|
String[] localIncludePaths = esi.getLocalIncludePath();
|
||||||
|
if (localIncludePaths != null) {
|
||||||
|
for (String path : localIncludePaths) {
|
||||||
|
entries.add(CDataUtil.createCIncludePathEntry(path, ICSettingEntry.LOCAL));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add system include paths to the list of entries.
|
||||||
|
*/
|
||||||
|
private void addSystemIncludePaths(List<ICLanguageSettingEntry> entries, IScannerInfo si) {
|
||||||
|
String[] includePaths = si.getIncludePaths();
|
||||||
|
if (includePaths != null) {
|
||||||
|
for (String path : includePaths) {
|
||||||
|
entries.add(CDataUtil.createCIncludePathEntry(path, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add defined macros to the list of entries.
|
||||||
|
*/
|
||||||
|
private void addDefinedSymbols(List<ICLanguageSettingEntry> entries, IScannerInfo si) {
|
||||||
|
Map<String, String> definedSymbols = si.getDefinedSymbols();
|
||||||
|
if (definedSymbols != null) {
|
||||||
|
for (Entry<String, String> entry : new TreeMap<String, String>(definedSymbols).entrySet()) {
|
||||||
|
String name = entry.getKey();
|
||||||
|
String value = entry.getValue();
|
||||||
|
entries.add(CDataUtil.createCMacroEntry(name, value, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add include files to the list of entries.
|
||||||
|
*/
|
||||||
|
private void addIncludeFiles(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
|
||||||
|
String[] includeFiles = esi.getIncludeFiles();
|
||||||
|
if (includeFiles != null) {
|
||||||
|
for (String path : includeFiles) {
|
||||||
|
entries.add(CDataUtil.createCIncludeFileEntry(path, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add macro files to the list of entries.
|
||||||
|
*/
|
||||||
|
private void addMacroFiles(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
|
||||||
|
String[] macroFiles = esi.getMacroFiles();
|
||||||
|
if (macroFiles != null) {
|
||||||
|
for (String path : macroFiles) {
|
||||||
|
entries.add(CDataUtil.createCMacroFileEntry(path, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,6 +38,7 @@ import org.eclipse.cdt.core.model.IPathEntryContainer;
|
||||||
import org.eclipse.cdt.core.model.IProjectEntry;
|
import org.eclipse.cdt.core.model.IProjectEntry;
|
||||||
import org.eclipse.cdt.core.model.ISourceEntry;
|
import org.eclipse.cdt.core.model.ISourceEntry;
|
||||||
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
||||||
|
import org.eclipse.cdt.utils.UNCPathConverter;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -513,6 +514,9 @@ public class PathEntryUtil {
|
||||||
|
|
||||||
private static boolean isValidExternalPath(IPath path) {
|
private static boolean isValidExternalPath(IPath path) {
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
|
if (path.isUNC()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
File file = path.toFile();
|
File file = path.toFile();
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
return file.exists();
|
return file.exists();
|
||||||
|
|
|
@ -52,6 +52,7 @@ import javax.xml.transform.stream.StreamResult;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
|
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
|
||||||
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
|
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
|
||||||
|
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
|
@ -1141,7 +1142,15 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
|
|
||||||
CConfigurationDataProvider provider = getProvider(des);
|
CConfigurationDataProvider provider = getProvider(des);
|
||||||
return provider.loadConfiguration(des, monitor);
|
CConfigurationData data = provider.loadConfiguration(des, monitor);
|
||||||
|
|
||||||
|
if (des instanceof ILanguageSettingsProvidersKeeper && ! des.isPreferenceConfiguration()) {
|
||||||
|
String[] defaultIds = ((ILanguageSettingsProvidersKeeper) des).getDefaultLanguageSettingsProvidersIds();
|
||||||
|
if (defaultIds == null) {
|
||||||
|
((ILanguageSettingsProvidersKeeper) des).setDefaultLanguageSettingsProvidersIds(ScannerDiscoveryLegacySupport.getDefaultProviderIdsLegacy(des));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
CConfigurationData applyData(CConfigurationDescriptionCache des, ICConfigurationDescription baseDescription, CConfigurationData base, SettingsContext context, IProgressMonitor monitor) throws CoreException {
|
CConfigurationData applyData(CConfigurationDescriptionCache des, ICConfigurationDescription baseDescription, CConfigurationData base, SettingsContext context, IProgressMonitor monitor) throws CoreException {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* Rational Software - initial implementation
|
* Rational Software - initial implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
|
* Nathan Ridge
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -183,6 +184,7 @@ public class ASTTypeUtil {
|
||||||
private static void appendArgument(ICPPTemplateArgument arg, boolean normalize, StringBuilder buf) {
|
private static void appendArgument(ICPPTemplateArgument arg, boolean normalize, StringBuilder buf) {
|
||||||
IValue val= arg.getNonTypeValue();
|
IValue val= arg.getNonTypeValue();
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
|
appendType(arg.getTypeOfNonTypeValue(), normalize, buf);
|
||||||
buf.append(val.getSignature());
|
buf.append(val.getSignature());
|
||||||
} else {
|
} else {
|
||||||
IType type = normalize ? arg.getTypeValue() : arg.getOriginalTypeValue();
|
IType type = normalize ? arg.getTypeValue() : arg.getOriginalTypeValue();
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer (IBM) - Initial API and implementation
|
* Doug Schaefer (IBM) - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,8 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
public interface IEnumeration extends IBinding, IType {
|
public interface IEnumeration extends IBinding, IType {
|
||||||
/**
|
/**
|
||||||
* Returns an array of the IEnumerators declared in this enumeration
|
* Returns an array of the IEnumerators declared in this enumeration
|
||||||
* @throws DOMException
|
|
||||||
*/
|
*/
|
||||||
IEnumerator[] getEnumerators() throws DOMException;
|
IEnumerator[] getEnumerators();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.2
|
* @since 5.2
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2013 Nathan Ridge.
|
||||||
|
* 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Nathan Ridge - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.5
|
||||||
|
*/
|
||||||
|
public interface ICPPEnumerationSpecialization extends ICPPEnumeration, ICPPSpecialization {
|
||||||
|
@Override
|
||||||
|
ICPPEnumeration getSpecializedBinding();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a specialized version of the given enumerator. The enumerator must be one
|
||||||
|
* of the enumerators of the enumeration being specialized.
|
||||||
|
*/
|
||||||
|
IEnumerator specializeEnumerator(IEnumerator enumerator);
|
||||||
|
}
|
|
@ -1,15 +1,15 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
* Copyright (c) 2005, 2010 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser;
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Nathan Ridge
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -25,18 +26,17 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binding for enumerations in C.
|
* Binding for enumerations in C.
|
||||||
*/
|
*/
|
||||||
public class CEnumeration extends PlatformObject implements IEnumeration, ICInternalBinding {
|
public class CEnumeration extends PlatformObject implements IEnumeration, ICInternalBinding {
|
||||||
|
|
||||||
private IASTName[] declarations = null;
|
private IASTName[] declarations = null;
|
||||||
private IASTName definition = null;
|
private IASTName definition = null;
|
||||||
private Long fMinValue;
|
private Long fMinValue;
|
||||||
|
@ -204,20 +204,7 @@ public class CEnumeration extends PlatformObject implements IEnumeration, ICInte
|
||||||
if (fMinValue != null)
|
if (fMinValue != null)
|
||||||
return fMinValue.longValue();
|
return fMinValue.longValue();
|
||||||
|
|
||||||
long minValue = Long.MAX_VALUE;
|
long minValue = SemanticUtil.computeMinValue(this);
|
||||||
IEnumerator[] enumerators = getEnumerators();
|
|
||||||
for (IEnumerator enumerator : enumerators) {
|
|
||||||
IValue value = enumerator.getValue();
|
|
||||||
if (value != null) {
|
|
||||||
Long val = value.numericalValue();
|
|
||||||
if (val != null) {
|
|
||||||
long v = val.longValue();
|
|
||||||
if (v < minValue) {
|
|
||||||
minValue = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fMinValue= minValue;
|
fMinValue= minValue;
|
||||||
return minValue;
|
return minValue;
|
||||||
}
|
}
|
||||||
|
@ -227,20 +214,7 @@ public class CEnumeration extends PlatformObject implements IEnumeration, ICInte
|
||||||
if (fMaxValue != null)
|
if (fMaxValue != null)
|
||||||
return fMaxValue.longValue();
|
return fMaxValue.longValue();
|
||||||
|
|
||||||
long maxValue = Long.MIN_VALUE;
|
long maxValue = SemanticUtil.computeMaxValue(this);
|
||||||
IEnumerator[] enumerators = getEnumerators();
|
|
||||||
for (IEnumerator enumerator : enumerators) {
|
|
||||||
IValue value = enumerator.getValue();
|
|
||||||
if (value != null) {
|
|
||||||
Long val = value.numericalValue();
|
|
||||||
if (val != null) {
|
|
||||||
long v = val.longValue();
|
|
||||||
if (v > maxValue) {
|
|
||||||
maxValue = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fMaxValue= maxValue;
|
fMaxValue= maxValue;
|
||||||
return maxValue;
|
return maxValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2012 IBM Corporation and others.
|
* Copyright (c) 2006, 2012 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Mike Kucera (IBM Corporation) - initial API and implementation
|
* Mike Kucera (IBM Corporation) - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2013 IBM Corporation and others.
|
* Copyright (c) 2004, 2013 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2011 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2011 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2011 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
|
* Nathan Ridge
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -29,7 +30,6 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTEnumerationSpecifier;
|
||||||
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;
|
||||||
|
@ -42,6 +42,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -220,20 +221,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I
|
||||||
if (fMinValue != null)
|
if (fMinValue != null)
|
||||||
return fMinValue.longValue();
|
return fMinValue.longValue();
|
||||||
|
|
||||||
long minValue = Long.MAX_VALUE;
|
long minValue = SemanticUtil.computeMinValue(this);
|
||||||
IEnumerator[] enumerators = getEnumerators();
|
|
||||||
for (IEnumerator enumerator : enumerators) {
|
|
||||||
IValue value = enumerator.getValue();
|
|
||||||
if (value != null) {
|
|
||||||
Long val = value.numericalValue();
|
|
||||||
if (val != null) {
|
|
||||||
long v = val.longValue();
|
|
||||||
if (v < minValue) {
|
|
||||||
minValue = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fMinValue= minValue;
|
fMinValue= minValue;
|
||||||
return minValue;
|
return minValue;
|
||||||
}
|
}
|
||||||
|
@ -243,20 +231,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I
|
||||||
if (fMaxValue != null)
|
if (fMaxValue != null)
|
||||||
return fMaxValue.longValue();
|
return fMaxValue.longValue();
|
||||||
|
|
||||||
long maxValue = Long.MIN_VALUE;
|
long maxValue = SemanticUtil.computeMaxValue(this);
|
||||||
IEnumerator[] enumerators = getEnumerators();
|
|
||||||
for (IEnumerator enumerator : enumerators) {
|
|
||||||
IValue value = enumerator.getValue();
|
|
||||||
if (value != null) {
|
|
||||||
Long val = value.numericalValue();
|
|
||||||
if (val != null) {
|
|
||||||
long v = val.longValue();
|
|
||||||
if (v > maxValue) {
|
|
||||||
maxValue = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fMaxValue= maxValue;
|
fMaxValue= maxValue;
|
||||||
return maxValue;
|
return maxValue;
|
||||||
}
|
}
|
||||||
|
@ -278,10 +253,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I
|
||||||
if (definition == null) {
|
if (definition == null) {
|
||||||
ICPPEnumeration typeInIndex= getIndexBinding();
|
ICPPEnumeration typeInIndex= getIndexBinding();
|
||||||
if (typeInIndex != null) {
|
if (typeInIndex != null) {
|
||||||
try {
|
return typeInIndex.getEnumerators();
|
||||||
return typeInIndex.getEnumerators();
|
|
||||||
} catch (DOMException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return EMPTY_ENUMERATORS;
|
return EMPTY_ENUMERATORS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2013 Nathan Ridge.
|
||||||
|
* 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Nathan Ridge - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binding for a specialization of an enumeration.
|
||||||
|
*/
|
||||||
|
public class CPPEnumerationSpecialization extends CPPSpecialization implements ICPPEnumerationSpecialization {
|
||||||
|
private IEnumerator[] fEnumerators;
|
||||||
|
private final IType fFixedType;
|
||||||
|
|
||||||
|
public CPPEnumerationSpecialization(ICPPEnumeration specialized, IBinding owner,
|
||||||
|
ICPPTemplateParameterMap argumentMap, IType fixedType) {
|
||||||
|
super(specialized, owner, argumentMap);
|
||||||
|
fFixedType = fixedType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnumerators(IEnumerator[] enumerators) {
|
||||||
|
fEnumerators = enumerators;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEnumeration getSpecializedBinding() {
|
||||||
|
return (ICPPEnumeration) super.getSpecializedBinding();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEnumerator[] getEnumerators() {
|
||||||
|
return fEnumerators;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getMinValue() {
|
||||||
|
return SemanticUtil.computeMinValue(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getMaxValue() {
|
||||||
|
return SemanticUtil.computeMaxValue(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSameType(IType type) {
|
||||||
|
if (type == this)
|
||||||
|
return true;
|
||||||
|
if (type instanceof ITypedef)
|
||||||
|
return type.isSameType(this);
|
||||||
|
if (!(type instanceof ICPPEnumerationSpecialization))
|
||||||
|
return false;
|
||||||
|
ICPPEnumerationSpecialization otherEnumSpec = (ICPPEnumerationSpecialization) type;
|
||||||
|
return getSpecializedBinding().isSameType(otherEnumSpec.getSpecializedBinding())
|
||||||
|
&& ((IType) getOwner()).isSameType((IType) otherEnumSpec.getOwner());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isScoped() {
|
||||||
|
return getSpecializedBinding().isScoped();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IType getFixedType() {
|
||||||
|
return fFixedType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPScope asScope() {
|
||||||
|
// TODO(nathanridge): Do we need a CPPEnumSpecializationScope?
|
||||||
|
return getSpecializedBinding().asScope();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object clone() {
|
||||||
|
throw new IllegalArgumentException("Enums must not be cloned"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEnumerator specializeEnumerator(IEnumerator enumerator) {
|
||||||
|
// The specialized enumerators are already computed, just need
|
||||||
|
// to look up the right one.
|
||||||
|
IEnumerator[] unspecializedEnumerators = getSpecializedBinding().getEnumerators();
|
||||||
|
for (int i = 0; i < fEnumerators.length; ++i) {
|
||||||
|
if (enumerator.equals(unspecializedEnumerators[i]))
|
||||||
|
return fEnumerators[i];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2013 Nathan Ridge.
|
||||||
|
* 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Nathan Ridge - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binding for a specialization of an enumerator.
|
||||||
|
*/
|
||||||
|
public class CPPEnumeratorSpecialization extends CPPSpecialization implements IEnumerator {
|
||||||
|
private final IValue fValue;
|
||||||
|
|
||||||
|
public CPPEnumeratorSpecialization(IEnumerator specialized, ICPPEnumerationSpecialization owner,
|
||||||
|
ICPPTemplateParameterMap argumentMap, IValue value) {
|
||||||
|
super(specialized, owner, argumentMap);
|
||||||
|
fValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEnumerationSpecialization getOwner() {
|
||||||
|
return (ICPPEnumerationSpecialization) super.getOwner();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IType getType() {
|
||||||
|
return getOwner();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IValue getValue() {
|
||||||
|
return fValue;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
* Copyright (c) 2004, 2010 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2011 Wind River Systems, Inc. and others.
|
* Copyright (c) 2011 Wind River Systems, Inc. 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2011 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2011 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
|
|
@ -39,23 +39,25 @@ public interface ICPPEvaluation extends ISerializableEvaluation {
|
||||||
boolean isValueDependent();
|
boolean isValueDependent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add description
|
* Returns the type of the expression, or a {@code FunctionSetType} if the expression evaluates
|
||||||
|
* to a function set.
|
||||||
*
|
*
|
||||||
* @param point determines the scope for name lookups
|
* @param point the point of instantiation, determines the scope for name lookups
|
||||||
*/
|
*/
|
||||||
IType getTypeOrFunctionSet(IASTNode point);
|
IType getTypeOrFunctionSet(IASTNode point);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add description
|
* Returns the value of the expression.
|
||||||
*
|
*
|
||||||
* @param point determines the scope for name lookups
|
* @param point the point of instantiation, determines the scope for name lookups
|
||||||
*/
|
*/
|
||||||
IValue getValue(IASTNode point);
|
IValue getValue(IASTNode point);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add description
|
* Returns the category of the expression value.
|
||||||
|
* @see ValueCategory
|
||||||
*
|
*
|
||||||
* @param point determines the scope for name lookups
|
* @param point the point of instantiation, determines the scope for name lookups
|
||||||
*/
|
*/
|
||||||
ValueCategory getValueCategory(IASTNode point);
|
ValueCategory getValueCategory(IASTNode point);
|
||||||
|
|
||||||
|
@ -78,7 +80,7 @@ public interface ICPPEvaluation extends ISerializableEvaluation {
|
||||||
*
|
*
|
||||||
* @param parameterMap maps function parameters to their values
|
* @param parameterMap maps function parameters to their values
|
||||||
* @param maxdepth allowed recursion depth
|
* @param maxdepth allowed recursion depth
|
||||||
* @param point determines the scope for name lookups
|
* @param point the point of instantiation, determines the scope for name lookups
|
||||||
* @return the computed evaluation
|
* @return the computed evaluation
|
||||||
*/
|
*/
|
||||||
ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, int maxdepth,
|
ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, int maxdepth,
|
||||||
|
@ -93,9 +95,7 @@ public interface ICPPEvaluation extends ISerializableEvaluation {
|
||||||
* CPPTemplates.PACK_SIZE_FAIL, and CPPTemplates.PACK_SIZE_NOT_FOUND. See their
|
* CPPTemplates.PACK_SIZE_FAIL, and CPPTemplates.PACK_SIZE_NOT_FOUND. See their
|
||||||
* declarations for their meanings.
|
* declarations for their meanings.
|
||||||
*
|
*
|
||||||
* See also CPPTemplates.determinePackSize().
|
* See also {@code CPPTemplates.determinePackSize()}.
|
||||||
*
|
|
||||||
* @noreference This method is not intended to be referenced by clients.
|
|
||||||
*/
|
*/
|
||||||
int determinePackSize(ICPPTemplateParameterMap tpMap);
|
int determinePackSize(ICPPTemplateParameterMap tpMap);
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Sergey Prigogin (Google) - initial API and implementation
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
* Nathan Ridge
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
|
@ -57,4 +58,14 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static IBinding instantiateBinding(IBinding binding, ICPPTemplateParameterMap tpMap, int packOffset,
|
||||||
|
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||||
|
try {
|
||||||
|
return CPPTemplates.instantiateBinding(binding, tpMap, packOffset, within, maxdepth, point);
|
||||||
|
} catch (DOMException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
return binding;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -42,7 +42,6 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
|
@ -76,6 +75,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||||
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.ICPPConstructor;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||||
|
@ -120,6 +121,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorSpecialization
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorTemplateSpecialization;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorTemplateSpecialization;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunction;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunction;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPEnumerationSpecialization;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPEnumeratorSpecialization;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFieldSpecialization;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFieldSpecialization;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionInstance;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionInstance;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionSpecialization;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionSpecialization;
|
||||||
|
@ -852,9 +855,29 @@ public class CPPTemplates {
|
||||||
ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) decl;
|
ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) decl;
|
||||||
IType type= instantiateType(aliasTemplate.getType(), tpMap, -1, getSpecializationContext(owner), point);
|
IType type= instantiateType(aliasTemplate.getType(), tpMap, -1, getSpecializationContext(owner), point);
|
||||||
spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), aliasTemplate, type);
|
spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), aliasTemplate, type);
|
||||||
} else if (decl instanceof IEnumeration || decl instanceof IEnumerator) {
|
} else if (decl instanceof ICPPEnumeration) {
|
||||||
// TODO(sprigogin): Deal with a case when an enumerator value depends on a template parameter.
|
ICPPClassSpecialization within = getSpecializationContext(owner);
|
||||||
spec = decl;
|
ICPPEnumeration enumeration = (ICPPEnumeration) decl;
|
||||||
|
IType fixedType = instantiateType(enumeration.getFixedType(), tpMap, -1, within, point);
|
||||||
|
CPPEnumerationSpecialization specializedEnumeration =
|
||||||
|
new CPPEnumerationSpecialization(enumeration, owner, tpMap, fixedType);
|
||||||
|
IEnumerator[] enumerators = enumeration.getEnumerators();
|
||||||
|
IEnumerator[] specializedEnumerators = new IEnumerator[enumerators.length];
|
||||||
|
for (int i = 0; i < enumerators.length; ++i) {
|
||||||
|
IEnumerator enumerator = enumerators[i];
|
||||||
|
IValue specializedValue =
|
||||||
|
instantiateValue(enumerator.getValue(), tpMap, -1, within, Value.MAX_RECURSION_DEPTH, point);
|
||||||
|
specializedEnumerators[i] =
|
||||||
|
new CPPEnumeratorSpecialization(enumerator, specializedEnumeration, tpMap, specializedValue);
|
||||||
|
}
|
||||||
|
specializedEnumeration.setEnumerators(specializedEnumerators);
|
||||||
|
spec = specializedEnumeration;
|
||||||
|
} else if (decl instanceof IEnumerator) {
|
||||||
|
IEnumerator enumerator = (IEnumerator) decl;
|
||||||
|
ICPPEnumeration enumeration = (ICPPEnumeration) enumerator.getOwner();
|
||||||
|
ICPPEnumerationSpecialization enumSpec =
|
||||||
|
(ICPPEnumerationSpecialization) owner.specializeMember(enumeration, point);
|
||||||
|
spec = enumSpec.specializeEnumerator(enumerator);
|
||||||
} else if (decl instanceof ICPPUsingDeclaration) {
|
} else if (decl instanceof ICPPUsingDeclaration) {
|
||||||
IBinding[] delegates= ((ICPPUsingDeclaration) decl).getDelegates();
|
IBinding[] delegates= ((ICPPUsingDeclaration) decl).getDelegates();
|
||||||
List<IBinding> result= new ArrayList<IBinding>();
|
List<IBinding> result= new ArrayList<IBinding>();
|
||||||
|
@ -1305,6 +1328,53 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IBinding instantiateBinding(IBinding binding, ICPPTemplateParameterMap tpMap, int packOffset,
|
||||||
|
ICPPClassSpecialization within, int maxdepth, IASTNode point) throws DOMException {
|
||||||
|
if (binding instanceof ICPPClassTemplate) {
|
||||||
|
binding = createDeferredInstance((ICPPClassTemplate) binding);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (binding instanceof ICPPUnknownBinding) {
|
||||||
|
return resolveUnknown((ICPPUnknownBinding) binding, tpMap, packOffset, within, point);
|
||||||
|
} else if (binding instanceof IEnumerator
|
||||||
|
|| binding instanceof ICPPMethod
|
||||||
|
|| binding instanceof ICPPField
|
||||||
|
|| binding instanceof ICPPEnumeration
|
||||||
|
|| binding instanceof ICPPClassType) {
|
||||||
|
IBinding owner = binding.getOwner();
|
||||||
|
if (!(owner instanceof ICPPSpecialization)) {
|
||||||
|
owner = instantiateBinding(owner, tpMap, packOffset, within, maxdepth, point);
|
||||||
|
}
|
||||||
|
if (binding instanceof IEnumerator) {
|
||||||
|
if (owner instanceof ICPPEnumerationSpecialization) {
|
||||||
|
return ((ICPPEnumerationSpecialization) owner).specializeEnumerator((IEnumerator) binding);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (owner instanceof ICPPClassSpecialization) {
|
||||||
|
return ((ICPPClassSpecialization) owner).specializeMember(binding, point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (binding instanceof CPPFunctionInstance) {
|
||||||
|
// TODO(nathanridge):
|
||||||
|
// Maybe we should introduce a CPPDeferredFunctionInstance and have things that can return
|
||||||
|
// a dependent CPPFunctionInstance (like instantiateForAddressOfFunction) return that when
|
||||||
|
// appropriate?
|
||||||
|
CPPFunctionInstance origInstance = (CPPFunctionInstance) binding;
|
||||||
|
ICPPTemplateArgument[] origArgs = origInstance.getTemplateArguments();
|
||||||
|
ICPPTemplateArgument[] newArgs = instantiateArguments(origArgs, tpMap, packOffset, within, point, false);
|
||||||
|
if (origArgs != newArgs) {
|
||||||
|
CPPTemplateParameterMap newMap = instantiateArgumentMap(origInstance.getTemplateParameterMap(),
|
||||||
|
tpMap, packOffset, within, point);
|
||||||
|
IType newType = instantiateType(origInstance.getType(), tpMap, packOffset, within, point);
|
||||||
|
IType[] newExceptionSpecs = instantiateTypes(origInstance.getExceptionSpecification(),
|
||||||
|
tpMap, packOffset, within, point);
|
||||||
|
return new CPPFunctionInstance((ICPPFunction) origInstance.getTemplateDefinition(), origInstance.getOwner(),
|
||||||
|
newMap, newArgs, (ICPPFunctionType) newType, newExceptionSpecs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return binding;
|
||||||
|
}
|
||||||
|
|
||||||
public static IType resolveTemplateTypeParameter(final ICPPTemplateParameter tpar,
|
public static IType resolveTemplateTypeParameter(final ICPPTemplateParameter tpar,
|
||||||
ICPPTemplateParameterMap tpMap, int packOffset, IASTNode point) {
|
ICPPTemplateParameterMap tpMap, int packOffset, IASTNode point) {
|
||||||
ICPPTemplateArgument arg= null;
|
ICPPTemplateArgument arg= null;
|
||||||
|
@ -2410,7 +2480,8 @@ public class CPPTemplates {
|
||||||
if (arg.isTypeValue())
|
if (arg.isTypeValue())
|
||||||
return isDependentType(arg.getTypeValue());
|
return isDependentType(arg.getTypeValue());
|
||||||
|
|
||||||
return arg.getNonTypeEvaluation().isValueDependent();
|
ICPPEvaluation evaluation = arg.getNonTypeEvaluation();
|
||||||
|
return evaluation.isTypeDependent() || evaluation.isValueDependent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean containsDependentType(List<IType> ts) {
|
public static boolean containsDependentType(List<IType> ts) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2012 Wind River Systems, Inc. and others.
|
* Copyright (c) 2012, 2013 Wind River Systems, Inc. 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
|
||||||
|
@ -25,10 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||||
|
@ -241,20 +238,14 @@ public class EvalBinding extends CPPEvaluation {
|
||||||
}
|
}
|
||||||
if (binding instanceof ICPPTemplateNonTypeParameter) {
|
if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||||
IType type= ((ICPPTemplateNonTypeParameter) binding).getType();
|
IType type= ((ICPPTemplateNonTypeParameter) binding).getType();
|
||||||
if (CPPTemplates.isDependentType(type))
|
|
||||||
return new TypeOfDependentExpression(this);
|
|
||||||
return prvalueType(type);
|
return prvalueType(type);
|
||||||
}
|
}
|
||||||
if (binding instanceof IVariable) {
|
if (binding instanceof IVariable) {
|
||||||
final IType type = ((IVariable) binding).getType();
|
final IType type = ((IVariable) binding).getType();
|
||||||
if (CPPTemplates.isDependentType(type))
|
|
||||||
return new TypeOfDependentExpression(this);
|
|
||||||
return SemanticUtil.mapToAST(glvalueType(type), point);
|
return SemanticUtil.mapToAST(glvalueType(type), point);
|
||||||
}
|
}
|
||||||
if (binding instanceof IFunction) {
|
if (binding instanceof IFunction) {
|
||||||
final IFunctionType type = ((IFunction) binding).getType();
|
final IFunctionType type = ((IFunction) binding).getType();
|
||||||
if (CPPTemplates.isDependentType(type))
|
|
||||||
return new TypeOfDependentExpression(this);
|
|
||||||
return SemanticUtil.mapToAST(type, point);
|
return SemanticUtil.mapToAST(type, point);
|
||||||
}
|
}
|
||||||
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||||
|
@ -325,55 +316,26 @@ public class EvalBinding extends CPPEvaluation {
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||||
IBinding binding = getBinding();
|
IBinding origBinding = getBinding();
|
||||||
if (binding instanceof IEnumerator) {
|
if (origBinding instanceof ICPPTemplateNonTypeParameter) {
|
||||||
IEnumerator enumerator = (IEnumerator) binding;
|
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding);
|
||||||
IType originalType = enumerator.getType();
|
|
||||||
IType type = CPPTemplates.instantiateType(originalType, tpMap, packOffset, within, point);
|
|
||||||
IValue originalValue = enumerator.getValue();
|
|
||||||
IValue value = CPPTemplates.instantiateValue(originalValue, tpMap, packOffset, within, maxdepth, point);
|
|
||||||
// TODO(sprigogin): Not sure if following condition is correct.
|
|
||||||
if (type != originalType || value != originalValue)
|
|
||||||
return new EvalFixed(type, ValueCategory.PRVALUE, value);
|
|
||||||
} else if (binding instanceof ICPPTemplateNonTypeParameter) {
|
|
||||||
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) binding);
|
|
||||||
if (argument != null && argument.isNonTypeValue()) {
|
if (argument != null && argument.isNonTypeValue()) {
|
||||||
return argument.getNonTypeEvaluation();
|
return argument.getNonTypeEvaluation();
|
||||||
}
|
}
|
||||||
// TODO(sprigogin): Do we need something similar for pack expansion?
|
// TODO(sprigogin): Do we need something similar for pack expansion?
|
||||||
} else if (binding instanceof ICPPUnknownBinding) {
|
} else if (origBinding instanceof ICPPParameter) {
|
||||||
binding = resolveUnknown((ICPPUnknownBinding) binding, tpMap, packOffset, within, point);
|
ICPPParameter parameter = (ICPPParameter) origBinding;
|
||||||
} else if (binding instanceof ICPPMethod) {
|
IType origType = parameter.getType();
|
||||||
IBinding owner = binding.getOwner();
|
IType instantiatedType = CPPTemplates.instantiateType(origType, tpMap, packOffset, within, point);
|
||||||
if (owner instanceof ICPPClassTemplate) {
|
if (origType != instantiatedType) {
|
||||||
owner = resolveUnknown(CPPTemplates.createDeferredInstance((ICPPClassTemplate) owner),
|
return new EvalFixed(instantiatedType, ValueCategory.LVALUE, Value.create(this));
|
||||||
tpMap, packOffset, within, point);
|
|
||||||
}
|
|
||||||
if (owner instanceof ICPPClassSpecialization) {
|
|
||||||
binding = CPPTemplates.createSpecialization((ICPPClassSpecialization) owner,
|
|
||||||
binding, point);
|
|
||||||
}
|
|
||||||
} else if (binding instanceof ICPPField) {
|
|
||||||
IBinding owner = binding.getOwner();
|
|
||||||
if (owner instanceof ICPPClassTemplate) {
|
|
||||||
owner = resolveUnknown(CPPTemplates.createDeferredInstance((ICPPClassTemplate) owner),
|
|
||||||
tpMap, packOffset, within, point);
|
|
||||||
}
|
|
||||||
if (owner instanceof ICPPClassSpecialization) {
|
|
||||||
binding = CPPTemplates.createSpecialization((ICPPClassSpecialization) owner,
|
|
||||||
binding, point);
|
|
||||||
}
|
|
||||||
} else if (binding instanceof ICPPParameter) {
|
|
||||||
ICPPParameter parameter = (ICPPParameter) binding;
|
|
||||||
IType originalType = parameter.getType();
|
|
||||||
IType type = CPPTemplates.instantiateType(originalType, tpMap, packOffset, within, point);
|
|
||||||
if (originalType != type) {
|
|
||||||
return new EvalFixed(type, ValueCategory.LVALUE, Value.create(this));
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
IBinding instantiatedBinding = instantiateBinding(origBinding, tpMap, packOffset, within, maxdepth, point);
|
||||||
|
if (instantiatedBinding != origBinding)
|
||||||
|
return new EvalBinding(instantiatedBinding, null);
|
||||||
}
|
}
|
||||||
if (binding == fBinding)
|
return this;
|
||||||
return this;
|
|
||||||
return new EvalBinding(binding, getFixedType());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,12 +34,15 @@ import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||||
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.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
|
@ -669,4 +672,40 @@ public class SemanticUtil {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long computeMaxValue(IEnumeration enumeration) {
|
||||||
|
long maxValue = Long.MIN_VALUE;
|
||||||
|
IEnumerator[] enumerators = enumeration.getEnumerators();
|
||||||
|
for (IEnumerator enumerator : enumerators) {
|
||||||
|
IValue value = enumerator.getValue();
|
||||||
|
if (value != null) {
|
||||||
|
Long val = value.numericalValue();
|
||||||
|
if (val != null) {
|
||||||
|
long v = val.longValue();
|
||||||
|
if (v > maxValue) {
|
||||||
|
maxValue = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return maxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long computeMinValue(IEnumeration enumeration) {
|
||||||
|
long minValue = Long.MAX_VALUE;
|
||||||
|
IEnumerator[] enumerators = enumeration.getEnumerators();
|
||||||
|
for (IEnumerator enumerator : enumerators) {
|
||||||
|
IValue value = enumerator.getValue();
|
||||||
|
if (value != null) {
|
||||||
|
Long val = value.numericalValue();
|
||||||
|
if (val != null) {
|
||||||
|
long v = val.longValue();
|
||||||
|
if (v < minValue) {
|
||||||
|
minValue = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return minValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -619,10 +619,11 @@ public class TemplateArgumentDeduction {
|
||||||
}
|
}
|
||||||
ICPPTemplateArgument pattern = p[j].getExpansionPattern();
|
ICPPTemplateArgument pattern = p[j].getExpansionPattern();
|
||||||
for (int i= j; i < a.length; i++) {
|
for (int i= j; i < a.length; i++) {
|
||||||
|
if (i != j)
|
||||||
|
deduct.incPackOffset();
|
||||||
if (!deduct.fromTemplateArgument(pattern, a[i], point)) {
|
if (!deduct.fromTemplateArgument(pattern, a[i], point)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
deduct.incPackOffset();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2009 Symbian Software Systems and others.
|
* Copyright (c) 2007, 2013 Symbian Software Systems 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
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Thomas Corbat (IFS)
|
* Thomas Corbat (IFS)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
|
||||||
|
@ -62,4 +63,6 @@ public interface IIndexCPPBindingConstants {
|
||||||
int CPP_USING_DECLARATION_SPECIALIZATION= IIndexBindingConstants.LAST_CONSTANT + 49;
|
int CPP_USING_DECLARATION_SPECIALIZATION= IIndexBindingConstants.LAST_CONSTANT + 49;
|
||||||
int CPP_UNKNOWN_METHOD = IIndexBindingConstants.LAST_CONSTANT + 50;
|
int CPP_UNKNOWN_METHOD = IIndexBindingConstants.LAST_CONSTANT + 50;
|
||||||
int CPP_TEMPLATE_ALIAS = IIndexBindingConstants.LAST_CONSTANT + 51;
|
int CPP_TEMPLATE_ALIAS = IIndexBindingConstants.LAST_CONSTANT + 51;
|
||||||
|
int CPP_ENUMERATION_SPECIALIZATION = IIndexBindingConstants.LAST_CONSTANT + 52;
|
||||||
|
int CPP_ENUMERATOR_SPECIALIZATION = IIndexBindingConstants.LAST_CONSTANT + 53;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index.composite.c;
|
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
@ -25,7 +24,7 @@ class CompositeCEnumeration extends CompositeCBinding implements IEnumeration, I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnumerator[] getEnumerators() throws DOMException {
|
public IEnumerator[] getEnumerators() {
|
||||||
IEnumerator[] result = ((IEnumeration)rbinding).getEnumerators();
|
IEnumerator[] result = ((IEnumeration)rbinding).getEnumerators();
|
||||||
for (int i= 0; i < result.length; i++)
|
for (int i= 0; i < result.length; i++)
|
||||||
result[i] = (IEnumerator) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
result[i] = (IEnumerator) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
@ -27,7 +26,7 @@ class CompositeCPPEnumeration extends CompositeCPPBinding implements ICPPEnumera
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnumerator[] getEnumerators() throws DOMException {
|
public IEnumerator[] getEnumerators() {
|
||||||
IEnumerator[] result = ((IEnumeration)rbinding).getEnumerators();
|
IEnumerator[] result = ((IEnumeration)rbinding).getEnumerators();
|
||||||
for (int i= 0; i < result.length; i++)
|
for (int i= 0; i < result.length; i++)
|
||||||
result[i] = (IEnumerator) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
result[i] = (IEnumerator) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.parser;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
@ -159,26 +158,15 @@ public class InternalParserUtil extends ParserFactory {
|
||||||
IFileStore store = EFS.getStore(file.getLocationURI());
|
IFileStore store = EFS.getStore(file.getLocationURI());
|
||||||
IFileInfo fileInfo = store.fetchInfo();
|
IFileInfo fileInfo = store.fetchInfo();
|
||||||
input= file.getContents(true);
|
input= file.getContents(true);
|
||||||
if (!(input instanceof FileInputStream)) {
|
if (input instanceof FileInputStream) {
|
||||||
/*
|
|
||||||
* In general, non-local file-systems will not use FileInputStream.
|
|
||||||
* Instead make a cached copy of the file and open an input stream to that.
|
|
||||||
*/
|
|
||||||
File fileCache = store.toLocalFile(EFS.CACHE, null);
|
|
||||||
try {
|
try {
|
||||||
input = new FileInputStream(fileCache);
|
return createFileContent(path, null, file.getCharset(), input,
|
||||||
} catch (FileNotFoundException e) {
|
fileInfo.getLastModified(), fileInfo.getLength(), fileReadTime);
|
||||||
CCorePlugin.log(e);
|
} finally {
|
||||||
return null;
|
try {
|
||||||
}
|
input.close();
|
||||||
}
|
} catch (IOException e) {
|
||||||
try {
|
}
|
||||||
return createFileContent(path, file.getCharset(), input,
|
|
||||||
fileInfo.getLastModified(), fileInfo.getLength(), fileReadTime);
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
input.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -193,18 +181,19 @@ public class InternalParserUtil extends ParserFactory {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a code reader for an external location, normalizing path to
|
* Creates a code reader for an external location, normalizing path to
|
||||||
* canonical path.
|
* canonical path.
|
||||||
*/
|
*/
|
||||||
public static InternalFileContent createExternalFileContent(String externalLocation, String encoding) {
|
public static InternalFileContent createExternalFileContent(final String externalLocation, String encoding) {
|
||||||
long fileReadTime = System.currentTimeMillis();
|
long fileReadTime = System.currentTimeMillis();
|
||||||
File includeFile = null;
|
File includeFile = null;
|
||||||
String path = null;
|
String path = null;
|
||||||
|
String localPath = null;
|
||||||
if (!UNCPathConverter.isUNC(externalLocation)) {
|
if (!UNCPathConverter.isUNC(externalLocation)) {
|
||||||
includeFile = new File(externalLocation);
|
includeFile = new File(externalLocation);
|
||||||
// Use the canonical path so that in case of non-case-sensitive OSs
|
// Use the canonical path so that in case of non-case-sensitive OSs
|
||||||
|
@ -216,6 +205,7 @@ public class InternalParserUtil extends ParserFactory {
|
||||||
IFileStore store = EFS.getStore(UNCPathConverter.getInstance().toURI(externalLocation));
|
IFileStore store = EFS.getStore(UNCPathConverter.getInstance().toURI(externalLocation));
|
||||||
includeFile = store.toLocalFile(EFS.CACHE, null);
|
includeFile = store.toLocalFile(EFS.CACHE, null);
|
||||||
path = externalLocation;
|
path = externalLocation;
|
||||||
|
localPath = includeFile.getAbsolutePath();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,7 +220,7 @@ public class InternalParserUtil extends ParserFactory {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return createFileContent(path, encoding, in, timestamp, fileSize, fileReadTime);
|
return createFileContent(path, localPath, encoding, in, timestamp, fileSize, fileReadTime);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
in.close();
|
in.close();
|
||||||
|
@ -241,10 +231,13 @@ public class InternalParserUtil extends ParserFactory {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static InternalFileContent createFileContent(String path, String charset, InputStream in,
|
private static InternalFileContent createFileContent(String path, String localPath, String charset, InputStream in,
|
||||||
long fileTimestamp, long fileSize, long fileReadTime) {
|
long fileTimestamp, long fileSize, long fileReadTime) {
|
||||||
|
if (localPath == null) {
|
||||||
|
localPath = path;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
AbstractCharArray chars= FileCharArray.create(path, charset, in);
|
AbstractCharArray chars= FileCharArray.create(localPath, charset, in);
|
||||||
if (chars == null)
|
if (chars == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,10 @@ import org.eclipse.cdt.internal.core.dom.IIncludeFileResolutionHeuristics;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
||||||
import org.eclipse.cdt.internal.core.parser.IMacroDictionary;
|
import org.eclipse.cdt.internal.core.parser.IMacroDictionary;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.InclusionKind;
|
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.InclusionKind;
|
||||||
|
import org.eclipse.cdt.utils.UNCPathConverter;
|
||||||
|
import org.eclipse.core.filesystem.EFS;
|
||||||
|
import org.eclipse.core.filesystem.IFileStore;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal implementation of the file content providers
|
* Internal implementation of the file content providers
|
||||||
|
@ -49,7 +53,16 @@ public abstract class InternalFileContentProvider extends IncludeFileContentProv
|
||||||
/**
|
/**
|
||||||
* Checks whether the specified inclusion exists.
|
* Checks whether the specified inclusion exists.
|
||||||
*/
|
*/
|
||||||
public boolean getInclusionExists(String path) {
|
public boolean getInclusionExists(final String path) {
|
||||||
|
if (UNCPathConverter.isUNC(path)) {
|
||||||
|
try {
|
||||||
|
IFileStore store = EFS.getStore(UNCPathConverter.getInstance().toURI(path));
|
||||||
|
return store.fetchInfo().exists();
|
||||||
|
} catch (CoreException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new File(path).exists();
|
return new File(path).exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,10 +229,11 @@ public class PDOM extends PlatformObject implements IPDOM {
|
||||||
* 137.0 - Fixed serialization of very large types and template arguments, bug 392278.
|
* 137.0 - Fixed serialization of very large types and template arguments, bug 392278.
|
||||||
* 138.0 - Constexpr functions, bug 395238.
|
* 138.0 - Constexpr functions, bug 395238.
|
||||||
* 139.0 - More efficient and robust storage of types and template arguments, bug 395243.
|
* 139.0 - More efficient and robust storage of types and template arguments, bug 395243.
|
||||||
|
* 140.0 - Enumerators with dependent values, bug 389009.
|
||||||
*/
|
*/
|
||||||
private static final int MIN_SUPPORTED_VERSION= version(139, 0);
|
private static final int MIN_SUPPORTED_VERSION= version(140, 0);
|
||||||
private static final int MAX_SUPPORTED_VERSION= version(139, Short.MAX_VALUE);
|
private static final int MAX_SUPPORTED_VERSION= version(140, Short.MAX_VALUE);
|
||||||
private static final int DEFAULT_VERSION = version(139, 0);
|
private static final int DEFAULT_VERSION = version(140, 0);
|
||||||
|
|
||||||
private static int version(int major, int minor) {
|
private static int version(int major, int minor) {
|
||||||
return (major << 16) + minor;
|
return (major << 16) + minor;
|
||||||
|
|
|
@ -309,7 +309,7 @@ public class PDOMASTAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnumerator[] getEnumerators() throws DOMException {
|
public IEnumerator[] getEnumerators() {
|
||||||
return fDelegate.getEnumerators();
|
return fDelegate.getEnumerators();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ public class PDOMASTAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnumerator[] getEnumerators() throws DOMException {
|
public IEnumerator[] getEnumerators() {
|
||||||
return ((IEnumeration) fDelegate).getEnumerators();
|
return ((IEnumeration) fDelegate).getEnumerators();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class PDOMNamedNode extends PDOMNode {
|
public abstract class PDOMNamedNode extends PDOMNode {
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +103,6 @@ public abstract class PDOMNamedNode extends PDOMNode {
|
||||||
fName= nameCharArray;
|
fName= nameCharArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(PDOMLinkage linkage) throws CoreException {
|
public void delete(PDOMLinkage linkage) throws CoreException {
|
||||||
final Database db = getDB();
|
final Database db = getDB();
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2010 Wind River Systems, Inc. and others.
|
* Copyright (c) 2010, 2013 Wind River Systems, Inc. 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.IPDOMBinding;
|
||||||
*/
|
*/
|
||||||
public interface IPDOMCPPEnumType extends ICPPEnumeration, IPDOMBinding, IIndexType {
|
public interface IPDOMCPPEnumType extends ICPPEnumeration, IPDOMBinding, IIndexType {
|
||||||
/**
|
/**
|
||||||
* Return the scope name, for use in {@link IScope#getScopeName()}
|
* Returns the scope name, for use in {@link IScope#getScopeName()}
|
||||||
*/
|
*/
|
||||||
IIndexName getScopeName();
|
IIndexName getScopeName();
|
||||||
|
|
||||||
|
@ -33,5 +34,5 @@ public interface IPDOMCPPEnumType extends ICPPEnumeration, IPDOMBinding, IIndexT
|
||||||
/**
|
/**
|
||||||
* Called by the scope to access the enumerators.
|
* Called by the scope to access the enumerators.
|
||||||
*/
|
*/
|
||||||
void loadEnumerators(CharArrayMap<PDOMCPPEnumerator> map);
|
void loadEnumerators(CharArrayMap<IPDOMCPPEnumerator> map);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2013 Google, Inc 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMBinding;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for a c++ enumerator stored in the index.
|
||||||
|
*/
|
||||||
|
public interface IPDOMCPPEnumerator extends IEnumerator, IPDOMBinding {
|
||||||
|
}
|
|
@ -65,7 +65,7 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope {
|
||||||
@Override
|
@Override
|
||||||
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) {
|
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) {
|
||||||
try {
|
try {
|
||||||
CharArrayMap<PDOMCPPEnumerator> map= getBindingMap(fBinding);
|
CharArrayMap<IPDOMCPPEnumerator> map= getBindingMap(fBinding);
|
||||||
return map.get(name.toCharArray());
|
return map.get(name.toCharArray());
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
@ -81,7 +81,7 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope {
|
||||||
@Override
|
@Override
|
||||||
public IBinding[] getBindings(ScopeLookupData lookup) {
|
public IBinding[] getBindings(ScopeLookupData lookup) {
|
||||||
try {
|
try {
|
||||||
CharArrayMap<PDOMCPPEnumerator> map= getBindingMap(fBinding);
|
CharArrayMap<IPDOMCPPEnumerator> map= getBindingMap(fBinding);
|
||||||
if (lookup.isPrefixLookup()) {
|
if (lookup.isPrefixLookup()) {
|
||||||
final List<IBinding> result= new ArrayList<IBinding>();
|
final List<IBinding> result= new ArrayList<IBinding>();
|
||||||
final char[] nc= lookup.getLookupKey();
|
final char[] nc= lookup.getLookupKey();
|
||||||
|
@ -135,36 +135,36 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope {
|
||||||
return fBinding.hashCode();
|
return fBinding.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CharArrayMap<PDOMCPPEnumerator> getBindingMap(IPDOMCPPEnumType enumeration) throws CoreException {
|
private static CharArrayMap<IPDOMCPPEnumerator> getBindingMap(IPDOMCPPEnumType enumeration) throws CoreException {
|
||||||
final Long key= enumeration.getRecord() + PDOMCPPLinkage.CACHE_MEMBERS;
|
final Long key= enumeration.getRecord() + PDOMCPPLinkage.CACHE_MEMBERS;
|
||||||
final PDOM pdom = enumeration.getPDOM();
|
final PDOM pdom = enumeration.getPDOM();
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Reference<CharArrayMap<PDOMCPPEnumerator>> cached= (Reference<CharArrayMap<PDOMCPPEnumerator>>) pdom.getCachedResult(key);
|
Reference<CharArrayMap<IPDOMCPPEnumerator>> cached= (Reference<CharArrayMap<IPDOMCPPEnumerator>>) pdom.getCachedResult(key);
|
||||||
CharArrayMap<PDOMCPPEnumerator> map= cached == null ? null : cached.get();
|
CharArrayMap<IPDOMCPPEnumerator> map= cached == null ? null : cached.get();
|
||||||
|
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
// there is no cache, build it:
|
// there is no cache, build it:
|
||||||
map= new CharArrayMap<PDOMCPPEnumerator>();
|
map= new CharArrayMap<IPDOMCPPEnumerator>();
|
||||||
enumeration.loadEnumerators(map);
|
enumeration.loadEnumerators(map);
|
||||||
pdom.putCachedResult(key, new SoftReference<CharArrayMap<?>>(map));
|
pdom.putCachedResult(key, new SoftReference<CharArrayMap<?>>(map));
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateCache(PDOMCPPEnumeration enumType, PDOMCPPEnumerator enumItem) {
|
public static void updateCache(IPDOMCPPEnumType enumType, IPDOMCPPEnumerator enumItem) {
|
||||||
final Long key= enumType.getRecord() + PDOMCPPLinkage.CACHE_MEMBERS;
|
final Long key= enumType.getRecord() + PDOMCPPLinkage.CACHE_MEMBERS;
|
||||||
final PDOM pdom = enumType.getPDOM();
|
final PDOM pdom = enumType.getPDOM();
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Reference<CharArrayMap<PDOMCPPEnumerator>> cached= (Reference<CharArrayMap<PDOMCPPEnumerator>>) pdom.getCachedResult(key);
|
Reference<CharArrayMap<IPDOMCPPEnumerator>> cached= (Reference<CharArrayMap<IPDOMCPPEnumerator>>) pdom.getCachedResult(key);
|
||||||
CharArrayMap<PDOMCPPEnumerator> map= cached == null ? null : cached.get();
|
CharArrayMap<IPDOMCPPEnumerator> map= cached == null ? null : cached.get();
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
map.put(enumType.getNameCharArray(), enumItem);
|
map.put(enumType.getNameCharArray(), enumItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerator[] getEnumerators(PDOMCPPEnumeration enumType) {
|
public static IEnumerator[] getEnumerators(IPDOMCPPEnumType enumType) {
|
||||||
try {
|
try {
|
||||||
CharArrayMap<PDOMCPPEnumerator> map = getBindingMap(enumType);
|
CharArrayMap<IPDOMCPPEnumerator> map = getBindingMap(enumType);
|
||||||
List<IEnumerator> result= new ArrayList<IEnumerator>();
|
List<IEnumerator> result= new ArrayList<IEnumerator>();
|
||||||
for (IEnumerator value : map.values()) {
|
for (IEnumerator value : map.values()) {
|
||||||
if (IndexFilter.ALL_DECLARED.acceptBinding(value)) {
|
if (IndexFilter.ALL_DECLARED.acceptBinding(value)) {
|
||||||
|
@ -179,10 +179,10 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope {
|
||||||
return new IEnumerator[0];
|
return new IEnumerator[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void acceptViaCache(PDOMCPPEnumeration enumType, IPDOMVisitor visitor) {
|
public static void acceptViaCache(IPDOMCPPEnumType enumType, IPDOMVisitor visitor) {
|
||||||
try {
|
try {
|
||||||
CharArrayMap<PDOMCPPEnumerator> map = getBindingMap(enumType);
|
CharArrayMap<IPDOMCPPEnumerator> map = getBindingMap(enumType);
|
||||||
for (PDOMCPPEnumerator enumItem : map.values()) {
|
for (IPDOMCPPEnumerator enumItem : map.values()) {
|
||||||
visitor.visit(enumItem);
|
visitor.visit(enumItem);
|
||||||
visitor.leave(enumItem);
|
visitor.leave(enumItem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IPDOMCPPEnumType, IPD
|
||||||
if (node instanceof PDOMCPPEnumerator) {
|
if (node instanceof PDOMCPPEnumerator) {
|
||||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST);
|
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST);
|
||||||
list.addMember(node);
|
list.addMember(node);
|
||||||
PDOMCPPEnumScope.updateCache(this, (PDOMCPPEnumerator) node);
|
PDOMCPPEnumScope.updateCache(this, (IPDOMCPPEnumerator) node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,14 +218,14 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IPDOMCPPEnumType, IPD
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadEnumerators(final CharArrayMap<PDOMCPPEnumerator> map) {
|
public void loadEnumerators(final CharArrayMap<IPDOMCPPEnumerator> map) {
|
||||||
try {
|
try {
|
||||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST);
|
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST);
|
||||||
list.accept(new IPDOMVisitor() {
|
list.accept(new IPDOMVisitor() {
|
||||||
@Override
|
@Override
|
||||||
public boolean visit(IPDOMNode node) throws CoreException {
|
public boolean visit(IPDOMNode node) throws CoreException {
|
||||||
if (node instanceof PDOMCPPEnumerator) {
|
if (node instanceof IPDOMCPPEnumerator) {
|
||||||
final PDOMCPPEnumerator item = (PDOMCPPEnumerator) node;
|
final IPDOMCPPEnumerator item = (IPDOMCPPEnumerator) node;
|
||||||
map.put(item.getNameCharArray(), item);
|
map.put(item.getNameCharArray(), item);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -0,0 +1,258 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2013 Google, Inc 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||||
|
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
|
import org.eclipse.cdt.core.parser.util.CharArrayMap;
|
||||||
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumeration specialization in the index.
|
||||||
|
*/
|
||||||
|
class PDOMCPPEnumerationSpecialization extends PDOMCPPSpecialization
|
||||||
|
implements IPDOMCPPEnumType, IPDOMMemberOwner, ICPPEnumerationSpecialization {
|
||||||
|
private static final int OFFSET_ENUMERATOR_LIST = PDOMCPPSpecialization.RECORD_SIZE;
|
||||||
|
private static final int OFFSET_MIN_VALUE= OFFSET_ENUMERATOR_LIST + Database.PTR_SIZE;
|
||||||
|
private static final int OFFSET_MAX_VALUE= OFFSET_MIN_VALUE + 8;
|
||||||
|
private static final int OFFSET_FIXED_TYPE = OFFSET_MAX_VALUE + 8;
|
||||||
|
private static final int OFFSET_FLAGS = OFFSET_FIXED_TYPE + Database.TYPE_SIZE;
|
||||||
|
|
||||||
|
@SuppressWarnings("hiding")
|
||||||
|
protected static final int RECORD_SIZE = OFFSET_FLAGS + 1;
|
||||||
|
|
||||||
|
private Long fMinValue; // No need for volatile, all fields of Long are final.
|
||||||
|
private Long fMaxValue; // No need for volatile, all fields of Long are final.
|
||||||
|
private volatile IType fFixedType= ProblemBinding.NOT_INITIALIZED;
|
||||||
|
private PDOMCPPEnumScope fScope; // No need for volatile, all fields of PDOMCPPEnumScope are final.
|
||||||
|
|
||||||
|
public PDOMCPPEnumerationSpecialization(PDOMLinkage linkage, PDOMNode parent,
|
||||||
|
ICPPEnumeration enumeration, PDOMBinding specialized) throws CoreException {
|
||||||
|
super(linkage, parent, (ICPPSpecialization) enumeration, specialized);
|
||||||
|
storeProperties(enumeration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PDOMCPPEnumerationSpecialization(PDOMLinkage linkage, long record) {
|
||||||
|
super(linkage, record);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEnumeration getSpecializedBinding() {
|
||||||
|
return (ICPPEnumeration) super.getSpecializedBinding();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
||||||
|
storeProperties((ICPPEnumeration) newBinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void storeProperties(ICPPEnumeration enumeration) throws CoreException {
|
||||||
|
final Database db= getDB();
|
||||||
|
db.putByte(record + OFFSET_FLAGS, enumeration.isScoped() ? (byte) 1 : (byte) 0);
|
||||||
|
|
||||||
|
getLinkage().storeType(record + OFFSET_FIXED_TYPE, enumeration.getFixedType());
|
||||||
|
|
||||||
|
if (enumeration instanceof ICPPInternalBinding) {
|
||||||
|
if (((ICPPInternalBinding) enumeration).getDefinition() != null) {
|
||||||
|
final long minValue = enumeration.getMinValue();
|
||||||
|
final long maxValue = enumeration.getMaxValue();
|
||||||
|
db.putLong(record + OFFSET_MIN_VALUE, minValue);
|
||||||
|
db.putLong(record + OFFSET_MAX_VALUE, maxValue);
|
||||||
|
fMinValue= minValue;
|
||||||
|
fMaxValue= maxValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getRecordSize() {
|
||||||
|
return RECORD_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNodeType() {
|
||||||
|
return IIndexCPPBindingConstants.CPP_ENUMERATION_SPECIALIZATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEnumerator[] getEnumerators() {
|
||||||
|
return PDOMCPPEnumScope.getEnumerators(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(IPDOMVisitor visitor) throws CoreException {
|
||||||
|
PDOMCPPEnumScope.acceptViaCache(this, visitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addChild(PDOMNode node) throws CoreException {
|
||||||
|
if (node instanceof IPDOMCPPEnumerator) {
|
||||||
|
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST);
|
||||||
|
list.addMember(node);
|
||||||
|
PDOMCPPEnumScope.updateCache(this, (IPDOMCPPEnumerator) node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mayHaveChildren() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSameType(IType type) {
|
||||||
|
if (type instanceof ITypedef) {
|
||||||
|
return type.isSameType(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type instanceof PDOMNode) {
|
||||||
|
PDOMNode node= (PDOMNode) type;
|
||||||
|
if (node.getPDOM() == getPDOM()) {
|
||||||
|
return node.getRecord() == getRecord();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type instanceof IEnumeration) {
|
||||||
|
IEnumeration etype= (IEnumeration) type;
|
||||||
|
char[] nchars = etype.getNameCharArray();
|
||||||
|
if (nchars.length == 0) {
|
||||||
|
nchars= ASTTypeUtil.createNameForAnonymous(etype);
|
||||||
|
}
|
||||||
|
if (nchars == null || !CharArrayUtils.equals(nchars, getNameCharArray()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return SemanticUtil.isSameOwner(getOwner(), etype.getOwner());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getMinValue() {
|
||||||
|
if (fMinValue != null) {
|
||||||
|
return fMinValue.longValue();
|
||||||
|
}
|
||||||
|
long minValue= 0;
|
||||||
|
try {
|
||||||
|
minValue= getDB().getLong(record + OFFSET_MIN_VALUE);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
fMinValue= minValue;
|
||||||
|
return minValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getMaxValue() {
|
||||||
|
if (fMaxValue != null) {
|
||||||
|
return fMaxValue.longValue();
|
||||||
|
}
|
||||||
|
long maxValue= 0;
|
||||||
|
try {
|
||||||
|
maxValue= getDB().getLong(record + OFFSET_MAX_VALUE);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
fMaxValue= maxValue;
|
||||||
|
return maxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object clone() {
|
||||||
|
throw new IllegalArgumentException("Enums must not be cloned"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isScoped() {
|
||||||
|
try {
|
||||||
|
return getDB().getByte(record + OFFSET_FLAGS) != 0;
|
||||||
|
} catch (CoreException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IType getFixedType() {
|
||||||
|
if (fFixedType == ProblemBinding.NOT_INITIALIZED) {
|
||||||
|
fFixedType= loadFixedType();
|
||||||
|
}
|
||||||
|
return fFixedType;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IType loadFixedType() {
|
||||||
|
try {
|
||||||
|
return getLinkage().loadType(record + OFFSET_FIXED_TYPE);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPScope asScope() {
|
||||||
|
if (fScope == null) {
|
||||||
|
fScope= new PDOMCPPEnumScope(this);
|
||||||
|
}
|
||||||
|
return fScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadEnumerators(final CharArrayMap<IPDOMCPPEnumerator> map) {
|
||||||
|
try {
|
||||||
|
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST);
|
||||||
|
list.accept(new IPDOMVisitor() {
|
||||||
|
@Override
|
||||||
|
public boolean visit(IPDOMNode node) throws CoreException {
|
||||||
|
if (node instanceof IPDOMCPPEnumerator) {
|
||||||
|
final IPDOMCPPEnumerator item = (IPDOMCPPEnumerator) node;
|
||||||
|
map.put(item.getNameCharArray(), item);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void leave(IPDOMNode node) {}
|
||||||
|
});
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEnumerator specializeEnumerator(IEnumerator enumerator) {
|
||||||
|
// The specialized enumerators are already computed, just need to look up the right one.
|
||||||
|
IEnumerator[] unspecializedEnumerators = getSpecializedBinding().getEnumerators();
|
||||||
|
for (int i = 0; i < unspecializedEnumerators.length; ++i) {
|
||||||
|
if (enumerator.equals(unspecializedEnumerators[i])) {
|
||||||
|
IEnumerator[] enumerators = getEnumerators();
|
||||||
|
return i < enumerators.length ? enumerators[i] : enumerator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,14 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2010 QNX Software Systems and others.
|
* Copyright (c) 2006, 2013 QNX Software Systems 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer (QNX) - Initial API and implementation
|
* Doug Schaefer (QNX) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -26,11 +28,11 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
/**
|
/**
|
||||||
* Binding for a c++ enumerator in the index.
|
* Binding for a c++ enumerator in the index.
|
||||||
*/
|
*/
|
||||||
class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator {
|
class PDOMCPPEnumerator extends PDOMCPPBinding implements IPDOMCPPEnumerator {
|
||||||
private static final int VALUE= PDOMCPPBinding.RECORD_SIZE;
|
private static final int VALUE= PDOMCPPBinding.RECORD_SIZE;
|
||||||
|
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
protected static final int RECORD_SIZE = VALUE + 4;
|
protected static final int RECORD_SIZE = VALUE + Database.VALUE_SIZE;
|
||||||
|
|
||||||
public PDOMCPPEnumerator(PDOMLinkage linkage, PDOMNode parent, IEnumerator enumerator)
|
public PDOMCPPEnumerator(PDOMLinkage linkage, PDOMNode parent, IEnumerator enumerator)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
|
@ -55,11 +57,10 @@ class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator {
|
||||||
private void storeValue(IEnumerator enumerator) throws CoreException {
|
private void storeValue(IEnumerator enumerator) throws CoreException {
|
||||||
IValue value= enumerator.getValue();
|
IValue value= enumerator.getValue();
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
Long val= value.numericalValue();
|
getLinkage().storeValue(record + VALUE, value);
|
||||||
getDB().putInt(record + VALUE, val == null ? -1 : val.intValue());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
||||||
if (newBinding instanceof IEnumerator)
|
if (newBinding instanceof IEnumerator)
|
||||||
|
@ -77,8 +78,7 @@ class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator {
|
||||||
@Override
|
@Override
|
||||||
public IValue getValue() {
|
public IValue getValue() {
|
||||||
try {
|
try {
|
||||||
int val= getDB().getInt(record + VALUE);
|
return getLinkage().loadValue(record + VALUE);
|
||||||
return Value.create(val);
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2013 Google, Inc 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binding for a specialization of an enumerator in the index.
|
||||||
|
*/
|
||||||
|
class PDOMCPPEnumeratorSpecialization extends PDOMCPPSpecialization implements IPDOMCPPEnumerator {
|
||||||
|
private static final int VALUE= PDOMCPPSpecialization.RECORD_SIZE;
|
||||||
|
|
||||||
|
@SuppressWarnings("hiding")
|
||||||
|
protected static final int RECORD_SIZE = VALUE + Database.VALUE_SIZE;
|
||||||
|
|
||||||
|
public PDOMCPPEnumeratorSpecialization(PDOMLinkage linkage, PDOMNode parent,
|
||||||
|
IEnumerator enumerator, PDOMBinding specialized) throws CoreException {
|
||||||
|
super(linkage, parent, (ICPPSpecialization) enumerator, specialized);
|
||||||
|
storeValue(enumerator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PDOMCPPEnumeratorSpecialization(PDOMLinkage linkage, long record) {
|
||||||
|
super(linkage, record);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getRecordSize() {
|
||||||
|
return RECORD_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNodeType() {
|
||||||
|
return IIndexCPPBindingConstants.CPP_ENUMERATOR_SPECIALIZATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void storeValue(IEnumerator enumerator) throws CoreException {
|
||||||
|
IValue value= enumerator.getValue();
|
||||||
|
if (value != null) {
|
||||||
|
getLinkage().storeValue(record + VALUE, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
||||||
|
if (newBinding instanceof IEnumerator)
|
||||||
|
storeValue((IEnumerator) newBinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IType getType() {
|
||||||
|
IIndexFragmentBinding owner = getOwner();
|
||||||
|
if (owner instanceof IType)
|
||||||
|
return (IType) owner;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IValue getValue() {
|
||||||
|
try {
|
||||||
|
return getLinkage().loadValue(record + VALUE);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
return Value.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2012 QNX Software Systems and others.
|
* Copyright (c) 2005, 2013 QNX Software Systems 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
|
||||||
|
@ -534,6 +534,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
result= new PDOMCPPTypedefSpecialization(this, parent, (ITypedef) special, orig);
|
result= new PDOMCPPTypedefSpecialization(this, parent, (ITypedef) special, orig);
|
||||||
} else if (special instanceof ICPPUsingDeclaration) {
|
} else if (special instanceof ICPPUsingDeclaration) {
|
||||||
result= new PDOMCPPUsingDeclarationSpecialization(this, parent, (ICPPUsingDeclaration) special, orig);
|
result= new PDOMCPPUsingDeclarationSpecialization(this, parent, (ICPPUsingDeclaration) special, orig);
|
||||||
|
} else if (special instanceof ICPPEnumeration) {
|
||||||
|
result= new PDOMCPPEnumerationSpecialization(this, parent, (ICPPEnumeration) special, orig);
|
||||||
|
} else if (special instanceof IEnumerator) {
|
||||||
|
result= new PDOMCPPEnumeratorSpecialization(this, parent, (IEnumerator) special, orig);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -893,6 +897,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
return new PDOMCPPUsingDeclarationSpecialization(this, record);
|
return new PDOMCPPUsingDeclarationSpecialization(this, record);
|
||||||
case CPP_TEMPLATE_ALIAS:
|
case CPP_TEMPLATE_ALIAS:
|
||||||
return new PDOMCPPAliasTemplate(this, record);
|
return new PDOMCPPAliasTemplate(this, record);
|
||||||
|
case CPP_ENUMERATION_SPECIALIZATION:
|
||||||
|
return new PDOMCPPEnumeratorSpecialization(this, record);
|
||||||
|
case CPP_ENUMERATOR_SPECIALIZATION:
|
||||||
|
return new PDOMCPPEnumeratorSpecialization(this, record);
|
||||||
}
|
}
|
||||||
assert false : "nodeid= " + nodeType; //$NON-NLS-1$
|
assert false : "nodeid= " + nodeType; //$NON-NLS-1$
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -132,4 +132,5 @@ CProjectStorageType.separatefile.name = Xml Storage (Separate Files)
|
||||||
scannerInfoProvider2.name = Scanner Info Provider
|
scannerInfoProvider2.name = Scanner Info Provider
|
||||||
efsExtensionProvider.name = EFSExtensionProvider
|
efsExtensionProvider.name = EFSExtensionProvider
|
||||||
refreshExclusionFactory.name = Refresh Exclusion Factory
|
refreshExclusionFactory.name = Refresh Exclusion Factory
|
||||||
uncPathConverter.name = UNC Path Converter
|
uncPathConverter.name = UNC Path Converter
|
||||||
|
ScannerInfoExtensionLanguageSettingsProvider.name=Contributed ScannerInfo Entries
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<?eclipse version="3.0"?>
|
<?eclipse version="3.0"?>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|
||||||
|
|
||||||
<!-- =================================================================================== -->
|
<!-- =================================================================================== -->
|
||||||
<!-- Obsolete extension point no longer in use, will be remove. -->
|
<!-- Obsolete extension point no longer in use, will be remove. -->
|
||||||
<!-- =================================================================================== -->
|
<!-- =================================================================================== -->
|
||||||
|
@ -806,6 +806,14 @@
|
||||||
factoryClass="org.eclipse.cdt.internal.core.resources.ResourceExclusionFactory">
|
factoryClass="org.eclipse.cdt.internal.core.resources.ResourceExclusionFactory">
|
||||||
</exclusionFactory>
|
</exclusionFactory>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||||
|
<provider
|
||||||
|
class="org.eclipse.cdt.internal.core.language.settings.providers.ScannerInfoExtensionLanguageSettingsProvider"
|
||||||
|
id="org.eclipse.cdt.core.LegacyScannerInfoLanguageSettingsProvider"
|
||||||
|
name="%ScannerInfoExtensionLanguageSettingsProvider.name">
|
||||||
|
</provider>
|
||||||
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.cdt.core.EFSExtensionProvider">
|
point="org.eclipse.cdt.core.EFSExtensionProvider">
|
||||||
<EFSExtensionProvider
|
<EFSExtensionProvider
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2001, 2012 IBM Corporation and others.
|
* Copyright (c) 2001, 2012 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Rational Software - initial implementation
|
* Rational Software - initial implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2009 IBM Corporation and others.
|
* Copyright (c) 2008, 2009 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.resources;
|
package org.eclipse.cdt.core.resources;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2009 QNX Software Systems and others.
|
* Copyright (c) 2008, 2009 QNX Software Systems 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - initial API and implementation
|
* QNX Software Systems - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.utils;
|
package org.eclipse.cdt.utils;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<version>${tycho-version}</version>
|
<version>${tycho-version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<useUIHarness>true</useUIHarness>
|
<useUIHarness>true</useUIHarness>
|
||||||
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
|
<argLine>-ea -Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/AutomatedSuite.*</include>
|
<include>**/AutomatedSuite.*</include>
|
||||||
</includes>
|
</includes>
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
* Copyright (c) 2004, 2013 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Nathan Ridge
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.tests.text.selection;
|
package org.eclipse.cdt.ui.tests.text.selection;
|
||||||
|
|
||||||
|
@ -75,7 +76,6 @@ import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
*/
|
*/
|
||||||
public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
|
public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
|
||||||
|
|
||||||
private static final String INDEX_FILE_ID = "2946365241"; //$NON-NLS-1$
|
private static final String INDEX_FILE_ID = "2946365241"; //$NON-NLS-1$
|
||||||
static NullProgressMonitor monitor;
|
static NullProgressMonitor monitor;
|
||||||
static IWorkspace workspace;
|
static IWorkspace workspace;
|
||||||
|
@ -1205,4 +1205,23 @@ public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
|
||||||
assertEquals(offsetV, ((ASTNode) decl).getOffset());
|
assertEquals(offsetV, ((ASTNode) decl).getOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <typename>
|
||||||
|
// struct A {
|
||||||
|
// struct S {
|
||||||
|
// void foo();
|
||||||
|
// };
|
||||||
|
// void test() {
|
||||||
|
// S s;
|
||||||
|
// s.foo();
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
public void testBug399142() throws Exception {
|
||||||
|
String code = getAboveComment();
|
||||||
|
IFile file = importFile("testBug399142.cpp", code); //$NON-NLS-1$
|
||||||
|
|
||||||
|
int offset = code.indexOf("s.foo()") + 2;
|
||||||
|
IASTNode decl = testF3(file, offset);
|
||||||
|
assertTrue(decl instanceof IASTName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
* Copyright (c) 2004, 2010 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.tests.text.selection;
|
package org.eclipse.cdt.ui.tests.text.selection;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<filter id="305365105">
|
<filter id="305365105">
|
||||||
<message_arguments>
|
<message_arguments>
|
||||||
<message_argument value="org.eclipse.cdt.ui.refactoring.actions.Messages"/>
|
<message_argument value="org.eclipse.cdt.ui.refactoring.actions.Messages"/>
|
||||||
<message_argument value="org.eclipse.cdt.ui_5.5.0"/>
|
<message_argument value="org.eclipse.cdt.ui_5.6.0"/>
|
||||||
</message_arguments>
|
</message_arguments>
|
||||||
</filter>
|
</filter>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.ui; singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.ui; singleton:=true
|
||||||
Bundle-Version: 5.5.0.qualifier
|
Bundle-Version: 5.6.0.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin
|
Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
|
|
|
@ -644,4 +644,6 @@ RefreshExclusionContributorExtensionPoint = Refresh Exclusion Contributor
|
||||||
newProjectWizard.name = C/C++ Project (prototype)
|
newProjectWizard.name = C/C++ Project (prototype)
|
||||||
projectTypePages = Project Type Pages
|
projectTypePages = Project Type Pages
|
||||||
|
|
||||||
|
semanticHighlightingExtensionPoint = Semantic Highlighting Extension Point
|
||||||
|
|
||||||
UserSettingEntries.name = CDT User Setting Entries
|
UserSettingEntries.name = CDT User Setting Entries
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
<extension-point id="LanguageSettingsProviderAssociation" name="%LanguageSettingsProviderAssociationExtensionPoint" schema="schema/LanguageSettingsProviderAssociation.exsd"/>
|
<extension-point id="LanguageSettingsProviderAssociation" name="%LanguageSettingsProviderAssociationExtensionPoint" schema="schema/LanguageSettingsProviderAssociation.exsd"/>
|
||||||
<extension-point id="RefreshExclusionContributor" name="%RefreshExclusionContributorExtensionPoint" schema="schema/RefreshExclusionContributor.exsd"/>
|
<extension-point id="RefreshExclusionContributor" name="%RefreshExclusionContributorExtensionPoint" schema="schema/RefreshExclusionContributor.exsd"/>
|
||||||
<extension-point id="projectTypePages" name="%projectTypePages" schema="schema/projectTypePages.exsd"/>
|
<extension-point id="projectTypePages" name="%projectTypePages" schema="schema/projectTypePages.exsd"/>
|
||||||
|
<extension-point id="semanticHighlighting" name="%semanticHighlightingExtensionPoint" schema="schema/semanticHighlighting.exsd"/>
|
||||||
|
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.core.runtime.adapters">
|
point="org.eclipse.core.runtime.adapters">
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<version>5.5.0-SNAPSHOT</version>
|
<version>5.6.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.ui</artifactId>
|
<artifactId>org.eclipse.cdt.ui</artifactId>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
245
core/org.eclipse.cdt.ui/schema/semanticHighlighting.exsd
Normal file
245
core/org.eclipse.cdt.ui/schema/semanticHighlighting.exsd
Normal file
|
@ -0,0 +1,245 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!-- Schema file written by PDE -->
|
||||||
|
<schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.schema plugin="org.eclipse.cdt.ui" id="semanticHighligher" name="Semantic Highlighting"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
This extension point allows extensions to contribute to the semantic highlighting.
|
||||||
|
<p>
|
||||||
|
Extensions specify the priority of the highlighting, which determines the order in which the highlighting is invoked.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
This extension point supports the <code>enablement</code> tag. Properties to test on are:
|
||||||
|
<dl>
|
||||||
|
<li>projectNatures: type Collection; all project natures of the current project</li>
|
||||||
|
<li>languageId: type String; the result if ILanguage.getId on the token's ITranslationUnit</li>
|
||||||
|
</dl>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Contributed highlightings will be visible in the Code tree of the 'C/C++ - Editor - Syntax Colouring' preference page.
|
||||||
|
</p>
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
|
||||||
|
|
||||||
|
<element name="extension">
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.element />
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
<complexType>
|
||||||
|
<sequence>
|
||||||
|
<element ref="semanticHighlighting" minOccurs="1" maxOccurs="unbounded"/>
|
||||||
|
</sequence>
|
||||||
|
<attribute name="point" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
a fully qualified identifier of the target extension point
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="id" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
an optional identifier of the extension instance
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="name" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
an optional name of the extension instance
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute translatable="true"/>
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<element name="semanticHighlighting">
|
||||||
|
<complexType>
|
||||||
|
<sequence>
|
||||||
|
<element ref="enablement" minOccurs="0" maxOccurs="1"/>
|
||||||
|
</sequence>
|
||||||
|
<attribute name="id" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
a unique identifier for the Quick Fix processor
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="name" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
a localized name of the Quick Fix processor
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute translatable="true"/>
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="class" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
The name of the class that implements this Semantic Highlighting. The
|
||||||
|
class must be public and implement
|
||||||
|
<samp>org.eclipse.cdt.ui.text.ISemanticHighlighter</samp>
|
||||||
|
with a public 0-argument constructor.
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.text.ISemanticHighlighting"/>
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="priority" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
The priority determines the order in which highlightings are given the opportunity to highlight a token. Lower values are more important.
|
||||||
|
|
||||||
|
The priorities of the built-in highlightings are available in org.eclipse.cdt.internal.ui.editor.SemanticHighlightings.loadBuiltInSemanticHighlightings.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="preferenceKey" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
A key to uniquely identify the highlighting's settings in the preference store.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="displayName" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
The name that is displayed for the highlighter in the Preferences window.
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute translatable="true"/>
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="defaultTextColor" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
The default text color of the contributed highlighting. The value must be the integer RGB values (0-255) separated by commas. E.g., "127,0,85". Defaults to "0,0,0" (black).
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="defaultBold" type="boolean">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
false by default
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="defaultItalic" type="boolean">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
false by default
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="defaultStrikethrough" type="boolean">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
false by default
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="defaultUnderline" type="boolean">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
false by default
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="defaultEnabled" type="boolean">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
false by default
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.section type="since"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
8.2
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.section type="examples"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
The following is an example of a Semantic Highligher contribution:
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<pre>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.cdt.ui.semanticHighlighting"
|
||||||
|
name="%extensionName"
|
||||||
|
id="com.example.ui.semanticHighlightings">
|
||||||
|
<semanticHighlighting
|
||||||
|
id="com.example.ui.keywordHighlighting"
|
||||||
|
priority="5"
|
||||||
|
class="com.example.internal.ui.ExampleHighlighting"
|
||||||
|
preferenceKey="example-keywords"
|
||||||
|
displayName="%exampleHighlighting.displayName"
|
||||||
|
defaultTextColor="127,0,85"
|
||||||
|
defaultBold="true"
|
||||||
|
defaultEnabled="true">
|
||||||
|
<enablement>
|
||||||
|
<with variable="projectNatures">
|
||||||
|
<iterate operator="or">
|
||||||
|
<equals value="org.eclipse.cdt.core.ccnature"/>
|
||||||
|
</iterate>
|
||||||
|
</with>
|
||||||
|
<with variable="languageId">
|
||||||
|
<or>
|
||||||
|
<equals value="org.eclipse.cdt.core.g++"/>
|
||||||
|
<equals value="org.eclipse.cdt.core.gcc"/>
|
||||||
|
</or>
|
||||||
|
</with>
|
||||||
|
</enablement>
|
||||||
|
</semanticHighlighting>
|
||||||
|
</extension>
|
||||||
|
</pre>
|
||||||
|
</p>
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.section type="apiInfo"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
The contributed class must implement <code>org.eclipse.cdt.ui.text.ISemanticHighlighter</code>
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.section type="copyright"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
Copyright (c) 2013 QNX Software Systems 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
|
||||||
|
http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
</schema>
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2008 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.corext;
|
package org.eclipse.cdt.internal.corext;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2010 IBM Corporation and others.
|
* Copyright (c) 2000, 2010 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* QNX Software Systems
|
* QNX Software Systems
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
* Copyright (c) 2005, 2010 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* QNX Software System
|
* QNX Software System
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2001, 2011 IBM Corporation and others.
|
* Copyright (c) 2001, 2011 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Rational Software - initial implementation
|
* Rational Software - initial implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
|
@ -0,0 +1,272 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2013 QNX Software Systems 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.ui.editor;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.eclipse.core.expressions.EvaluationContext;
|
||||||
|
import org.eclipse.core.expressions.EvaluationResult;
|
||||||
|
import org.eclipse.core.expressions.Expression;
|
||||||
|
import org.eclipse.core.expressions.ExpressionConverter;
|
||||||
|
import org.eclipse.core.expressions.ExpressionTagNames;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
|
import org.eclipse.jface.resource.DataFormatException;
|
||||||
|
import org.eclipse.jface.resource.StringConverter;
|
||||||
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.cdt.ui.text.ISemanticHighlighter;
|
||||||
|
import org.eclipse.cdt.ui.text.ISemanticToken;
|
||||||
|
|
||||||
|
public class ContributedSemanticHighlighting extends SemanticHighlighting {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The configuration element needs to be cached until the class is instantiated. Instantiation is deferred
|
||||||
|
* to avoid loading the contributing plugin when the highlighter is not actually needed.
|
||||||
|
*/
|
||||||
|
private IConfigurationElement configurationElement;
|
||||||
|
private Boolean fStatus = null;
|
||||||
|
private ISemanticHighlighter semanticHighlighter;
|
||||||
|
|
||||||
|
private final Expression enablementExpression;
|
||||||
|
|
||||||
|
private final int priority;
|
||||||
|
private final String id;
|
||||||
|
private final String preferenceKey;
|
||||||
|
private final String displayName;
|
||||||
|
|
||||||
|
private final RGB defaultTextColor;
|
||||||
|
private final boolean defaultBold;
|
||||||
|
private final boolean defaultItalic;
|
||||||
|
private final boolean defaultStrikethrough;
|
||||||
|
private final boolean defaultUnderline;
|
||||||
|
private final boolean defaultEnabled;
|
||||||
|
|
||||||
|
private static final String Attr_Class = "class"; //$NON-NLS-1$
|
||||||
|
private static final String Attr_Priority = "priority"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String Attr_PrefKey = "preferenceKey"; //$NON-NLS-1$
|
||||||
|
private static final String Attr_DisplayName = "displayName"; //$NON-NLS-1$
|
||||||
|
private static final String Attr_DefaultTextColor = "defaultTextColor"; //$NON-NLS-1$
|
||||||
|
private static final String Attr_DefaultBold = "defaultBold"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String Attr_DefaultItalic = "defaultItalic"; //$NON-NLS-1$
|
||||||
|
private static final String Attr_DefaultStrikethrough = "defaultStrikethrough"; //$NON-NLS-1$
|
||||||
|
private static final String Attr_DefaultUnderline = "defaultUnderline"; //$NON-NLS-1$
|
||||||
|
private static final String Attr_DefaultEnabled = "defaultEnabled"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String Var_projectNature = "projectNatures"; //$NON-NLS-1$
|
||||||
|
private static final String Var_languageId = "languageId"; //$NON-NLS-1$
|
||||||
|
private static final int Default_Priority = 1000;
|
||||||
|
|
||||||
|
public ContributedSemanticHighlighting(IConfigurationElement element) {
|
||||||
|
configurationElement = element;
|
||||||
|
|
||||||
|
// required
|
||||||
|
id = element.getDeclaringExtension().getNamespaceIdentifier() + '.'
|
||||||
|
+ element.getDeclaringExtension().getSimpleIdentifier();
|
||||||
|
|
||||||
|
int pri = Default_Priority;
|
||||||
|
String priStr = element.getAttribute(Attr_Priority);
|
||||||
|
if (priStr != null)
|
||||||
|
try {
|
||||||
|
pri = Integer.parseInt(priStr);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
CUIPlugin.log("Error in priority attribute of " + id + " was " + priStr, e); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
priority = pri;
|
||||||
|
|
||||||
|
Expression expr = null;
|
||||||
|
IConfigurationElement[] children = element.getChildren(ExpressionTagNames.ENABLEMENT);
|
||||||
|
switch (children.length) {
|
||||||
|
case 0:
|
||||||
|
fStatus = Boolean.TRUE;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
try {
|
||||||
|
ExpressionConverter parser = ExpressionConverter.getDefault();
|
||||||
|
expr = parser.perform(children[0]);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CUIPlugin.log("Error in enablement expression of " + id, e); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
CUIPlugin.logError("Too many enablement expressions for " + id); //$NON-NLS-1$
|
||||||
|
fStatus = Boolean.FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
enablementExpression = expr;
|
||||||
|
|
||||||
|
preferenceKey = element.getAttribute(Attr_PrefKey);
|
||||||
|
displayName = element.getAttribute(Attr_DisplayName);
|
||||||
|
|
||||||
|
// optional
|
||||||
|
defaultTextColor = getRGBAttribute(element, id, Attr_DefaultTextColor);
|
||||||
|
defaultBold = Boolean.parseBoolean(element.getAttribute(Attr_DefaultBold));
|
||||||
|
defaultItalic = Boolean.parseBoolean(element.getAttribute(Attr_DefaultItalic));
|
||||||
|
defaultStrikethrough = Boolean.parseBoolean(element.getAttribute(Attr_DefaultStrikethrough));
|
||||||
|
defaultUnderline = Boolean.parseBoolean(element.getAttribute(Attr_DefaultUnderline));
|
||||||
|
defaultEnabled = Boolean.parseBoolean(element.getAttribute(Attr_DefaultEnabled));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPriority() {
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static RGB getRGBAttribute(IConfigurationElement element, String extensionId, String key) {
|
||||||
|
String val = element.getAttribute(key);
|
||||||
|
if (val != null)
|
||||||
|
try {
|
||||||
|
return StringConverter.asRGB(val);
|
||||||
|
} catch (DataFormatException e) {
|
||||||
|
CUIPlugin
|
||||||
|
.log("Error in " + Attr_DefaultTextColor + " attribute of " + extensionId + ' ' + val + " is not a RGB value", e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
}
|
||||||
|
|
||||||
|
// black by default
|
||||||
|
return new RGB(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ISemanticHighlighter createSemanticHighlighter() {
|
||||||
|
|
||||||
|
// only one try at creating the class
|
||||||
|
if (configurationElement == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
IConfigurationElement element = configurationElement;
|
||||||
|
configurationElement = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return (ISemanticHighlighter) element.createExecutableExtension(Attr_Class);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CUIPlugin.log("Error in class attribute of " + id, e); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPreferenceKey() {
|
||||||
|
return preferenceKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RGB getDefaultDefaultTextColor() {
|
||||||
|
return defaultTextColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBoldByDefault() {
|
||||||
|
return defaultBold;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isItalicByDefault() {
|
||||||
|
return defaultItalic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isStrikethroughByDefault() {
|
||||||
|
return defaultStrikethrough;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUnderlineByDefault() {
|
||||||
|
return defaultUnderline;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabledByDefault() {
|
||||||
|
return defaultEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresImplicitNames() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean matches(ITranslationUnit tu) {
|
||||||
|
|
||||||
|
// if the enablement expression is missing or structurally invalid, then return immediately
|
||||||
|
if (fStatus != null)
|
||||||
|
return fStatus.booleanValue();
|
||||||
|
|
||||||
|
if (enablementExpression != null)
|
||||||
|
try {
|
||||||
|
EvaluationContext evalContext = new EvaluationContext(null, tu);
|
||||||
|
|
||||||
|
ICProject cProject = tu.getCProject();
|
||||||
|
String[] natures = cProject.getProject().getDescription().getNatureIds();
|
||||||
|
evalContext.addVariable(Var_projectNature, Arrays.asList(natures));
|
||||||
|
|
||||||
|
ILanguage language = tu.getLanguage();
|
||||||
|
if( language != null )
|
||||||
|
evalContext.addVariable(Var_languageId, language.getId());
|
||||||
|
|
||||||
|
return enablementExpression.evaluate(evalContext) == EvaluationResult.TRUE;
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CUIPlugin.log("Error while evaluating enablement expression for " + id, e); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
fStatus = Boolean.FALSE;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the contributed ISemanticHighlighter if the receiver should be applied to the specified TU and
|
||||||
|
* null otherwise.
|
||||||
|
*/
|
||||||
|
private ISemanticHighlighter getSemanticHighlighter(ITranslationUnit tu) {
|
||||||
|
if (!matches(tu))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (semanticHighlighter == null)
|
||||||
|
synchronized (this) {
|
||||||
|
if (semanticHighlighter == null) {
|
||||||
|
semanticHighlighter = createSemanticHighlighter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return semanticHighlighter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean consumes(ISemanticToken token) {
|
||||||
|
if (token == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
IASTTranslationUnit astTU = token.getRoot();
|
||||||
|
if (astTU == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ITranslationUnit tu = astTU.getOriginatingTranslationUnit();
|
||||||
|
if (tu == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ISemanticHighlighter highlighter = getSemanticHighlighter(tu);
|
||||||
|
if (highlighter == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return highlighter.consumes(token);
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,11 +17,12 @@ import org.eclipse.swt.graphics.RGB;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.cdt.ui.text.ISemanticToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Semantic highlighting.
|
* Semantic highlighting.
|
||||||
* Cloned from JDT.
|
* Cloned from JDT.
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public abstract class SemanticHighlighting {
|
public abstract class SemanticHighlighting {
|
||||||
|
@ -81,9 +82,9 @@ public abstract class SemanticHighlighting {
|
||||||
* @return the display name
|
* @return the display name
|
||||||
*/
|
*/
|
||||||
public abstract String getDisplayName();
|
public abstract String getDisplayName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that the highlighting needs to visit implicit names
|
* Indicates that the highlighting needs to visit implicit names
|
||||||
* (e.g. overloaded operators)
|
* (e.g. overloaded operators)
|
||||||
*/
|
*/
|
||||||
public boolean requiresImplicitNames() {
|
public boolean requiresImplicitNames() {
|
||||||
|
@ -100,7 +101,7 @@ public abstract class SemanticHighlighting {
|
||||||
* @param token the semantic token for a {@link org.eclipse.cdt.core.dom.ast.IASTName}
|
* @param token the semantic token for a {@link org.eclipse.cdt.core.dom.ast.IASTName}
|
||||||
* @return <code>true</code> iff the semantic highlighting consumes the semantic token
|
* @return <code>true</code> iff the semantic highlighting consumes the semantic token
|
||||||
*/
|
*/
|
||||||
public abstract boolean consumes(SemanticToken token);
|
public abstract boolean consumes(ISemanticToken token);
|
||||||
|
|
||||||
private String getThemeColorKey() {
|
private String getThemeColorKey() {
|
||||||
return CUIPlugin.PLUGIN_ID + "." + getPreferenceKey() + "Highlighting"; //$NON-NLS-1$//$NON-NLS-2$
|
return CUIPlugin.PLUGIN_ID + "." + getPreferenceKey() + "Highlighting"; //$NON-NLS-1$//$NON-NLS-2$
|
||||||
|
|
|
@ -11,7 +11,11 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
package org.eclipse.cdt.internal.ui.editor;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.preference.PreferenceConverter;
|
import org.eclipse.jface.preference.PreferenceConverter;
|
||||||
|
@ -56,6 +60,7 @@ import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
import org.eclipse.cdt.core.index.IIndexName;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
|
import org.eclipse.cdt.ui.text.ISemanticToken;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||||
|
@ -228,7 +233,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof IASTName) {
|
if (node instanceof IASTName) {
|
||||||
IASTName name= (IASTName) node;
|
IASTName name= (IASTName) node;
|
||||||
|
@ -279,7 +284,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof IASTName) {
|
if (node instanceof IASTName) {
|
||||||
IASTName name= (IASTName) node;
|
IASTName name= (IASTName) node;
|
||||||
|
@ -330,7 +335,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof IASTImplicitName)
|
if (node instanceof IASTImplicitName)
|
||||||
return false;
|
return false;
|
||||||
|
@ -407,7 +412,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof IASTName) {
|
if (node instanceof IASTName) {
|
||||||
IASTName name= (IASTName) node;
|
IASTName name= (IASTName) node;
|
||||||
|
@ -461,7 +466,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof IASTImplicitName)
|
if (node instanceof IASTImplicitName)
|
||||||
return false;
|
return false;
|
||||||
|
@ -514,7 +519,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof IASTImplicitName)
|
if (node instanceof IASTImplicitName)
|
||||||
return false;
|
return false;
|
||||||
|
@ -585,7 +590,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof IASTImplicitName)
|
if (node instanceof IASTImplicitName)
|
||||||
return false;
|
return false;
|
||||||
|
@ -638,7 +643,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof IASTName) {
|
if (node instanceof IASTName) {
|
||||||
IASTName name= (IASTName) node;
|
IASTName name= (IASTName) node;
|
||||||
|
@ -698,7 +703,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof IASTName) {
|
if (node instanceof IASTName) {
|
||||||
IASTName name= (IASTName) node;
|
IASTName name= (IASTName) node;
|
||||||
|
@ -774,7 +779,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof IASTName) {
|
if (node instanceof IASTName) {
|
||||||
IASTName name= (IASTName) node;
|
IASTName name= (IASTName) node;
|
||||||
|
@ -836,7 +841,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IBinding binding= token.getBinding();
|
IBinding binding= token.getBinding();
|
||||||
if (binding instanceof IParameter) {
|
if (binding instanceof IParameter) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -880,7 +885,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof IASTName) {
|
if (node instanceof IASTName) {
|
||||||
IBinding binding= token.getBinding();
|
IBinding binding= token.getBinding();
|
||||||
|
@ -927,7 +932,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof ICPPASTQualifiedName || node instanceof ICPPASTTemplateId) {
|
if (node instanceof ICPPASTQualifiedName || node instanceof ICPPASTTemplateId) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -977,7 +982,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof IASTName) {
|
if (node instanceof IASTName) {
|
||||||
IBinding binding= token.getBinding();
|
IBinding binding= token.getBinding();
|
||||||
|
@ -1024,7 +1029,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IBinding binding= token.getBinding();
|
IBinding binding= token.getBinding();
|
||||||
if (binding instanceof IMacroBinding) {
|
if (binding instanceof IMacroBinding) {
|
||||||
IASTName name= (IASTName)token.getNode();
|
IASTName name= (IASTName)token.getNode();
|
||||||
|
@ -1071,7 +1076,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IBinding binding= token.getBinding();
|
IBinding binding= token.getBinding();
|
||||||
if (binding instanceof IMacroBinding) {
|
if (binding instanceof IMacroBinding) {
|
||||||
IASTName name= (IASTName)token.getNode();
|
IASTName name= (IASTName)token.getNode();
|
||||||
|
@ -1118,7 +1123,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof IASTName) {
|
if (node instanceof IASTName) {
|
||||||
IASTName name= (IASTName) node;
|
IASTName name= (IASTName) node;
|
||||||
|
@ -1169,7 +1174,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IBinding binding= token.getBinding();
|
IBinding binding= token.getBinding();
|
||||||
if (binding instanceof ICPPNamespace) {
|
if (binding instanceof ICPPNamespace) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1213,7 +1218,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IBinding binding= token.getBinding();
|
IBinding binding= token.getBinding();
|
||||||
if (binding instanceof ILabel) {
|
if (binding instanceof ILabel) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1257,7 +1262,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof IASTName) {
|
if (node instanceof IASTName) {
|
||||||
IASTName name= (IASTName) node;
|
IASTName name= (IASTName) node;
|
||||||
|
@ -1313,7 +1318,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node.getTranslationUnit().isBasedOnIncompleteIndex()) {
|
if (node.getTranslationUnit().isBasedOnIncompleteIndex()) {
|
||||||
// Do not highlight problems is the AST is unreliable.
|
// Do not highlight problems is the AST is unreliable.
|
||||||
|
@ -1370,7 +1375,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
if (node instanceof IASTName) {
|
if (node instanceof IASTName) {
|
||||||
IASTName name= (IASTName) node;
|
IASTName name= (IASTName) node;
|
||||||
|
@ -1459,7 +1464,7 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean consumes(SemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node = token.getNode();
|
IASTNode node = token.getNode();
|
||||||
// So far we only have implicit names for overloaded operators and destructors,
|
// So far we only have implicit names for overloaded operators and destructors,
|
||||||
// so this works.
|
// so this works.
|
||||||
|
@ -1545,36 +1550,106 @@ public class SemanticHighlightings {
|
||||||
return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX;
|
return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class Key implements Comparable<Key> {
|
||||||
|
public final int priority;
|
||||||
|
public final String id;
|
||||||
|
|
||||||
|
public Key(int priority) {
|
||||||
|
this(priority, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Key(int priority, String id) {
|
||||||
|
this.priority = priority;
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Key o) {
|
||||||
|
if (priority < o.priority)
|
||||||
|
return -1;
|
||||||
|
if (o.priority < priority)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (id == null)
|
||||||
|
return o.id == null ? 0 : -1;
|
||||||
|
|
||||||
|
return o.id == null ? 1 : id.compareTo(o.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
str.append(priority);
|
||||||
|
if (id != null) {
|
||||||
|
str.append(' ');
|
||||||
|
str.append(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return str.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void loadBuiltInSemanticHighlightings(Map<Key, SemanticHighlighting> highlightings) {
|
||||||
|
|
||||||
|
highlightings.put(new Key(10), new MacroReferenceHighlighting()); // before all others!
|
||||||
|
highlightings.put(new Key(20), new ProblemHighlighting());
|
||||||
|
highlightings.put(new Key(30), new ExternalSDKHighlighting());
|
||||||
|
highlightings.put(new Key(40), new ClassHighlighting());
|
||||||
|
highlightings.put(new Key(50), new StaticFieldHighlighting());
|
||||||
|
highlightings.put(new Key(60), new FieldHighlighting()); // after all other fields
|
||||||
|
highlightings.put(new Key(70), new MethodDeclarationHighlighting());
|
||||||
|
highlightings.put(new Key(80), new StaticMethodInvocationHighlighting());
|
||||||
|
highlightings.put(new Key(90), new ParameterVariableHighlighting()); // before local variables
|
||||||
|
highlightings.put(new Key(100), new LocalVariableDeclarationHighlighting());
|
||||||
|
highlightings.put(new Key(110), new LocalVariableHighlighting());
|
||||||
|
highlightings.put(new Key(120), new GlobalVariableHighlighting());
|
||||||
|
highlightings.put(new Key(130), new TemplateParameterHighlighting()); // before template arguments!
|
||||||
|
highlightings.put(new Key(140), new OverloadedOperatorHighlighting()); // before both method and function
|
||||||
|
highlightings.put(new Key(150), new MethodHighlighting()); // before types to get ctors
|
||||||
|
highlightings.put(new Key(160), new EnumHighlighting());
|
||||||
|
highlightings.put(new Key(170), new MacroDefinitionHighlighting());
|
||||||
|
highlightings.put(new Key(180), new FunctionDeclarationHighlighting());
|
||||||
|
highlightings.put(new Key(190), new FunctionHighlighting());
|
||||||
|
highlightings.put(new Key(200), new TypedefHighlighting());
|
||||||
|
highlightings.put(new Key(210), new NamespaceHighlighting());
|
||||||
|
highlightings.put(new Key(220), new LabelHighlighting());
|
||||||
|
highlightings.put(new Key(230), new EnumeratorHighlighting());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String ExtensionPoint = "semanticHighlighting"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static SemanticHighlighting[] loadSemanticHighlightings() {
|
||||||
|
|
||||||
|
Map<Key, SemanticHighlighting> highlightings = new TreeMap<SemanticHighlightings.Key, SemanticHighlighting>();
|
||||||
|
|
||||||
|
// load the built-in highlightings
|
||||||
|
loadBuiltInSemanticHighlightings(highlightings);
|
||||||
|
|
||||||
|
// load the extensions
|
||||||
|
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
|
||||||
|
CUIPlugin.getPluginId(), ExtensionPoint);
|
||||||
|
for (IConfigurationElement element : elements) {
|
||||||
|
ContributedSemanticHighlighting contributedHighlighting = new ContributedSemanticHighlighting(
|
||||||
|
element);
|
||||||
|
|
||||||
|
Key key = new Key(contributedHighlighting.getPriority(), contributedHighlighting.getId());
|
||||||
|
highlightings.put(key, contributedHighlighting);
|
||||||
|
}
|
||||||
|
|
||||||
|
return highlightings.values().toArray(new SemanticHighlighting[highlightings.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Object SemanticHighlightingsLock = new Object();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The semantic highlightings, the order defines the precedence of matches, the first match wins.
|
* @return The semantic highlightings, the order defines the precedence of matches, the first match wins.
|
||||||
*/
|
*/
|
||||||
public static SemanticHighlighting[] getSemanticHighlightings() {
|
public static SemanticHighlighting[] getSemanticHighlightings() {
|
||||||
if (fgSemanticHighlightings == null)
|
if (fgSemanticHighlightings == null)
|
||||||
fgSemanticHighlightings= new SemanticHighlighting[] {
|
synchronized (SemanticHighlightingsLock) {
|
||||||
new MacroReferenceHighlighting(), // before all others!
|
if (fgSemanticHighlightings == null)
|
||||||
new ProblemHighlighting(),
|
fgSemanticHighlightings = loadSemanticHighlightings();
|
||||||
new ExternalSDKHighlighting(),
|
}
|
||||||
new ClassHighlighting(),
|
|
||||||
new StaticFieldHighlighting(),
|
|
||||||
new FieldHighlighting(), // after all other fields
|
|
||||||
new MethodDeclarationHighlighting(),
|
|
||||||
new StaticMethodInvocationHighlighting(),
|
|
||||||
new ParameterVariableHighlighting(), // before local variables
|
|
||||||
new LocalVariableDeclarationHighlighting(),
|
|
||||||
new LocalVariableHighlighting(),
|
|
||||||
new GlobalVariableHighlighting(),
|
|
||||||
new TemplateParameterHighlighting(), // before template arguments!
|
|
||||||
new OverloadedOperatorHighlighting(), // before both method and function
|
|
||||||
new MethodHighlighting(), // before types to get ctors
|
|
||||||
new EnumHighlighting(),
|
|
||||||
new MacroDefinitionHighlighting(),
|
|
||||||
new FunctionDeclarationHighlighting(),
|
|
||||||
new FunctionHighlighting(),
|
|
||||||
new TypedefHighlighting(),
|
|
||||||
new NamespaceHighlighting(),
|
|
||||||
new LabelHighlighting(),
|
|
||||||
new EnumeratorHighlighting(),
|
|
||||||
};
|
|
||||||
return fgSemanticHighlightings;
|
return fgSemanticHighlightings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,15 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.ui.text.ISemanticToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Semantic token.
|
* Semantic token.
|
||||||
* Cloned from JDT.
|
* Cloned from JDT.
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public final class SemanticToken {
|
public final class SemanticToken implements ISemanticToken {
|
||||||
/** AST node */
|
/** AST node */
|
||||||
private IASTNode fNode;
|
private IASTNode fNode;
|
||||||
|
|
||||||
|
@ -38,26 +39,29 @@ public final class SemanticToken {
|
||||||
/**
|
/**
|
||||||
* @return Returns the binding, can be <code>null</code>.
|
* @return Returns the binding, can be <code>null</code>.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public IBinding getBinding() {
|
public IBinding getBinding() {
|
||||||
if (!fIsBindingResolved) {
|
if (!fIsBindingResolved) {
|
||||||
fIsBindingResolved= true;
|
fIsBindingResolved= true;
|
||||||
if (fNode instanceof IASTName)
|
if (fNode instanceof IASTName)
|
||||||
fBinding= ((IASTName) fNode).resolveBinding();
|
fBinding= ((IASTName) fNode).resolveBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
return fBinding;
|
return fBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the AST node
|
* @return the AST node
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public IASTNode getNode() {
|
public IASTNode getNode() {
|
||||||
return fNode;
|
return fNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the AST root
|
* @return the AST root
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public IASTTranslationUnit getRoot() {
|
public IASTTranslationUnit getRoot() {
|
||||||
if (!fIsRootResolved) {
|
if (!fIsRootResolved) {
|
||||||
fIsRootResolved= true;
|
fIsRootResolved= true;
|
||||||
|
|
|
@ -378,9 +378,9 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
||||||
tableProvidersViewer.refresh();
|
tableProvidersViewer.refresh();
|
||||||
tableProvidersViewer.setChecked(newProvider, isChecked);
|
tableProvidersViewer.setChecked(newProvider, isChecked);
|
||||||
tableProviders.setSelection(pos);
|
tableProviders.setSelection(pos);
|
||||||
tableProvidersViewer.refresh(newProvider);
|
|
||||||
|
|
||||||
saveCheckedProviders();
|
saveCheckedProviders();
|
||||||
|
tableProvidersViewer.refresh(newProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -460,8 +460,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
||||||
replaceSelectedProvider(newProvider); // will refresh and save checked providers
|
replaceSelectedProvider(newProvider); // will refresh and save checked providers
|
||||||
createOptionsPage(newProvider);
|
createOptionsPage(newProvider);
|
||||||
} else {
|
} else {
|
||||||
tableProvidersViewer.refresh(checkedProvider);
|
|
||||||
saveCheckedProviders();
|
saveCheckedProviders();
|
||||||
|
tableProvidersViewer.refresh(checkedProvider);
|
||||||
// option page is reused
|
// option page is reused
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,7 +483,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
||||||
} else {
|
} else {
|
||||||
// Toggle to configuration-owned provider
|
// Toggle to configuration-owned provider
|
||||||
newProvider = getInitialProvider(id);
|
newProvider = getInitialProvider(id);
|
||||||
if(newProvider == null) {
|
if(newProvider == null || LanguageSettingsManager.isWorkspaceProvider(newProvider)) {
|
||||||
try {
|
try {
|
||||||
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
|
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
|
||||||
if (rawProvider instanceof ILanguageSettingsEditableProvider) {
|
if (rawProvider instanceof ILanguageSettingsEditableProvider) {
|
||||||
|
@ -926,7 +926,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
||||||
|
|
||||||
for (ILanguageSettingsProvider provider : allAvailableProvidersSet) {
|
for (ILanguageSettingsProvider provider : allAvailableProvidersSet) {
|
||||||
String id = provider.getId();
|
String id = provider.getId();
|
||||||
if (!idsList.contains(id)) {
|
if (!idsList.contains(id) && ScannerDiscoveryLegacySupport.isProviderCompatible(id, cfgDescription)) {
|
||||||
providers.add(provider);
|
providers.add(provider);
|
||||||
idsList.add(id);
|
idsList.add(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||||
import org.eclipse.cdt.ui.CDTSharedImages;
|
import org.eclipse.cdt.ui.CDTSharedImages;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.cdt.utils.UNCPathConverter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class to provide unified images for {@link ICLanguageSettingEntry}.
|
* Helper class to provide unified images for {@link ICLanguageSettingEntry}.
|
||||||
|
@ -168,6 +169,8 @@ public class LanguageSettingsImages {
|
||||||
IPath path = new Path(entry.getValue());
|
IPath path = new Path(entry.getValue());
|
||||||
IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
|
IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
|
||||||
exists = (rc !=null) && rc.isAccessible();
|
exists = (rc !=null) && rc.isAccessible();
|
||||||
|
} else if (UNCPathConverter.isUNC(entry.getName())) {
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
String pathname = entry.getName();
|
String pathname = entry.getName();
|
||||||
java.io.File file = new java.io.File(pathname);
|
java.io.File file = new java.io.File(pathname);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
* Copyright (c) 2005, 2011 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* QNX Software System
|
* QNX Software System
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2009 IBM Corporation and others.
|
* Copyright (c) 2000, 2009 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* QNX Software System
|
* QNX Software System
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2009 IBM Corporation and others.
|
* Copyright (c) 2000, 2009 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2011 IBM Corporation and others.
|
* Copyright (c) 2000, 2011 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2009 IBM Corporation and others.
|
* Copyright (c) 2000, 2009 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* QNX Software System
|
* QNX Software System
|
||||||
* Andrew Ferguson (Symbian) - refactored to TokenStore (previously part of AbstractCScanner)
|
* Andrew Ferguson (Symbian) - refactored to TokenStore (previously part of AbstractCScanner)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.text;
|
package org.eclipse.cdt.internal.ui.text;
|
||||||
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Copyright (c) 2000, 2009 IBM Corporation and others.
|
# Copyright (c) 2000, 2009 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
|
||||||
# http://www.eclipse.org/legal/epl-v10.html
|
# http://www.eclipse.org/legal/epl-v10.html
|
||||||
#
|
#
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# IBM Corporation - initial API and implementation
|
# IBM Corporation - initial API and implementation
|
||||||
# Anton Leherbauer (Wind River Systems)
|
# Anton Leherbauer (Wind River Systems)
|
||||||
# Sergey Prigogin (Google)
|
# Sergey Prigogin (Google)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
AbstractAnnotationHover_action_configureAnnotationPreferences= Configure Annotation Preferences
|
AbstractAnnotationHover_action_configureAnnotationPreferences= Configure Annotation Preferences
|
||||||
AbstractAnnotationHover_message_singleQuickFix= 1 quick fix available:
|
AbstractAnnotationHover_message_singleQuickFix= 1 quick fix available:
|
||||||
AbstractAnnotationHover_message_multipleQuickFix= {0} quick fixes available:
|
AbstractAnnotationHover_message_multipleQuickFix= {0} quick fixes available:
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2008 IBM Corporation and others.
|
* Copyright (c) 2000, 2008 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Copyright (c) 2000, 2008 IBM Corporation and others.
|
# Copyright (c) 2000, 2008 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
|
||||||
# http://www.eclipse.org/legal/epl-v10.html
|
# http://www.eclipse.org/legal/epl-v10.html
|
||||||
#
|
#
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# IBM Corporation - initial API and implementation
|
# IBM Corporation - initial API and implementation
|
||||||
# Sergey Prigogin (Google)
|
# Sergey Prigogin (Google)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2008 IBM Corporation and others.
|
* Copyright (c) 2000, 2008 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2009 IBM Corporation and others.
|
* Copyright (c) 2000, 2009 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
* Copyright (c) 2005, 2009 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2009 IBM Corporation and others.
|
* Copyright (c) 2000, 2009 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2013 Wind River Systems, Inc. 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
|
||||||
|
@ -19,8 +19,6 @@ import java.util.List;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
|
@ -39,7 +37,7 @@ import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
|
import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
|
||||||
|
|
||||||
class THGraph {
|
class THGraph {
|
||||||
private static final ICElement[] NO_MEMBERS = new ICElement[0];
|
private static final ICElement[] NO_MEMBERS = {};
|
||||||
private THGraphNode fInputNode= null;
|
private THGraphNode fInputNode= null;
|
||||||
private HashSet<THGraphNode> fRootNodes= new HashSet<THGraphNode>();
|
private HashSet<THGraphNode> fRootNodes= new HashSet<THGraphNode>();
|
||||||
private HashSet<THGraphNode> fLeaveNodes= new HashSet<THGraphNode>();
|
private HashSet<THGraphNode> fLeaveNodes= new HashSet<THGraphNode>();
|
||||||
|
@ -251,25 +249,22 @@ class THGraph {
|
||||||
private void addMembers(IIndex index, THGraphNode graphNode, IBinding binding) throws CoreException {
|
private void addMembers(IIndex index, THGraphNode graphNode, IBinding binding) throws CoreException {
|
||||||
if (graphNode.getMembers(false) == null) {
|
if (graphNode.getMembers(false) == null) {
|
||||||
ArrayList<ICElement> memberList= new ArrayList<ICElement>();
|
ArrayList<ICElement> memberList= new ArrayList<ICElement>();
|
||||||
try {
|
if (binding instanceof ICPPClassType) {
|
||||||
if (binding instanceof ICPPClassType) {
|
ICPPClassType ct= (ICPPClassType) binding;
|
||||||
ICPPClassType ct= (ICPPClassType) binding;
|
IBinding[] members= ct.getDeclaredFields();
|
||||||
IBinding[] members= ct.getDeclaredFields();
|
addMemberElements(index, members, memberList);
|
||||||
addMemberElements(index, members, memberList);
|
members= ct.getDeclaredMethods();
|
||||||
members= ct.getDeclaredMethods();
|
addMemberElements(index, members, memberList);
|
||||||
addMemberElements(index, members, memberList);
|
} else if (binding instanceof ICompositeType) {
|
||||||
} else if (binding instanceof ICompositeType) {
|
ICompositeType ct= (ICompositeType) binding;
|
||||||
ICompositeType ct= (ICompositeType) binding;
|
IBinding[] members= ct.getFields();
|
||||||
IBinding[] members= ct.getFields();
|
addMemberElements(index, members, memberList);
|
||||||
addMemberElements(index, members, memberList);
|
} else if (binding instanceof IEnumeration) {
|
||||||
} else if (binding instanceof IEnumeration) {
|
IEnumeration ct= (IEnumeration) binding;
|
||||||
IEnumeration ct= (IEnumeration) binding;
|
IBinding[] members= ct.getEnumerators();
|
||||||
IBinding[] members= ct.getEnumerators();
|
addMemberElements(index, members, memberList);
|
||||||
addMemberElements(index, members, memberList);
|
|
||||||
}
|
|
||||||
} catch (DOMException e) {
|
|
||||||
// Problem bindings should not be reported to the log.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memberList.isEmpty()) {
|
if (memberList.isEmpty()) {
|
||||||
graphNode.setMembers(NO_MEMBERS);
|
graphNode.setMembers(NO_MEMBERS);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2003, 2011 IBM Corporation and others.
|
* Copyright (c) 2003, 2011 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial implementation
|
* QNX Software Systems - Initial implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui;
|
package org.eclipse.cdt.ui;
|
||||||
|
|
|
@ -2219,7 +2219,7 @@ public class PreferenceConstants {
|
||||||
* the workspace setting should be taken. Note that passing {@code null} should be avoided.
|
* the workspace setting should be taken. Note that passing {@code null} should be avoided.
|
||||||
* @param defaultValue The default value if not specified in the preferences.
|
* @param defaultValue The default value if not specified in the preferences.
|
||||||
* @return Returns the current value of the preference.
|
* @return Returns the current value of the preference.
|
||||||
* @since 5.5
|
* @since 5.6
|
||||||
*/
|
*/
|
||||||
public static String getPreference(String key, ICProject project, String defaultValue) {
|
public static String getPreference(String key, ICProject project, String defaultValue) {
|
||||||
return getPreferenceNode(key, project).get(key, defaultValue);
|
return getPreferenceNode(key, project).get(key, defaultValue);
|
||||||
|
|
|
@ -276,11 +276,17 @@ public class ManageConfigDialog extends Dialog {
|
||||||
for (int i=0; i<cfgds.length; i++ ) {
|
for (int i=0; i<cfgds.length; i++ ) {
|
||||||
TableItem t = new TableItem(table, 0);
|
TableItem t = new TableItem(table, 0);
|
||||||
t.setText(0, cfgds[i].getName());
|
t.setText(0, cfgds[i].getName());
|
||||||
t.setText(1, cfgds[i].getDescription());
|
String description = cfgds[i].getDescription();
|
||||||
|
if (description == null) {
|
||||||
|
description = ""; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
t.setText(1, description);
|
||||||
t.setText(2, cfgds[i].isActive() ? Messages.ManageConfigDialog_5 : ""); //$NON-NLS-1$
|
t.setText(2, cfgds[i].isActive() ? Messages.ManageConfigDialog_5 : ""); //$NON-NLS-1$
|
||||||
t.setData(cfgds[i]);
|
t.setData(cfgds[i]);
|
||||||
}
|
}
|
||||||
if (table.getItemCount() > 0) table.select(0);
|
if (table.getItemCount() > 0) {
|
||||||
|
table.select(0);
|
||||||
|
}
|
||||||
table.setFocus();
|
table.setFocus();
|
||||||
updateButtons();
|
updateButtons();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.newui;
|
package org.eclipse.cdt.ui.newui;
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue