1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Introduces an API to access the PDOM, bug 149565.

This commit is contained in:
Markus Schorn 2006-10-12 13:23:56 +00:00
parent 1b927015bb
commit f5a4ba1d76
159 changed files with 3946 additions and 1393 deletions

View file

@ -15,6 +15,10 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.index.IIndexInclude;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.pdom.PDOM;
@ -56,21 +60,29 @@ public class PDOMDependencyCalculator implements IManagedDependencyCalculator {
if (resource != null) {
ICProject project = CoreModel.getDefault().create(resource.getProject());
try {
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
PDOMFile file = pdom.getFile(resource.getLocation());
IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES);
index.acquireReadLock();
try {
IIndexFile file = index.getFile(resource.getLocation());
if (file != null) {
PDOMFile[] includes = file.getAllIncludes();
IIndexInclude[] includes = index.findIncludes(file, IIndex.DEPTH_INFINITE);
List/*<IPath>*/ list = new ArrayList/*<IPath>*/();
for (int i = 0; i < includes.length; ++i)
list.add(new Path(includes[i].getFileName().getString()));
list.add(new Path(includes[i].getIncludesLocation()));
dependencies = (IPath[])list.toArray(new IPath[list.size()]);
} else
dependencies = new IPath[0];
}
finally {
index.releaseReadLock();
}
} catch (CoreException e) {
// Activator.getDefault().getLog().log(e.getStatus());
dependencies = new IPath[0];
} catch (InterruptedException e) {
dependencies = new IPath[0];
}
} else
dependencies = new IPath[0];

View file

@ -98,7 +98,7 @@ public class CModelElementsTests extends TestCase {
//ITranslationUnit included = (ITranslationUnit)CoreModel.getDefault().create(includedFile);
// parse the translation unit to get the elements tree
tu.parse();
// tu.parse();
// tu ---> include
checkInclude(tu);

View file

@ -57,7 +57,7 @@ public class IIncludeTests extends IntegratedCModelTest {
return suite;
}
public void testGetIncludeName()
public void testGetIncludeName() throws CModelException
{
ITranslationUnit tu = getTU();
IInclude[] theIncludes = null;
@ -100,7 +100,7 @@ public class IIncludeTests extends IntegratedCModelTest {
}
public void testIsStandard()
public void testIsStandard() throws CModelException
{
ITranslationUnit tu = getTU();
IInclude[] theIncludes = null;

View file

@ -318,7 +318,7 @@ public class IStructureTests extends IntegratedCModelTest {
}
// IInheritance
public void testGetBaseTypes() {
public void testGetBaseTypes() throws CModelException {
ITranslationUnit tu = getTU();
ICElement myElementDerived = null;
String[] myBaseTypes = null;
@ -345,7 +345,7 @@ public class IStructureTests extends IntegratedCModelTest {
}
// IInheritance
public void testGetAccessControl() {
public void testGetAccessControl() throws CModelException {
ITranslationUnit tu = getTU();
ICElement myElementDerived = null;
String[] myBaseTypes = null;
@ -390,7 +390,7 @@ public class IStructureTests extends IntegratedCModelTest {
// Language Specification Tests
//
public void testAnonymousStructObject() {
public void testAnonymousStructObject() throws CModelException {
ITranslationUnit tu = getTU();
ICElement myElement = null;
try {

View file

@ -20,6 +20,7 @@ import java.io.FileNotFoundException;
import junit.framework.TestCase;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit;
@ -87,7 +88,7 @@ public abstract class IntegratedCModelTest extends TestCase {
CProjectHelper.delete(fCProject);
}
protected ITranslationUnit getTU() {
protected ITranslationUnit getTU() throws CModelException {
ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(sourceFile);
if(isStructuralParse()) {
CCorePlugin.getDefault().setStructuralParseMode(true);
@ -96,7 +97,8 @@ public abstract class IntegratedCModelTest extends TestCase {
}
// parse the translation unit to get the elements tree
// Force the parsing now to do this in the right ParseMode.
tu.parse();
tu.close();
tu.open(new NullProgressMonitor());
CCorePlugin.getDefault().setStructuralParseMode(false);
return tu;
}

View file

@ -96,13 +96,10 @@ public class StructuralCModelElementsTests extends TestCase {
public void testCModelElements() throws CModelException{
ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(headerFile);
//ITranslationUnit included = (ITranslationUnit)CoreModel.getDefault().create(includedFile);
// turn on the structural parse mode
tu.close();
CCorePlugin.getDefault().setStructuralParseMode(true);
// parse the translation unit to get the elements tree
tu.parse();
// tu ---> include
checkInclude(tu);

View file

@ -54,21 +54,21 @@ public class StructuralStructureTests extends IStructureTests {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testAnonymousStructObject()
*/
public void testAnonymousStructObject() {
public void testAnonymousStructObject() throws CModelException {
setStructuralParse(true);
super.testAnonymousStructObject();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetAccessControl()
*/
public void testGetAccessControl() {
public void testGetAccessControl() throws CModelException {
setStructuralParse(true);
super.testGetAccessControl();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetBaseTypes()
*/
public void testGetBaseTypes() {
public void testGetBaseTypes() throws CModelException {
setStructuralParse(true);
super.testGetBaseTypes();
}

View file

@ -27,9 +27,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
@ -162,7 +162,7 @@ public class DOMSearchUtil {
}
IBinding binding = searchName.resolveBinding();
if (binding instanceof PDOMBinding) {
if (binding instanceof IIndexBinding) {
Assert.fail("Not implemented");
// try {
// ArrayList pdomNames = new ArrayList();

View file

@ -7,6 +7,7 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
@ -39,7 +40,7 @@ public class DOMSelectionParseBaseTest extends DOMFileBasePluginTest {
protected IASTNode parse(IFile file, int offset1, int offset2, boolean expectedToPass) throws Exception {
ITranslationUnit tu = (ITranslationUnit)CCorePlugin.getDefault().getCoreModel().create(file);
IASTTranslationUnit ast = tu.getLanguage().getASTTranslationUnit(tu, 0);
IASTTranslationUnit ast = tu.getAST();
IASTName[] names = tu.getLanguage().getSelectedNames(ast, offset1, offset2 - offset1);
if (!expectedToPass) return null;

View file

@ -22,6 +22,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IndexFilter;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.NullProgressMonitor;
@ -47,21 +49,21 @@ public class ClassTests extends PDOMTestBase {
}
public void test1() throws Exception {
IBinding[] Bs = pdom.findBindings(Pattern.compile("B"), new NullProgressMonitor());
IBinding[] Bs = pdom.findBindings(Pattern.compile("B"), false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, Bs.length);
ICPPClassType B = (ICPPClassType)Bs[0];
ICPPMethod[] Bmethods = B.getAllDeclaredMethods();
assertEquals(1, Bmethods.length);
ICPPMethod Bf = Bmethods[0];
assertEquals("f", Bf.getName());
IName [] Bf_refs = pdom.getReferences(Bf);
IName [] Bf_refs = pdom.findNames(Bf, IIndex.FIND_REFERENCES);
assertEquals(1, Bf_refs.length);
IASTFileLocation loc = Bf_refs[0].getFileLocation();
assertEquals(offset("class.cpp", "b.f()") + 2, loc.getNodeOffset());
}
public void testNested() throws Exception {
IBinding[] bindings = pdom.findBindings(Pattern.compile("NestedA"), new NullProgressMonitor());
IBinding[] bindings = pdom.findBindings(Pattern.compile("NestedA"), false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, bindings.length);
ICPPClassType NestedA = (ICPPClassType)bindings[0];
ICPPClassType[] nested = NestedA.getNestedClasses();
@ -72,24 +74,24 @@ public class ClassTests extends PDOMTestBase {
assertEquals(1, fields.length);
IField NestedB_x = fields[0];
IName[] refs = pdom.getReferences(NestedB);
IName[] refs = pdom.findNames(NestedB, IIndex.FIND_REFERENCES);
assertEquals(1, refs.length);
IASTFileLocation loc = refs[0].getFileLocation();
assertEquals(offset("nested.cpp", "::NestedB") + 2, loc.getNodeOffset());
refs = pdom.getReferences(NestedB_x);
refs = pdom.findNames(NestedB_x, IIndex.FIND_REFERENCES);
assertEquals(1, refs.length);
loc = refs[0].getFileLocation();
assertEquals(offset("nested.cpp", "x.x") + 2, loc.getNodeOffset());
}
public void failedTest147903() throws Exception {
IBinding[] bindings = pdom.findBindings(Pattern.compile("pr147903"), new NullProgressMonitor());
IBinding[] bindings = pdom.findBindings(Pattern.compile("pr147903"), false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, bindings.length);
ICPPNamespaceScope ns = ((ICPPNamespace)bindings[0]).getNamespaceScope();
bindings = ns.find("testRef");
assertEquals(1, bindings.length);
IName[] refs = pdom.getReferences(bindings[0]);
IName[] refs = pdom.findNames(bindings[0], IIndex.FIND_REFERENCES);
for (int i = 0; i < refs.length; ++i)
System.out.println(refs[i].getFileLocation().getNodeOffset());
assertEquals(5, refs.length);

View file

@ -19,6 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
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.index.IIndex;
import org.eclipse.cdt.core.index.IndexFilter;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.NullProgressMonitor;
@ -46,7 +48,7 @@ public class EnumerationTests extends PDOMTestBase {
public void testC() throws Exception {
// Check bindings
Pattern pattern = Pattern.compile("TestCEnum");
IBinding[] bindings = pdom.findBindings(pattern, new NullProgressMonitor());
IBinding[] bindings = pdom.findBindings(pattern, false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, bindings.length);
IEnumeration enumeration = (IEnumeration)bindings[0];
assertEquals("TestCEnum", enumeration.getName());
@ -57,19 +59,19 @@ public class EnumerationTests extends PDOMTestBase {
assertEquals("cc", enumerators[2].getName());
// Declaration of TestEnum
IName[] enumDecls = pdom.getDeclarations(enumeration);
IName[] enumDecls = pdom.findNames(enumeration, IIndex.FIND_DECLARATIONS_DEFINITIONS);
assertEquals(1, enumDecls.length);
IASTFileLocation loc = enumDecls[0].getFileLocation();
assertEquals(5, loc.getNodeOffset());
// Reference to TestEnum
IName[] enumRefs = pdom.getReferences(enumeration);
IName[] enumRefs = pdom.findNames(enumeration, IIndex.FIND_REFERENCES);
assertEquals(1, enumRefs.length);
loc = enumRefs[0].getFileLocation();
assertEquals(offset("enumTest.c", "TestCEnum test"), loc.getNodeOffset());
// Reference to a
IName[] aRefs = pdom.getReferences(enumerators[0]);
IName[] aRefs = pdom.findNames(enumerators[0], IIndex.FIND_REFERENCES);
assertEquals(1, aRefs.length);
loc = aRefs[0].getFileLocation();
assertEquals(offset("enumTest.c", "ca;"), loc.getNodeOffset());
@ -78,7 +80,7 @@ public class EnumerationTests extends PDOMTestBase {
public void testCPP() throws Exception {
// Check bindings
Pattern pattern = Pattern.compile("TestCPPEnum");
IBinding[] bindings = pdom.findBindings(pattern, new NullProgressMonitor());
IBinding[] bindings = pdom.findBindings(pattern, false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, bindings.length);
IEnumeration enumeration = (IEnumeration)bindings[0];
assertEquals("TestCPPEnum", enumeration.getName());
@ -89,19 +91,19 @@ public class EnumerationTests extends PDOMTestBase {
assertEquals("cppc", enumerators[2].getName());
// Declaration of TestEnum
IName[] enumDecls = pdom.getDeclarations(enumeration);
IName[] enumDecls = pdom.findNames(enumeration, IIndex.FIND_DECLARATIONS_DEFINITIONS);
assertEquals(1, enumDecls.length);
IASTFileLocation loc = enumDecls[0].getFileLocation();
assertEquals(5, loc.getNodeOffset());
// Reference to TestEnum
IName[] enumRefs = pdom.getReferences(enumeration);
IName[] enumRefs = pdom.findNames(enumeration, IIndex.FIND_REFERENCES);
assertEquals(1, enumRefs.length);
loc = enumRefs[0].getFileLocation();
assertEquals(offset("enumTest.cpp", "TestCPPEnum test"), loc.getNodeOffset());
// Reference to a
IName[] aRefs = pdom.getReferences(enumerators[0]);
IName[] aRefs = pdom.findNames(enumerators[0], IIndex.FIND_REFERENCES);
assertEquals(1, aRefs.length);
loc = aRefs[0].getFileLocation();
assertEquals(offset("enumTest.cpp", "cppa;"), loc.getNodeOffset());

View file

@ -11,9 +11,10 @@
package org.eclipse.cdt.internal.pdom.tests;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.index.IIndexInclude;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
import org.eclipse.core.runtime.IPath;
/**
@ -23,12 +24,12 @@ import org.eclipse.core.runtime.IPath;
public class IncludesTests extends PDOMTestBase {
protected ICProject project;
protected PDOM pdom;
protected IIndex pdom;
protected void setUp() throws Exception {
if (pdom == null) {
project = createProject("includesTests");
pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
pdom = CCorePlugin.getIndexManager().getIndex(project);
}
pdom.acquireReadLock();
}
@ -39,9 +40,9 @@ public class IncludesTests extends PDOMTestBase {
public void test1() throws Exception {
IPath loc = project.getProject().getLocation().append("I2.h");
PDOMFile file = pdom.getFile(loc.toOSString());
IIndexFile file = pdom.getFile(loc);
assertNotNull(file);
PDOMFile[] allIncludedBy = file.getAllIncludedBy();
IIndexInclude[] allIncludedBy = pdom.findIncludedBy(file, -1);
assertEquals(9, allIncludedBy.length); // i.e. all of them
}

View file

@ -22,6 +22,8 @@ import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IndexFilter;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.NullProgressMonitor;
@ -48,7 +50,7 @@ public class TypesTests extends PDOMTestBase {
public void testC() throws Exception {
// Get the binding for A::f
IBinding [] CAs = pdom.findBindings(Pattern.compile("CA"), new NullProgressMonitor());
IBinding [] CAs = pdom.findBindings(Pattern.compile("CA"), false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, CAs.length);
ICompositeType CA = (ICompositeType)CAs[0];
IField [] CAfields = CA.getFields();
@ -57,7 +59,7 @@ public class TypesTests extends PDOMTestBase {
assertEquals("x", x.getName());
// Make sure that there is a reference in g();
IName[] xRefs = pdom.getReferences(x);
IName[] xRefs = pdom.findNames(x, IIndex.FIND_REFERENCES);
assertEquals(1, xRefs.length);
IASTFileLocation loc = xRefs[0].getFileLocation();
assertEquals(offset("typedef.c", "x->x") + 3, loc.getNodeOffset());
@ -65,7 +67,7 @@ public class TypesTests extends PDOMTestBase {
public void testCPP() throws Exception {
// Get the binding for A::f
IBinding [] As = pdom.findBindings(Pattern.compile("A"), new NullProgressMonitor());
IBinding [] As = pdom.findBindings(Pattern.compile("A"), false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, As.length);
ICPPClassType A = (ICPPClassType)As[0];
ICPPMethod[] Amethods = A.getMethods();
@ -74,17 +76,17 @@ public class TypesTests extends PDOMTestBase {
assertEquals("f", f.getName());
// Make sure that there is a reference in g();
IName[] fRefs = pdom.getReferences(f);
IName[] fRefs = pdom.findNames(f, IIndex.FIND_REFERENCES);
assertEquals(1, fRefs.length);
IASTFileLocation loc = fRefs[0].getFileLocation();
assertEquals(offset("typedef.cpp", "x->f") + 3, loc.getNodeOffset());
}
public void test145351() throws Exception {
IBinding [] bindings = pdom.findBindings(Pattern.compile("spinlock_t"), new NullProgressMonitor());
IBinding [] bindings = pdom.findBindings(Pattern.compile("spinlock_t"), false, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, bindings.length);
ITypedef spinlock_t = (ITypedef)bindings[0];
IName [] refs = pdom.getReferences(spinlock_t);
IName [] refs = pdom.findNames(spinlock_t, IIndex.FIND_REFERENCES);
assertEquals(1, refs.length);
IASTFileLocation loc = refs[0].getFileLocation();
assertEquals(offset("bug145351.c", "spinlock_t global_bh_lock"), loc.getNodeOffset());

View file

@ -1,3 +1,5 @@
#Mon Oct 09 11:18:42 BST 2006
#Tue Oct 10 16:32:29 CEST 2006
eclipse.preferences.version=1
encoding//parser/org/eclipse/cdt/internal/core/index/messages.properties=8859_1
encoding//parser/org/eclipse/cdt/internal/core/pdom/db/messages.properties=8859_1
encoding//parser/org/eclipse/cdt/internal/core/pdom/messages.properties=8859_1

View file

@ -1,4 +1,4 @@
#Mon Jul 03 19:51:10 CEST 2006
#Thu Oct 05 16:52:57 CEST 2006
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4

View file

@ -0,0 +1,3 @@
#Thu Oct 05 16:52:57 CEST 2006
eclipse.preferences.version=1
internal.default.compliance=user

View file

@ -14,17 +14,17 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
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;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
@ -120,12 +120,12 @@ public class AllTypesCache {
return;
case ICElement.C_STRUCT:
if (node instanceof ICPPClassType
&& ((ICPPClassType)node).getKey() == ICPPClassType.k_struct)
&& ((ICPPClassType)node).getKey() == ICompositeType.k_struct)
types.add(new PDOMTypeInfo((PDOMBinding)node, kind, project));
return;
case ICElement.C_UNION:
if (node instanceof ICPPClassType
&& ((ICPPClassType)node).getKey() == ICPPClassType.k_union)
&& ((ICPPClassType)node).getKey() == ICompositeType.k_union)
types.add(new PDOMTypeInfo((PDOMBinding)node, kind, project));
return;
case ICElement.C_ENUMERATION:
@ -152,10 +152,15 @@ public class AllTypesCache {
CPPTypesCollector cppCollector = new CPPTypesCollector(kinds, types, project);
PDOM pdom = (PDOM)pdomManager.getPDOM(project);
PDOMLinkage cLinkage = pdom.getLinkage(GCCLanguage.getDefault());
cLinkage.accept(cCollector);
PDOMLinkage cppLinkage = pdom.getLinkage(GPPLanguage.getDefault());
cppLinkage.accept(cppCollector);
PDOMLinkage linkage= pdom.getLinkage(ILinkage.C_LINKAGE_ID);
if (linkage != null) {
linkage.accept(cCollector);
}
linkage= pdom.getLinkage(ILinkage.CPP_LINKAGE_ID);
if (linkage != null) {
linkage.accept(cppCollector);
}
}
return (ITypeInfo[])types.toArray(new ITypeInfo[types.size()]);

View file

@ -15,13 +15,14 @@ package org.eclipse.cdt.core.browser;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.dom.IPDOMResolver;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.runtime.CoreException;
@ -120,9 +121,8 @@ public class PDOMTypeInfo implements ITypeInfo {
public ITypeReference getResolvedReference() {
try {
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(project);
IPDOMResolver resolver = (IPDOMResolver) pdom.getAdapter(IPDOMResolver.class);
IName[] names= resolver.getDefinitions(binding);
PDOM pdom = (PDOM) CCorePlugin.getPDOMManager().getPDOM(project);
IName[] names= pdom.findNames(binding, IIndex.FIND_DEFINITIONS);
return names != null && names.length > 0 ? new PDOMTypeReference(names[0], project) : null;
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2006 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
*******************************************************************************/
package org.eclipse.cdt.core.model;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject;
/**
* Models the differences between various languages.
* @since 4.0
*/
public abstract class AbstractLanguage extends PlatformObject implements ILanguage {
final public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style) throws CoreException {
throw new UnsupportedOperationException();
}
final public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, ICodeReaderFactory codeReaderFactory,
int style) throws CoreException {
throw new UnsupportedOperationException();
}
}

View file

@ -326,14 +326,8 @@ public class CoreModel {
*/
public static String getRegistedContentTypeId(IProject project, String name) {
IContentType contentType = CCorePlugin.getContentType(project, name);
if (contentType != null) {
String id = contentType.getId();
String[] ids = getRegistedContentTypeIds();
for (int i = 0; i < ids.length; i++) {
if (ids[i].equals(id)) {
return id;
}
}
if (contentType != null && LanguageManager.getInstance().getLanguage(contentType) != null) {
return contentType.getId();
}
return null;
}

View file

@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.model;
@ -15,12 +16,16 @@ import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
/**
* Models differences between languages. The interace is not supposed to be implemented directly.
* Rather than that clients may subclass {@link AbstractLanguage}.
* @author Doug Schaefer
*
*/
public interface ILanguage extends IAdaptable {
@ -28,31 +33,27 @@ public interface ILanguage extends IAdaptable {
public static final String KEY = "language"; //$NON-NLS-1$
/**
* Style for getTranslationUnit. Use the index for resolving bindings that aren't
* found in the AST.
* @deprecated has no effect.
*/
public static final int AST_USE_INDEX = 1;
/**
* Style for getTranslationUnit. Don't parse header files. It's a good idea to
* turn on AST_USE_INDEX when you do this.
* @deprecated use {@link ITranslationUnit#AST_SKIP_ALL_HEADERS}
*/
public static final int AST_SKIP_ALL_HEADERS = 2;
public static final int AST_SKIP_ALL_HEADERS = ITranslationUnit.AST_SKIP_ALL_HEADERS;
/**
* Style for getTranslationUnit. Used by the indexer to skip over headers it
* already has indexed.
* @deprecated use {@link ITranslationUnit#AST_SKIP_INDEXED_HEADERS}
*/
public static final int AST_SKIP_INDEXED_HEADERS = 4;
public static final int AST_SKIP_INDEXED_HEADERS = ITranslationUnit.AST_SKIP_INDEXED_HEADERS;
/**
* Style for getTranslationUnit. Don't parse the file if there is no build
* information for it.
* @deprecated use {@link ITranslationUnit#AST_SKIP_IF_NO_BUILD_INFO}
*/
public static final int AST_SKIP_IF_NO_BUILD_INFO = 8;
public static final int AST_SKIP_IF_NO_BUILD_INFO = ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO;
/**
* Return the language id for this language in the given PDOM.
* Return the language id for this language.
* This is to differentiate languages from eachother.
*
* @return language id
@ -60,23 +61,14 @@ public interface ILanguage extends IAdaptable {
public String getId();
/**
* Create the AST for the given file with the given style.
*
* @param file
* @param style
* @return
* @deprecated use {@link ITranslationUnit#getAST()}.
*/
public IASTTranslationUnit getASTTranslationUnit(
ITranslationUnit file,
int style) throws CoreException;
/**
* Create the AST for the given file with the given style with a given
* code reader factory.
*
* @param file
* @param style
* @return
* @deprecated use {@link ITranslationUnit#getAST(...)}.
*/
public IASTTranslationUnit getASTTranslationUnit(
ITranslationUnit file,
@ -114,4 +106,7 @@ public interface ILanguage extends IAdaptable {
* to parse using the default CDT model builder
*/
public IContributedModelBuilder createModelBuilder(ITranslationUnit tu);
// mstodo javadoc
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index) throws CoreException;
}

View file

@ -7,13 +7,19 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.model;
import java.util.Map;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.internal.core.model.IBufferFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* Represents an entire C translation unit (<code>.c</code> source file).
@ -25,6 +31,23 @@ import org.eclipse.core.runtime.IProgressMonitor;
* the case.
*/
public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISourceReference, ISourceManipulation {
/**
* Style for {@link #getAST(IIndex, int)}. Don't parse header files.
*/
public static final int AST_SKIP_ALL_HEADERS = 2;
/**
* Style for {@link #getAST(IIndex, int)}. Skips over headers that are found in the index.
*/
public static final int AST_SKIP_INDEXED_HEADERS = 4;
/**
* Style for {@link #getAST(IIndex, int)}. Don't parse the file if there is no build
* information for it.
*/
public static final int AST_SKIP_IF_NO_BUILD_INFO = 8;
/**
* Creates and returns an include declaration in this translation unit
* with the given name.
@ -386,4 +409,51 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
*
*/
public void setIsStructureKnown(boolean wasSuccessful);
/**
* Returns the absolute path of the location of the translation unit. May be <code>null</code>, in
* case the location does not exist.
* @return an absolute path to the location, or <code>null</code>
* @since 4.0
*/
public IPath getLocation();
/**
* Returns the code reader that can be used to parse the translation unit. If the translation unit is a
* working copy the reader will read from the buffer.
* @return a code reader for parsing the translation unit
* @since 4.0
*/
public CodeReader getCodeReader();
/**
* Returns the scanner info associated with this translation unit. May return <code>null</code> if no
* configuration is available.
* @param force if <code>true</code> a default info is returned, even if nothing is configured for this
* translation unit
* @return a scanner info for parsing the translation unit or <code>null</code> if none is configured
* @since 4.0
*/
public IScannerInfo getScannerInfo(boolean force);
/**
* Creates the full AST for this translation unit. May return <code>null</code> if the language of this
* translation unit does not support ASTs.
* @return the AST for the translation unit or <code>null</code>
* @throws CoreException
* @since 4.0
*/
public IASTTranslationUnit getAST() throws CoreException;
/**
* Creates an AST based on the requested style. May return <code>null</code> if the language of this
* translation unit does not support ASTs.
* @param index index to back up the parsing of the AST, may be <code>null</code>
* @param style <code>0</code> or a combination of {@link #AST_SKIP_ALL_HEADERS},
* {@link #AST_SKIP_IF_NO_BUILD_INFO} and {@link #AST_SKIP_INDEXED_HEADERS}
* @return the AST requested or <code>null</code>
* @throws CoreException
* @since 4.0
*/
public IASTTranslationUnit getAST(IIndex index, int style) throws CoreException;
}

View file

@ -19,12 +19,16 @@ import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
@ -33,9 +37,18 @@ import org.eclipse.core.runtime.content.IContentTypeManager;
*
*/
public class LanguageManager {
private static final String NAMESPACE_SEPARATOR = "."; //$NON-NLS-1$
private static final String LANGUAGE_EXTENSION_POINT_ID = "org.eclipse.cdt.core.language"; //$NON-NLS-1$
private static final String ELEMENT_LANGUAGE = "language"; //$NON-NLS-1$
private static final String ELEMENT_CONTENT_TYPE = "contentType"; //$NON-NLS-1$
private static final String ELEMENT_PDOM_LINKAGE_FACTORY = "pdomLinkageFactory"; //$NON-NLS-1$
private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$
private static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
private static LanguageManager instance;
private Map cache = new HashMap();
private Map fLanguageCache = new HashMap();
private Map fPDOMLinkageFactoryCache= new HashMap();
private Map fContentTypeToLanguageCache= new HashMap();
public static LanguageManager getInstance() {
if (instance == null)
@ -43,46 +56,67 @@ public class LanguageManager {
return instance;
}
public ILanguage getLanguage(String id) throws CoreException {
ILanguage language = (ILanguage)cache.get(id);
public ILanguage getLanguage(String id) {
ILanguage language = (ILanguage)fLanguageCache.get(id);
if (language != null)
return language;
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, ILanguage.KEY);
IExtension[] extensions = point.getExtensions();
for (int i = 0; i < extensions.length; ++i) {
IExtension extension = extensions[i];
IConfigurationElement[] languages = extension.getConfigurationElements();
for (int j = 0; j < languages.length; ++j) {
IConfigurationElement languageElem = languages[j];
String langId = extension.getNamespaceIdentifier() + "." + languageElem.getAttribute("id"); //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
for (int j = 0; j < configs.length; ++j) {
final IConfigurationElement languageElem = configs[j];
if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
String langId = getLanguageID(languageElem);
if (langId.equals(id)) {
language = (ILanguage)languageElem.createExecutableExtension("class"); //$NON-NLS-1$
cache.put(id, language);
return language;
}
}
final ILanguage[] result= new ILanguage[]{null};
SafeRunner.run(new ISafeRunnable(){
public void handleException(Throwable exception) {
CCorePlugin.log(exception);
}
public void run() throws Exception {
result[0]= (ILanguage)languageElem.createExecutableExtension(ATTRIBUTE_CLASS);
}
});
if (result[0] != null) {
fLanguageCache.put(id, result[0]);
return result[0];
}
}
}
}
return null;
}
public ILanguage getLanguage(IContentType contentType) throws CoreException {
String contentTypeId= contentType.getId();
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, ILanguage.KEY);
IExtension[] extensions = point.getExtensions();
for (int i = 0; i < extensions.length; ++i) {
IConfigurationElement[] languages = extensions[i].getConfigurationElements();
for (int j = 0; j < languages.length; ++j) {
IConfigurationElement language = languages[j];
IConfigurationElement[] assocContentTypes = language.getChildren("contentType"); //$NON-NLS-1$
private String getLanguageID(final IConfigurationElement languageElem) {
return languageElem.getNamespaceIdentifier() + NAMESPACE_SEPARATOR + languageElem.getAttribute(ATTRIBUTE_ID);
}
public ILanguage getLanguage(IContentType contentType) {
String contentTypeID= contentType.getId();
return getLanguageForContentTypeID(contentTypeID);
}
private ILanguage getLanguageForContentTypeID(String contentTypeID) {
ILanguage language = (ILanguage)fContentTypeToLanguageCache.get(contentTypeID);
if (language != null || fContentTypeToLanguageCache.containsKey(contentTypeID))
return language;
IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
for (int j = 0; j < configs.length; ++j) {
final IConfigurationElement languageElem = configs[j];
if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
IConfigurationElement[] assocContentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE);
for (int k = 0; k < assocContentTypes.length; ++k) {
if (contentTypeId.equals(assocContentTypes[k].getAttribute("id"))) { //$NON-NLS-1$
return (ILanguage)language.createExecutableExtension("class"); //$NON-NLS-1$
if (contentTypeID.equals(assocContentTypes[k].getAttribute(ATTRIBUTE_ID))) {
String id= getLanguageID(languageElem);
ILanguage lang= getLanguage(id);
fContentTypeToLanguageCache.put(contentTypeID, lang);
return lang;
}
}
}
}
fContentTypeToLanguageCache.put(contentTypeID, null);
return null;
}
@ -98,15 +132,13 @@ public class LanguageManager {
allTypes.add(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
IContentTypeManager manager = Platform.getContentTypeManager();
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, ILanguage.KEY);
IExtension[] extensions = point.getExtensions();
for (int i = 0; i < extensions.length; ++i) {
IConfigurationElement[] languages = extensions[i].getConfigurationElements();
for (int j = 0; j < languages.length; ++j) {
IConfigurationElement language = languages[j];
IConfigurationElement[] contentTypes = language.getChildren("contentType"); //$NON-NLS-1$
IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
for (int j = 0; j < configs.length; ++j) {
final IConfigurationElement languageElem = configs[j];
if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
IConfigurationElement[] contentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE);
for (int k = 0; k < contentTypes.length; ++k) {
IContentType langContType = manager.getContentType(contentTypes[k].getAttribute("id")); //$NON-NLS-1$
IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID));
allTypes.add(langContType.getId());
}
}
@ -133,15 +165,15 @@ public class LanguageManager {
allTypes.add(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
IContentTypeManager manager = Platform.getContentTypeManager();
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, ILanguage.KEY);
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, LANGUAGE_EXTENSION_POINT_ID);
IExtension[] extensions = point.getExtensions();
for (int i = 0; i < extensions.length; ++i) {
IConfigurationElement[] languages = extensions[i].getConfigurationElements();
for (int j = 0; j < languages.length; ++j) {
IConfigurationElement language = languages[j];
IConfigurationElement[] contentTypes = language.getChildren("contentType"); //$NON-NLS-1$
IConfigurationElement[] contentTypes = language.getChildren(ELEMENT_CONTENT_TYPE);
for (int k = 0; k < contentTypes.length; ++k) {
IContentType langContType = manager.getContentType(contentTypes[k].getAttribute("id")); //$NON-NLS-1$
IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID));
allTypes.add(langContType.getId());
}
}
@ -151,7 +183,7 @@ public class LanguageManager {
}
public boolean isContributedContentType(String contentTypeId) {
return collectContentTypeIds().contains(contentTypeId);
return contentTypeId != null && getLanguageForContentTypeID(contentTypeId) != null;
}
public IContributedModelBuilder getContributedModelBuilderFor(TranslationUnit tu) {
@ -162,4 +194,38 @@ public class LanguageManager {
return null;
}
}
/**
* Returns a factory for the given linkage ID. The IDs are defined in {@link ILinkage}.
* @param linkageID an ID for a linkage.
* @return a factory or <code>null</code>.
* @since 4.0
*/
public IPDOMLinkageFactory getPDOMLinkageFactory(String linkageID) {
final IPDOMLinkageFactory[] result= new IPDOMLinkageFactory[] {null};
result[0]= (IPDOMLinkageFactory) fPDOMLinkageFactoryCache.get(linkageID);
if (result[0] == null) {
// read configuration
IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
for (int i = 0; result[0] == null && i < configs.length; i++) {
final IConfigurationElement element = configs[i];
if (ELEMENT_PDOM_LINKAGE_FACTORY.equals(element.getName())) {
if (linkageID.equals(element.getAttribute(ATTRIBUTE_ID))) {
SafeRunner.run(new ISafeRunnable(){
public void handleException(Throwable exception) {
CCorePlugin.log(exception);
}
public void run() throws Exception {
result[0]= (IPDOMLinkageFactory) element.createExecutableExtension(ATTRIBUTE_CLASS);
}}
);
}
}
}
fPDOMLinkageFactoryCache.put(linkageID, result[0]);
}
return result[0];
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2002, 2005 QNX Software Systems and others.
* Copyright (c) 2002, 2006 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
@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.model;
@ -24,6 +25,7 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IOpenable;
import org.eclipse.cdt.core.model.ISourceRoot;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@ -89,13 +91,7 @@ public class ContentTypeProcessor extends CModelOperation {
if (id == null || id.length() == 0) {
return false;
}
String[] ids = CoreModel.getRegistedContentTypeIds();
for (int i = 0; i < ids.length; i++) {
if (ids[i].equals(id)) {
return true;
}
}
return false;
return LanguageManager.getInstance().isContributedContentType(id);
}
protected void processContentType(ICElement celement, IContentType contentType, IScopeContext context) {

View file

@ -17,9 +17,13 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IContributedModelBuilder;
import org.eclipse.cdt.core.model.IInclude;
import org.eclipse.cdt.core.model.ILanguage;
@ -32,7 +36,15 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IUsing;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.core.parser.ScannerInfo;
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@ -56,7 +68,6 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
*/
protected IProblemRequestor problemRequestor;
SourceManipulationInfo sourceManipulationInfo = null;
public TranslationUnit(ICElement parent, IFile file, String idType) {
@ -744,4 +755,69 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} catch (CModelException e) {
}
}
public IASTTranslationUnit getAST() throws CoreException {
return getAST(null, 0);
}
public IASTTranslationUnit getAST(IIndex index, int style) throws CoreException {
ICodeReaderFactory codeReaderFactory;
if (index != null && (style & (ITranslationUnit.AST_SKIP_INDEXED_HEADERS | ITranslationUnit.AST_SKIP_ALL_HEADERS)) != 0) {
codeReaderFactory= new IndexBasedCodeReaderFactory(index);
}
else {
codeReaderFactory = SavedCodeReaderFactory.getInstance();
}
IScannerInfo scanInfo = getScannerInfo( (style & ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO) == 0);
if (scanInfo == null) {
return null;
}
CodeReader reader;
reader = getCodeReader();
ILanguage language= getLanguage();
if (language != null) {
return language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, index);
}
return null;
}
public CodeReader getCodeReader() {
CodeReader reader;
IPath location= getLocation();
if (isWorkingCopy() || location == null) {
if (location == null) {
reader= new CodeReader(getContents());
}
else {
reader= new CodeReader(location.toOSString(), getContents());
}
}
else {
reader= ParserUtil.createReader(location.toOSString(), null);
}
return reader;
}
public IScannerInfo getScannerInfo(boolean force) {
IResource resource = getResource();
ICProject project = getCProject();
IProject rproject = project.getProject();
IScannerInfoProvider provider = CCorePlugin.getDefault()
.getScannerInfoProvider(rproject);
if (provider != null) {
IResource infoResource = resource != null ? resource : rproject;
IScannerInfo scanInfo = provider
.getScannerInformation(infoResource);
if (scanInfo != null)
return scanInfo;
}
if (force) {
return new ScannerInfo();
}
return null;
}
}

View file

@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2006 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
*******************************************************************************/
package org.eclipse.cdt.core.dom;
/**
* Represents a linkage in the AST or the index.
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will
* work or that it will remain the same. Please do not use this API without
* consulting with the CDT team.
* </p>
* @since 4.0
*/
public interface ILinkage {
final static String NO_LINKAGE_ID= "none"; //$NON-NLS-1$
final static String C_LINKAGE_ID= "C"; //$NON-NLS-1$
final static String CPP_LINKAGE_ID= "C++"; //$NON-NLS-1$
final static String FORTRAN_LINKAGE_ID= "Fortran"; //$NON-NLS-1$
String getID();
}

View file

@ -13,16 +13,19 @@ package org.eclipse.cdt.core.dom;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
/**
* Common interface for names in the index and the AST
* Common interface for names in the index and the AST.
* <p> This interface is not intended to be implemented by clients. </p>
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will
* work or that it will remain the same. Please do not use this API without
* consulting with the CDT team.
* </p>
* @since 4.0
*/
public interface IName {
public static final IName[] EMPTY_NAME_ARRAY = new IName[0];
/**
* Return a char array representation of the name.
*
@ -30,13 +33,6 @@ public interface IName {
*/
public char[] toCharArray();
/**
* Resolve the semantic object this name is referring to.
*
* @return <code>IBinding</code> binding
*/
public IBinding resolveBinding();
/**
* Is this name being used in the AST as the introduction of a declaration?
* @return boolean

View file

@ -11,13 +11,7 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom;
import java.util.regex.Pattern;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* This is the reader interface to the PDOM. It is used by general
@ -25,74 +19,4 @@ import org.eclipse.core.runtime.IProgressMonitor;
*
* @author Doug Schaefer
*/
public interface IPDOM extends IAdaptable {
/**
* Find all the bindings whose names that match the pattern.
*
* @param pattern
* @return
* @throws CoreException
*/
public IBinding[] findBindings(Pattern pattern, IProgressMonitor monitor) throws CoreException;
/**
* Find all bindings whose qualified names match the array of patterns.
*
* @param pattern
* @return
* @throws CoreException
*/
public IBinding[] findBindings(Pattern[] pattern, IProgressMonitor monitor) throws CoreException;
/**
* Recursively visit the nodes in this PDOM using the given visitor.
*
* @param visitor
* @throws CoreException
*/
public void accept(IPDOMVisitor visitor) throws CoreException;
/**
* Clear all the contents of this PDOM.
*
* @throws CoreException
*/
public void clear() throws CoreException;
/**
* Looks to see if anything has been stored in this PDOM.
*
* @return is the PDOM empty
* @throws CoreException
*/
public boolean isEmpty() throws CoreException;
public ICodeReaderFactory getCodeReaderFactory();
public ICodeReaderFactory getCodeReaderFactory(IWorkingCopy root);
/**
* When accessing a PDOM and working with its objects it's neccessary to hold
* a read-lock on the PDOM. Make sure to release it: <pre>
* pdom.acquireReadLock();
* try {
* // do what you have to do.
* }
* finally {
* pdom.releaseReadLock();
* } </pre>
* @throws InterruptedException
* @since 4.0
*/
public void acquireReadLock() throws InterruptedException;
public void releaseReadLock();
/**
* You must not hold any other lock on any PDOM when acquiring a write lock.
* Failing to do so may lead to dead-locks.
*/
public void acquireWriteLock() throws InterruptedException;
public void releaseWriteLock();
}
public interface IPDOM extends IAdaptable {}

View file

@ -1,35 +0,0 @@
/*******************************************************************************
* Copyright (c) 2006 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:
* QNX - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
/**
* This is the interface used by the DOM to help with resolving
* bindings amongst other things.
*
* @author Doug Schaefer
*/
public interface IPDOMResolver extends IAdaptable {
public IBinding resolveBinding(IASTName name);
public IName[] getDeclarations(IBinding binding) throws CoreException;
public IName[] getDefinitions(IBinding binding) throws CoreException;
public IName[] getReferences(IBinding binding) throws CoreException;
}

View file

@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.IName;
/**
@ -42,6 +43,13 @@ public interface IASTName extends IASTNode, IName {
*/
public void setBinding( IBinding binding );
/**
* Resolve the semantic object this name is referring to.
*
* @return <code>IBinding</code> binding
*/
public IBinding resolveBinding();
/**
* Return a list of bindings in the scope of the name that have the name as
* a prefix.
@ -49,4 +57,9 @@ public interface IASTName extends IASTNode, IName {
* @return <code>IBinding []</code> bindings that start with this name
*/
public IBinding[] resolvePrefix();
/**
* Determines the current linkage in which the name has to be resolved.
*/
public ILinkage getLinkage();
}

View file

@ -12,7 +12,7 @@
package org.eclipse.cdt.core.dom.ast;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.parser.ParserLanguage;
@ -219,14 +219,14 @@ public interface IASTTranslationUnit extends IASTNode {
*
* @return the Index for this translation unit
*/
public IPDOM getIndex();
public IIndex getIndex();
/**
* Set the Index to be used for this translation unit.
*
* @param index
*/
public void setIndex(IPDOM index);
public void setIndex(IIndex index);
/**
* Returns the language for this translation unit.

View file

@ -7,12 +7,16 @@
*
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
/**
* Represents the semantics of a name found in the AST or the index.
* @author Doug Schaefer
*/
public interface IBinding extends IAdaptable {
@ -38,4 +42,9 @@ public interface IBinding extends IAdaptable {
*/
public IScope getScope() throws DOMException;
/**
* Every binding has a linkage.
*/
public ILinkage getLinkage() throws CoreException;
}

View file

@ -46,15 +46,10 @@ public interface IScope {
*/
public IBinding[] find(String name) throws DOMException;
/**
* Return the physical IASTNode that this scope was created for
* @return
*/
public IASTNode getPhysicalNode() throws DOMException;
/**
* The IScope serves as a mechanism for caching IASTNames and bindings to
* speed up resolution.
* mstodo more work: remove the ast-specific methods.
*/
/**
@ -97,24 +92,4 @@ public interface IScope {
* @throws DOMException
*/
public void addBinding(IBinding binding) throws DOMException;
/**
* Set whether or not all the names in this scope have been cached
*
* @param b
*/
public void setFullyCached(boolean b) throws DOMException;
/**
* whether or not this scope's cache contains all the names
*
* @return
*/
public boolean isFullyCached() throws DOMException;
/**
* clear the name cache in this scope
* @throws DOMException
*/
public void flushCache() throws DOMException;
}

View file

@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.gnu.c;
@ -22,9 +23,10 @@ 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.c.CASTVisitor;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.AbstractLanguage;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IContributedModelBuilder;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.CodeReader;
@ -36,28 +38,23 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.core.parser.ScannerInfo;
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration;
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration;
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.PDOMCodeReaderFactory;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject;
/**
* @author Doug Schaefer
*
*/
public class GCCLanguage extends PlatformObject implements ILanguage {
public class GCCLanguage extends AbstractLanguage {
protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
// Must match the id in the extension
@ -80,53 +77,9 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
return super.getAdapter(adapter);
}
public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style) throws CoreException {
ICodeReaderFactory fileCreator;
if ((style & (ILanguage.AST_SKIP_INDEXED_HEADERS | ILanguage.AST_SKIP_ALL_HEADERS)) != 0) {
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(file.getCProject()).getAdapter(PDOM.class);
fileCreator = new PDOMCodeReaderFactory(pdom);
} else
fileCreator = SavedCodeReaderFactory.getInstance();
return getASTTranslationUnit(file, fileCreator, style);
}
public IASTTranslationUnit getASTTranslationUnit(
ITranslationUnit file,
ICodeReaderFactory codeReaderFactory,
int style) throws CoreException {
IResource resource = file.getResource();
ICProject project = file.getCProject();
IProject rproject = project.getProject();
IScannerInfo scanInfo = null;
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject);
if (provider != null){
IResource infoResource = resource != null ? resource : rproject;
IScannerInfo buildScanInfo = provider.getScannerInformation(infoResource);
if (buildScanInfo != null)
scanInfo = buildScanInfo;
else if ((style & ILanguage.AST_SKIP_IF_NO_BUILD_INFO) != 0)
return null;
else
scanInfo = new ScannerInfo();
}
CodeReader reader;
IFile rfile = (IFile)file.getResource();
String path = rfile != null ? rfile.getLocation().toOSString() : file.getPath().toOSString();
if (file instanceof IWorkingCopy) {
// get the working copy contents
reader = new CodeReader(path, file.getContents());
} else {
reader = codeReaderFactory.createCodeReaderForTranslationUnit(path);
if (reader == null)
return null;
}
IScannerExtensionConfiguration scannerExtensionConfiguration
= C_GNU_SCANNER_EXTENSION;
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader,
IScannerInfo scanInfo, ICodeReaderFactory codeReaderFactory, IIndex index) throws CoreException {
IScannerExtensionConfiguration scannerExtensionConfiguration= C_GNU_SCANNER_EXTENSION;
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
ParserLanguage.C, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, codeReaderFactory);
//assume GCC
@ -135,8 +88,8 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
// Parse
IASTTranslationUnit ast = parser.parse();
if ((style & AST_USE_INDEX) != 0)
ast.setIndex(CCorePlugin.getPDOMManager().getPDOM(file.getCProject()));
// mstodo isn't that too late to set the index?
ast.setIndex(index);
return ast;
}

View file

@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.gnu.cpp;
@ -22,9 +23,10 @@ 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.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.AbstractLanguage;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IContributedModelBuilder;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.CodeReader;
@ -36,28 +38,23 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.core.parser.ScannerInfo;
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.PDOMCodeReaderFactory;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject;
/**
* @author Doug Schaefer
*
*/
public class GPPLanguage extends PlatformObject implements ILanguage {
public class GPPLanguage extends AbstractLanguage {
protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION = new GPPScannerExtensionConfiguration();
public static final String ID = CCorePlugin.PLUGIN_ID + ".g++"; //$NON-NLS-1$
@ -79,53 +76,10 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
return super.getAdapter(adapter);
}
public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style) throws CoreException {
ICodeReaderFactory fileCreator;
if ((style & (ILanguage.AST_SKIP_INDEXED_HEADERS | ILanguage.AST_SKIP_ALL_HEADERS)) != 0) {
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(file.getCProject()).getAdapter(PDOM.class);
fileCreator = new PDOMCodeReaderFactory(pdom);
} else
fileCreator = SavedCodeReaderFactory.getInstance();
return getASTTranslationUnit(file, fileCreator, style);
}
public IASTTranslationUnit getASTTranslationUnit(
ITranslationUnit file,
ICodeReaderFactory codeReaderFactory,
int style) throws CoreException {
IResource resource = file.getResource();
ICProject project = file.getCProject();
IProject rproject = project.getProject();
IScannerInfo scanInfo = null;
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject);
if (provider != null){
IResource infoResource = resource != null ? resource : rproject;
IScannerInfo buildScanInfo = provider.getScannerInformation(infoResource);
if (buildScanInfo != null)
scanInfo = buildScanInfo;
else if ((style & ILanguage.AST_SKIP_IF_NO_BUILD_INFO) != 0)
return null;
else
scanInfo = new ScannerInfo();
}
CodeReader reader;
IFile rfile = (IFile)file.getResource();
String path = rfile != null ? rfile.getLocation().toOSString() : file.getPath().toOSString();
if (file instanceof IWorkingCopy) {
// get the working copy contents
reader = new CodeReader(path, file.getContents());
} else {
reader = codeReaderFactory.createCodeReaderForTranslationUnit(path);
if (reader == null)
return null;
}
IScannerExtensionConfiguration scannerExtensionConfiguration
= CPP_GNU_SCANNER_EXTENSION;
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
ICodeReaderFactory codeReaderFactory, IIndex index) throws CoreException {
IScannerExtensionConfiguration scannerExtensionConfiguration= CPP_GNU_SCANNER_EXTENSION;
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
ParserLanguage.CPP, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, codeReaderFactory);
//assume GCC
@ -134,8 +88,8 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
// Parse
IASTTranslationUnit ast= parser.parse();
if ((style & AST_USE_INDEX) != 0)
ast.setIndex(CCorePlugin.getPDOMManager().getPDOM(file.getCProject()));
// mstodo isn't that too late to set the index?
ast.setIndex(index);
return ast;
}

View file

@ -0,0 +1,278 @@
/*******************************************************************************
* Copyright (c) 2006 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
*******************************************************************************/
package org.eclipse.cdt.core.index;
import java.util.regex.Pattern;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* Interface for accessing the index for one or more projects.
*
* <p>
* This interface is not intended to be implemented by clients.
* </p>
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will work or
* that it will remain the same. Please do not use this API without consulting
* with the CDT team.
* </p>
*
* @since 4.0
*/
public interface IIndex {
/**
* Constant to specify infinite depth.
* @see #findIncludedBy(IIndexFile, int)
* @see #findIncludes(IIndexFile, int)
*/
final int DEPTH_INFINITE = -1;
/**
* Constant to find direct includes, only.
* @see #findIncludedBy(IIndexFile, int)
* @see #findIncludes(IIndexFile, int)
*/
final int DEPTH_ZERO = 0;
/**
* Constant to search for declarations. This does not include definitions.
*/
final int FIND_DECLARATIONS = 0x1;
/**
* Constant to search for definitions. This does not include declarations.
*/
final int FIND_DEFINITIONS = 0x2;
/**
* Constant to search for all declarations including definitons.
*/
final int FIND_REFERENCES = 0x4;
/**
* Constant to search for references. This does not include declarations or definitions.
*/
final int FIND_DECLARATIONS_DEFINITIONS = FIND_DECLARATIONS | FIND_DEFINITIONS;
/**
* Constant to search for all occurrences of a binding. This includes declarations, definitons and references.
*/
final int FIND_ALL_OCCURENCES = FIND_DECLARATIONS | FIND_DEFINITIONS | FIND_REFERENCES;
/**
* Before making calls to an index you have to obtain a lock. The objects
* returned by an index become invalid as soon as the indexer writes to the
* index. You may obtain nested read locks. Make sure you release the lock.
* @see #getLastWriteAccess()
* <pre>
* index.acquireReadLock();
* try {
* ....
* }
* finally {
* index.releaseReadLock();
* }
* </pre>
*/
public void acquireReadLock() throws InterruptedException;
/**
* Any lock obtained by {@link #acquireReadLock()} must be released.
*/
public void releaseReadLock();
/**
* Returns a timestamp of when the index was last written to. This can
* be used to figure out whether information read from the index is
* still reliable or not.
*
* <pre>
* long timestamp;
* IBinding binding= null;
* index.acquireReadLock();
* try {
* timestamp= index.getLastWriteAccess();
* binding= index.findBinding(...);
* }
* finally {
* index.releaseReadLock();
* }
* ...
* index.acqureReadLock();
* try {
* if (index.getLastWriteAccess() != timestamp) {
* // don't use binding, it's not valid anymore
* binding= index.findBinding(...);
* }
* String name= binding.getName();
* ...
* }
* finally {
* index.releaseReadLock();
* }
*/
public long getLastWriteAccess();
/**
* Looks for a file with the given location. May return <code>null</code>.
* @param location absolute path of the file location
* @return the file in the index or <code>null</code>
* @throws CoreException
*/
public IIndexFile getFile(IPath location) throws CoreException;
/**
* Looks for include relations originated by the given file.
* This is the same as <pre> findIncludes(file, DEPTH_ZERO); </pre>
* @param file the file containing the include directives
* @return an array of include relations
* @throws CoreException
*/
public IIndexInclude[] findIncludes(IIndexFile file) throws CoreException;
/**
* Looks for include relations pointing to the given file.
* This is the same as <pre> findIncludedBy(file, DEPTH_ZERO); </pre>
* @param file the file included by the directives to be found
* @return an array of include relations
* @throws CoreException
*/
public IIndexInclude[] findIncludedBy(IIndexFile file) throws CoreException;
/**
* Looks recursively for include relations originated by the given file.
* @param file the file containing the include directives
* @param depth depth to which includes are followed, should be one of
* {@link #DEPTH_ZERO} or {@link #DEPTH_INFINITE}
* @return an array of include relations
* @throws CoreException
*/
public IIndexInclude[] findIncludes(IIndexFile file, int depth) throws CoreException;
/**
* Looks recursively for include relations pointing to the given file.
* @param file the file the include directives point to
* @param depth depth to which includes are followed, should be one of
* {@link #DEPTH_ZERO} or {@link #DEPTH_INFINITE}
* @return an array of include relations
* @throws CoreException
*/
public IIndexInclude[] findIncludedBy(IIndexFile file, int depth) throws CoreException;
/**
* Resolves the file that is included by the given include directive. May return <code>null</code>
* in case the file cannot be found. This is usually more efficient than using:
* <pre>
* getFile(include.getIncludesLocation())
* </pre>
* @param include
* @return the file included or <code>null</code>.
* @throws CoreException
* @since 4.0
*/
public IIndexFile resolveInclude(IIndexInclude include) throws CoreException;
/**
* Looks for a binding for the given ICElement. May return <code>null</code>.
* @param element an element a binding is searched for
* @return a binding for the element or <code>null</code>
* @throws CoreException
*/
public IIndexBinding findBinding(ICElement element) throws CoreException;
/**
* Searches for the binding of a name. The name may be originated by
* an AST or by a search in an index. May return <code>null</code>.
* @param name a name to find the binding for
* @return the binding or <code>null</code>
* @throws CoreException
*/
public IIndexBinding findBinding(IName name) throws CoreException;
/**
* Searches for all bindings with simple names that match the given pattern. In case a binding exists
* in multiple projects, no duplicate bindings are returned.
* This is fully equivalent to
* <pre>
* findBindings(new Pattern[]{pattern}, isFullyQualified, filter, monitor);
* </pre>
* @param pattern the pattern the name of the binding has to match.
* @param isFullyQualified if <code>true</code>, binding must be in global scope
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor to report progress
* @return an array of bindings matching the pattern
* @throws CoreException
*/
public IIndexBinding[] findBindings(Pattern pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
/**
* Searches for all bindings with qualified names that seen as an array of simple names match the given array
* of patterns. In case a binding exists in multiple projects, no duplicate bindings are returned.
* You can search with an array of patterns that specifies a partial qualification only.
* @param patterns an array of patterns the names of the qualified name of the bindings have to match.
* @param isFullyQualified if <code>true</code>, the array of pattern specifies the fully qualified name
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor to report progress
* @return an array of bindings matching the pattern
* @throws CoreException
*/
public IIndexBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
/**
* Searches for all names that resolve to the given binding. You can limit the result to references, declarations
* or definitions, or a combination of those.
* @param binding a binding for which names are searched for
* @param flags a combination of {@link #FIND_DECLARATIONS}, {@link #FIND_DEFINITIONS} and {@link #FIND_REFERENCES}
* @return an array of names
* @throws CoreException
*/
public IIndexName[] findNames(IBinding binding, int flags) throws CoreException;
/**
* Searches for all references that resolve to the given binding.
* This is fully equivalent to
* <pre>
* findNames(binding, IIndex.FIND_REFERENCES);
* </pre>
* @param binding a binding for which references are searched for
* @return an array of names
* @throws CoreException
*/
public IIndexName[] findReferences(IBinding binding) throws CoreException;
/**
* Searches for all declarations and definitions that resolve to the given binding.
* This is fully equivalent to
* <pre>
* findNames(binding, IIndex.FIND_DECLARATIONS_DEFINITIONS);
* </pre>
* @param binding a binding for which declarations are searched for
* @return an array of names
* @throws CoreException
*/
public IIndexName[] findDeclarations(IBinding binding) throws CoreException;
/**
* Searches for all definitions that resolve to the given binding.
* This is fully equivalent to
* <pre>
* findNames(binding, IIndex.FIND_DEFINITIONS);
* </pre>
* @param binding a binding for which declarations are searched for
* @return an array of names
* @throws CoreException
*/
public IIndexName[] findDefinitions(IBinding binding) throws CoreException;
}

View file

@ -0,0 +1,39 @@
/*******************************************************************************
* Copyright (c) 2006 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
*******************************************************************************/
package org.eclipse.cdt.core.index;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.core.runtime.CoreException;
/**
* Represents the semantics of a name in the index.
*
* <p>
* This interface is not intended to be implemented by clients.
* </p>
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will work or
* that it will remain the same. Please do not use this API without consulting
* with the CDT team.
* </p>
*
* @since 4.0
*/
public interface IIndexBinding extends IBinding {
/**
* Returns the enclosing binding. May return <code>null</code>. To give an example, for a member function
* the parent binding would be the class defining the member.
* @throws CoreException
*/
IIndexBinding getParentBinding() throws CoreException;
}

View file

@ -0,0 +1,53 @@
/*******************************************************************************
* Copyright (c) 2006 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
*******************************************************************************/
package org.eclipse.cdt.core.index;
import org.eclipse.core.runtime.CoreException;
/**
* Represents a file that has been indexed.
*
* <p>
* This interface is not intended to be implemented by clients.
* </p>
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will work or
* that it will remain the same. Please do not use this API without consulting
* with the CDT team.
* </p>
*
* @since 4.0
*/
public interface IIndexFile {
/**
* Returns the absolute path of the location of the file.
* @return the absolute path of the location of the file
* @throws CoreException
*/
String getLocation() throws CoreException;
/**
* Returns all includes found in this file.
* @return an array of all includes found in this file
* @throws CoreException
*/
IIndexInclude[] getIncludes() throws CoreException;
/**
* Returns all macros defined in this file.
* @return an array of macros found in this file
* @throws CoreException
*/
IIndexMacro[] getMacros() throws CoreException;
}

View file

@ -0,0 +1,53 @@
/*******************************************************************************
* Copyright (c) 2006 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
*******************************************************************************/
package org.eclipse.cdt.core.index;
import org.eclipse.core.runtime.CoreException;
/**
* Interface for an include directive stored in the index.
* <p>
* This interface is not intended to be implemented by clients.
* </p>
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will work or
* that it will remain the same. Please do not use this API without consulting
* with the CDT team.
* </p>
*
* @since 4.0
*/
public interface IIndexInclude {
IIndexInclude[] EMPTY_INCLUDES_ARRAY = new IIndexInclude[0];
/**
* Returns the file that contains this directive.
* @return the file performing the include
* @throws CoreException
*/
IIndexFile getIncludedBy() throws CoreException;
/**
* Returns the absolute path of the location of the file that contains this directive.
* @return the absolute path of the location of the file performing the include
* @throws CoreException
*/
String getIncludedByLocation() throws CoreException;
/**
* Returns the absolute path of the location of the file that is included by this directive.
* @return the absolute path of the location of the file that is included by this directive
* @throws CoreException
*/
String getIncludesLocation() throws CoreException;
}

View file

@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2006 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
*******************************************************************************/
package org.eclipse.cdt.core.index;
import org.eclipse.cdt.core.dom.ILinkage;
/**
* Represents the linkage of a name in the index.
* <p>
* This interface is not intended to be implemented by clients.
* </p>
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will work or
* that it will remain the same. Please do not use this API without consulting
* with the CDT team.
* </p>
*
* @since 4.0
*/
public interface IIndexLinkage extends ILinkage {
}

View file

@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2006 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
*******************************************************************************/
package org.eclipse.cdt.core.index;
import org.eclipse.cdt.core.parser.IMacro;
/**
* Represents a macro stored in the index.
* <p>
* This interface is not intended to be implemented by clients.
* </p>
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will work or
* that it will remain the same. Please do not use this API without consulting
* with the CDT team.
* </p>
*
* @since 4.0
*/
public interface IIndexMacro extends IMacro {
}

View file

@ -0,0 +1,70 @@
/*******************************************************************************
* Copyright (c) 2006 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
*******************************************************************************/
package org.eclipse.cdt.core.index;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.core.runtime.CoreException;
/**
* Starting point for working with the index. The manager can be obtained via
* {@link CCorePlugin#getIndexManager()}.
* <p>
* This interface is not intended to be implemented by clients.
* </p>
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will work or
* that it will remain the same. Please do not use this API without consulting
* with the CDT team.
* </p>
*
* @since 4.0
*/
public interface IIndexManager {
public final static int ADD_DEPENDENCIES = 0x1;
public final static int ADD_DEPENDENT = 0x2;
/**
* Returns the index for the given project.
* @param project the project to get the index for
* @return an index for the project
* @throws CoreException
*/
IIndex getIndex(ICProject project) throws CoreException;
/**
* Returns the index for the given projects.
* @param projects the projects to get the index for
* @return an index for the projects
* @throws CoreException
*/
IIndex getIndex(ICProject[] projects) throws CoreException;
/**
* Returns the index for the given project. You can specify to add dependencies or dependent projects.
* @param project the project to get the index for
* @param options <code>0</code> or a combination of {@link #ADD_DEPENDENCIES} and {@link #ADD_DEPENDENT}.
* @return an index for the project
* @throws CoreException
*/
IIndex getIndex(ICProject project, int options) throws CoreException;
/**
* Returns the index for the given projects. You can specify to add dependencies or dependent projects.
* @param projects the projects to get the index for
* @param options <code>0</code> or a combination of {@link #ADD_DEPENDENCIES} and {@link #ADD_DEPENDENT}.
* @return an index for the projects
* @throws CoreException
*/
IIndex getIndex(ICProject[] projects, int options) throws CoreException;
}

View file

@ -17,27 +17,31 @@ import org.eclipse.cdt.core.dom.IName;
/**
* Interface for all the names in the index. These constitute either a
* declaration or a reference.
* <p>
* This interface is not intended to be implemented by clients.
* </p>
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will work or
* that it will remain the same. Please do not use this API without consulting
* with the CDT team.
* </p>
*
* @since 4.0
*/
public interface IIndexName extends IName {
public static final IIndexName[] EMPTY_NAME_ARRAY = new IIndexName[0];
/**
* Returns the location of the file the name resides in.
* @since 4.0
*/
public String getFileName();
/**
* Returns the character offset of the location of the name.
* @since 4.0
*/
public int getNodeOffset();
/**
* Returns the length of the name.
* @since 4.0
*/
public int getNodeLength();
}

View file

@ -0,0 +1,37 @@
/*******************************************************************************
* Copyright (c) 2006 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
*******************************************************************************/
package org.eclipse.cdt.core.index;
import org.eclipse.cdt.core.dom.ILinkage;
/**
* Can be subclassed and used for queries in the index.
* @since 4.0
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will
* work or that it will remain the same. Please do not use this API without
* consulting with the CDT team.
* </p>
*/
public class IndexFilter {
/**
* Returns whether or not to include objects of the given linkage in the query.
* @see IIndex#findBindings(java.util.regex.Pattern, boolean, IndexFilter, org.eclipse.core.runtime.IProgressMonitor)
* @param linkage a linkage to be tested
* @return whether to include objects of the given linkage in the query.
*/
public boolean acceptLinkage(ILinkage linkage) {
return true;
}
}

View file

@ -0,0 +1,29 @@
/*******************************************************************************
* Copyright (c) 2006 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
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.core.dom.ILinkage;
public class Linkage implements ILinkage {
public static final ILinkage NO_LINKAGE = new Linkage(NO_LINKAGE_ID);
public static final ILinkage C_LINKAGE = new Linkage(C_LINKAGE_ID);
public static final ILinkage CPP_LINKAGE = new Linkage(CPP_LINKAGE_ID);
private String fID;
private Linkage(String id) {
fID= id;
}
public String getID() {
return fID;
}
}

View file

@ -0,0 +1,60 @@
/*******************************************************************************
* Copyright (c) 2006 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
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
/**
* Access to methods on scopes and bindings internal to the parser.
* @since 4.0
*/
public class ASTInternal {
public static IASTNode[] getDeclarationsOfBinding(IBinding binding) {
if( binding instanceof ICPPInternalBinding ) {
return ((ICPPInternalBinding)binding).getDeclarations();
}
assert false;
return IASTNode.EMPTY_NODE_ARRAY;
}
public static IASTNode getPhysicalNodeOfScope(IScope scope) throws DOMException {
if (scope instanceof IASTInternalScope) {
return ((IASTInternalScope) scope).getPhysicalNode();
}
assert false;
return null;
}
public static void flushCache(IScope scope) throws DOMException {
if (scope instanceof IASTInternalScope) {
((IASTInternalScope) scope).flushCache();
}
}
public static boolean isFullyCached(IScope scope) throws DOMException {
if (scope instanceof IASTInternalScope) {
return ((IASTInternalScope) scope).isFullyCached();
}
return true;
}
public static void setFullyCached(IScope scope, boolean val) throws DOMException {
if (scope instanceof IASTInternalScope) {
((IASTInternalScope) scope).setFullyCached(val);
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others.
* Copyright (c) 2005, 2006 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
@ -7,9 +7,11 @@
*
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTBuiltinSymbolProvider;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
@ -22,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.c.CBasicType;
import org.eclipse.cdt.internal.core.dom.parser.c.CFunctionType;
import org.eclipse.cdt.internal.core.dom.parser.c.CImplicitFunction;
@ -2352,6 +2355,9 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
return null;
}
public ILinkage getLinkage() {
return Linkage.C_LINKAGE;
}
}
static public class CPPBuiltinParameter extends PlatformObject implements ICPPParameter {
@ -2436,5 +2442,8 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
return false;
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}
}

View file

@ -0,0 +1,47 @@
/*******************************************************************************
* Copyright (c) 2006 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
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
/**
* Interface for methods on scopes that are internal to the AST.
* @since 4.0
*/
public interface IASTInternalScope {
/**
* Return the physical IASTNode that this scope was created for
* @return
*/
public IASTNode getPhysicalNode() throws DOMException;
/**
* Set whether or not all the names in this scope have been cached
*
* @param b
*/
public void setFullyCached(boolean b) throws DOMException;
/**
* whether or not this scope's cache contains all the names
*
* @return
*/
public boolean isFullyCached() throws DOMException;
/**
* clear the name cache in this scope
* @throws DOMException
*/
public void flushCache() throws DOMException;
}

View file

@ -17,6 +17,7 @@ package org.eclipse.cdt.internal.core.dom.parser;
import java.text.MessageFormat;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
@ -26,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
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.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
import org.eclipse.cdt.internal.core.parser.ParserMessages;
import org.eclipse.core.runtime.PlatformObject;
@ -33,7 +35,7 @@ import org.eclipse.core.runtime.PlatformObject;
/**
* @author aniefer
*/
public class ProblemBinding extends PlatformObject implements IProblemBinding, IType, IScope {
public class ProblemBinding extends PlatformObject implements IProblemBinding, IType, IScope, IASTInternalScope {
protected final int id;
protected final char [] arg;
protected IASTNode node;
@ -208,4 +210,8 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I
public void addBinding(IBinding binding) throws DOMException {
throw new DOMException( this );
}
public ILinkage getLinkage() {
return Linkage.NO_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
@ -21,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
@ -75,7 +77,7 @@ public abstract class CASTAmbiguity extends CASTNode {
if( scope != null )
{
try {
scope.flushCache();
ASTInternal.flushCache(scope);
} catch (DOMException e) {
}
}

View file

@ -7,14 +7,17 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.internal.core.dom.Linkage;
/**
* @author jcamelon
@ -141,4 +144,7 @@ public class CASTName extends CASTNode implements IASTName {
return false;
}
public ILinkage getLinkage() {
return Linkage.C_LINKAGE;
}
}

View file

@ -13,8 +13,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.dom.IPDOMResolver;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
@ -42,6 +40,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
@ -51,7 +50,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTPreprocessorSelectionResult;
import org.eclipse.cdt.internal.core.dom.parser.IRequiresLocationInformation;
import org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver;
import org.eclipse.cdt.internal.core.parser.scanner2.InvalidPreprocessorNodeException;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.CoreException;
/**
@ -68,7 +66,7 @@ public class CASTTranslationUnit extends CASTNode implements
private ILocationResolver resolver;
private IPDOM pdom;
private IIndex index;
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
@ -125,11 +123,9 @@ public class CASTTranslationUnit extends CASTNode implements
*/
public IName[] getDeclarations(IBinding binding) {
IName[] names= getDeclarationsInAST(binding);
if (names.length == 0 && pdom != null) {
if (names.length == 0 && index != null) {
try {
binding = ((PDOM)pdom).getLinkage(getLanguage()).adaptBinding(binding);
if (binding != null)
names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDeclarations(binding);
names = index.findDeclarations(binding);
} catch (CoreException e) {
CCorePlugin.log(e);
return names;
@ -156,11 +152,9 @@ public class CASTTranslationUnit extends CASTNode implements
*/
public IName[] getDefinitions(IBinding binding) {
IName[] names= getDefinitionsInAST(binding);
if (names.length == 0 && pdom != null) {
if (names.length == 0 && index != null) {
try {
binding = ((PDOM)pdom).getLinkage(getLanguage()).adaptBinding(binding);
if (binding != null)
names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDefinitions(binding);
names= index.findDefinitions(binding);
} catch (CoreException e) {
CCorePlugin.log(e);
return names;
@ -566,12 +560,12 @@ public class CASTTranslationUnit extends CASTNode implements
return new GCCLanguage();
}
public IPDOM getIndex() {
return pdom;
public IIndex getIndex() {
return index;
}
public void setIndex(IPDOM pdom) {
this.pdom = pdom;
public void setIndex(IIndex index) {
this.index = index;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@ -14,6 +15,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
@ -28,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@ -156,4 +159,8 @@ public class CEnumeration extends PlatformObject implements IEnumeration {
return false;
}
public ILinkage getLinkage() {
return Linkage.C_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@ -14,6 +15,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTName;
@ -23,6 +25,7 @@ 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.IASTEnumerationSpecifier.IASTEnumerator;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@ -76,4 +79,7 @@ public class CEnumerator extends PlatformObject implements IEnumerator {
return enumeration;
}
public ILinkage getLinkage() {
return Linkage.C_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@ -14,12 +15,15 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject;
/**
@ -91,4 +95,8 @@ public class CExternalVariable extends PlatformObject implements ICExternalBindi
public boolean isRegister() {
return false;
}
public ILinkage getLinkage() throws CoreException {
return Linkage.C_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,9 +7,11 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
@ -31,7 +33,9 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
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.CPPVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject;
/**
@ -431,4 +435,8 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
else
bits &= ~FULLY_RESOLVED;
}
public ILinkage getLinkage() throws CoreException {
return Linkage.C_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others.
* Copyright (c) 2005, 2006 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
@ -7,9 +7,11 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
@ -20,6 +22,7 @@ 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.c.ICASTTypedefNameSpecifier;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@ -114,4 +117,8 @@ public class CKnRParameter extends PlatformObject implements IParameter {
return ((IASTSimpleDeclaration)declaration).getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_register;
return false;
}
public ILinkage getLinkage() {
return Linkage.C_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@ -14,12 +15,14 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.ILabel;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@ -71,4 +74,7 @@ public class CLabel extends PlatformObject implements ILabel {
return CVisitor.getContainingScope( labelStatement.getParent() );
}
public ILinkage getLinkage() {
return Linkage.C_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,10 +7,12 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
@ -26,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@ -184,4 +187,8 @@ public class CParameter extends PlatformObject implements IParameter {
}
return false;
}
public ILinkage getLinkage() {
return Linkage.C_LINKAGE;
}
}

View file

@ -35,11 +35,12 @@ import org.eclipse.cdt.core.dom.ast.c.ICScope;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
/**
* @author aniefer
*/
public class CScope implements ICScope {
public class CScope implements ICScope, IASTInternalScope {
/**
* ISO C:99 6.2.3 there are seperate namespaces for various categories of
* identifiers: - label names ( labels have ICFunctionScope ) - tags of

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others.
* Copyright (c) 2005, 2006 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
@ -7,10 +7,12 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
@ -31,6 +33,8 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.core.runtime.PlatformObject;
/**
@ -107,7 +111,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
IField[] fields = new IField[ size ];
if( size > 0 ){
ICCompositeTypeScope scope = (ICCompositeTypeScope) getCompositeScope();
if( scope.isFullyCached() )
if( ASTInternal.isFullyCached(scope) )
scope = null;
for( int i = 0; i < size; i++ ){
IASTNode node = members[i];
@ -125,7 +129,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
}
}
if( scope != null )
scope.setFullyCached( true );
ASTInternal.setFullyCached(scope, true);
}
return (IField[]) ArrayUtil.trim( IField.class, fields );
}
@ -142,7 +146,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
}
ICCompositeTypeScope scope = (ICCompositeTypeScope) getCompositeScope();
if( scope != null && scope.isFullyCached() ){
if( scope != null && ASTInternal.isFullyCached(scope) ){
IBinding binding = scope.getBinding( name.toCharArray() );
if( binding instanceof IField )
return (IField) binding;
@ -186,7 +190,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
}
}
if( scope != null )
scope.setFullyCached( true );
ASTInternal.setFullyCached(scope, true);
if( found != null )
return found;
}
@ -237,4 +241,8 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
return type.isSameType( this );
return false;
}
public ILinkage getLinkage() {
return Linkage.C_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others.
* Copyright (c) 2005, 2006 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
@ -7,10 +7,12 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTName;
@ -18,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
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.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.core.runtime.PlatformObject;
@ -98,4 +101,8 @@ public class CTypedef extends PlatformObject implements ITypedef, ITypeContainer
return temp.isSameType( t );
return false;
}
public ILinkage getLinkage() {
return Linkage.C_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others.
* Copyright (c) 2005, 2006 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
@ -7,10 +7,12 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@ -22,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@ -131,4 +134,8 @@ public class CVariable extends PlatformObject implements IVariable, ICInternalBi
public boolean isRegister() {
return hasStorageClass( IASTDeclSpecifier.sc_register );
}
public ILinkage getLinkage() {
return Linkage.C_LINKAGE;
}
}

View file

@ -7,12 +7,12 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.dom.IPDOMResolver;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
@ -89,10 +89,12 @@ import org.eclipse.cdt.core.dom.ast.c.ICScope;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectSet;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.CoreException;
@ -851,7 +853,7 @@ public class CVisitor {
binding = new CParameter( name );
}
try {
if( scope != null && scope.getPhysicalNode() instanceof IASTTranslationUnit ){
if( scope != null && ASTInternal.getPhysicalNodeOfScope(scope) instanceof IASTTranslationUnit ){
return binding;
}
} catch (DOMException e) {
@ -1205,7 +1207,7 @@ public class CVisitor {
if( prefix )
scope = null;
if( scope != null && scope.isFullyCached() ){
if( scope != null && ASTInternal.isFullyCached(scope) ){
try {
binding = scope.getBinding( name, true );
} catch ( DOMException e ) {
@ -1278,7 +1280,7 @@ public class CVisitor {
}
if( scope != null ) {
try {
scope.setFullyCached( true );
ASTInternal.setFullyCached(scope, true);
} catch ( DOMException e ) {
}
}
@ -1305,9 +1307,13 @@ public class CVisitor {
if( blockItem != null) {
// We're at the end of our rope, check the PDOM if we can
IASTTranslationUnit tu = (IASTTranslationUnit)blockItem;
IPDOM pdom = tu.getIndex();
if (pdom != null) {
binding = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).resolveBinding(name);
IIndex index = tu.getIndex();
if (index != null) {
try {
binding = index.findBinding(name);
} catch (CoreException e) {
CCorePlugin.log(e);
}
}
if (binding == null)
@ -1915,7 +1921,7 @@ public class CVisitor {
}
public static IBinding[] findBindings( IScope scope, String name ) throws DOMException{
IASTNode node = scope.getPhysicalNode();
IASTNode node = ASTInternal.getPhysicalNodeOfScope(scope);
if( node instanceof IASTFunctionDefinition )
node = ((IASTFunctionDefinition)node).getBody();

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
public abstract class CPPASTAmbiguity extends CPPASTNode {
@ -76,7 +77,7 @@ public abstract class CPPASTAmbiguity extends CPPASTNode {
if( scope != null )
{
try {
scope.flushCache();
ASTInternal.flushCache(scope);
} catch (DOMException de) {}
}
}

View file

@ -10,11 +10,13 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.internal.core.dom.Linkage;
/**
* @author jcamelon
@ -151,5 +153,4 @@ public class CPPASTName extends CPPASTNode implements IASTName {
}
return false;
}
}

View file

@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/**
@ -17,6 +19,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
*/
public abstract class CPPASTNode extends ASTNode {
// A little empty isn't it...
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
@ -20,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
/**
* @author jcamelon
@ -276,6 +278,4 @@ public class CPPASTQualifiedName extends CPPASTNode implements
}
return false;
}
}

View file

@ -13,8 +13,6 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.dom.IPDOMResolver;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
@ -56,6 +54,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
@ -67,7 +66,6 @@ import org.eclipse.cdt.internal.core.dom.parser.IRequiresLocationInformation;
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider.CPPBuiltinParameter;
import org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver;
import org.eclipse.cdt.internal.core.parser.scanner2.InvalidPreprocessorNodeException;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.CoreException;
/**
@ -83,7 +81,7 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
private ILocationResolver resolver;
private IPDOM pdom;
private IIndex index;
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
@ -189,11 +187,9 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
public IName[] getDeclarations(IBinding b) {
IName[] names = getDeclarationsInAST(b);
if (names.length == 0 && pdom != null) {
if (names.length == 0 && index != null) {
try {
b = ((PDOM)pdom).getLinkage(getLanguage()).adaptBinding(b);
if (binding != null)
names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDeclarations(b);
names = index.findDeclarations(b);
} catch (CoreException e) {
CCorePlugin.log(e);
return names;
@ -220,11 +216,9 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
public IName[] getDefinitions(IBinding binding) {
IName[] names = getDefinitionsInAST(binding);
if (names.length == 0 && pdom != null) {
if (names.length == 0 && index != null) {
try {
binding = ((PDOM)pdom).getLinkage(getLanguage()).adaptBinding(binding);
if (binding != null)
names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDefinitions(binding);
names = index.findDefinitions(binding);
} catch (CoreException e) {
CCorePlugin.log(e);
return names;
@ -609,12 +603,12 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
return new GPPLanguage();
}
public IPDOM getIndex() {
return pdom;
public IIndex getIndex() {
return index;
}
public void setIndex(IPDOM pdom) {
this.pdom = pdom;
public void setIndex(IIndex pdom) {
this.index = pdom;
}
}

View file

@ -13,6 +13,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
@ -30,6 +31,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.CoreException;
/**
* @author aniefer
@ -197,5 +200,4 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
public ICPPClassType[] getNestedClasses() throws DOMException {
return ICPPClassType.EMPTY_CLASS_ARRAY;
}
}

View file

@ -33,11 +33,13 @@ import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.core.parser.util.ObjectSet;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
/**
* @author aniefer
*/
public class CPPClassInstanceScope implements ICPPClassScope {
public class CPPClassInstanceScope implements ICPPClassScope, IASTInternalScope {
private static final char[] CONSTRUCTOR_KEY = "!!!CTOR!!!".toCharArray(); //$NON-NLS-1$
private CharArrayObjectMap bindings;
@ -251,14 +253,17 @@ public class CPPClassInstanceScope implements ICPPClassScope {
public IASTNode getPhysicalNode() throws DOMException {
ICPPClassType cls = getOriginalClass();
ICPPClassScope scope = (ICPPClassScope)cls.getCompositeScope();
if( scope != null )
return scope.getPhysicalNode();
if( cls instanceof ICPPInternalBinding ){
IASTNode [] nds = ((ICPPInternalBinding)cls).getDeclarations();
IASTNode node= ASTInternal.getPhysicalNodeOfScope(scope);
if (node != null) {
return node;
}
IASTNode[] nds= ASTInternal.getDeclarationsOfBinding(cls);
if( nds != null && nds.length > 0 )
return nds[0];
}
return null;
}

View file

@ -181,5 +181,4 @@ public class CPPClassSpecialization extends CPPSpecialization implements
public ICPPClassType[] getNestedClasses() throws DOMException {
return ICPPClassType.EMPTY_CLASS_ARRAY;
}
}

View file

@ -50,6 +50,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBas
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectSet;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType.CPPClassTypeProblem;
/**
@ -389,7 +390,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
}
ICPPClassScope scope = (ICPPClassScope) getCompositeScope();
if( scope.isFullyCached() )
if( ASTInternal.isFullyCached(scope))
return ((CPPClassScope)scope).getConstructors( true );
IASTDeclaration [] members = getCompositeTypeSpecifier().getMembers();

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,12 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Nov 29, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
@ -47,12 +49,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectSet;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@ -373,7 +376,7 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
{
while( scope instanceof ICPPClassScope || scope instanceof ICPPFunctionScope ){
try {
scope = (ICPPScope) scope.getParent();
scope = scope.getParent();
} catch (DOMException e1) {
}
}
@ -678,7 +681,7 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
}
ICPPClassScope scope = (ICPPClassScope) getCompositeScope();
if( scope.isFullyCached() )
if( ASTInternal.isFullyCached(scope) )
return ((CPPClassScope)scope).getConstructors( true );
IASTDeclaration [] members = getCompositeTypeSpecifier().getMembers();
@ -821,4 +824,8 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
}
return (ICPPClassType[]) ArrayUtil.trim( ICPPClassType.class, result );
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -13,11 +13,14 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject;
/**
@ -66,4 +69,8 @@ public class CPPCompositeBinding extends PlatformObject implements IBinding {
return bindings;
}
public ILinkage getLinkage() throws CoreException {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -14,6 +14,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -21,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@ -155,4 +157,7 @@ public class CPPDelegate extends PlatformObject implements ICPPDelegate, ICPPInt
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -14,6 +14,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTName;
@ -25,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@ -188,4 +190,8 @@ public class CPPEnumeration extends PlatformObject implements IEnumeration, ICPP
return ((ITypedef)type).isSameType( this );
return false;
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -14,6 +14,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTName;
@ -25,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@ -152,4 +154,7 @@ public class CPPEnumerator extends PlatformObject implements IEnumerator, ICPPIn
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Nov 29, 2004
@ -28,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
/**
* @author aniefer
@ -87,7 +89,7 @@ public class CPPField extends CPPVariable implements ICPPField, ICPPInternalBind
char [] myName = getNameCharArray();
ICPPClassScope scope = (ICPPClassScope) getScope();
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) scope.getPhysicalNode();
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(scope);
IASTDeclaration [] members = compSpec.getMembers();
for( int i = 0; i < members.length; i++ ){
if( members[i] instanceof IASTSimpleDeclaration ){

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,12 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Dec 1, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@ -36,6 +38,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@ -172,7 +176,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
//implicit binding
IScope scope = getScope();
try {
IASTNode node = scope.getPhysicalNode();
IASTNode node = ASTInternal.getPhysicalNodeOfScope(scope);
tu = node.getTranslationUnit();
} catch ( DOMException e ) {
}
@ -592,4 +596,8 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
}
return false;
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@ -32,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
/**
* @author aniefer
@ -84,7 +86,7 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
IFunctionType ftype = getType();
IType [] params = ftype.getParameterTypes();
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) getScope().getPhysicalNode();
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(getScope());
IASTDeclaration [] members = compSpec.getMembers();
for( int i = 0; i < members.length; i++ ){
IASTDeclarator dtor = null;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@ -14,12 +15,14 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.ILabel;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@ -143,5 +146,8 @@ public class CPPLabel extends PlatformObject implements ILabel, ICPPInternalBind
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Dec 1, 2004
@ -33,6 +34,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
/**
* @author aniefer
@ -118,7 +120,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
char [] myName = getNameCharArray();
ICPPClassScope scope = (ICPPClassScope) getScope();
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) scope.getPhysicalNode();
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(scope);
IASTDeclaration [] members = compSpec.getMembers();
for( int i = 0; i < members.length; i++ ){
if( members[i] instanceof IASTSimpleDeclaration ){

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others.
* Copyright (c) 2005, 2006 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
@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Mar 31, 2005
@ -30,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
/**
* @author aniefer
@ -64,7 +66,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements
if( scope instanceof ICPPTemplateScope )
scope = scope.getParent();
ICPPClassScope clsScope = (ICPPClassScope) scope;
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) clsScope.getPhysicalNode();
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(clsScope);
IASTDeclaration [] members = compSpec.getMembers();
for( int i = 0; i < members.length; i++ ){
if( members[i] instanceof ICPPASTTemplateDeclaration ){

View file

@ -7,12 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Dec 1, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@ -37,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectSet;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@ -240,7 +243,7 @@ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPI
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/
public String getName() {
return tu != null ? null : namespaceDefinitions[0].toString(); //$NON-NLS-1$
return tu != null ? null : namespaceDefinitions[0].toString();
}
/* (non-Javadoc)
@ -363,4 +366,7 @@ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPI
return IBinding.EMPTY_BINDING_ARRAY;
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others.
* Copyright (c) 2005, 2006 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
@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@ -14,6 +15,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -24,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@ -151,4 +154,8 @@ public class CPPNamespaceAlias extends PlatformObject implements ICPPNamespaceAl
public IBinding[] getMemberBindings() throws DOMException {
return namespace.getMemberBindings();
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,12 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Dec 10, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@ -28,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.core.runtime.PlatformObject;
@ -280,4 +283,8 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
}
return null;
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -7,13 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Nov 29, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -23,16 +24,18 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
import org.eclipse.cdt.core.parser.util.ObjectSet;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.CoreException;
/**
* @author aniefer
*/
abstract public class CPPScope implements ICPPScope{
abstract public class CPPScope implements ICPPScope, IASTInternalScope {
public static class CPPScopeProblem extends ProblemBinding implements ICPPScope {
public CPPScopeProblem( IASTNode node, int id, char[] arg ) {
super( node, id, arg );
@ -125,13 +128,18 @@ abstract public class CPPScope implements ICPPScope{
}
return (IBinding) obj;
} else {
IPDOM pdom = name.getTranslationUnit().getIndex();
if (pdom != null) {
IIndex index = name.getTranslationUnit().getIndex();
if (index != null) {
// Try looking this up in the PDOM
if (physicalNode instanceof ICPPASTNamespaceDefinition) {
ICPPASTNamespaceDefinition nsdef = (ICPPASTNamespaceDefinition)physicalNode;
IASTName nsname = nsdef.getName();
IBinding nsbinding = ((PDOM)pdom).resolveBinding(nsname);
IBinding nsbinding= null;
try {
nsbinding = index.findBinding(nsname);
} catch (CoreException e) {
CCorePlugin.log(e);
}
if (nsbinding instanceof ICPPScope)
return ((ICPPScope)nsbinding).getBinding(name, forceResolve);
}

View file

@ -7,14 +7,14 @@
*
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Dec 8, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.dom.IPDOMResolver;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
@ -117,16 +117,19 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.core.parser.util.ObjectSet;
import org.eclipse.cdt.core.parser.util.ArrayUtil.ArrayWrapper;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.core.runtime.CoreException;
/**
* @author aniefer
@ -136,7 +139,7 @@ public class CPPSemantics {
protected static final ASTNodeProperty STRING_LOOKUP_PROPERTY = new ASTNodeProperty("CPPSemantics.STRING_LOOKUP_PROPERTY - STRING_LOOKUP"); //$NON-NLS-1$
public static final char[] EMPTY_NAME_ARRAY = new char[0];
public static final String EMPTY_NAME = ""; //$NON-NLS-1$
public static final char[] OPERATOR_ = new char[] {'o','p','e','r','a','t','o','r',' '}; //$NON-NLS-1$
public static final char[] OPERATOR_ = new char[] {'o','p','e','r','a','t','o','r',' '};
public static final IType VOID_TYPE = new CPPBasicType( IBasicType.t_void, 0 );
static protected class LookupData
@ -749,9 +752,13 @@ public class CPPSemantics {
}
if( binding == null || binding instanceof IProblemBinding ){
// Let's try the pdom
IPDOM pdom = name.getTranslationUnit().getIndex();
if (pdom != null) {
binding = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).resolveBinding(name);
IIndex index = name.getTranslationUnit().getIndex();
if (index != null) {
try {
binding = index.findBinding(name);
} catch (CoreException e) {
CCorePlugin.log(e);
}
}
// If we're still null...
@ -1015,7 +1022,7 @@ public class CPPSemantics {
ArrayWrapper directives = null;
if( !data.usingDirectivesOnly ){
if( scope.isFullyCached() && !data.prefixLookup && data.astName != null ){
if( ASTInternal.isFullyCached(scope) && !data.prefixLookup && data.astName != null ){
IBinding binding = data.prefixLookup ? null : scope.getBinding( data.astName, true );
if( binding != null &&
( CPPSemantics.declaredBefore( binding, data.astName ) ||
@ -1156,7 +1163,7 @@ public class CPPSemantics {
//is circular inheritance
if( ! data.inheritanceChain.containsKey( parent ) ){
//is this name define in this scope?
if( data.astName != null && !data.prefixLookup && parent.isFullyCached() )
if( data.astName != null && !data.prefixLookup && ASTInternal.isFullyCached(parent) )
inherited = parent.getBinding( data.astName, true );
else
inherited = lookupInScope( data, parent, null );
@ -1363,7 +1370,7 @@ public class CPPSemantics {
static protected IASTName[] lookupInScope( CPPSemantics.LookupData data, ICPPScope scope, IASTNode blockItem ) throws DOMException {
Object possible = null;
IASTNode [] nodes = null;
IASTNode parent = scope.getPhysicalNode();
IASTNode parent = ASTInternal.getPhysicalNodeOfScope(scope);
IASTName [] namespaceDefs = null;
int namespaceIdx = -1;
@ -1521,7 +1528,7 @@ public class CPPSemantics {
}
scope.setFullyCached( true );
ASTInternal.setFullyCached(scope, true);
return found;
}
@ -1546,7 +1553,7 @@ public class CPPSemantics {
ArrayWrapper usings = new ArrayWrapper();
boolean found = false;
if( temp.isFullyCached() && !data.prefixLookup ){
if( ASTInternal.isFullyCached(temp) && !data.prefixLookup ){
IBinding binding = temp.getBinding( data.astName, true );
if( binding != null &&
( CPPSemantics.declaredBefore( binding, data.astName ) ||
@ -2155,7 +2162,7 @@ public class CPPSemantics {
if( scope instanceof ICPPClassScope ){
cls = ((ICPPClassScope)scope).getClassType();
} else {
cls = new CPPClassType.CPPClassTypeProblem( scope.getPhysicalNode(), IProblemBinding.SEMANTIC_BAD_SCOPE, fn.getNameCharArray() );
cls = new CPPClassType.CPPClassTypeProblem(ASTInternal.getPhysicalNodeOfScope(scope), IProblemBinding.SEMANTIC_BAD_SCOPE, fn.getNameCharArray() );
}
if( cls instanceof ICPPClassTemplate ){
IBinding within = CPPTemplates.instantiateWithinClassTemplate( (ICPPClassTemplate) cls );
@ -3211,7 +3218,7 @@ public class CPPSemantics {
public static IBinding[] findBindings( IScope scope, char []name, boolean qualified ) throws DOMException{
CPPASTName astName = new CPPASTName();
astName.setName( name );
astName.setParent( scope.getPhysicalNode() );
astName.setParent( ASTInternal.getPhysicalNodeOfScope(scope));
astName.setPropertyInParent( STRING_LOOKUP_PROPERTY );
LookupData data = new LookupData( astName );

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others.
* Copyright (c) 2005, 2006 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
@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
* /
*******************************************************************************/
/*
@ -14,6 +15,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
@ -22,6 +24,7 @@ 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.ArrayUtil;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.core.runtime.PlatformObject;
@ -114,5 +117,7 @@ public abstract class CPPSpecialization extends PlatformObject implements ICPPSp
public boolean isGloballyQualified() throws DOMException {
return ((ICPPInternalBinding)specialized).isGloballyQualified();
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -7,12 +7,14 @@
*
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Mar 14, 2005
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
@ -41,6 +43,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@ -387,4 +390,8 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
public IASTNode getDefinition() {
return definition;
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others.
* Copyright (c) 2005, 2006 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
@ -7,12 +7,14 @@
*
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Mar 11, 2005
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IScope;
@ -20,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.core.runtime.PlatformObject;
@ -153,4 +156,8 @@ public class CPPTemplateParameter extends PlatformObject implements ICPPTemplate
}
}
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,12 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Dec 11, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTName;
@ -23,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.core.runtime.PlatformObject;
@ -215,4 +218,8 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
}
}
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@ -14,6 +15,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -24,6 +26,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.core.runtime.PlatformObject;
/**
@ -146,7 +150,7 @@ public class CPPUnknownBinding extends PlatformObject implements ICPPInternalUnk
if( t instanceof ICPPClassType ){
IScope s = ((ICPPClassType)t).getCompositeScope();
if( s != null && s.isFullyCached() )
if( s != null && ASTInternal.isFullyCached(s) )
result = s.getBinding( name, true );
// CPPSemantics.LookupData data = CPPSemantics.createLookupData( name, false );
// CPPSemantics.lookup( data, s );
@ -156,4 +160,8 @@ public class CPPUnknownBinding extends PlatformObject implements ICPPInternalUnk
}
return result;
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -23,11 +23,12 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
/**
* @author aniefer
*/
public class CPPUnknownScope implements ICPPScope {
public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
private IBinding binding = null;
private IASTName scopeName = null;
private CharArrayObjectMap map = null;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
@ -14,6 +15,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -25,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;
/**
@ -152,4 +155,7 @@ public class CPPUsingDeclaration extends PlatformObject implements ICPPUsingDecl
public void removeDeclaration( IASTNode node ) {
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 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
@ -7,12 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Nov 29, 2004
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@ -28,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.PlatformObject;
@ -368,4 +371,8 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
public boolean isRegister() {
return hasStorageClass( IASTDeclSpecifier.sc_register );
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
}

View file

@ -141,6 +141,7 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
@ -618,7 +619,7 @@ public class CPPVisitor {
ICPPASTCompositeTypeSpecifier clsTypeSpec;
try {
IASTNode node = ((ICPPClassScope)containingScope).getPhysicalNode();
IASTNode node = ASTInternal.getPhysicalNodeOfScope(containingScope);
if (node instanceof ICPPASTCompositeTypeSpecifier)
clsTypeSpec = (ICPPASTCompositeTypeSpecifier)node;
else
@ -1639,7 +1640,7 @@ public class CPPVisitor {
IASTNode node = null;
while( scope != null ){
if( scope instanceof ICPPBlockScope ){
node = ((ICPPBlockScope)scope).getPhysicalNode();
node = ASTInternal.getPhysicalNodeOfScope(scope);
if( node.getParent() instanceof IASTFunctionDefinition )
break;
}

View file

@ -0,0 +1,311 @@
/*******************************************************************************
* Copyright (c) 2006 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
*******************************************************************************/
package org.eclipse.cdt.internal.core.index;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.index.IIndexInclude;
import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.core.index.IndexFilter;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubProgressMonitor;
public class CIndex implements IIndex {
final private IIndexFragment[] fFragments;
final private int fPrimaryFragmentCount;
private int fReadLock;
public CIndex(IIndexFragment[] fragments, int primaryFragmentCount) {
fFragments= fragments;
fPrimaryFragmentCount= primaryFragmentCount;
}
public CIndex(IIndexFragment[] fragments) {
this(fragments, fragments.length);
}
public IIndexBinding findBinding(ICElement element) throws CoreException {
// mstodo ICElement to IBinding
return null;
}
public IIndexBinding findBinding(IName name) throws CoreException {
if (name instanceof IIndexFragmentName) {
return findBinding((IIndexFragmentName) name);
}
if (name instanceof IASTName) {
return findBinding((IASTName) name);
}
return null;
}
private IIndexBinding findBinding(IIndexFragmentName indexName) throws CoreException {
IIndexProxyBinding proxy= indexName.getBinding();
if (proxy instanceof IIndexFragmentBinding) {
IIndexFragmentBinding binding= (IIndexFragmentBinding) proxy;
if (isFragment(binding.getFragment())) {
return binding;
}
}
if (proxy != null) {
for (int i = 0; i < fFragments.length; i++) {
IIndexProxyBinding result= fFragments[i].adaptBinding(proxy);
if (result instanceof IIndexFragmentBinding) {
return (IIndexFragmentBinding) result;
}
}
}
return null;
}
private boolean isFragment(IIndexFragment frag) {
for (int i = 0; i < fFragments.length; i++) {
if (frag == fFragments[i]) {
return true;
}
}
return false;
}
private boolean isPrimaryFragment(IIndexFragment frag) {
for (int i = 0; i < fPrimaryFragmentCount; i++) {
if (frag == fFragments[i]) {
return true;
}
}
return false;
}
private IIndexBinding findBinding(IASTName astName) throws CoreException {
IIndexProxyBinding binding= null;
for (int i = 0; i < fFragments.length; i++) {
if (binding == null) {
binding= fFragments[i].findBinding(astName);
if (binding instanceof IIndexFragmentBinding) {
return (IIndexFragmentBinding) binding;
}
}
else {
IIndexProxyBinding alt= fFragments[i].adaptBinding(binding);
if (alt instanceof IIndexFragmentBinding) {
return (IIndexFragmentBinding) alt;
}
}
}
return null;
}
public IIndexBinding[] findBindings(Pattern pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
return findBindings(new Pattern[]{pattern}, isFullyQualified, filter, monitor);
}
public IIndexBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
ArrayList result= new ArrayList();
monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length);
for (int i = 0; !monitor.isCanceled() && i < fFragments.length; i++) {
result.addAll(Arrays.asList(fFragments[i].findBindings(patterns, isFullyQualified, filter, new SubProgressMonitor(monitor, 1))));
}
monitor.done();
return (IIndexBinding[]) result.toArray(new IIndexBinding[result.size()]);
}
public IIndexName[] findNames(IBinding binding, int flags) throws CoreException {
ArrayList result= new ArrayList();
for (int i = 0; i < fPrimaryFragmentCount; i++) {
IIndexProxyBinding adaptedBinding= fFragments[i].adaptBinding(binding);
if (adaptedBinding != null) {
result.addAll(Arrays.asList(fFragments[i].findNames(adaptedBinding, flags)));
}
}
return (IIndexName[]) result.toArray(new IIndexName[result.size()]);
}
public IIndexName[] findDeclarations(IBinding binding) throws CoreException {
return findNames(binding, FIND_DECLARATIONS_DEFINITIONS);
}
public IIndexName[] findDefinitions(IBinding binding) throws CoreException {
return findNames(binding, FIND_DEFINITIONS);
}
public IIndexName[] findReferences(IBinding binding) throws CoreException {
return findNames(binding, FIND_REFERENCES);
}
public IIndexFile getFile(IPath location) throws CoreException {
IIndexFile result= null;
for (int i = 0; result==null && i < fPrimaryFragmentCount; i++) {
result= fFragments[i].getFile(location);
}
return result;
}
public IIndexFile resolveInclude(IIndexInclude include) throws CoreException {
IIndexFragmentInclude fragmentInclude = (IIndexFragmentInclude) include;
IIndexFragment frag= fragmentInclude.getFragment();
if (isPrimaryFragment(frag)) {
IIndexFile result= fragmentInclude.getIncludes();
if (result != null) {
return result;
}
}
Path location= new Path(include.getIncludesLocation());
for (int i = 0; i < fPrimaryFragmentCount; i++) {
IIndexFragment otherFrag = fFragments[i];
if (otherFrag != frag) {
IIndexFile result= otherFrag.getFile(location);
if (result != null) {
return result;
}
}
}
return null;
}
public IIndexInclude[] findIncludedBy(IIndexFile file) throws CoreException {
return findIncludedBy(file, 0);
}
public IIndexInclude[] findIncludedBy(IIndexFile file, int depth) throws CoreException {
List result= new ArrayList();
findIncludedBy(Collections.singletonList(file), result, depth, new HashSet());
return (IIndexInclude[]) result.toArray(new IIndexInclude[result.size()]);
}
public void findIncludedBy(List in, List out, int depth, HashSet handled) throws CoreException {
List nextLevel= depth != 0 ? new LinkedList() : null;
for (Iterator it= in.iterator(); it.hasNext(); ) {
IIndexFragmentFile file = (IIndexFragmentFile) it.next();
for (int j= 0; j < fPrimaryFragmentCount; j++) {
IIndexInclude[] includedBy= fFragments[j].findIncludedBy(file);
for (int k= 0; k < includedBy.length; k++) {
IIndexInclude include = includedBy[k];
if (handled.add(include.getIncludedByLocation())) {
out.add(include);
if (depth != 0) {
nextLevel.add(include.getIncludedBy());
}
}
}
}
}
if (depth == 0 || nextLevel.isEmpty()) {
return;
}
if (depth > 0) {
depth--;
}
findIncludedBy(nextLevel, out, depth, handled);
}
public IIndexInclude[] findIncludes(IIndexFile file) throws CoreException {
return findIncludes(file, 0);
}
public IIndexInclude[] findIncludes(IIndexFile file, int depth) throws CoreException {
List result= new ArrayList();
findIncludes(Collections.singletonList(file), result, depth, new HashSet());
result= result.subList(1, result.size());
return (IIndexInclude[]) result.toArray(new IIndexInclude[result.size()]);
}
public void findIncludes(List in, List out, int depth, HashSet handled) throws CoreException {
List nextLevel= depth != 0 ? new LinkedList() : null;
for (Iterator it= in.iterator(); it.hasNext(); ) {
IIndexFragmentFile file = (IIndexFragmentFile) it.next();
IIndexFragment frag= file.getIndexFragment();
if (isPrimaryFragment(frag)) {
IIndexInclude[] includes= file.getIncludes();
for (int k= 0; k < includes.length; k++) {
IIndexInclude include = includes[k];
if (handled.add(include.getIncludesLocation())) {
out.add(include);
if (depth != 0) {
IIndexFile includedByFile= resolveInclude(include);
if (includedByFile != null) {
nextLevel.add(includedByFile);
}
}
}
}
}
}
if (depth == 0 || nextLevel.isEmpty()) {
return;
}
if (depth > 0) {
depth--;
}
findIncludes(nextLevel, out, depth, handled);
}
public synchronized void acquireReadLock() throws InterruptedException {
if (++fReadLock == 1) {
int i= 0;
try {
for (i = 0; i < fFragments.length; i++) {
fFragments[i].acquireReadLock();
}
}
finally {
if (i < fFragments.length) {
// rollback
fReadLock--;
while (--i >= 0) {
fFragments[i].releaseReadLock();
}
}
}
}
}
public synchronized void releaseReadLock() {
if (--fReadLock == 0) {
for (int i=0; i < fFragments.length; i++) {
fFragments[i].releaseReadLock();
}
}
}
protected synchronized int getReadLockCount() {
return fReadLock;
}
public long getLastWriteAccess() {
long result= 0;
for (int i=0; i < fFragments.length; i++) {
result= Math.max(result, fFragments[i].getLastWriteAccess());
}
return result;
}
}

View file

@ -0,0 +1,100 @@
/*******************************************************************************
* Copyright (c) 2006 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
*******************************************************************************/
package org.eclipse.cdt.internal.core.index;
import java.util.regex.Pattern;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.index.IIndexInclude;
import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.core.index.IndexFilter;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
final public class EmptyCIndex implements IIndex {
public static IIndex INSTANCE= new EmptyCIndex();
private EmptyCIndex() {
}
public IIndexBinding findBinding(ICElement element) {
return null;
}
public IIndexName[] findDeclarations(IBinding binding) {
return IIndexFragmentName.EMPTY_NAME_ARRAY;
}
public IIndexName[] findDefinitions(IBinding binding) {
return IIndexFragmentName.EMPTY_NAME_ARRAY;
}
public IIndexName[] findReferences(IBinding binding) {
return IIndexFragmentName.EMPTY_NAME_ARRAY;
}
public IIndexName[] findNames(IBinding binding, int flags) {
return IIndexFragmentName.EMPTY_NAME_ARRAY;
}
public IIndexFile getFile(IPath location) {
return null;
}
public IIndexFile resolveInclude(IIndexInclude include) {
return null;
}
public IIndexInclude[] findIncludedBy(IIndexFile file) {
return IIndexInclude.EMPTY_INCLUDES_ARRAY;
}
public IIndexInclude[] findIncludedBy(IIndexFile file, int depth) {
return IIndexInclude.EMPTY_INCLUDES_ARRAY;
}
public IIndexInclude[] findIncludes(IIndexFile file) {
return IIndexInclude.EMPTY_INCLUDES_ARRAY;
}
public IIndexInclude[] findIncludes(IIndexFile file, int depth) {
return IIndexInclude.EMPTY_INCLUDES_ARRAY;
}
public void acquireReadLock() {
}
public void releaseReadLock() {
}
public long getLastWriteAccess() {
return 0;
}
public IIndexBinding findBinding(IName name) {
return null;
}
public IIndexBinding[] findBindings(Pattern pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) {
return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
}
public IIndexBinding[] findBindings(Pattern[] pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
}
}

Some files were not shown because too many files have changed in this diff Show more