diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java index 1df00d08f76..13f87f2dcb1 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java @@ -10,8 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.managedbuilder.core.tests; -import java.io.File; -import java.io.IOException; import java.util.Arrays; import java.util.Map; 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.IScannerInfoChangeListener; 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.IConfiguration; 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. * 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 - IPath buildCWD = project.getLocation().append("Sub Config"); + final String[] expectedPaths = new String[5]; - final String[] expectedPaths; - if (new Path("C:\\home\\tester/include").isAbsolute()) { - // Windows - expectedPaths = new String[] { - toOSLocation("/usr/include"), - toOSLocation("/opt/gnome/include"), - toOSLocation("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 - }; - } 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 - }; - } + // This first path is a built-in, so it will not be manipulated by build manager + expectedPaths[0] = (new Path("/usr/include")).toOSString(); + expectedPaths[1] = (new Path("/opt/gnome/include")).toOSString(); + IPath path = new Path("C:\\home\\tester/include"); + if(path.isAbsolute()) // for win32 path is treated as absolute + expectedPaths[2] = path.toOSString(); + else // for Linux path is relative + expectedPaths[2] = project.getLocation().append("Sub Config").append(path).toOSString(); + expectedPaths[3] = project.getLocation().append( "includes" ).toOSString(); + expectedPaths[4] = (new Path("/usr/gnu/include")).toOSString(); // Create a new managed project based on the sub project type 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 IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project); assertNotNull(provider); - assertTrue(provider instanceof LanguageSettingsScannerInfoProvider); // Now subscribe (note that the method will be called after a change provider.subscribe(project, new IScannerInfoChangeListener () { diff --git a/codan/org.eclipse.cdt.codan.core.test/pom.xml b/codan/org.eclipse.cdt.codan.core.test/pom.xml index ee202abfb79..1f00466e914 100644 --- a/codan/org.eclipse.cdt.codan.core.test/pom.xml +++ b/codan/org.eclipse.cdt.codan.core.test/pom.xml @@ -24,7 +24,7 @@ true - -Xms256m -Xmx512m -XX:MaxPermSize=256M + -ea -Xms256m -Xmx512m -XX:MaxPermSize=256M **/AutomatedIntegrationSuite.* diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java index 5f28ad59cf6..eb2d81fa18e 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,6 +9,7 @@ * Devin Steffler (IBM Corporation) - initial API and implementation * Markus Schorn (Wind River Systems) * Sergey Prigogin (Google) + * Nathan Ridge *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; @@ -6060,14 +6061,14 @@ public class AST2CPPSpecTest extends AST2SpecTestBase { BindingAssertionHelper bh= new BindingAssertionHelper(code, true); ICPPTemplateInstance inst; inst= bh.assertNonProblem("f1(v)", 2); - assertEquals("<20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); + assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); inst= bh.assertNonProblem("f1<20>(v)", -3); - assertEquals("<20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); + assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); bh.assertProblem("f2(v)", 2); inst= bh.assertNonProblem("f2<10>(v)", -3); - assertEquals("<10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); + assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); inst= bh.assertNonProblem("f3(v)", 2); - assertEquals("<10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); + assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); } // template class A { }; @@ -6086,9 +6087,9 @@ public class AST2CPPSpecTest extends AST2SpecTestBase { ICPPTemplateInstance inst; bh.assertProblem("g(a1)", 1); inst= bh.assertNonProblem("g<0>(a1)", -4); - assertEquals("<0>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); + assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); inst= bh.assertNonProblem("f(a1, a2)", 1); - assertEquals("<1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); + assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); } // template class A { @@ -6134,9 +6135,9 @@ public class AST2CPPSpecTest extends AST2SpecTestBase { ICPPTemplateInstance inst; bh.assertProblem("f(a)", 1); inst= bh.assertNonProblem("f<1>(a)", -3); - assertEquals("<1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); + assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); inst= bh.assertNonProblem("g(b)", 1); - assertEquals("<1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); + assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); } // template void f(void(*)(T,int)); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index f6f66498610..31e4ef589b2 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -7051,7 +7051,7 @@ public class AST2TemplateTests extends AST2TestBase { // void test() { // int x = C::id; // } - public void _testDependentEnumValue_389009() throws Exception { + public void testDependentEnumValue_389009() throws Exception { BindingAssertionHelper ah = getAssertionHelper(); IEnumerator binding = ah.assertNonProblem("C::id", "id"); IValue value = binding.getValue(); @@ -7125,4 +7125,44 @@ public class AST2TemplateTests extends AST2TestBase { public void testClassTemplateSpecializationPartialOrdering_398044b() throws Exception { parseAndCheckBindings(); } + + // template + // struct meta { + // static const bool value = 1; + // }; + // template + // struct enable_if {}; + // template <> + // struct enable_if { + // typedef void type; + // }; + // template + // struct pair { + // template ::value>::type> + // pair(int); + // }; + // void push_back(pair&&); + // void push_back(const pair&); + // void test() { + // push_back(0); + // } + public void testRegression_399142() throws Exception { + parseAndCheckBindings(); + } + + // template + // struct A { + // struct impl { + // static T x; + // }; + // static const int value = sizeof(impl::x); + // }; + // template struct W {}; + // template <> struct W<1> { typedef int type; }; + // int main() { + // W::value>::type w; + // } + public void testDependentExpressionInvolvingFieldInNestedClass_399362() throws Exception { + parseAndCheckBindings(); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java index 2c1033ffc30..54d2e340f7a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java @@ -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.Kind; 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.IFunctionType; import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; 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.ICPPBasicType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; @@ -2063,6 +2065,27 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa checkBindings(); } + // template + // struct B { + // enum { value = 1 }; + // }; + // + // template + // struct C { + // enum { id = B::value }; + // }; + + // void test() { + // int x = C::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 // struct A { // typedef U type1; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java index b1ba0f5c4e4..92ef9cf4046 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,13 +7,13 @@ * * Contributors: * Andrew Ferguson (Symbian) - Initial implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.index.tests; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; 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 */ 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 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.createCProject(name, "bin", IPDOMManager.ID_NO_INDEXER); + + IFile lastFile= null; + for (Map.Entry 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() { return suite(IndexCompositeTests.class); @@ -101,8 +151,9 @@ public class IndexCompositeTests extends BaseTestCase { setIndex(cprojA, REFD); assertBCount(1, 1); setIndex(cprojA, BOTH); assertBCount(2, 2); } finally { - for (ICProject project : projects) + for (ICProject project : projects) { project.getProject().delete(true, true, new NullProgressMonitor()); + } } } @@ -175,7 +226,6 @@ public class IndexCompositeTests extends BaseTestCase { assertNamespaceXMemberCount(5); assertFieldCount("C1", 1); - setIndex(cprojB, NONE); assertBCount(gBC, aBC); assertNamespaceXMemberCount(2); @@ -195,7 +245,6 @@ public class IndexCompositeTests extends BaseTestCase { assertBCount(gABC, aABC); assertNamespaceXMemberCount(5); assertFieldCount("C1", 1); - setIndex(cprojA, NONE); assertBCount(gABC, aABC); @@ -217,8 +266,9 @@ public class IndexCompositeTests extends BaseTestCase { assertNamespaceXMemberCount(5); assertFieldCount("C1", 1); } finally { - for (ICProject project : projects) + for (ICProject project : projects) { project.getProject().delete(true, true, new NullProgressMonitor()); + } } } @@ -259,7 +309,6 @@ public class IndexCompositeTests extends BaseTestCase { ICProject cprojC = pb.create(); projects.add(cprojC); - /* A C | * \ / | Depends On / References * B V @@ -278,7 +327,6 @@ public class IndexCompositeTests extends BaseTestCase { final int gAB= gA + gB - 1, aAB= aA + aB - 1; final int gABC= gA + gBC - 1, aABC= aA + aBC - 1; - setIndex(cprojC, NONE); assertBCount(gBC, aBC); assertNamespaceXMemberCount(3); @@ -318,8 +366,9 @@ public class IndexCompositeTests extends BaseTestCase { assertBCount(gABC, aABC); assertNamespaceXMemberCount(4); } finally { - for (ICProject project : projects) + for (ICProject project : projects) { project.getProject().delete(true, true, new NullProgressMonitor()); + } } } @@ -415,8 +464,9 @@ public class IndexCompositeTests extends BaseTestCase { assertBCount(gABC, aABC); assertNamespaceXMemberCount(4); } finally { - for (ICProject project : projects) + for (ICProject project : projects) { project.getProject().delete(true, true, new NullProgressMonitor()); + } } } @@ -438,13 +488,13 @@ public class IndexCompositeTests extends BaseTestCase { private void assertNamespaceXMemberCount(int count) throws CoreException, DOMException { IBinding[] bindings = index.findBindings(Pattern.compile("X"), true, FILTER, new NullProgressMonitor()); 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 { IBinding[] bindings = index.findBindings(Pattern.compile(qnPattern), true, FILTER, new NullProgressMonitor()); 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 { @@ -463,53 +513,3 @@ public class IndexCompositeTests extends BaseTestCase { 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; - } -} diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java index 80faf0f2e50..0fd42ab7ded 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java @@ -240,7 +240,8 @@ public class IndexUpdateTests extends IndexTestBase { for (int i = 0; i < nchars.length; i++) { 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() { @@ -256,7 +257,6 @@ public class IndexUpdateTests extends IndexTestBase { // short globalVar; // register int globalVar; - public void testGlobalCppVariable() throws Exception { setupFile(3, true); checkCppVariable("globalVar", INT, new String[]{}); @@ -345,7 +345,6 @@ public class IndexUpdateTests extends IndexTestBase { // struct my_struct {int fField;}; // struct my_struct {short fField;}; - public void testCField() throws Exception { setupFile(2, false); checkVariable("my_struct::fField", INT, new String[]{}); @@ -402,7 +401,6 @@ public class IndexUpdateTests extends IndexTestBase { checkModifier(modifiers, PRIVATE, visibility == ICPPMember.v_private); } - // class MyClass {int 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 {virtual int method(char a) = 0;}; - public void testCppMethod() throws Exception { setupFile(10, true); checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PRIVATE}); @@ -453,7 +450,6 @@ public class IndexUpdateTests extends IndexTestBase { // #include "header.h" // char MyClass::method(int a, int b); - public void testFixedCppMethod() throws Exception { setupHeader(3, true); 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 {private: MyClass(char a, int b);}; - public void testCppConstructor() throws Exception { setupFile(6, true); 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); - 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; for (int i = 0; i < assignmentOps.length; i++) { IIndexBinding assignmentOp= assignmentOps[i]; @@ -717,7 +713,6 @@ public class IndexUpdateTests extends IndexTestBase { } } - // class myType { // int a; // }; @@ -1183,7 +1178,6 @@ public class IndexUpdateTests extends IndexTestBase { } } - // void funcTypeDeletion(int); // #include "header.h" diff --git a/core/org.eclipse.cdt.core.tests/pom.xml b/core/org.eclipse.cdt.core.tests/pom.xml index 9c6c3c90e40..7f57c786ad6 100644 --- a/core/org.eclipse.cdt.core.tests/pom.xml +++ b/core/org.eclipse.cdt.core.tests/pom.xml @@ -32,7 +32,7 @@ ${tycho-version} false - -Xms256m -Xmx512m -XX:MaxPermSize=256M + -ea -Xms256m -Xmx512m -XX:MaxPermSize=256M **/AutomatedIntegrationSuite.* diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java index d458b04a10a..251313e5c27 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java @@ -1,14 +1,14 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2005, 2010 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * IBM Corporation - initial API and implementation - * Markus Schorn (Wind River Systems) - * Norbert Ploett (Siemens AG) + * Contributors: + * IBM Corporation - initial API and implementation + * Markus Schorn (Wind River Systems) + * Norbert Ploett (Siemens AG) *******************************************************************************/ package org.eclipse.cdt.core.suite; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java index 90f083bfcde..e27d13e956e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * 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.language.settings.providers.LanguageSettingsExtensionManager; 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.runtime.preferences.InstanceScope; 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$ /** 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$ + /** 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$ // 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 getDefaultProvidersLegacy() { List providers = new ArrayList(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) { providers.add(provider); } - providers.add(LanguageSettingsProvidersSerializer.getWorkspaceProvider(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID)); + providers.add(LanguageSettingsProvidersSerializer.getWorkspaceProvider(MBS_LANGUAGE_SETTINGS_PROVIDER_ID)); return providers; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java index 25797a7adbd..f7dda7b3f10 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CProjectNature; 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.ScannerDiscoveryLegacySupport; import org.eclipse.cdt.core.resources.IPathEntryStore; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSetting; @@ -1253,11 +1254,12 @@ public class CoreModel { if(des != null){ ICConfigurationDescription indexCfg = des.getDefaultSettingConfiguration(); if(indexCfg != null){ - if(!mngr.isNewStyleCfg(indexCfg)){ + if (!mngr.isNewStyleCfg(indexCfg)) { return oldIsScannerInformationEmpty(resource); } - if (indexCfg instanceof ILanguageSettingsProvidersKeeper) { + if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project) && + indexCfg instanceof ILanguageSettingsProvidersKeeper) { List languageIds = LanguageSettingsManager.getLanguages(resource, indexCfg); for (String langId : languageIds) { List entries = LanguageSettingsManager.getSettingEntriesByKind(indexCfg, resource, langId, diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java index 759e0e18b42..2dfdc007014 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java @@ -38,7 +38,8 @@ public interface ICSettingEntry { /** * Flag {@code LOCAL} is used during creation of {@link IIncludeEntry} * 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 + * "Local" path is denoted by quotes as in #include "x.h" */ int LOCAL = 1 << 2; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java index 282727ca63b..99b8fd8948a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * 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$ 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_PROJECT_PATH = ".settings/language.settings.xml"; //$NON-NLS-1$ @@ -833,8 +833,13 @@ public class LanguageSettingsProvidersSerializer { LanguageSettingsLogger.logWarning("LanguageSettingsProvidersSerializer.serializeLanguageSettings() for " + project); try { - // Using side effect of adding the module to the storage - prjDescription.getStorage(CPROJECT_STORAGE_MODULE, true); + // Add the storage module to .cpoject and persist on disk as a side effect of adding + 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) { 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) { IProject project = prjDescription.getProject(); IFile storeInPrjArea = getStoreInProjectArea(project); - if (storeInPrjArea.exists()) { + boolean isStoreInProjectAreaExist = storeInPrjArea.exists(); + boolean enableLSP = isStoreInProjectAreaExist; + if (isStoreInProjectAreaExist) { Document doc = null; try { 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$ } - } else { - // Storage in project area does not exist - ICStorageElement storageElement = null; + } else { // Storage in project area does not exist + ICStorageElement lspStorageModule = null; try { - storageElement = prjDescription.getStorage(CPROJECT_STORAGE_MODULE, false); + lspStorageModule = prjDescription.getStorage(CPROJECT_STORAGE_MODULE_LANGUAGE_SETTINGS_PROVIDERS, false); } catch (CoreException e) { String msg = "Internal error while trying to load language settings"; //$NON-NLS-1$ CCorePlugin.log(msg, e); } - if (storageElement != null) { - // set default providers defined in the tool-chain - for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) { + // set default providers defined in the tool-chain + for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) { + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { String[] ids = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds(); if (ids != null) { List providers = new ArrayList(ids.length); @@ -1182,23 +1188,16 @@ public class LanguageSettingsProvidersSerializer { ((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); + } + } /** diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java new file mode 100644 index 00000000000..fb2d1e637bc --- /dev/null +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java @@ -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 getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + List entries = new ArrayList(); + 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 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 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 entries, IScannerInfo si) { + Map definedSymbols = si.getDefinedSymbols(); + if (definedSymbols != null) { + for (Entry entry : new TreeMap(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 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 entries, IExtendedScannerInfo esi) { + String[] macroFiles = esi.getMacroFiles(); + if (macroFiles != null) { + for (String path : macroFiles) { + entries.add(CDataUtil.createCMacroFileEntry(path, 0)); + } + } + } +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java index 4682d1838cb..bb1c9b597da 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java @@ -38,6 +38,7 @@ import org.eclipse.cdt.core.model.IPathEntryContainer; import org.eclipse.cdt.core.model.IProjectEntry; import org.eclipse.cdt.core.model.ISourceEntry; import org.eclipse.cdt.core.resources.IPathEntryVariableManager; +import org.eclipse.cdt.utils.UNCPathConverter; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -513,6 +514,9 @@ public class PathEntryUtil { private static boolean isValidExternalPath(IPath path) { if (path != null) { + if (path.isUNC()) { + return true; + } File file = path.toFile(); if (file != null) { return file.exists(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java index a8a881a4b63..61c95fc315d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java @@ -52,6 +52,7 @@ import javax.xml.transform.stream.StreamResult; import org.eclipse.cdt.core.CCorePlugin; 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.ScannerDiscoveryLegacySupport; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElementDelta; @@ -1141,7 +1142,15 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { monitor = new NullProgressMonitor(); 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 { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java index f2097edf8d8..5a254287247 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java @@ -9,6 +9,7 @@ * Rational Software - initial implementation * Markus Schorn (Wind River Systems) * Sergey Prigogin (Google) + * Nathan Ridge *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -183,6 +184,7 @@ public class ASTTypeUtil { private static void appendArgument(ICPPTemplateArgument arg, boolean normalize, StringBuilder buf) { IValue val= arg.getNonTypeValue(); if (val != null) { + appendType(arg.getTypeOfNonTypeValue(), normalize, buf); buf.append(val.getSignature()); } else { IType type = normalize ? arg.getTypeValue() : arg.getOriginalTypeValue(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFileLocation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFileLocation.java index 4ad690da89d..ef76745892c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFileLocation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFileLocation.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation + * Contributors: + * Doug Schaefer (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IEnumeration.java index 7e976248eb9..47577e3a252 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IEnumeration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IEnumeration.java @@ -18,9 +18,8 @@ package org.eclipse.cdt.core.dom.ast; public interface IEnumeration extends IBinding, IType { /** * Returns an array of the IEnumerators declared in this enumeration - * @throws DOMException */ - IEnumerator[] getEnumerators() throws DOMException; + IEnumerator[] getEnumerators(); /** * @since 5.2 diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPEnumerationSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPEnumerationSpecialization.java new file mode 100644 index 00000000000..684747193ad --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPEnumerationSpecialization.java @@ -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); +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java index 461a2afa83f..ed5c8c13acc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java @@ -1,15 +1,15 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2005, 2010 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Anton Leherbauer (Wind River Systems) - * Sergey Prigogin (Google) + * Contributors: + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Anton Leherbauer (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java index e0fdf88dd99..f70277a545b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java @@ -8,6 +8,7 @@ * Contributors: * Andrew Niefer (IBM Corporation) - initial API and implementation * Markus Schorn (Wind River Systems) + * Nathan Ridge *******************************************************************************/ 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.IType; 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.ICASTEnumerationSpecifier; import org.eclipse.cdt.core.index.IIndexBinding; 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; /** * Binding for enumerations in C. */ public class CEnumeration extends PlatformObject implements IEnumeration, ICInternalBinding { - private IASTName[] declarations = null; private IASTName definition = null; private Long fMinValue; @@ -204,20 +204,7 @@ public class CEnumeration extends PlatformObject implements IEnumeration, ICInte if (fMinValue != null) return fMinValue.longValue(); - long minValue = Long.MAX_VALUE; - 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; - } - } - } - } + long minValue = SemanticUtil.computeMinValue(this); fMinValue= minValue; return minValue; } @@ -227,20 +214,7 @@ public class CEnumeration extends PlatformObject implements IEnumeration, ICInte if (fMaxValue != null) return fMaxValue.longValue(); - long maxValue = Long.MIN_VALUE; - 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; - } - } - } - } + long maxValue = SemanticUtil.computeMaxValue(this); fMaxValue= maxValue; return maxValue; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java index 6cd767286e1..1f05eb9f02f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2006, 2012 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2006, 2012 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * Mike Kucera (IBM Corporation) - initial API and implementation * Markus Schorn (Wind River Systems) *******************************************************************************/ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryTypeIdExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryTypeIdExpression.java index a0a508069fc..916731241c1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryTypeIdExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryTypeIdExpression.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2013 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * John Camelon (IBM) - Initial API and implementation * Markus Schorn (Wind River Systems) *******************************************************************************/ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatementExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatementExpression.java index dad73eb5078..8d363e18898 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatementExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatementExpression.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * John Camelon (IBM) - Initial API and implementation * Markus Schorn (Wind River Systems) *******************************************************************************/ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConditionalExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConditionalExpression.java index e3d05cf340f..cbc866f92a6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConditionalExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConditionalExpression.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2012 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * John Camelon (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Contributors: + * John Camelon (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java index 1d0575f6d22..adb1ad1db1b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * John Camelon (IBM) - Initial API and implementation * Markus Schorn (Wind River Systems) *******************************************************************************/ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeIdExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeIdExpression.java index 5e0c71d7bff..5de9d648038 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeIdExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeIdExpression.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2012 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * John Camelon (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Contributors: + * John Camelon (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java index ff1ade59140..ba3e732e58b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * John Camelon (IBM) - Initial API and implementation * Markus Schorn (Wind River Systems) *******************************************************************************/ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java index 12a06267a49..146430c12ff 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java @@ -1,14 +1,14 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2012 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * Andrew Niefer (IBM Corporation) - initial API and implementation - * Markus Schorn (Wind River Systems) - * Sergey Prigogin (Google) + * Contributors: + * Andrew Niefer (IBM Corporation) - initial API and implementation + * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java index 1ea5e20d6de..e595d99b1a2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java @@ -9,6 +9,7 @@ * Andrew Niefer (IBM Corporation) - initial API and implementation * Markus Schorn (Wind River Systems) * Sergey Prigogin (Google) + * Nathan Ridge *******************************************************************************/ 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.IType; 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.ICPPASTQualifiedName; 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.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.SemanticUtil; import org.eclipse.core.runtime.PlatformObject; /** @@ -220,20 +221,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I if (fMinValue != null) return fMinValue.longValue(); - long minValue = Long.MAX_VALUE; - 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; - } - } - } - } + long minValue = SemanticUtil.computeMinValue(this); fMinValue= minValue; return minValue; } @@ -243,20 +231,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I if (fMaxValue != null) return fMaxValue.longValue(); - long maxValue = Long.MIN_VALUE; - 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; - } - } - } - } + long maxValue = SemanticUtil.computeMaxValue(this); fMaxValue= maxValue; return maxValue; } @@ -278,10 +253,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I if (definition == null) { ICPPEnumeration typeInIndex= getIndexBinding(); if (typeInIndex != null) { - try { - return typeInIndex.getEnumerators(); - } catch (DOMException e) { - } + return typeInIndex.getEnumerators(); } return EMPTY_ENUMERATORS; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerationSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerationSpecialization.java new file mode 100644 index 00000000000..8f0c041607d --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerationSpecialization.java @@ -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; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeratorSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeratorSpecialization.java new file mode 100644 index 00000000000..b3c3ca4516e --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeratorSpecialization.java @@ -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; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java index dd10111a8ec..28fad2be5be 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2010 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * Andrew Niefer (IBM Corporation) - initial API and implementation * Markus Schorn (Wind River Systems) *******************************************************************************/ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDeclarationSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDeclarationSpecialization.java index 2f17485600e..1da54960e1f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDeclarationSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDeclarationSpecialization.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011 Wind River Systems, 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 + * Copyright (c) 2011 Wind River Systems, 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: + * Contributors: * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTExplicitTemplateInstantiation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTExplicitTemplateInstantiation.java index b448edc6823..9939dba8dfd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTExplicitTemplateInstantiation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTExplicitTemplateInstantiation.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * IBM - Initial API and implementation + * Contributors: + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTPointer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTPointer.java index cedafe070b5..50c8a49de9a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTPointer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTPointer.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * IBM - Initial API and implementation + * Contributors: + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java index 4bff763279a..043325baa46 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java @@ -39,23 +39,25 @@ public interface ICPPEvaluation extends ISerializableEvaluation { 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); /** - * 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); /** - * 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); @@ -78,7 +80,7 @@ public interface ICPPEvaluation extends ISerializableEvaluation { * * @param parameterMap maps function parameters to their values * @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 */ 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 * declarations for their meanings. * - * See also CPPTemplates.determinePackSize(). - * - * @noreference This method is not intended to be referenced by clients. + * See also {@code CPPTemplates.determinePackSize()}. */ int determinePackSize(ICPPTemplateParameterMap tpMap); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java index 81a51e64dd1..c68c28a7f23 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java @@ -7,6 +7,7 @@ * * Contributors: * Sergey Prigogin (Google) - initial API and implementation + * Nathan Ridge *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; @@ -57,4 +58,14 @@ public abstract class CPPEvaluation implements ICPPEvaluation { } 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; + } } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 9e4a6d0a356..a1421067623 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -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.IArrayType; 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.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.ICPPClassType; 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.ICPPFunction; 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.CPPDeferredClassInstance; 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.CPPFunctionInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionSpecialization; @@ -852,9 +855,29 @@ public class CPPTemplates { ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) decl; IType type= instantiateType(aliasTemplate.getType(), tpMap, -1, getSpecializationContext(owner), point); spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), aliasTemplate, type); - } else if (decl instanceof IEnumeration || decl instanceof IEnumerator) { - // TODO(sprigogin): Deal with a case when an enumerator value depends on a template parameter. - spec = decl; + } else if (decl instanceof ICPPEnumeration) { + ICPPClassSpecialization within = getSpecializationContext(owner); + 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) { IBinding[] delegates= ((ICPPUsingDeclaration) decl).getDelegates(); List result= new ArrayList(); @@ -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, ICPPTemplateParameterMap tpMap, int packOffset, IASTNode point) { ICPPTemplateArgument arg= null; @@ -2410,7 +2480,8 @@ public class CPPTemplates { if (arg.isTypeValue()) return isDependentType(arg.getTypeValue()); - return arg.getNonTypeEvaluation().isValueDependent(); + ICPPEvaluation evaluation = arg.getNonTypeEvaluation(); + return evaluation.isTypeDependent() || evaluation.isValueDependent(); } public static boolean containsDependentType(List ts) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java index a4419e5c668..d8567779e1e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * 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.IVariable; 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.ICPPMethod; 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.ICPPTemplateArgument; @@ -241,20 +238,14 @@ public class EvalBinding extends CPPEvaluation { } if (binding instanceof ICPPTemplateNonTypeParameter) { IType type= ((ICPPTemplateNonTypeParameter) binding).getType(); - if (CPPTemplates.isDependentType(type)) - return new TypeOfDependentExpression(this); return prvalueType(type); } if (binding instanceof IVariable) { final IType type = ((IVariable) binding).getType(); - if (CPPTemplates.isDependentType(type)) - return new TypeOfDependentExpression(this); return SemanticUtil.mapToAST(glvalueType(type), point); } if (binding instanceof IFunction) { final IFunctionType type = ((IFunction) binding).getType(); - if (CPPTemplates.isDependentType(type)) - return new TypeOfDependentExpression(this); return SemanticUtil.mapToAST(type, point); } return ProblemType.UNKNOWN_FOR_EXPRESSION; @@ -325,55 +316,26 @@ public class EvalBinding extends CPPEvaluation { @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, int maxdepth, IASTNode point) { - IBinding binding = getBinding(); - if (binding instanceof IEnumerator) { - IEnumerator enumerator = (IEnumerator) binding; - 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); + IBinding origBinding = getBinding(); + if (origBinding instanceof ICPPTemplateNonTypeParameter) { + ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding); if (argument != null && argument.isNonTypeValue()) { return argument.getNonTypeEvaluation(); } // TODO(sprigogin): Do we need something similar for pack expansion? - } else if (binding instanceof ICPPUnknownBinding) { - binding = resolveUnknown((ICPPUnknownBinding) binding, tpMap, packOffset, within, point); - } else if (binding instanceof ICPPMethod) { - 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 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 if (origBinding instanceof ICPPParameter) { + ICPPParameter parameter = (ICPPParameter) origBinding; + IType origType = parameter.getType(); + IType instantiatedType = CPPTemplates.instantiateType(origType, tpMap, packOffset, within, point); + if (origType != instantiatedType) { + return new EvalFixed(instantiatedType, 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 new EvalBinding(binding, getFixedType()); + return this; } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java index 5e86257e167..a5d91072c07 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java @@ -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.Kind; 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.IPointerType; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IType; 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.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; @@ -669,4 +672,40 @@ public class SemanticUtil { } 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; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java index 555f1ec9e77..8d33b882c8d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java @@ -619,10 +619,11 @@ public class TemplateArgumentDeduction { } ICPPTemplateArgument pattern = p[j].getExpansionPattern(); for (int i= j; i < a.length; i++) { + if (i != j) + deduct.incPackOffset(); if (!deduct.fromTemplateArgument(pattern, a[i], point)) { return false; } - deduct.incPackOffset(); } break; } else { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexCPPBindingConstants.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexCPPBindingConstants.java index 7aab87f9d8d..a56f3d3318f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexCPPBindingConstants.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexCPPBindingConstants.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,6 +9,7 @@ * Andrew Ferguson (Symbian) - Initial implementation * Markus Schorn (Wind River Systems) * Thomas Corbat (IFS) + * Sergey Prigogin (Google) *******************************************************************************/ 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_UNKNOWN_METHOD = IIndexBindingConstants.LAST_CONSTANT + 50; int CPP_TEMPLATE_ALIAS = IIndexBindingConstants.LAST_CONSTANT + 51; + int CPP_ENUMERATION_SPECIALIZATION = IIndexBindingConstants.LAST_CONSTANT + 52; + int CPP_ENUMERATOR_SPECIALIZATION = IIndexBindingConstants.LAST_CONSTANT + 53; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCEnumeration.java index a08ab1bb058..6b6416b7c5b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCEnumeration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCEnumeration.java @@ -11,7 +11,6 @@ *******************************************************************************/ 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.IEnumerator; import org.eclipse.cdt.core.dom.ast.IType; @@ -25,7 +24,7 @@ class CompositeCEnumeration extends CompositeCBinding implements IEnumeration, I } @Override - public IEnumerator[] getEnumerators() throws DOMException { + public IEnumerator[] getEnumerators() { IEnumerator[] result = ((IEnumeration)rbinding).getEnumerators(); for (int i= 0; i < result.length; i++) result[i] = (IEnumerator) cf.getCompositeBinding((IIndexFragmentBinding) result[i]); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumeration.java index dbae723aa2f..21835141616 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumeration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumeration.java @@ -11,7 +11,6 @@ *******************************************************************************/ 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.IEnumerator; import org.eclipse.cdt.core.dom.ast.IType; @@ -27,7 +26,7 @@ class CompositeCPPEnumeration extends CompositeCPPBinding implements ICPPEnumera } @Override - public IEnumerator[] getEnumerators() throws DOMException { + public IEnumerator[] getEnumerators() { IEnumerator[] result = ((IEnumeration)rbinding).getEnumerators(); for (int i= 0; i < result.length; i++) result[i] = (IEnumerator) cf.getCompositeBinding((IIndexFragmentBinding) result[i]); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java index a9de019b08e..456eec950f4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.parser; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -159,26 +158,15 @@ public class InternalParserUtil extends ParserFactory { IFileStore store = EFS.getStore(file.getLocationURI()); IFileInfo fileInfo = store.fetchInfo(); input= file.getContents(true); - 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); + if (input instanceof FileInputStream) { try { - input = new FileInputStream(fileCache); - } catch (FileNotFoundException e) { - CCorePlugin.log(e); - return null; - } - } - try { - return createFileContent(path, file.getCharset(), input, - fileInfo.getLastModified(), fileInfo.getLength(), fileReadTime); - } finally { - try { - input.close(); - } catch (IOException e) { + return createFileContent(path, null, file.getCharset(), input, + fileInfo.getLastModified(), fileInfo.getLength(), fileReadTime); + } finally { + try { + input.close(); + } catch (IOException e) { + } } } } catch (CoreException e) { @@ -193,18 +181,19 @@ public class InternalParserUtil extends ParserFactory { CCorePlugin.log(e); break; } - return null; } + return null; } /** * Creates a code reader for an external location, normalizing path to * canonical path. */ - public static InternalFileContent createExternalFileContent(String externalLocation, String encoding) { + public static InternalFileContent createExternalFileContent(final String externalLocation, String encoding) { long fileReadTime = System.currentTimeMillis(); File includeFile = null; String path = null; + String localPath = null; if (!UNCPathConverter.isUNC(externalLocation)) { includeFile = new File(externalLocation); // 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)); includeFile = store.toLocalFile(EFS.CACHE, null); path = externalLocation; + localPath = includeFile.getAbsolutePath(); } catch (CoreException e) { } } @@ -230,7 +220,7 @@ public class InternalParserUtil extends ParserFactory { return null; } try { - return createFileContent(path, encoding, in, timestamp, fileSize, fileReadTime); + return createFileContent(path, localPath, encoding, in, timestamp, fileSize, fileReadTime); } finally { try { in.close(); @@ -241,10 +231,13 @@ public class InternalParserUtil extends ParserFactory { 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) { + if (localPath == null) { + localPath = path; + } try { - AbstractCharArray chars= FileCharArray.create(path, charset, in); + AbstractCharArray chars= FileCharArray.create(localPath, charset, in); if (chars == null) return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java index 1899ef3bc29..ff79a122a88 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java @@ -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.parser.IMacroDictionary; 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 @@ -49,7 +53,16 @@ public abstract class InternalFileContentProvider extends IncludeFileContentProv /** * 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(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java index c042cd8cf51..03c11be0d0c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java @@ -229,10 +229,11 @@ public class PDOM extends PlatformObject implements IPDOM { * 137.0 - Fixed serialization of very large types and template arguments, bug 392278. * 138.0 - Constexpr functions, bug 395238. * 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 MAX_SUPPORTED_VERSION= version(139, Short.MAX_VALUE); - private static final int DEFAULT_VERSION = version(139, 0); + private static final int MIN_SUPPORTED_VERSION= version(140, 0); + private static final int MAX_SUPPORTED_VERSION= version(140, Short.MAX_VALUE); + private static final int DEFAULT_VERSION = version(140, 0); private static int version(int major, int minor) { return (major << 16) + minor; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java index d320edec18a..0ea282443f2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java @@ -309,7 +309,7 @@ public class PDOMASTAdapter { } @Override - public IEnumerator[] getEnumerators() throws DOMException { + public IEnumerator[] getEnumerators() { return fDelegate.getEnumerators(); } @@ -507,7 +507,7 @@ public class PDOMASTAdapter { } @Override - public IEnumerator[] getEnumerators() throws DOMException { + public IEnumerator[] getEnumerators() { return ((IEnumeration) fDelegate).getEnumerators(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMNamedNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMNamedNode.java index 2c0fe31c7e5..41c821468c4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMNamedNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMNamedNode.java @@ -6,10 +6,10 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation - * IBM Corporation - * Andrew Ferguson (Symbian) - * Markus Schorn (Wind River Systems) + * QNX - Initial API and implementation + * IBM Corporation + * Andrew Ferguson (Symbian) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom; @@ -24,7 +24,6 @@ import org.eclipse.core.runtime.CoreException; /** * @author Doug Schaefer - * */ public abstract class PDOMNamedNode extends PDOMNode { /** @@ -104,7 +103,6 @@ public abstract class PDOMNamedNode extends PDOMNode { fName= nameCharArray; } - @Override public void delete(PDOMLinkage linkage) throws CoreException { final Database db = getDB(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/IPDOMCPPEnumType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/IPDOMCPPEnumType.java index 19b7e2b5c5a..807886f84a1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/IPDOMCPPEnumType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/IPDOMCPPEnumType.java @@ -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 * 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: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ 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 { /** - * Return the scope name, for use in {@link IScope#getScopeName()} + * Returns the scope name, for use in {@link IScope#getScopeName()} */ IIndexName getScopeName(); @@ -33,5 +34,5 @@ public interface IPDOMCPPEnumType extends ICPPEnumeration, IPDOMBinding, IIndexT /** * Called by the scope to access the enumerators. */ - void loadEnumerators(CharArrayMap map); + void loadEnumerators(CharArrayMap map); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/IPDOMCPPEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/IPDOMCPPEnumerator.java new file mode 100644 index 00000000000..ff2f767d2e1 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/IPDOMCPPEnumerator.java @@ -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 { +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumScope.java index 25f34538a52..f892e243acd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumScope.java @@ -65,7 +65,7 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope { @Override public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) { try { - CharArrayMap map= getBindingMap(fBinding); + CharArrayMap map= getBindingMap(fBinding); return map.get(name.toCharArray()); } catch (CoreException e) { CCorePlugin.log(e); @@ -81,7 +81,7 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope { @Override public IBinding[] getBindings(ScopeLookupData lookup) { try { - CharArrayMap map= getBindingMap(fBinding); + CharArrayMap map= getBindingMap(fBinding); if (lookup.isPrefixLookup()) { final List result= new ArrayList(); final char[] nc= lookup.getLookupKey(); @@ -135,36 +135,36 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope { return fBinding.hashCode(); } - private static CharArrayMap getBindingMap(IPDOMCPPEnumType enumeration) throws CoreException { + private static CharArrayMap getBindingMap(IPDOMCPPEnumType enumeration) throws CoreException { final Long key= enumeration.getRecord() + PDOMCPPLinkage.CACHE_MEMBERS; final PDOM pdom = enumeration.getPDOM(); @SuppressWarnings("unchecked") - Reference> cached= (Reference>) pdom.getCachedResult(key); - CharArrayMap map= cached == null ? null : cached.get(); + Reference> cached= (Reference>) pdom.getCachedResult(key); + CharArrayMap map= cached == null ? null : cached.get(); if (map == null) { // there is no cache, build it: - map= new CharArrayMap(); + map= new CharArrayMap(); enumeration.loadEnumerators(map); pdom.putCachedResult(key, new SoftReference>(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 PDOM pdom = enumType.getPDOM(); @SuppressWarnings("unchecked") - Reference> cached= (Reference>) pdom.getCachedResult(key); - CharArrayMap map= cached == null ? null : cached.get(); + Reference> cached= (Reference>) pdom.getCachedResult(key); + CharArrayMap map= cached == null ? null : cached.get(); if (map != null) { map.put(enumType.getNameCharArray(), enumItem); } } - public static IEnumerator[] getEnumerators(PDOMCPPEnumeration enumType) { + public static IEnumerator[] getEnumerators(IPDOMCPPEnumType enumType) { try { - CharArrayMap map = getBindingMap(enumType); + CharArrayMap map = getBindingMap(enumType); List result= new ArrayList(); for (IEnumerator value : map.values()) { if (IndexFilter.ALL_DECLARED.acceptBinding(value)) { @@ -179,10 +179,10 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope { return new IEnumerator[0]; } - public static void acceptViaCache(PDOMCPPEnumeration enumType, IPDOMVisitor visitor) { + public static void acceptViaCache(IPDOMCPPEnumType enumType, IPDOMVisitor visitor) { try { - CharArrayMap map = getBindingMap(enumType); - for (PDOMCPPEnumerator enumItem : map.values()) { + CharArrayMap map = getBindingMap(enumType); + for (IPDOMCPPEnumerator enumItem : map.values()) { visitor.visit(enumItem); visitor.leave(enumItem); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java index 33cc375ef8f..1c8c7b53f6a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java @@ -114,7 +114,7 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IPDOMCPPEnumType, IPD if (node instanceof PDOMCPPEnumerator) { PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST); 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 - public void loadEnumerators(final CharArrayMap map) { + public void loadEnumerators(final CharArrayMap 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 PDOMCPPEnumerator) { - final PDOMCPPEnumerator item = (PDOMCPPEnumerator) node; + if (node instanceof IPDOMCPPEnumerator) { + final IPDOMCPPEnumerator item = (IPDOMCPPEnumerator) node; map.put(item.getNameCharArray(), item); } return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerationSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerationSpecialization.java new file mode 100644 index 00000000000..e4e9d451bc0 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerationSpecialization.java @@ -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 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; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerator.java index b449b88b6ab..3e28624a9cd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerator.java @@ -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 * 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: - * Doug Schaefer (QNX) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Doug Schaefer (QNX) - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ 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.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.PDOMLinkage; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; import org.eclipse.core.runtime.CoreException; @@ -26,11 +28,11 @@ import org.eclipse.core.runtime.CoreException; /** * 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; @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) throws CoreException { @@ -55,11 +57,10 @@ class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator { private void storeValue(IEnumerator enumerator) throws CoreException { IValue value= enumerator.getValue(); if (value != null) { - Long val= value.numericalValue(); - getDB().putInt(record + VALUE, val == null ? -1 : val.intValue()); + getLinkage().storeValue(record + VALUE, value); } } - + @Override public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException { if (newBinding instanceof IEnumerator) @@ -77,8 +78,7 @@ class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator { @Override public IValue getValue() { try { - int val= getDB().getInt(record + VALUE); - return Value.create(val); + return getLinkage().loadValue(record + VALUE); } catch (CoreException e) { CCorePlugin.log(e); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeratorSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeratorSpecialization.java new file mode 100644 index 00000000000..2044ee6b535 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeratorSpecialization.java @@ -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; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java index 80eeb687946..b21ab32e014 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * 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); } else if (special instanceof ICPPUsingDeclaration) { 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; @@ -893,6 +897,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { return new PDOMCPPUsingDeclarationSpecialization(this, record); case CPP_TEMPLATE_ALIAS: 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$ return null; diff --git a/core/org.eclipse.cdt.core/plugin.properties b/core/org.eclipse.cdt.core/plugin.properties index 05f9ed7440a..46e1547c2f1 100644 --- a/core/org.eclipse.cdt.core/plugin.properties +++ b/core/org.eclipse.cdt.core/plugin.properties @@ -132,4 +132,5 @@ CProjectStorageType.separatefile.name = Xml Storage (Separate Files) scannerInfoProvider2.name = Scanner Info Provider efsExtensionProvider.name = EFSExtensionProvider refreshExclusionFactory.name = Refresh Exclusion Factory -uncPathConverter.name = UNC Path Converter \ No newline at end of file +uncPathConverter.name = UNC Path Converter +ScannerInfoExtensionLanguageSettingsProvider.name=Contributed ScannerInfo Entries diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml index b0a0c3a9e7a..8ab01a9e13a 100644 --- a/core/org.eclipse.cdt.core/plugin.xml +++ b/core/org.eclipse.cdt.core/plugin.xml @@ -2,7 +2,7 @@ - + @@ -806,6 +806,14 @@ factoryClass="org.eclipse.cdt.internal.core.resources.ResourceExclusionFactory"> + + + + ${tycho-version} true - -Xms256m -Xmx512m -XX:MaxPermSize=256M + -ea -Xms256m -Xmx512m -XX:MaxPermSize=256M **/AutomatedSuite.* diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java index 9a1efb93186..29c78c5e609 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java @@ -1,13 +1,14 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2013 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Contributors: + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Nathan Ridge *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.selection; @@ -75,7 +76,6 @@ import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction; * @author dsteffle */ public class CPPSelectionTestsNoIndexer extends BaseUITestCase { - private static final String INDEX_FILE_ID = "2946365241"; //$NON-NLS-1$ static NullProgressMonitor monitor; static IWorkspace workspace; @@ -1205,4 +1205,23 @@ public class CPPSelectionTestsNoIndexer extends BaseUITestCase { assertEquals(offsetV, ((ASTNode) decl).getOffset()); } + // template + // 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); + } + } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java index 55dec936572..be1b165c749 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2010 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Contributors: + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.selection; diff --git a/core/org.eclipse.cdt.ui/.settings/.api_filters b/core/org.eclipse.cdt.ui/.settings/.api_filters index 6d77fc00926..55723afdab0 100644 --- a/core/org.eclipse.cdt.ui/.settings/.api_filters +++ b/core/org.eclipse.cdt.ui/.settings/.api_filters @@ -4,7 +4,7 @@ - + diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF index 80a26f88146..eb9c2d464a2 100644 --- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName 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-Vendor: %providerName Bundle-Localization: plugin diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index 82a725516ba..18028baf180 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -644,4 +644,6 @@ RefreshExclusionContributorExtensionPoint = Refresh Exclusion Contributor newProjectWizard.name = C/C++ Project (prototype) projectTypePages = Project Type Pages +semanticHighlightingExtensionPoint = Semantic Highlighting Extension Point + UserSettingEntries.name = CDT User Setting Entries diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index d748f309685..84082641ddc 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -29,6 +29,7 @@ + diff --git a/core/org.eclipse.cdt.ui/pom.xml b/core/org.eclipse.cdt.ui/pom.xml index f50cfd9479d..b3981b4c87a 100644 --- a/core/org.eclipse.cdt.ui/pom.xml +++ b/core/org.eclipse.cdt.ui/pom.xml @@ -11,7 +11,7 @@ ../../pom.xml - 5.5.0-SNAPSHOT + 5.6.0-SNAPSHOT org.eclipse.cdt.ui eclipse-plugin diff --git a/core/org.eclipse.cdt.ui/schema/semanticHighlighting.exsd b/core/org.eclipse.cdt.ui/schema/semanticHighlighting.exsd new file mode 100644 index 00000000000..f5960fd03c8 --- /dev/null +++ b/core/org.eclipse.cdt.ui/schema/semanticHighlighting.exsd @@ -0,0 +1,245 @@ + + + + + + + + + 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> + + + + + + + + + + + + + + + + + + + a fully qualified identifier of the target extension point + + + + + + + an optional identifier of the extension instance + + + + + + + an optional name of the extension instance + + + + + + + + + + + + + + + + + + a unique identifier for the Quick Fix processor + + + + + + + a localized name of the Quick Fix processor + + + + + + + + + + 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. + + + + + + + + + + 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. + + + + + + + A key to uniquely identify the highlighting's settings in the preference store. + + + + + + + The name that is displayed for the highlighter in the Preferences window. + + + + + + + + + + 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). + + + + + + + false by default + + + + + + + false by default + + + + + + + false by default + + + + + + + false by default + + + + + + + false by default + + + + + + + + + + + + 8.2 + + + + + + + + + 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> + + + + + + + + + The contributed class must implement <code>org.eclipse.cdt.ui.text.ISemanticHighlighter</code> + + + + + + + + + + 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 + + + + diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/CorextMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/CorextMessages.java index 04425a71de7..ffa1711cdfa 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/CorextMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/CorextMessages.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * IBM Rational Software - Initial API and implementation + * Contributors: + * IBM Rational Software - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.corext; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/AddIncludesOperation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/AddIncludesOperation.java index 188c3aaa7b1..8df7383de33 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/AddIncludesOperation.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/AddIncludesOperation.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2000, 2010 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation * QNX Software Systems * Sergey Prigogin (Google) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java index e506fbfdd7d..43c3420facf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2005, 2010 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation * QNX Software System * Markus Schorn (Wind River Systems) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java index b68ebfdb6cf..65fdc01a89c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2001, 2011 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2001, 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * Rational Software - initial implementation * Sergey Prigogin (Google) *******************************************************************************/ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ContributedSemanticHighlighting.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ContributedSemanticHighlighting.java new file mode 100644 index 00000000000..ada16913806 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ContributedSemanticHighlighting.java @@ -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); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java index a58b7463bc6..b6d72dc3562 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java @@ -17,11 +17,12 @@ import org.eclipse.swt.graphics.RGB; import org.eclipse.ui.PlatformUI; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.text.ISemanticToken; /** * Semantic highlighting. * Cloned from JDT. - * + * * @since 4.0 */ public abstract class SemanticHighlighting { @@ -81,9 +82,9 @@ public abstract class SemanticHighlighting { * @return the display name */ 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) */ 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} * @return true iff the semantic highlighting consumes the semantic token */ - public abstract boolean consumes(SemanticToken token); + public abstract boolean consumes(ISemanticToken token); private String getThemeColorKey() { return CUIPlugin.PLUGIN_ID + "." + getPreferenceKey() + "Highlighting"; //$NON-NLS-1$//$NON-NLS-2$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java index e3df7aedf1e..5e6da1c7d65 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java @@ -11,7 +11,11 @@ *******************************************************************************/ 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.IConfigurationElement; import org.eclipse.core.runtime.Platform; import org.eclipse.jface.preference.IPreferenceStore; 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.ui.CUIPlugin; 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.OverloadableOperator; @@ -228,7 +233,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { IASTName name= (IASTName) node; @@ -279,7 +284,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { IASTName name= (IASTName) node; @@ -330,7 +335,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTImplicitName) return false; @@ -407,7 +412,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { IASTName name= (IASTName) node; @@ -461,7 +466,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTImplicitName) return false; @@ -514,7 +519,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTImplicitName) return false; @@ -585,7 +590,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTImplicitName) return false; @@ -638,7 +643,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { IASTName name= (IASTName) node; @@ -698,7 +703,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { IASTName name= (IASTName) node; @@ -774,7 +779,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { IASTName name= (IASTName) node; @@ -836,7 +841,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IBinding binding= token.getBinding(); if (binding instanceof IParameter) { return true; @@ -880,7 +885,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { IBinding binding= token.getBinding(); @@ -927,7 +932,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof ICPPASTQualifiedName || node instanceof ICPPASTTemplateId) { return false; @@ -977,7 +982,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { IBinding binding= token.getBinding(); @@ -1024,7 +1029,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IBinding binding= token.getBinding(); if (binding instanceof IMacroBinding) { IASTName name= (IASTName)token.getNode(); @@ -1071,7 +1076,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IBinding binding= token.getBinding(); if (binding instanceof IMacroBinding) { IASTName name= (IASTName)token.getNode(); @@ -1118,7 +1123,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { IASTName name= (IASTName) node; @@ -1169,7 +1174,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IBinding binding= token.getBinding(); if (binding instanceof ICPPNamespace) { return true; @@ -1213,7 +1218,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IBinding binding= token.getBinding(); if (binding instanceof ILabel) { return true; @@ -1257,7 +1262,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { IASTName name= (IASTName) node; @@ -1313,7 +1318,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node.getTranslationUnit().isBasedOnIncompleteIndex()) { // Do not highlight problems is the AST is unreliable. @@ -1370,7 +1375,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { IASTName name= (IASTName) node; @@ -1459,7 +1464,7 @@ public class SemanticHighlightings { } @Override - public boolean consumes(SemanticToken token) { + public boolean consumes(ISemanticToken token) { IASTNode node = token.getNode(); // So far we only have implicit names for overloaded operators and destructors, // so this works. @@ -1545,36 +1550,106 @@ public class SemanticHighlightings { return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX; } + private static class Key implements Comparable { + 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 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 highlightings = new TreeMap(); + + // 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. */ public static SemanticHighlighting[] getSemanticHighlightings() { if (fgSemanticHighlightings == null) - fgSemanticHighlightings= new SemanticHighlighting[] { - new MacroReferenceHighlighting(), // before all others! - new ProblemHighlighting(), - 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(), - }; + synchronized (SemanticHighlightingsLock) { + if (fgSemanticHighlightings == null) + fgSemanticHighlightings = loadSemanticHighlightings(); + } return fgSemanticHighlightings; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticToken.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticToken.java index 6b34458aae0..03b8e5136de 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticToken.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticToken.java @@ -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.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.ui.text.ISemanticToken; /** * Semantic token. * Cloned from JDT. - * + * * @since 4.0 */ -public final class SemanticToken { +public final class SemanticToken implements ISemanticToken { /** AST node */ private IASTNode fNode; @@ -38,26 +39,29 @@ public final class SemanticToken { /** * @return Returns the binding, can be null. */ + @Override public IBinding getBinding() { if (!fIsBindingResolved) { fIsBindingResolved= true; if (fNode instanceof IASTName) fBinding= ((IASTName) fNode).resolveBinding(); } - + return fBinding; } /** * @return the AST node */ + @Override public IASTNode getNode() { return fNode; } - + /** * @return the AST root */ + @Override public IASTTranslationUnit getRoot() { if (!fIsRootResolved) { fIsRootResolved= true; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java index 078e30ce016..41ada730f5f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java @@ -378,9 +378,9 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab { tableProvidersViewer.refresh(); tableProvidersViewer.setChecked(newProvider, isChecked); tableProviders.setSelection(pos); - tableProvidersViewer.refresh(newProvider); saveCheckedProviders(); + tableProvidersViewer.refresh(newProvider); } /** @@ -460,8 +460,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab { replaceSelectedProvider(newProvider); // will refresh and save checked providers createOptionsPage(newProvider); } else { - tableProvidersViewer.refresh(checkedProvider); saveCheckedProviders(); + tableProvidersViewer.refresh(checkedProvider); // option page is reused } @@ -483,7 +483,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab { } else { // Toggle to configuration-owned provider newProvider = getInitialProvider(id); - if(newProvider == null) { + if(newProvider == null || LanguageSettingsManager.isWorkspaceProvider(newProvider)) { try { ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider); if (rawProvider instanceof ILanguageSettingsEditableProvider) { @@ -926,7 +926,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab { for (ILanguageSettingsProvider provider : allAvailableProvidersSet) { String id = provider.getId(); - if (!idsList.contains(id)) { + if (!idsList.contains(id) && ScannerDiscoveryLegacySupport.isProviderCompatible(id, cfgDescription)) { providers.add(provider); idsList.add(id); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/LanguageSettingsImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/LanguageSettingsImages.java index 7e26e3a295c..92044bf3e66 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/LanguageSettingsImages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/LanguageSettingsImages.java @@ -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.ui.CDTSharedImages; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.utils.UNCPathConverter; /** * Helper class to provide unified images for {@link ICLanguageSettingEntry}. @@ -168,6 +169,8 @@ public class LanguageSettingsImages { IPath path = new Path(entry.getValue()); IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(path); exists = (rc !=null) && rc.isAccessible(); + } else if (UNCPathConverter.isUNC(entry.getName())) { + return true; } else { String pathname = entry.getName(); java.io.File file = new java.io.File(pathname); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java index 84d2f2b45a1..6ed0dd248b2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2005, 2011 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2005, 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation * QNX Software System * Anton Leherbauer (Wind River Systems) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java index 7fa89c33b88..e965de83e0e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2000, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation * QNX Software System * Anton Leherbauer (Wind River Systems) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java index 4686f48201a..08e2ab9926f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2000, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation * Anton Leherbauer (Wind River Systems) * Andrew Ferguson (Symbian) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TaskTagRule.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TaskTagRule.java index 2f59f9a7e7c..484e6fd6edf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TaskTagRule.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TaskTagRule.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2000, 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation * Anton Leherbauer (Wind River Systems) * Sergey Prigogin (Google) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java index 5f7e3a2eb41..cd88a165a6e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2000, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation * QNX Software System * Andrew Ferguson (Symbian) - refactored to TokenStore (previously part of AbstractCScanner) *******************************************************************************/ package org.eclipse.cdt.internal.ui.text; - import java.util.HashMap; import java.util.Map; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.properties index cb14e7af8f7..e0c0d601d9e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.properties @@ -1,16 +1,15 @@ ############################################################################### -# Copyright (c) 2000, 2009 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html +# Copyright (c) 2000, 2009 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html # -# Contributors: +# Contributors: # IBM Corporation - initial API and implementation # Anton Leherbauer (Wind River Systems) # Sergey Prigogin (Google) ############################################################################### - AbstractAnnotationHover_action_configureAnnotationPreferences= Configure Annotation Preferences AbstractAnnotationHover_message_singleQuickFix= 1 quick fix available: AbstractAnnotationHover_message_multipleQuickFix= {0} quick fixes available: diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.java index 6b2f81c6450..b3caefb4215 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2000, 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation * Sergey Prigogin (Google) *******************************************************************************/ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.properties index 0c35c4b4fa0..1a8afd5ce5c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.properties @@ -1,11 +1,11 @@ ############################################################################### -# Copyright (c) 2000, 2008 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html +# Copyright (c) 2000, 2008 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html # -# Contributors: +# Contributors: # IBM Corporation - initial API and implementation # Sergey Prigogin (Google) ############################################################################### diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ASTRewriteCorrectionProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ASTRewriteCorrectionProposal.java index a92164cea93..4ec95dee6fc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ASTRewriteCorrectionProposal.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ASTRewriteCorrectionProposal.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2000, 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation * Sergey Prigogin (Google) *******************************************************************************/ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java index 7627cb04c8b..66a1d596c58 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2000, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation * Sergey Prigogin (Google) * Andrew Ferguson (Symbian) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java index 74f4de2fdcb..8abd4996359 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2005, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation * Sergey Prigogin (Google) *******************************************************************************/ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java index 8145d331956..bd20c15c579 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2000, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation * Sergey Prigogin (Google) *******************************************************************************/ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java index 5ab9c6dc2c2..814f1506258 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * 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.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.ICompositeType; 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; class THGraph { - private static final ICElement[] NO_MEMBERS = new ICElement[0]; + private static final ICElement[] NO_MEMBERS = {}; private THGraphNode fInputNode= null; private HashSet fRootNodes= new HashSet(); private HashSet fLeaveNodes= new HashSet(); @@ -251,25 +249,22 @@ class THGraph { private void addMembers(IIndex index, THGraphNode graphNode, IBinding binding) throws CoreException { if (graphNode.getMembers(false) == null) { ArrayList memberList= new ArrayList(); - try { - if (binding instanceof ICPPClassType) { - ICPPClassType ct= (ICPPClassType) binding; - IBinding[] members= ct.getDeclaredFields(); - addMemberElements(index, members, memberList); - members= ct.getDeclaredMethods(); - addMemberElements(index, members, memberList); - } else if (binding instanceof ICompositeType) { - ICompositeType ct= (ICompositeType) binding; - IBinding[] members= ct.getFields(); - addMemberElements(index, members, memberList); - } else if (binding instanceof IEnumeration) { - IEnumeration ct= (IEnumeration) binding; - IBinding[] members= ct.getEnumerators(); - addMemberElements(index, members, memberList); - } - } catch (DOMException e) { - // Problem bindings should not be reported to the log. + if (binding instanceof ICPPClassType) { + ICPPClassType ct= (ICPPClassType) binding; + IBinding[] members= ct.getDeclaredFields(); + addMemberElements(index, members, memberList); + members= ct.getDeclaredMethods(); + addMemberElements(index, members, memberList); + } else if (binding instanceof ICompositeType) { + ICompositeType ct= (ICompositeType) binding; + IBinding[] members= ct.getFields(); + addMemberElements(index, members, memberList); + } else if (binding instanceof IEnumeration) { + IEnumeration ct= (IEnumeration) binding; + IBinding[] members= ct.getEnumerators(); + addMemberElements(index, members, memberList); } + if (memberList.isEmpty()) { graphNode.setMembers(NO_MEMBERS); } else { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java index 4188e1b9407..b504257278e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2003, 2011 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2003, 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * QNX Software Systems - Initial implementation *******************************************************************************/ package org.eclipse.cdt.ui; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java index 6bcaf7ba388..da5ab127bed 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java @@ -2219,7 +2219,7 @@ public class PreferenceConstants { * 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. * @return Returns the current value of the preference. - * @since 5.5 + * @since 5.6 */ public static String getPreference(String key, ICProject project, String defaultValue) { return getPreferenceNode(key, project).get(key, defaultValue); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java index 8ed8a840392..ba1cb6126e4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java @@ -276,11 +276,17 @@ public class ManageConfigDialog extends Dialog { for (int i=0; i 0) table.select(0); + if (table.getItemCount() > 0) { + table.select(0); + } table.setFocus(); updateButtons(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/UIMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/UIMessages.java index c5554d4b578..f252923ef7a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/UIMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/UIMessages.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * IBM - Initial API and implementation + * Contributors: + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.ui.newui; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AbstractCScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AbstractCScanner.java index 945e4493b31..a91291d6f46 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AbstractCScanner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AbstractCScanner.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2000, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation * QNX Software System * Andrew Ferguson (Symbian) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ISemanticHighlighter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ISemanticHighlighter.java new file mode 100644 index 00000000000..0c2d3a169bb --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ISemanticHighlighter.java @@ -0,0 +1,31 @@ +/* + * 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.ui.text; + + +/** + * Interface that must be implemented by contributors to the org.eclipse.cdt.ui.semanticHighlighting extension + * point. + * + * @since 5.6 + */ +public interface ISemanticHighlighter { + /** + * Returns true iff the semantic highlighting consumes the semantic token. + *

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

+ * + * @param token + * the semantic token for a {@link org.eclipse.cdt.core.dom.ast.IASTName} + * @return true iff the semantic highlighting consumes the semantic token + */ + public boolean consumes(ISemanticToken token); +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ISemanticToken.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ISemanticToken.java new file mode 100644 index 00000000000..239f43f1340 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ISemanticToken.java @@ -0,0 +1,27 @@ +package org.eclipse.cdt.ui.text; + +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.dom.ast.IBinding; + +/** + * An interface for accessing details of the token that is being highlighted. + * + * @since 5.6 + */ +public interface ISemanticToken { + /** + * @return Returns the binding, can be null. + */ + public IBinding getBinding(); + + /** + * @return the AST node + */ + public IASTNode getNode(); + + /** + * @return the AST root + */ + public IASTTranslationUnit getRoot(); +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/TaskTagRule.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/TaskTagRule.java index 98f830aa25c..e2395b3922a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/TaskTagRule.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/TaskTagRule.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2000, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation * Anton Leherbauer (Wind River Systems) * Sergey Prigogin (Google) diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointPropertyDialogAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointPropertyDialogAction.java index 16883079cf1..461c050d625 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointPropertyDialogAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointPropertyDialogAction.java @@ -16,10 +16,13 @@ import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointContext; import org.eclipse.core.runtime.Assert; import org.eclipse.debug.ui.contexts.IDebugContextProvider; +import org.eclipse.jface.preference.IPreferenceNode; import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.jface.window.IShellProvider; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.SelectionProviderAction; @@ -56,10 +59,7 @@ public class CBreakpointPropertyDialogAction extends SelectionProviderAction { private IDebugContextProvider fDebugContextProvider; - /** - * The id of the page to open up on. - */ - private String fInitialPageId = "org.eclipse.cdt.debug.ui.propertypages.breakpoint.common"; //$NON-NLS-1$ + private static final String PAGE_ID_COMMON = "org.eclipse.cdt.debug.ui.propertypages.breakpoint.common"; //$NON-NLS-1$ public CBreakpointPropertyDialogAction(IShellProvider shell, ISelectionProvider selectionProvider, IDebugContextProvider debugContextProvider) { super(selectionProvider, WorkbenchMessages.PropertyDialog_text); @@ -133,7 +133,6 @@ public class CBreakpointPropertyDialogAction extends SelectionProviderAction { return true; } - /* (non-Javadoc) * @see org.eclipse.jface.action.IAction#run() */ @@ -143,8 +142,31 @@ public class CBreakpointPropertyDialogAction extends SelectionProviderAction { PreferenceDialog dialog = createDialog(bpContext); if (dialog != null) { + TreeViewer viewer = dialog.getTreeViewer(); + if (viewer != null) { + viewer.setComparator(new ViewerComparator() { + @Override + public int category(Object element) { + if (element instanceof IPreferenceNode) { + IPreferenceNode node = (IPreferenceNode)element; + if ( PAGE_ID_COMMON.equals(node.getId()) ) { + return 0; + } else if (node.getSubNodes() == null || node.getSubNodes().length == 0) { + // Pages without children (not categories) + return super.category(element) + 1; + } + } + // Categories last. + return super.category(element) + 2; + } + }); + // Expand all categories + viewer.expandToLevel(TreeViewer.ALL_LEVELS); + } + dialog.open(); } + } } @@ -168,7 +190,7 @@ public class CBreakpointPropertyDialogAction extends SelectionProviderAction { if (ss.isEmpty()) return null; - return PreferencesUtil.createPropertyDialogOn(fShellProvider.getShell(), bpContext, fInitialPageId, null, null); + return PreferencesUtil.createPropertyDialogOn(fShellProvider.getShell(), bpContext, null, null, null); } diff --git a/doc/org.eclipse.cdt.doc.isv/.gitignore b/doc/org.eclipse.cdt.doc.isv/.gitignore index 9cd5171a1a3..1ff9a2b1348 100644 --- a/doc/org.eclipse.cdt.doc.isv/.gitignore +++ b/doc/org.eclipse.cdt.doc.isv/.gitignore @@ -1,3 +1,4 @@ .metadata cdtconvert.txt reference +/doc.bin.log diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/.settings/.api_filters b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/.settings/.api_filters new file mode 100644 index 00000000000..e70d7175758 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/.settings/.api_filters @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/META-INF/MANIFEST.MF index b761cf5ccf9..7b35047f936 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/META-INF/MANIFEST.MF +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/META-INF/MANIFEST.MF @@ -18,8 +18,8 @@ Require-Bundle: org.eclipse.ui, Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.ibm.icu.text -Export-Package: org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui, - org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.actions, - org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model, - org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view, - org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils +Export-Package: org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui;x-internal:=true, + org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.actions;x-internal:=true, + org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model;x-internal:=true, + org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;x-internal:=true, + org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils;x-internal:=true diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java index f3f7ac3e792..f9ea96ac601 100755 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java @@ -8,6 +8,7 @@ * Contributors: * William R. Swanson (Tilera Corporation) - initial API and implementation * IBM Corporation + * Marc Dumais (Ericsson) - Bug 399281 *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view; @@ -705,10 +706,11 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer protected void setCanvasModel(VisualizerModel model) { final VisualizerModel model_f = model; GUIUtils.exec(new Runnable() { @Override public void run() { - m_canvas.setModel(model_f); - - // Update the canvas's selection from the current workbench selection. - updateCanvasSelectionInternal(); + if(m_canvas != null) { + m_canvas.setModel(model_f); + // Update the canvas's selection from the current workbench selection. + updateCanvasSelectionInternal(); + } }}); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCanvas.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCanvas.java index 291a5a95a8d..093501c1cb4 100755 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCanvas.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCanvas.java @@ -11,6 +11,7 @@ * Marc Dumais (Ericsson) - Bug 396184 * Marc Dumais (Ericsson) - Bug 396200 * Marc Dumais (Ericsson) - Bug 396293 + * Marc Dumais (Ericsson) - Bug 399281 *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view; @@ -303,7 +304,9 @@ public class MulticoreVisualizerCanvas extends GraphicCanvas */ public void requestUpdate() { GUIUtils.exec(new Runnable() { @Override public void run() { - m_updateTimer.start(); + if (m_updateTimer != null) { + m_updateTimer.start(); + } }}); } @@ -867,7 +870,9 @@ public class MulticoreVisualizerCanvas extends GraphicCanvas /** Removes external listener for selection change events. */ @Override public void removeSelectionChangedListener(ISelectionChangedListener listener) { - m_selectionManager.removeSelectionChangedListener(listener); + if (m_selectionManager != null) { + m_selectionManager.removeSelectionChangedListener(listener); + } } /** Raises selection changed event. */ diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/SessionOSData.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/SessionOSData.java index bfcbed340ea..7784f92f91d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/SessionOSData.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/SessionOSData.java @@ -27,6 +27,8 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin; import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS2; +import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS2.IResourceClass; +import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS2.IResourcesInformation; import org.eclipse.cdt.dsf.mi.service.IMIRunControl; import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; import org.eclipse.cdt.dsf.service.DsfServicesTracker; @@ -48,7 +50,7 @@ public class SessionOSData { private IGDBHardwareAndOS2 fHardwareOs; private ICommandControlDMContext fContext; - private IGDBHardwareAndOS2.IResourceClass[] fResourceClasses = new IGDBHardwareAndOS2.IResourceClass[0]; + private IResourceClass[] fResourceClasses = new IResourceClass[0]; private Map fExistingData = new HashMap(); private Map fTimestamp = new HashMap(); @@ -100,7 +102,7 @@ public class SessionOSData { { fWaitingForSession = false; fFetchingClasses = true; - fHardwareOs.getResourceClasses(fContext, new DataRequestMonitor(fSession.getExecutor(), null) { + fHardwareOs.getResourceClasses(fContext, new DataRequestMonitor(fSession.getExecutor(), null) { @Override @ConfinedToDsfExecutor("fExecutor") protected void handleCompleted() { @@ -145,7 +147,7 @@ public class SessionOSData { fTracker.dispose(); } - public IGDBHardwareAndOS2.IResourceClass[] getResourceClasses() + public IResourceClass[] getResourceClasses() { return fResourceClasses; } @@ -202,7 +204,7 @@ public class SessionOSData { @Override public void run() { - fHardwareOs.getResourcesInformation(fContext, resourceClass, new DataRequestMonitor(executor, null) { + fHardwareOs.getResourcesInformation(fContext, resourceClass, new DataRequestMonitor(executor, null) { @Override @ConfinedToDsfExecutor("fExecutor") diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence_7_0.java index 0a03927b29c..c910204f01e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence_7_0.java @@ -43,7 +43,6 @@ public class FinalLaunchSequence_7_0 extends FinalLaunchSequence { private IGDBControl fCommandControl; private CommandFactory fCommandFactory; - private DsfServicesTracker fTracker; private DsfSession fSession; public FinalLaunchSequence_7_0(DsfSession session, Map attributes, RequestMonitorWithProgress rm) { @@ -76,9 +75,10 @@ public class FinalLaunchSequence_7_0 extends FinalLaunchSequence { */ @Execute public void stepInitializeFinalLaunchSequence_7_0(RequestMonitor rm) { - fTracker = new DsfServicesTracker(GdbPlugin.getBundleContext(), fSession.getId()); + DsfServicesTracker tracker = new DsfServicesTracker(GdbPlugin.getBundleContext(), fSession.getId()); + fCommandControl = tracker.getService(IGDBControl.class); + tracker.dispose(); - fCommandControl = fTracker.getService(IGDBControl.class); if (fCommandControl == null) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, "Cannot obtain control service", null)); //$NON-NLS-1$ rm.done(); @@ -96,8 +96,6 @@ public class FinalLaunchSequence_7_0 extends FinalLaunchSequence { */ @RollBack("stepInitializeFinalLaunchSequence_7_0") public void rollBackInitializeFinalLaunchSequence_7_0(RequestMonitor rm) { - if (fTracker != null) fTracker.dispose(); - fTracker = null; rm.done(); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIInfoOsInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIInfoOsInfo.java index 9c9f5191812..abb4337cc1d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIInfoOsInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIInfoOsInfo.java @@ -14,9 +14,8 @@ package org.eclipse.cdt.dsf.mi.service.command.output; import java.util.ArrayList; import java.util.List; -import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS2; -import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; -import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput; +import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS2.IResourceClass; +import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS2.IResourcesInformation; /** * Example output: @@ -63,7 +62,7 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput; public class MIInfoOsInfo extends MIInfo { // The fields below are used for response with list of classes. - private IGDBHardwareAndOS2.IResourceClass[] resourceClasses; + private IResourceClass[] resourceClasses; // The below fields are used only for data with specific resource class private String[] columnNames; @@ -79,9 +78,9 @@ public class MIInfoOsInfo extends MIInfo { } } - public IGDBHardwareAndOS2.IResourcesInformation getResourcesInformation() + public IResourcesInformation getResourcesInformation() { - return new IGDBHardwareAndOS2.IResourcesInformation() { + return new IResourcesInformation() { @Override public String[][] getContent() { return content; } @@ -91,14 +90,14 @@ public class MIInfoOsInfo extends MIInfo { }; } - public IGDBHardwareAndOS2.IResourceClass[] getResourceClasses() + public IResourceClass[] getResourceClasses() { return resourceClasses; } private void parseResourceClasses() { - List classes = new ArrayList(); + List classes = new ArrayList(); MITuple table = (MITuple)get(getMIOutput(), "OSDataTable"); //$NON-NLS-1$ @@ -109,7 +108,7 @@ public class MIInfoOsInfo extends MIInfo { final String id = getString(row.getMIResults()[0]); final String description = getString(row.getMIResults()[2]); - classes.add(new IGDBHardwareAndOS2.IResourceClass() { + classes.add(new IResourceClass() { @Override public String getId() { return id; } @@ -120,7 +119,7 @@ public class MIInfoOsInfo extends MIInfo { }); } - resourceClasses = classes.toArray(new IGDBHardwareAndOS2.IResourceClass[classes.size()]); + resourceClasses = classes.toArray(new IResourceClass[classes.size()]); } private void parseResourcesInformation() diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchUtilsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchUtilsTest.java index 7b912de703e..798eb125af8 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchUtilsTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchUtilsTest.java @@ -10,17 +10,17 @@ *******************************************************************************/ package org.eclipse.cdt.tests.dsf.gdb.tests; +import static org.junit.Assert.assertEquals; + import java.util.HashMap; import java.util.Map; -import junit.framework.TestCase; - import org.eclipse.cdt.dsf.gdb.launching.LaunchUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; -public class LaunchUtilsTest extends TestCase { +public class LaunchUtilsTest { @Before public void init() { @@ -31,7 +31,7 @@ public class LaunchUtilsTest extends TestCase { } @Test - public void testGetGDBVersionFromText() { + public void tesetGDBVersionFromText() { Map versions = new HashMap(10); versions.put("GNU gdb 6.8.50.20080730", "6.8.50.20080730"); diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/AnnotationHover.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/AnnotationHover.java index ed2087c56cc..ae91bb7855f 100644 --- a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/AnnotationHover.java +++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/AnnotationHover.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2005, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation * Bjorn Freeman-Benson - initial API and implementation * Wind River Systems - adopted to use with DSF @@ -46,5 +46,4 @@ public class AnnotationHover implements IAnnotationHover { } return null; } - } diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java index ee669909627..84d603e782c 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java @@ -21,9 +21,9 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; -import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.core.runtime.PlatformObject; @SuppressWarnings("restriction") @@ -114,38 +114,10 @@ public class C99Enumeration extends PlatformObject implements IC99Binding, IEnum } public long getMinValue() { - long minValue = Long.MAX_VALUE; - 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; - } - } - } - } - return minValue; + return SemanticUtil.computeMinValue(this); } public long getMaxValue() { - long maxValue = Long.MIN_VALUE; - 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; - } - } - } - } - return maxValue; + return SemanticUtil.computeMaxValue(this); } } diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/CPreprocessorAdapter.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/CPreprocessorAdapter.java index 99603893503..1fd1a5e0533 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/CPreprocessorAdapter.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/CPreprocessorAdapter.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2006, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.lrparser; @@ -25,7 +25,6 @@ import org.eclipse.cdt.core.parser.OffsetLimitReachedException; * TODO move into an internal package */ public class CPreprocessorAdapter { - /** * During content assist the preprocessor may return a completion token * which represents the identifier on which the user invoked content assist. diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GCCLanguage.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GCCLanguage.java index 8fdc058e0ea..da00102ddd7 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GCCLanguage.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GCCLanguage.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2006, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.lrparser.gnu; @@ -31,7 +31,6 @@ import org.eclipse.cdt.internal.core.dom.lrparser.gcc.GCCParser; * @author Mike Kucera */ public class GCCLanguage extends BaseExtensibleLanguage { - public static final String ID = "org.eclipse.cdt.core.lrparser.gcc"; //$NON-NLS-1$ private static GCCLanguage DEFAULT = new GCCLanguage(); diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GPPLanguage.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GPPLanguage.java index d44bec922c7..09352219234 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GPPLanguage.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GPPLanguage.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2006, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.lrparser.gnu; diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPRules.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPRules.java index 08e56e52b92..6e6d85fd50d 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPRules.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPRules.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * IBM Corporation - initial API and implementation + * Contributors: + * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.lrparser.cpp; @@ -18,7 +18,6 @@ public class CPPRules { static Map fRules = new HashMap(); static { - fRules.put(Integer.valueOf(3), "] ::= RightBracket"); fRules.put(Integer.valueOf(4), "] ::= EndOfCompletion"); fRules.put(Integer.valueOf(5), ") ::= RightParen"); diff --git a/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF index b4ca9e8d545..b014adcf875 100644 --- a/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF +++ b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF @@ -11,3 +11,4 @@ Require-Bundle: org.eclipse.core.runtime, Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin +Export-Package: org.eclipse.cdt.qt.core diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtKeywords.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtKeywords.java new file mode 100644 index 00000000000..36b2112585d --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtKeywords.java @@ -0,0 +1,20 @@ +/* + * 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.qt.core; + +/** + * Declares constants related to tokens that are special in Qt applications. + */ +public class QtKeywords +{ + public static final String Q_SIGNALS = "Q_SIGNALS"; + public static final String Q_SLOTS = "Q_SLOTS"; + public static final String SIGNALS = "signals"; + public static final String SLOTS = "slots"; +} diff --git a/qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF b/qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF index 50e19770980..0e024d23ae1 100644 --- a/qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF +++ b/qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF @@ -1,11 +1,15 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: CDT Qt Support UI -Bundle-SymbolicName: org.eclipse.cdt.qt.ui +Bundle-SymbolicName: org.eclipse.cdt.qt.ui;singleton:=true Bundle-Version: 1.0.0.qualifier Bundle-Activator: org.eclipse.cdt.qt.ui.Activator Bundle-Vendor: Eclipse CDT +Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime + org.eclipse.core.runtime, + org.eclipse.cdt.ui, + org.eclipse.cdt.core, + org.eclipse.cdt.qt.core Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy diff --git a/qt/org.eclipse.cdt.qt.ui/build.properties b/qt/org.eclipse.cdt.qt.ui/build.properties index 34d2e4d2dad..0dc34f7833b 100644 --- a/qt/org.eclipse.cdt.qt.ui/build.properties +++ b/qt/org.eclipse.cdt.qt.ui/build.properties @@ -1,4 +1,6 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ - . + .,\ + plugin.xml,\ + plugin.properties diff --git a/qt/org.eclipse.cdt.qt.ui/plugin.properties b/qt/org.eclipse.cdt.qt.ui/plugin.properties new file mode 100644 index 00000000000..5f970b962b6 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.ui/plugin.properties @@ -0,0 +1,8 @@ +# 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 + +qtHighlighting.extName=Qt Semantic Highlighting +qtHighlighting.displayName=Qt Keywords \ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.ui/plugin.xml b/qt/org.eclipse.cdt.qt.ui/plugin.xml new file mode 100644 index 00000000000..7d86d31f7c4 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.ui/plugin.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + diff --git a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/QtHighlighting.java b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/QtHighlighting.java new file mode 100644 index 00000000000..3e53db1afc0 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/QtHighlighting.java @@ -0,0 +1,38 @@ +/* + * 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.qt.ui; + +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IMacroBinding; +import org.eclipse.cdt.qt.core.QtKeywords; +import org.eclipse.cdt.ui.text.ISemanticHighlighter; +import org.eclipse.cdt.ui.text.ISemanticToken; + +public class QtHighlighting implements ISemanticHighlighter +{ + @Override + public boolean consumes( ISemanticToken token ) + { + IBinding binding = token.getBinding(); + if( binding instanceof IMacroBinding ) + { + IASTNode node = token.getNode(); + if( node instanceof IASTName && ( (IASTName)node ).isReference() ) + { + String n = binding.getName(); + return QtKeywords.SIGNALS.equals( n ) || QtKeywords.SLOTS.equals( n ) + || QtKeywords.Q_SIGNALS.equals( n ) || QtKeywords.Q_SLOTS.equals( n ); + } + } + + return false; + } +} diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerViewer.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerViewer.java index a9c71c2d1b3..344e3cddf94 100644 --- a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerViewer.java +++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerViewer.java @@ -7,6 +7,7 @@ * * Contributors: * William R. Swanson (Tilera Corporation) + * Marc Dumais (Ericsson) - Bug 399281 *******************************************************************************/ package org.eclipse.cdt.visualizer.ui; @@ -29,6 +30,8 @@ import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.MenuDetectEvent; import org.eclipse.swt.events.MenuDetectListener; import org.eclipse.swt.events.PaintEvent; @@ -97,6 +100,13 @@ public class VisualizerViewer extends PageBook public VisualizerViewer(VisualizerView view, Composite parent) { super(parent, SWT.NONE); initVisualizerViewer(view, parent); + // so we're notified when the widget is disposed + addDisposeListener(new DisposeListener() { + @Override + public void widgetDisposed(DisposeEvent e) { + dispose(); + } + }); } /** Dispose method. */ @@ -431,7 +441,9 @@ public class VisualizerViewer extends PageBook /** Removes external listener for selection change events. */ public void removeSelectionChangedListener(ISelectionChangedListener listener) { - m_selectionManager.removeSelectionChangedListener(listener); + if(m_selectionManager != null) { + m_selectionManager.removeSelectionChangedListener(listener); + } } /** Raises selection changed event. */ diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/BufferedCanvas.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/BufferedCanvas.java index b4f2778cef4..e2112ab95fd 100755 --- a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/BufferedCanvas.java +++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/BufferedCanvas.java @@ -7,6 +7,7 @@ * * Contributors: * William R. Swanson (Tilera Corporation) + * Marc Dumais (Ericsson) - Bug 399281 *******************************************************************************/ package org.eclipse.cdt.visualizer.ui.canvas; @@ -68,8 +69,10 @@ public class BufferedCanvas extends Canvas /** Cleans up control. */ protected void cleanupBufferedCanvas() { - removePaintListener(this); - removeControlListener(this); + if(!this.isDisposed()) { + removePaintListener(this); + removeControlListener(this); + } if (m_doubleBuffer != null) { m_doubleBuffer.dispose(); m_doubleBuffer = null;