mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
169666: remove duplicate binding results from index queries, provide composite bindings
This commit is contained in:
parent
3ccc12e868
commit
b130569488
79 changed files with 3303 additions and 548 deletions
|
@ -25,7 +25,8 @@ Require-Bundle: org.eclipse.core.resources,
|
||||||
org.eclipse.core.runtime,
|
org.eclipse.core.runtime,
|
||||||
org.eclipse.ui.ide,
|
org.eclipse.ui.ide,
|
||||||
org.eclipse.ui,
|
org.eclipse.ui,
|
||||||
org.eclipse.jface.text
|
org.eclipse.jface.text,
|
||||||
|
org.eclipse.core.filesystem
|
||||||
Eclipse-LazyStart: true
|
Eclipse-LazyStart: true
|
||||||
Bundle-Vendor: Eclipse.org
|
Bundle-Vendor: Eclipse.org
|
||||||
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Symbian Software Systems and others.
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -108,7 +108,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
// class A1 {};
|
// class A1 {};
|
||||||
// void foo(X::B2 c) {}
|
// void foo(X::B2 c) {}
|
||||||
// namespace X { class A2 {}; B2 b; C2 c; }
|
// namespace X { class A2 {}; B2 b; C2 c; }
|
||||||
public void _testTripleLinear() throws Exception {
|
public void testTripleLinear() throws Exception {
|
||||||
StringBuffer[] contents = getContentsForTest(3);
|
StringBuffer[] contents = getContentsForTest(3);
|
||||||
List projects = new ArrayList();
|
List projects = new ArrayList();
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
// void foo(X::B2 c) {}
|
// void foo(X::B2 c) {}
|
||||||
// namespace X { class A2 {}; }
|
// namespace X { class A2 {}; }
|
||||||
// B1 ab;
|
// B1 ab;
|
||||||
public void _testTripleUpwardV() throws Exception {
|
public void testTripleUpwardV() throws Exception {
|
||||||
StringBuffer[] contents = getContentsForTest(3);
|
StringBuffer[] contents = getContentsForTest(3);
|
||||||
List projects = new ArrayList();
|
List projects = new ArrayList();
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
// class A1 {};
|
// class A1 {};
|
||||||
// void foo(A1 a, A1 b) {}
|
// void foo(A1 a, A1 b) {}
|
||||||
// namespace X { class A2 {}; }
|
// namespace X { class A2 {}; }
|
||||||
public void _testTripleDownwardV() throws Exception {
|
public void testTripleDownwardV() throws Exception {
|
||||||
StringBuffer[] contents = getContentsForTest(3);
|
StringBuffer[] contents = getContentsForTest(3);
|
||||||
List projects = new ArrayList();
|
List projects = new ArrayList();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Symbian Software Systems and others.
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -17,12 +17,12 @@ import junit.framework.Test;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
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.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -74,8 +74,8 @@ public class FilesOnReindexTests extends PDOMTestBase {
|
||||||
IBinding[] bs = index.findBindings(Pattern.compile("C"), true, new IndexFilter(), new NullProgressMonitor());
|
IBinding[] bs = index.findBindings(Pattern.compile("C"), true, new IndexFilter(), new NullProgressMonitor());
|
||||||
assertEquals(1, bs.length);
|
assertEquals(1, bs.length);
|
||||||
|
|
||||||
PDOMBinding binding = (PDOMBinding) bs[0];
|
IIndexBinding binding = (IIndexBinding) bs[0];
|
||||||
IIndexFile file2 = binding.getFirstDefinition().getFile();
|
IIndexFile file2 = index.findDefinitions(binding)[0].getFile();
|
||||||
assertEquals(file.getLocationURI(), file2.getLocation().getURI());
|
assertEquals(file.getLocationURI(), file2.getLocation().getURI());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,15 +7,13 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.pdom.tests;
|
package org.eclipse.cdt.internal.pdom.tests;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For testing PDOM binding resolution
|
* For testing PDOM binding resolution
|
||||||
|
@ -26,11 +24,8 @@ public class IndexBindingResolutionBugs extends IndexBindingResolutionTestBase {
|
||||||
return suite(IndexBindingResolutionBugs.class);
|
return suite(IndexBindingResolutionBugs.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
public IndexBindingResolutionBugs() {
|
||||||
cproject= CProjectHelper.createCCProject("ResolveBindingBugs", "bin", IPDOMManager.ID_NO_INDEXER);
|
setStrategy(new SinglePDOMTestStrategy(true));
|
||||||
header = new Path("header.h");
|
|
||||||
references = new Path("references.cpp");
|
|
||||||
super.setUp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// // header file
|
// // header file
|
||||||
|
|
|
@ -30,15 +30,18 @@ import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.LanguageManager;
|
import org.eclipse.cdt.core.model.LanguageManager;
|
||||||
|
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IProjectDescription;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.osgi.framework.Bundle;
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,45 +54,27 @@ import org.osgi.framework.Bundle;
|
||||||
* the PDOM purely from AST information (i.e. without a real binding from the DOM)
|
* the PDOM purely from AST information (i.e. without a real binding from the DOM)
|
||||||
*/
|
*/
|
||||||
public abstract class IndexBindingResolutionTestBase extends PDOMTestBase {
|
public abstract class IndexBindingResolutionTestBase extends PDOMTestBase {
|
||||||
|
private ITestStrategy strategy;
|
||||||
|
|
||||||
IIndex index;
|
public void setStrategy(ITestStrategy strategy) {
|
||||||
ICProject cproject;
|
this.strategy = strategy;
|
||||||
IPath header, references;
|
}
|
||||||
StringBuffer[] testData;
|
|
||||||
IASTTranslationUnit ast;
|
|
||||||
|
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
Bundle b = CTestPlugin.getDefault().getBundle();
|
strategy.setUp();
|
||||||
testData = TestSourceReader.getContentsForTest(b, "parser", getClass(), getName(), 2);
|
|
||||||
|
|
||||||
IFile file = TestSourceReader.createFile(cproject.getProject(), header, testData[0].toString());
|
|
||||||
CCoreInternals.getPDOMManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
|
|
||||||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
|
||||||
|
|
||||||
IFile cppfile= TestSourceReader.createFile(cproject.getProject(), references, testData[1].toString());
|
|
||||||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
|
||||||
|
|
||||||
index= CCorePlugin.getIndexManager().getIndex(cproject);
|
|
||||||
index.acquireReadLock();
|
|
||||||
ast = TestSourceReader.createIndexBasedAST(index, cproject, cppfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
if (index != null) {
|
strategy.tearDown();
|
||||||
index.releaseReadLock();
|
|
||||||
}
|
|
||||||
if (cproject != null) {
|
|
||||||
cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
|
||||||
}
|
|
||||||
super.tearDown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IBinding getBindingFromASTName(String section, int len) {
|
protected IBinding getBindingFromASTName(String section, int len) {
|
||||||
// get the language from the language manager
|
// get the language from the language manager
|
||||||
ILanguage language = null;
|
ILanguage language = null;
|
||||||
|
ICProject cproject = strategy.getCProject();
|
||||||
|
IASTTranslationUnit ast = strategy.getAst();
|
||||||
try {
|
try {
|
||||||
language = LanguageManager.getInstance().getLanguageForFile(ast.getFilePath(), cproject.getProject());
|
language = LanguageManager.getInstance().getLanguageForFile(strategy.getAst().getFilePath(), cproject.getProject());
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
fail("Unexpected exception while getting language for file.");
|
fail("Unexpected exception while getting language for file.");
|
||||||
}
|
}
|
||||||
|
@ -97,7 +82,8 @@ public abstract class IndexBindingResolutionTestBase extends PDOMTestBase {
|
||||||
|
|
||||||
assertNotNull("No language for file " + ast.getFilePath().toString(), language);
|
assertNotNull("No language for file " + ast.getFilePath().toString(), language);
|
||||||
|
|
||||||
IASTName[] names= language.getSelectedNames(ast, testData[1].indexOf(section), len);
|
IASTName[] names= language.getSelectedNames(ast, strategy.getTestData()[1].indexOf(section), len);
|
||||||
|
|
||||||
assertEquals("<>1 name found for \""+section+"\"", 1, names.length);
|
assertEquals("<>1 name found for \""+section+"\"", 1, names.length);
|
||||||
IBinding binding = names[0].resolveBinding();
|
IBinding binding = names[0].resolveBinding();
|
||||||
assertNotNull("No binding for "+names[0].getRawSignature(), binding);
|
assertNotNull("No binding for "+names[0].getRawSignature(), binding);
|
||||||
|
@ -108,6 +94,8 @@ public abstract class IndexBindingResolutionTestBase extends PDOMTestBase {
|
||||||
protected IBinding getProblemFromASTName(String section, int len) {
|
protected IBinding getProblemFromASTName(String section, int len) {
|
||||||
// get the language from the language manager
|
// get the language from the language manager
|
||||||
ILanguage language = null;
|
ILanguage language = null;
|
||||||
|
ICProject cproject = strategy.getCProject();
|
||||||
|
IASTTranslationUnit ast = strategy.getAst();
|
||||||
try {
|
try {
|
||||||
language = LanguageManager.getInstance().getLanguageForFile(ast.getFilePath(), cproject.getProject());
|
language = LanguageManager.getInstance().getLanguageForFile(ast.getFilePath(), cproject.getProject());
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -116,7 +104,7 @@ public abstract class IndexBindingResolutionTestBase extends PDOMTestBase {
|
||||||
|
|
||||||
assertNotNull("No language for file " + ast.getFilePath().toString(), language);
|
assertNotNull("No language for file " + ast.getFilePath().toString(), language);
|
||||||
|
|
||||||
IASTName[] names= language.getSelectedNames(ast, testData[1].indexOf(section), len);
|
IASTName[] names= language.getSelectedNames(ast, strategy.getTestData()[1].indexOf(section), len);
|
||||||
assertEquals("<>1 name found for \""+section+"\"", 1, names.length);
|
assertEquals("<>1 name found for \""+section+"\"", 1, names.length);
|
||||||
IBinding binding = names[0].resolveBinding();
|
IBinding binding = names[0].resolveBinding();
|
||||||
assertNotNull("No binding for "+names[0].getRawSignature(), binding);
|
assertNotNull("No binding for "+names[0].getRawSignature(), binding);
|
||||||
|
@ -124,9 +112,13 @@ public abstract class IndexBindingResolutionTestBase extends PDOMTestBase {
|
||||||
return names[0].resolveBinding();
|
return names[0].resolveBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertQNEquals(String expectedQn, IBinding b12) throws DOMException {
|
protected static void assertQNEquals(String expectedQn, IBinding b12) {
|
||||||
|
try {
|
||||||
assertTrue(b12 instanceof ICPPBinding);
|
assertTrue(b12 instanceof ICPPBinding);
|
||||||
assertEquals(expectedQn, CPPVisitor.renderQualifiedName(((ICPPBinding)b12).getQualifiedName()));
|
assertEquals(expectedQn, CPPVisitor.renderQualifiedName(((ICPPBinding)b12).getQualifiedName()));
|
||||||
|
} catch(DOMException de) {
|
||||||
|
fail(de.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IType getVariableType(IBinding binding) throws DOMException {
|
protected IType getVariableType(IBinding binding) throws DOMException {
|
||||||
|
@ -158,4 +150,147 @@ public abstract class IndexBindingResolutionTestBase extends PDOMTestBase {
|
||||||
protected String readTaggedComment(final String tag) throws IOException {
|
protected String readTaggedComment(final String tag) throws IOException {
|
||||||
return TestSourceReader.readTaggedComment(CTestPlugin.getDefault().getBundle(), "parser", getClass(), tag);
|
return TestSourceReader.readTaggedComment(CTestPlugin.getDefault().getBundle(), "parser", getClass(), tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IIndex getIndex() {
|
||||||
|
return strategy.getIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ITestStrategy {
|
||||||
|
IIndex getIndex();
|
||||||
|
void setUp() throws Exception;
|
||||||
|
void tearDown() throws Exception;
|
||||||
|
public IASTTranslationUnit getAst();
|
||||||
|
public StringBuffer[] getTestData();
|
||||||
|
public ICProject getCProject();
|
||||||
|
}
|
||||||
|
|
||||||
|
class SinglePDOMTestStrategy implements ITestStrategy {
|
||||||
|
private IIndex index;
|
||||||
|
private ICProject cproject;
|
||||||
|
private StringBuffer[] testData;
|
||||||
|
private IASTTranslationUnit ast;
|
||||||
|
private boolean cpp;
|
||||||
|
|
||||||
|
public SinglePDOMTestStrategy(boolean cpp) {
|
||||||
|
this.cpp = cpp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICProject getCProject() {
|
||||||
|
return cproject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringBuffer[] getTestData() {
|
||||||
|
return testData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTTranslationUnit getAst() {
|
||||||
|
return ast;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
cproject = cpp ? CProjectHelper.createCCProject(getName()+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER)
|
||||||
|
: CProjectHelper.createCProject(getName()+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
|
||||||
|
Bundle b = CTestPlugin.getDefault().getBundle();
|
||||||
|
testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2);
|
||||||
|
|
||||||
|
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString());
|
||||||
|
CCoreInternals.getPDOMManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
|
||||||
|
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
||||||
|
|
||||||
|
IFile cppfile= TestSourceReader.createFile(cproject.getProject(), new Path("references.c" + (cpp ? "pp" : "")), testData[1].toString());
|
||||||
|
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
||||||
|
|
||||||
|
index= CCorePlugin.getIndexManager().getIndex(cproject);
|
||||||
|
|
||||||
|
index.acquireReadLock();
|
||||||
|
ast = TestSourceReader.createIndexBasedAST(index, cproject, cppfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
if(index != null) {
|
||||||
|
index.releaseReadLock();
|
||||||
|
}
|
||||||
|
if (cproject != null) {
|
||||||
|
cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndex getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ReferencedProject implements ITestStrategy {
|
||||||
|
private IIndex index;
|
||||||
|
private ICProject cproject, referenced;
|
||||||
|
private StringBuffer[] testData;
|
||||||
|
private IASTTranslationUnit ast;
|
||||||
|
private boolean cpp;
|
||||||
|
|
||||||
|
public ReferencedProject(boolean cpp) {
|
||||||
|
this.cpp = cpp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICProject getCProject() {
|
||||||
|
return cproject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
if(index != null) {
|
||||||
|
index.releaseReadLock();
|
||||||
|
}
|
||||||
|
if (cproject != null) {
|
||||||
|
cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||||
|
}
|
||||||
|
if (referenced != null) {
|
||||||
|
referenced.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
cproject= cpp ? CProjectHelper.createCCProject("OnlineContent", "bin", IPDOMManager.ID_NO_INDEXER)
|
||||||
|
: CProjectHelper.createCProject("OnlineContent", "bin", IPDOMManager.ID_NO_INDEXER);
|
||||||
|
Bundle b= CTestPlugin.getDefault().getBundle();
|
||||||
|
testData= TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2);
|
||||||
|
referenced = createReferencedContent();
|
||||||
|
|
||||||
|
IFile references= TestSourceReader.createFile(cproject.getProject(), new Path("refs.c" + (cpp ? "pp" : "")), testData[1].toString());
|
||||||
|
|
||||||
|
IProject[] refs = new IProject[] {referenced.getProject()};
|
||||||
|
IProjectDescription pd = cproject.getProject().getDescription();
|
||||||
|
pd.setReferencedProjects(refs);
|
||||||
|
cproject.getProject().setDescription(pd, new NullProgressMonitor());
|
||||||
|
|
||||||
|
CCoreInternals.getPDOMManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
|
||||||
|
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
||||||
|
|
||||||
|
index= CCorePlugin.getIndexManager().getIndex(cproject);
|
||||||
|
index.acquireReadLock();
|
||||||
|
ast= TestSourceReader.createIndexBasedAST(index, cproject, references);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ICProject createReferencedContent() throws CoreException {
|
||||||
|
ICProject referenced = cpp ? CProjectHelper.createCCProject("ReferencedContent"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER)
|
||||||
|
: CProjectHelper.createCProject("ReferencedContent"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
|
||||||
|
String content = testData[0].toString();
|
||||||
|
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), content);
|
||||||
|
|
||||||
|
CCoreInternals.getPDOMManager().setIndexerId(referenced, IPDOMManager.ID_FAST_INDEXER);
|
||||||
|
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
||||||
|
|
||||||
|
return referenced;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTTranslationUnit getAst() {
|
||||||
|
return ast;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndex getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringBuffer[] getTestData() {
|
||||||
|
return testData;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Symbian Software Systems and others.
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -14,12 +14,9 @@ import java.io.IOException;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For testing PDOM binding C language resolution
|
* For testing PDOM binding C language resolution
|
||||||
|
@ -31,15 +28,20 @@ import org.eclipse.core.runtime.Path;
|
||||||
*/
|
*/
|
||||||
public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase {
|
public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase {
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static class SingleProject extends IndexCBindingResolutionTest {
|
||||||
return suite(IndexCBindingResolutionTest.class);
|
public SingleProject() {setStrategy(new SinglePDOMTestStrategy(false));}
|
||||||
|
}
|
||||||
|
public static class ProjectWithDepProj extends IndexCBindingResolutionTest {
|
||||||
|
public ProjectWithDepProj() {setStrategy(new ReferencedProject(false));}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
public static void addTests(TestSuite suite) {
|
||||||
cproject= CProjectHelper.createCProject("ResolveBindingTestsC", "bin", IPDOMManager.ID_NO_INDEXER);
|
suite.addTest(suite(SingleProject.class));
|
||||||
header = new Path("header.h");
|
suite.addTest(suite(ProjectWithDepProj.class));
|
||||||
references = new Path("references.c");
|
}
|
||||||
super.setUp();
|
|
||||||
|
public IndexCBindingResolutionTest() {
|
||||||
|
setStrategy(new SinglePDOMTestStrategy(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
// // header file
|
// // header file
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Symbian Software Systems and others.
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -11,20 +11,30 @@
|
||||||
package org.eclipse.cdt.internal.pdom.tests;
|
package org.eclipse.cdt.internal.pdom.tests;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||||
|
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.ICPPClassType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For testing PDOM binding CPP language resolution
|
* For testing PDOM binding CPP language resolution
|
||||||
|
@ -34,76 +44,76 @@ import org.eclipse.core.runtime.Path;
|
||||||
* additionally check that the binding obtained has characteristics as
|
* additionally check that the binding obtained has characteristics as
|
||||||
* expected (type,name,etc..)
|
* expected (type,name,etc..)
|
||||||
*/
|
*/
|
||||||
public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBase {
|
public abstract class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBase {
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static class SingleProject extends IndexCPPBindingResolutionTest {
|
||||||
return suite(IndexCPPBindingResolutionTest.class);
|
public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true));}
|
||||||
|
}
|
||||||
|
public static class ProjectWithDepProj extends IndexCPPBindingResolutionTest {
|
||||||
|
public ProjectWithDepProj() {setStrategy(new ReferencedProject(true));}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
public static void addTests(TestSuite suite) {
|
||||||
cproject= CProjectHelper.createCCProject("ResolveBindingTestsCPP", "bin", IPDOMManager.ID_NO_INDEXER);
|
suite.addTest(suite(SingleProject.class));
|
||||||
header = new Path("header.h");
|
suite.addTest(suite(ProjectWithDepProj.class));
|
||||||
references = new Path("references.cpp");
|
|
||||||
super.setUp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// // header file
|
// // header file
|
||||||
// class C {
|
// class Base {public: int field; void foo() {}};
|
||||||
|
// class C : public Base {
|
||||||
// public:
|
// public:
|
||||||
// int field;
|
|
||||||
// struct CS { long* l; C *method(CS **); };
|
// struct CS { long* l; C *method(CS **); };
|
||||||
// CS cs;
|
// CS cs;
|
||||||
// CS **cspp;
|
// CS **cspp;
|
||||||
// long * CS::* ouch;
|
// long * CS::* ouch;
|
||||||
// long * CS::* autsch;
|
// long * CS::* autsch;
|
||||||
// C * CS::* method(CS **);
|
// C* (CS::*method)(CS **);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// // referencing file
|
// // referencing file
|
||||||
// #include "header.h"
|
// #include "referenced.h"
|
||||||
// void references() {
|
// void references() {
|
||||||
// C *cp = new C();
|
// C *cp = new C(); /*b0, b1*/
|
||||||
// long l = 5, *lp;
|
// long l = 5, *lp;
|
||||||
// lp = &l;
|
// lp = &l;
|
||||||
// cp->cs.*cp->ouch = lp = cp->cs.*cp->autsch;
|
// cp->cs.*cp->ouch = lp = cp->cs.*cp->autsch; /*b2, b3, b4*/
|
||||||
// &(cp->cs)->*cp->autsch = lp = &(cp->cs)->*cp->ouch;
|
// &(cp->cs)->*cp->autsch = lp = &(cp->cs)->*cp->ouch;
|
||||||
// cp->cs.*method(cp->cspp);/*1*/ &(cp->cs)->*method(cp->cspp);/*2*/
|
// (cp->cs).method(cp->cspp);/*1*/ (&(cp->cs))->method(cp->cspp);/*2*/
|
||||||
|
// ((cp->cs).*(cp->method))(cp->cspp);/*3*/
|
||||||
|
// ((&(cp->cs))->*(cp->method))(cp->cspp);/*4*/
|
||||||
// }
|
// }
|
||||||
public void testPointerToMemberFields() throws IOException {
|
public void testPointerToMemberFields() throws IOException, DOMException {
|
||||||
IBinding b0 = getBindingFromASTName("cs.*cp->o", 2);
|
IBinding b0 = getBindingFromASTName("C *cp", 1);
|
||||||
IBinding b1 = getBindingFromASTName("ouch = lp", 4);
|
assertClassType((ICPPClassType)b0, "C", ICPPClassType.k_class, 1, 6, 5, 9, 0, 1, 0, 2, 1);
|
||||||
IBinding b2 = getBindingFromASTName("autsch;", 6);
|
|
||||||
IBinding b3 = getBindingFromASTName("cs)->*cp->a", 2);
|
|
||||||
IBinding b4 = getBindingFromASTName("autsch = lp", 6);
|
|
||||||
IBinding b5 = getBindingFromASTName("ouch;", 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
// // header file
|
IBinding b1 = getBindingFromASTName("cp = new C()", 2);
|
||||||
|
assertVariable(b1, "cp", IPointerType.class, null);
|
||||||
|
IPointerType b1type = (IPointerType) ((ICPPVariable)b1).getType();
|
||||||
|
assertClassType(b1type.getType(), "C", ICPPClassType.k_class, 1, 6, 5, 9, 0, 1, 0, 2, 1);
|
||||||
|
|
||||||
// class C {
|
IBinding b2 = getBindingFromASTName("cs.*cp->o", 2);
|
||||||
// public:
|
ICPPField field0 = (ICPPField) b2;
|
||||||
// int field;
|
assertTrue(field0.getType() instanceof ICPPClassType);
|
||||||
// struct CS { long* l; C *method(CS **); };
|
|
||||||
// CS cs;
|
IBinding b3 = getBindingFromASTName("ouch = lp", 4);
|
||||||
// CS **cspp;
|
assertField(b3, "C::ouch", ICPPPointerToMemberType.class, null);
|
||||||
// long * CS::* ouch;
|
assertPTM(((ICPPField)b3).getType(), "C::CS", null);
|
||||||
// long * CS::* autsch;
|
|
||||||
// C * CS::* method(CS **);
|
IBinding b4 = getBindingFromASTName("autsch;", 6);
|
||||||
// };
|
assertField(b4, "C::autsch", ICPPPointerToMemberType.class, null);
|
||||||
// // referencing file
|
assertPTM(((ICPPField)b4).getType(), "C::CS", null);
|
||||||
// #include "header.h"
|
|
||||||
// void references() {
|
IBinding b5 = getBindingFromASTName("cs)->*cp->a", 2);
|
||||||
// C *cp = new C();
|
assertField(b5, "C::cs", ICPPClassType.class, "C::CS");
|
||||||
// long l = 5, *lp;
|
assertClassType(((ICPPField)b5).getType(), "C::CS", ICompositeType.k_struct, 0, 1, 1, 5, 1, 1, 0, 2, 0);
|
||||||
// lp = &l;
|
|
||||||
// cp->cs.*cp->ouch = lp = cp->cs.*cp->autsch;
|
IBinding b6 = getBindingFromASTName("autsch = lp", 6);
|
||||||
// &(cp->cs)->*cp->autsch = lp = &(cp->cs)->*cp->ouch;
|
assertField(b4, "C::autsch", ICPPPointerToMemberType.class, null);
|
||||||
// cp->cs.*method(cp->cspp);/*1*/ &(cp->cs)->*method(cp->cspp);/*2*/
|
assertPTM(((ICPPField)b4).getType(), "C::CS", null);
|
||||||
// }
|
|
||||||
public void _testPointerToMemberFields_2() throws IOException {
|
IBinding b7 = getBindingFromASTName("ouch;", 4);
|
||||||
// also fails without using the index (the header is empty)
|
assertField(b3, "C::ouch", ICPPPointerToMemberType.class, null);
|
||||||
IBinding b6 = getBindingFromASTName("method(cp->cspp);/*1*/", 6);
|
assertPTM(((ICPPField)b3).getType(), "C::CS", null);
|
||||||
IBinding b7 = getBindingFromASTName("method(cp->cspp);/*2*/", 6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// // header file
|
// // header file
|
||||||
|
@ -112,6 +122,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
||||||
// namespace ns {}
|
// namespace ns {}
|
||||||
// typedef int Int; typedef int *IntPtr;
|
// typedef int Int; typedef int *IntPtr;
|
||||||
// void func(int*); void func(int);
|
// void func(int*); void func(int);
|
||||||
|
|
||||||
// // referencing file
|
// // referencing file
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// void references() {
|
// void references() {
|
||||||
|
@ -124,19 +135,66 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
||||||
// }
|
// }
|
||||||
// class C2 : public C {}; /*base*/
|
// class C2 : public C {}; /*base*/
|
||||||
// struct S2 : public S {}; /*base*/
|
// struct S2 : public S {}; /*base*/
|
||||||
public void testSimpleGlobalBindings() throws IOException {
|
public void testSimpleGlobalBindings() throws IOException, DOMException {
|
||||||
|
{
|
||||||
IBinding b0 = getBindingFromASTName("C c; ", 1);
|
IBinding b0 = getBindingFromASTName("C c; ", 1);
|
||||||
|
assertClassTypeBinding(b0, "C", ICPPClassType.k_class, 0, 0, 0, 4, 0, 0, 0, 2, 0);
|
||||||
|
|
||||||
IBinding b1 = getBindingFromASTName("c; ", 1);
|
IBinding b1 = getBindingFromASTName("c; ", 1);
|
||||||
|
assertVariable(b1, "c", ICPPClassType.class, "C");
|
||||||
|
ICPPClassType b1type = (ICPPClassType)((ICPPVariable)b1).getType();
|
||||||
|
assertClassTypeBinding(b1type, "C", ICPPClassType.k_class, 0, 0, 0, 4, 0, 0, 0, 2, 0);
|
||||||
|
assertTrue(b1type.getScope() == null);
|
||||||
|
assertTrue(b1type.getCompositeScope() instanceof ICPPClassScope);
|
||||||
|
assertClassTypeBinding(((ICPPClassScope)b1type.getCompositeScope()).getClassType(), "C", ICPPClassType.k_class, 0, 0, 0, 4, 0, 0, 0, 2, 0);
|
||||||
|
}
|
||||||
|
{
|
||||||
IBinding b2 = getBindingFromASTName("S s;", 1);
|
IBinding b2 = getBindingFromASTName("S s;", 1);
|
||||||
|
assertClassTypeBinding(b2, "S", ICompositeType.k_struct, 0, 0, 0, 4, 0, 0, 0, 2, 0);
|
||||||
|
|
||||||
IBinding b3 = getBindingFromASTName("s;", 1);
|
IBinding b3 = getBindingFromASTName("s;", 1);
|
||||||
|
assertVariable(b3, "s", ICPPClassType.class, "S");
|
||||||
|
ICPPClassType b3type = (ICPPClassType)((ICPPVariable)b3).getType();
|
||||||
|
assertClassTypeBinding(b3type, "S", ICompositeType.k_struct, 0, 0, 0, 4, 0, 0, 0, 2, 0);
|
||||||
|
}
|
||||||
|
{
|
||||||
IBinding b4 = getBindingFromASTName("U u;", 1);
|
IBinding b4 = getBindingFromASTName("U u;", 1);
|
||||||
|
assertClassTypeBinding(b4, "U", ICompositeType.k_union, 0, 0, 0, 4, 0, 0, 0, 2, 0);
|
||||||
|
|
||||||
IBinding b5 = getBindingFromASTName("u; ", 1);
|
IBinding b5 = getBindingFromASTName("u; ", 1);
|
||||||
|
assertVariable(b5, "u", ICPPClassType.class, "U");
|
||||||
|
ICPPClassType b5type = (ICPPClassType)((ICPPVariable)b5).getType();
|
||||||
|
assertClassTypeBinding(b5type, "U", ICompositeType.k_union, 0, 0, 0, 4, 0, 0, 0, 2, 0);
|
||||||
|
}
|
||||||
|
{
|
||||||
IBinding b6 = getBindingFromASTName("E e; ", 1);
|
IBinding b6 = getBindingFromASTName("E e; ", 1);
|
||||||
|
assertEnumeration(b6, "E", new String[] {"ER1","ER2","ER3"});
|
||||||
|
|
||||||
IBinding b7 = getBindingFromASTName("e; ", 1);
|
IBinding b7 = getBindingFromASTName("e; ", 1);
|
||||||
|
assertVariable(b7, "e", IEnumeration.class, "E");
|
||||||
|
IEnumeration b5type = (IEnumeration)((ICPPVariable)b7).getType();
|
||||||
|
assertEnumeration(b5type, "E", new String[] {"ER1","ER2","ER3"});
|
||||||
|
assertTrue(b5type.getScope() == null);
|
||||||
|
}
|
||||||
|
{
|
||||||
IBinding b8 = getBindingFromASTName("var1 = 1;", 4);
|
IBinding b8 = getBindingFromASTName("var1 = 1;", 4);
|
||||||
|
assertVariable(b8, "var1", ICPPBasicType.class, null);
|
||||||
|
}
|
||||||
|
{
|
||||||
IBinding b9 = getBindingFromASTName("var2 = c;", 4);
|
IBinding b9 = getBindingFromASTName("var2 = c;", 4);
|
||||||
|
assertVariable(b9, "var2", ICPPClassType.class, "C");
|
||||||
|
ICPPClassType b9type = (ICPPClassType)((ICPPVariable)b9).getType();
|
||||||
|
assertClassTypeBinding(b9type, "C", ICPPClassType.k_class, 0, 0, 0, 4, 0, 0, 0, 2, 0);
|
||||||
|
}
|
||||||
|
{
|
||||||
IBinding b10 = getBindingFromASTName("var3 = &s;", 4);
|
IBinding b10 = getBindingFromASTName("var3 = &s;", 4);
|
||||||
|
assertVariable(b10, "var3", IPointerType.class, null);
|
||||||
|
IPointerType b10type = (IPointerType) ((ICPPVariable)b10).getType();
|
||||||
|
assertClassTypeBinding((ICPPClassType) b10type.getType(), "S", ICompositeType.k_struct, 0, 0, 0, 4, 0, 0, 0, 2, 0);
|
||||||
|
}
|
||||||
|
{
|
||||||
IBinding b11 = getBindingFromASTName("func(e);", 4);
|
IBinding b11 = getBindingFromASTName("func(e);", 4);
|
||||||
|
}
|
||||||
IBinding b12 = getBindingFromASTName("func(var1);", 4);
|
IBinding b12 = getBindingFromASTName("func(var1);", 4);
|
||||||
IBinding b13 = getBindingFromASTName("func(c);", 4);
|
IBinding b13 = getBindingFromASTName("func(c);", 4);
|
||||||
IBinding b14 = getBindingFromASTName("Int a; ", 3);
|
IBinding b14 = getBindingFromASTName("Int a; ", 3);
|
||||||
|
@ -161,10 +219,10 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
||||||
//// referencing content
|
//// referencing content
|
||||||
//namespace n1 {
|
//namespace n1 {
|
||||||
// class TopC {}; struct TopS {}; union TopU {}; enum TopE {TopER1,TopER2};
|
// class TopC {}; struct TopS {}; union TopU {}; enum TopE {TopER1,TopER2};
|
||||||
// short topBasic; void *topPtr; TopC *topCPtr; TopU topFunc(){return *new TopU();}
|
// short topBasic; void *topPtr;/*A*/ TopC *topCPtr;/*A*/ TopU topFunc(){return *new TopU();}
|
||||||
// class C {
|
// class C {
|
||||||
// class TopC {}; struct TopS {}; union TopU {}; enum TopE {TopER1,TopER2};
|
// class TopC {}; struct TopS {}; union TopU {}; enum TopE {TopER1,TopER2};
|
||||||
// short topBasic; void *topPtr; TopC *topCPtr; TopU topFunc(){return *new TopU();}
|
// short topBasic; void *topPtr;/*B*/ TopC *topCPtr;/*B*/ TopU topFunc(){return *new TopU();}
|
||||||
// void references() {
|
// void references() {
|
||||||
// ::TopC c; ::TopS s; ::TopU u; ::TopE e = ::TopER1;
|
// ::TopC c; ::TopS s; ::TopU u; ::TopE e = ::TopER1;
|
||||||
// ::topBasic++; ::topPtr = &::topBasic; ::topCPtr = &c; ::topFunc();
|
// ::topBasic++; ::topPtr = &::topBasic; ::topCPtr = &c; ::topFunc();
|
||||||
|
@ -178,10 +236,17 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
||||||
IBinding b3 = getBindingFromASTName("TopE e", 4);
|
IBinding b3 = getBindingFromASTName("TopE e", 4);
|
||||||
IBinding b4 = getBindingFromASTName("TopER1;", 6);
|
IBinding b4 = getBindingFromASTName("TopER1;", 6);
|
||||||
IBinding b5 = getBindingFromASTName("topBasic++", 8);
|
IBinding b5 = getBindingFromASTName("topBasic++", 8);
|
||||||
IBinding b6 = getBindingFromASTName("topPtr", 6);
|
IBinding b6 = getBindingFromASTName("topPtr = &", 6);
|
||||||
IBinding b7 = getBindingFromASTName("topBasic", 8);
|
IBinding b7 = getBindingFromASTName("topBasic; ::", 8);
|
||||||
IBinding b8 = getBindingFromASTName("topCPtr", 7);
|
IBinding b8 = getBindingFromASTName("topCPtr = &", 7);
|
||||||
IBinding b9 = getBindingFromASTName("topFunc", 7);
|
IBinding b9 = getBindingFromASTName("topFunc();", 7);
|
||||||
|
|
||||||
|
IBinding _b5 = getBindingFromASTName("topBasic; v", 8);
|
||||||
|
IBinding _b6 = getBindingFromASTName("topPtr;/*A*/", 6);
|
||||||
|
IBinding _b7 = getBindingFromASTName("topPtr;/*B*/", 6);
|
||||||
|
IBinding _b8 = getBindingFromASTName("topCPtr;/*A*/", 7);
|
||||||
|
IBinding _b9 = getBindingFromASTName("topCPtr;/*B*/", 7);
|
||||||
|
IBinding _b10 = getBindingFromASTName("topFunc(){", 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void _testMultiVirtualBaseClassLookup() {fail("aftodo");}
|
public void _testMultiVirtualBaseClassLookup() {fail("aftodo");}
|
||||||
|
@ -211,11 +276,23 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
||||||
// namespace n1 { namespace n2 { S _s12; }}
|
// namespace n1 { namespace n2 { S _s12; }}
|
||||||
public void testQualifiedNamesForStruct() throws DOMException {
|
public void testQualifiedNamesForStruct() throws DOMException {
|
||||||
IBinding b0 = getBindingFromASTName("S _s0;", 1);
|
IBinding b0 = getBindingFromASTName("S _s0;", 1);
|
||||||
|
assertTrue(b0.getScope() instanceof ICPPNamespaceScope);
|
||||||
|
assertTrue(b0.getScope().getParent() instanceof ICPPNamespaceScope);
|
||||||
|
assertTrue(b0.getScope().getParent().getParent() == null);
|
||||||
assertQNEquals("n1::n2::S", b0);
|
assertQNEquals("n1::n2::S", b0);
|
||||||
|
|
||||||
IBinding b1 = getBindingFromASTName("S _s1;", 1);
|
IBinding b1 = getBindingFromASTName("S _s1;", 1);
|
||||||
|
assertTrue(b1.getScope() instanceof ICPPNamespaceScope);
|
||||||
|
assertTrue(b1.getScope().getParent() instanceof ICPPNamespaceScope);
|
||||||
|
assertTrue(b1.getScope().getParent().getParent() == null);
|
||||||
assertQNEquals("n1::n2::S", b1);
|
assertQNEquals("n1::n2::S", b1);
|
||||||
|
|
||||||
IBinding b2 = getBindingFromASTName("S _s2;", 1);
|
IBinding b2 = getBindingFromASTName("S _s2;", 1);
|
||||||
|
assertTrue(b2.getScope() instanceof ICPPClassScope);
|
||||||
|
assertTrue(b2.getScope().getParent() instanceof ICPPClassScope);
|
||||||
|
assertTrue(b2.getScope().getParent().getParent() == null);
|
||||||
assertQNEquals("c1::c2::S", b2);
|
assertQNEquals("c1::c2::S", b2);
|
||||||
|
|
||||||
IBinding b3 = getBindingFromASTName("S _s3;", 1);
|
IBinding b3 = getBindingFromASTName("S _s3;", 1);
|
||||||
assertQNEquals("c1::c2::S", b3);
|
assertQNEquals("c1::c2::S", b3);
|
||||||
IBinding b4 = getBindingFromASTName("S _s4;", 1);
|
IBinding b4 = getBindingFromASTName("S _s4;", 1);
|
||||||
|
@ -230,8 +307,15 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
||||||
assertQNEquals("n3::c3::s3::u3::S", b8);
|
assertQNEquals("n3::c3::s3::u3::S", b8);
|
||||||
IBinding b9 = getBindingFromASTName("S _s9;", 1);
|
IBinding b9 = getBindingFromASTName("S _s9;", 1);
|
||||||
assertQNEquals("n3::c3::s3::u3::S", b9);
|
assertQNEquals("n3::c3::s3::u3::S", b9);
|
||||||
|
|
||||||
IBinding b10 = getBindingFromASTName("S _s10;", 1);
|
IBinding b10 = getBindingFromASTName("S _s10;", 1);
|
||||||
|
assertTrue(b10.getScope() instanceof ICPPClassScope);
|
||||||
|
assertTrue(b10.getScope().getParent() instanceof ICPPClassScope);
|
||||||
|
assertTrue(b10.getScope().getParent().getParent() instanceof ICPPClassScope);
|
||||||
|
assertTrue(b10.getScope().getParent().getParent().getParent() instanceof ICPPNamespaceScope);
|
||||||
|
assertTrue(b10.getScope().getParent().getParent().getParent().getParent() == null);
|
||||||
assertQNEquals("n3::c3::s3::u3::S", b10);
|
assertQNEquals("n3::c3::s3::u3::S", b10);
|
||||||
|
|
||||||
IBinding b11 = getBindingFromASTName("S _s11;", 1);
|
IBinding b11 = getBindingFromASTName("S _s11;", 1);
|
||||||
assertQNEquals("n1::n2::S", b11);
|
assertQNEquals("n1::n2::S", b11);
|
||||||
IBinding b12 = getBindingFromASTName("S _s12;", 1);
|
IBinding b12 = getBindingFromASTName("S _s12;", 1);
|
||||||
|
@ -450,7 +534,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
||||||
IBinding b2 = getBindingFromASTName("ER2; }", 3);
|
IBinding b2 = getBindingFromASTName("ER2; }", 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// // teh header
|
// // the header
|
||||||
// void foo(int a=2, int b=3);
|
// void foo(int a=2, int b=3);
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
|
@ -618,8 +702,8 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
||||||
IBinding b4 = getBindingFromASTName("foo/*e*/", 3);
|
IBinding b4 = getBindingFromASTName("foo/*e*/", 3);
|
||||||
IBinding b4a = getBindingFromASTName("c);/*3*/", 1);
|
IBinding b4a = getBindingFromASTName("c);/*3*/", 1);
|
||||||
|
|
||||||
IBinding b5 = getBindingFromASTName("foo/*f*/", 3);
|
IBinding b5 = getBindingFromASTName("cp);/*4*/", 2);
|
||||||
IBinding b5a = getBindingFromASTName("cp);/*4*/", 2);
|
IBinding b5a = getBindingFromASTName("foo/*f*/", 3);
|
||||||
IBinding b5b = getBindingFromASTName("cp->cp);/*5*/", 2);
|
IBinding b5b = getBindingFromASTName("cp->cp);/*5*/", 2);
|
||||||
IBinding b5c = getBindingFromASTName("cp);/*5*/", 2);
|
IBinding b5c = getBindingFromASTName("cp);/*5*/", 2);
|
||||||
|
|
||||||
|
@ -955,8 +1039,8 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
||||||
assertEquals(binding2, getBindingFromASTName("f(const_int_ptr_const)", 1));
|
assertEquals(binding2, getBindingFromASTName("f(const_int_ptr_const)", 1));
|
||||||
assertEquals(binding2, getBindingFromASTName("f(int_const_ptr_const)", 1));
|
assertEquals(binding2, getBindingFromASTName("f(int_const_ptr_const)", 1));
|
||||||
|
|
||||||
assertEquals(2, index.findNames(binding1, IIndex.FIND_DECLARATIONS).length);
|
assertEquals(2, getIndex().findNames(binding1, IIndex.FIND_DECLARATIONS).length);
|
||||||
assertEquals(4, index.findNames(binding2, IIndex.FIND_DECLARATIONS).length);
|
assertEquals(4, getIndex().findNames(binding2, IIndex.FIND_DECLARATIONS).length);
|
||||||
}
|
}
|
||||||
|
|
||||||
// typedef struct S {int a;} S;
|
// typedef struct S {int a;} S;
|
||||||
|
@ -974,4 +1058,136 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
||||||
assertTrue(b2 instanceof IEnumeration);
|
assertTrue(b2 instanceof IEnumeration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* CPP assertion helpers */
|
||||||
|
/* ##################################################################### */
|
||||||
|
|
||||||
|
static protected void assertVariable(
|
||||||
|
IBinding binding,
|
||||||
|
String qn,
|
||||||
|
Class expType,
|
||||||
|
String expTypeQN
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
assertTrue(binding instanceof ICPPVariable);
|
||||||
|
ICPPVariable variable = (ICPPVariable) binding;
|
||||||
|
assertQNEquals(qn, variable);
|
||||||
|
assertTrue(expType.isInstance(variable.getType()));
|
||||||
|
if(expTypeQN!=null) {
|
||||||
|
assert(variable.getType() instanceof ICPPBinding);
|
||||||
|
ICPPBinding tyBinding = (ICPPBinding) variable.getType();
|
||||||
|
assertQNEquals(expTypeQN, tyBinding);
|
||||||
|
}
|
||||||
|
} catch(DOMException de) {
|
||||||
|
fail(de.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected void assertField(
|
||||||
|
IBinding binding,
|
||||||
|
String qn,
|
||||||
|
Class expType,
|
||||||
|
String expTypeQN
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
assertTrue(binding instanceof ICPPField);
|
||||||
|
ICPPField field = (ICPPField) binding;
|
||||||
|
assertQNEquals(qn, field);
|
||||||
|
assertTrue(expType.isInstance(field.getType()));
|
||||||
|
if(expTypeQN!=null) {
|
||||||
|
assert(field.getType() instanceof ICPPBinding);
|
||||||
|
ICPPBinding tyBinding = (ICPPBinding) field.getType();
|
||||||
|
assertQNEquals(expTypeQN, tyBinding);
|
||||||
|
}
|
||||||
|
} catch(DOMException de) {
|
||||||
|
fail(de.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected void assertClassTypeBinding(IBinding binding,
|
||||||
|
String qn,
|
||||||
|
int key,
|
||||||
|
int bases,
|
||||||
|
int fields,
|
||||||
|
int declaredFields,
|
||||||
|
int methods,
|
||||||
|
int declaredMethods,
|
||||||
|
int allDeclaredMethods,
|
||||||
|
int friends,
|
||||||
|
int constructors,
|
||||||
|
int nestedClasses) {
|
||||||
|
assertTrue(binding instanceof ICPPClassType);
|
||||||
|
assertClassType(((ICPPClassType) binding), qn, key, bases, fields, declaredFields, methods, declaredMethods, allDeclaredMethods, friends, constructors, nestedClasses);
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected void assertClassType(
|
||||||
|
IType type,
|
||||||
|
String qn,
|
||||||
|
int key,
|
||||||
|
int bases,
|
||||||
|
int fields,
|
||||||
|
int declaredFields,
|
||||||
|
int methods,
|
||||||
|
int declaredMethods,
|
||||||
|
int allDeclaredMethods,
|
||||||
|
int friends,
|
||||||
|
int constructors,
|
||||||
|
int nestedClasses
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
assertTrue(type instanceof ICPPClassType);
|
||||||
|
ICPPClassType classType = (ICPPClassType) type;
|
||||||
|
assertQNEquals(qn, classType);
|
||||||
|
assertEquals(key, classType.getKey());
|
||||||
|
assertEquals(bases, classType.getBases().length);
|
||||||
|
assertEquals(fields, classType.getFields().length);
|
||||||
|
assertEquals(declaredFields, classType.getDeclaredFields().length);
|
||||||
|
assertEquals(methods, classType.getMethods().length);
|
||||||
|
assertEquals(declaredMethods, classType.getDeclaredMethods().length);
|
||||||
|
assertEquals(allDeclaredMethods, classType.getAllDeclaredMethods().length);
|
||||||
|
// assertEquals(friends, classType.getFriends().length); (PDOMNotImplementedError)
|
||||||
|
assertEquals(constructors, classType.getConstructors().length);
|
||||||
|
assertEquals(nestedClasses, classType.getNestedClasses().length);
|
||||||
|
} catch(DOMException de) {
|
||||||
|
fail(de.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void assertEnumeration(IBinding binding, String name, String[] enumerators) throws DOMException {
|
||||||
|
assertTrue(binding instanceof IEnumeration);
|
||||||
|
assertEquals(name, binding.getName());
|
||||||
|
IEnumerator[] aEnumerators = ((IEnumeration)binding).getEnumerators();
|
||||||
|
Set expectedEnumerators = new HashSet();
|
||||||
|
expectedEnumerators.addAll(Arrays.asList(enumerators));
|
||||||
|
Set actualEnumerators = new HashSet();
|
||||||
|
for(int i=0; i<aEnumerators.length; i++){
|
||||||
|
actualEnumerators.add(aEnumerators[i].getName());
|
||||||
|
}
|
||||||
|
assertEquals(expectedEnumerators, actualEnumerators);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param binding
|
||||||
|
* @param cqn
|
||||||
|
* @param qn may be null
|
||||||
|
*/
|
||||||
|
static protected void assertPTM(IType type, String cqn, String qn) {
|
||||||
|
try {
|
||||||
|
assertTrue(type instanceof ICPPPointerToMemberType);
|
||||||
|
ICPPPointerToMemberType ptmt = (ICPPPointerToMemberType) type;
|
||||||
|
ICPPClassType classType = ptmt.getMemberOfClass();
|
||||||
|
assertQNEquals(cqn, classType);
|
||||||
|
if(qn!=null) {
|
||||||
|
assert(ptmt.getType() instanceof ICPPBinding);
|
||||||
|
ICPPBinding tyBinding = (ICPPBinding) ptmt.getType();
|
||||||
|
assertQNEquals(qn, tyBinding);
|
||||||
|
}
|
||||||
|
} catch(DOMException de) {
|
||||||
|
fail(de.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 IBM Corporation.
|
* Copyright (c) 2007 IBM Corporation.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -124,13 +124,13 @@ public class PDOMSearchTest extends PDOMTestBase {
|
||||||
|
|
||||||
/** result #1 * */
|
/** result #1 * */
|
||||||
ICPPClassType class1 = (ICPPClassType) class1s[0];
|
ICPPClassType class1 = (ICPPClassType) class1s[0];
|
||||||
assertEquals("Class1", getBindingQualifiedName(pdom.getLinkages()[0].adaptBinding(class1)));
|
assertEquals("Class1", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(class1)));
|
||||||
IBinding[] methods = class1.getDeclaredMethods();
|
IBinding[] methods = class1.getDeclaredMethods();
|
||||||
assertEquals(0, methods.length);
|
assertEquals(0, methods.length);
|
||||||
|
|
||||||
/** result #2 * */
|
/** result #2 * */
|
||||||
ICPPClassType class2 = (ICPPClassType) class1s[1];
|
ICPPClassType class2 = (ICPPClassType) class1s[1];
|
||||||
assertEquals("namespace1::Class1", getBindingQualifiedName(pdom.getLinkages()[0].adaptBinding(class2)));
|
assertEquals("namespace1::Class1", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(class2)));
|
||||||
|
|
||||||
/* Members in this class */
|
/* Members in this class */
|
||||||
|
|
||||||
|
@ -153,12 +153,12 @@ public class PDOMSearchTest extends PDOMTestBase {
|
||||||
|
|
||||||
/** result #3 * */
|
/** result #3 * */
|
||||||
ICPPMethod method3 = (ICPPMethod) class1s[2];
|
ICPPMethod method3 = (ICPPMethod) class1s[2];
|
||||||
assertEquals("namespace1::Class1::Class1", getBindingQualifiedName(pdom.getLinkages()[0].adaptBinding(method3)));
|
assertEquals("namespace1::Class1::Class1", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(method3)));
|
||||||
assertEquals(method3, methods[0]);
|
assertEquals(method3, methods[0]);
|
||||||
|
|
||||||
/** result #4 * */
|
/** result #4 * */
|
||||||
ICPPClassType class4 = (ICPPClassType) class1s[3];
|
ICPPClassType class4 = (ICPPClassType) class1s[3];
|
||||||
assertEquals("namespace1::namespace2::Class1", getBindingQualifiedName(pdom.getLinkages()[0].adaptBinding(class4)));
|
assertEquals("namespace1::namespace2::Class1", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(class4)));
|
||||||
methods = class4.getDeclaredMethods();
|
methods = class4.getDeclaredMethods();
|
||||||
assertEquals(0, methods.length);
|
assertEquals(0, methods.length);
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ public class PDOMSearchTest extends PDOMTestBase {
|
||||||
|
|
||||||
/** result #1 * */
|
/** result #1 * */
|
||||||
ICPPClassType cls1 = (ICPPClassType) class2s[0];
|
ICPPClassType cls1 = (ICPPClassType) class2s[0];
|
||||||
assertEquals("Class2", getBindingQualifiedName(pdom.getLinkages()[0].adaptBinding(cls1)));
|
assertEquals("Class2", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(cls1)));
|
||||||
methods = cls1.getDeclaredMethods();
|
methods = cls1.getDeclaredMethods();
|
||||||
assertEquals(3, methods.length);
|
assertEquals(3, methods.length);
|
||||||
assertEquals("Class2", methods[0].getName());
|
assertEquals("Class2", methods[0].getName());
|
||||||
|
@ -181,16 +181,16 @@ public class PDOMSearchTest extends PDOMTestBase {
|
||||||
|
|
||||||
/** result #2 * */
|
/** result #2 * */
|
||||||
ICPPMethod meth2 = (ICPPMethod) class2s[1];
|
ICPPMethod meth2 = (ICPPMethod) class2s[1];
|
||||||
assertEquals("Class2::Class2", getBindingQualifiedName(pdom.getLinkages()[0].adaptBinding(meth2)));
|
assertEquals("Class2::Class2", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(meth2)));
|
||||||
assertEquals(meth2, methods[0]);
|
assertEquals(meth2, methods[0]);
|
||||||
|
|
||||||
/** result #3 * */
|
/** result #3 * */
|
||||||
ICPPClassType cls3 = (ICPPClassType) class2s[2];
|
ICPPClassType cls3 = (ICPPClassType) class2s[2];
|
||||||
assertEquals("namespace1::Class1::Class2", getBindingQualifiedName(pdom.getLinkages()[0].adaptBinding(cls3)));
|
assertEquals("namespace1::Class1::Class2", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(cls3)));
|
||||||
|
|
||||||
/** result #3 * */
|
/** result #3 * */
|
||||||
ICPPClassType cls4 = (ICPPClassType) class2s[3];
|
ICPPClassType cls4 = (ICPPClassType) class2s[3];
|
||||||
assertEquals("namespace1::Class2", getBindingQualifiedName(pdom.getLinkages()[0].adaptBinding(cls4)));
|
assertEquals("namespace1::Class2", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(cls4)));
|
||||||
|
|
||||||
/* Nested class references - namespace1::Class1::Class2 */
|
/* Nested class references - namespace1::Class1::Class2 */
|
||||||
IName[] refs = pdom.findNames(cls3, IIndex.FIND_REFERENCES);
|
IName[] refs = pdom.findNames(cls3, IIndex.FIND_REFERENCES);
|
||||||
|
@ -212,12 +212,12 @@ public class PDOMSearchTest extends PDOMTestBase {
|
||||||
IBinding[] functions = pdom.findBindings(Pattern.compile("foo2"), false, INDEX_FILTER, NULL_MONITOR);
|
IBinding[] functions = pdom.findBindings(Pattern.compile("foo2"), false, INDEX_FILTER, NULL_MONITOR);
|
||||||
assertEquals(1, functions.length);
|
assertEquals(1, functions.length);
|
||||||
assertTrue(functions[0] instanceof ICPPFunction);
|
assertTrue(functions[0] instanceof ICPPFunction);
|
||||||
assertEquals("foo2", getBindingQualifiedName(pdom.getLinkages()[0].adaptBinding(functions[0])));
|
assertEquals("foo2", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(functions[0])));
|
||||||
|
|
||||||
functions = pdom.findBindings(Pattern.compile("main"), false, INDEX_FILTER, NULL_MONITOR);
|
functions = pdom.findBindings(Pattern.compile("main"), false, INDEX_FILTER, NULL_MONITOR);
|
||||||
assertEquals(1, functions.length);
|
assertEquals(1, functions.length);
|
||||||
assertTrue(functions[0] instanceof ICPPFunction);
|
assertTrue(functions[0] instanceof ICPPFunction);
|
||||||
assertEquals("main", getBindingQualifiedName(pdom.getLinkages()[0].adaptBinding(functions[0])));
|
assertEquals("main", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(functions[0])));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ public class PDOMSearchTest extends PDOMTestBase {
|
||||||
IBinding[] methods = pdom.findBindings(Pattern.compile("~Class2"), false, INDEX_FILTER, NULL_MONITOR);
|
IBinding[] methods = pdom.findBindings(Pattern.compile("~Class2"), false, INDEX_FILTER, NULL_MONITOR);
|
||||||
assertEquals(1, methods.length);
|
assertEquals(1, methods.length);
|
||||||
assertTrue(methods[0] instanceof ICPPMethod);
|
assertTrue(methods[0] instanceof ICPPMethod);
|
||||||
assertEquals("Class2::~Class2", getBindingQualifiedName(pdom.getLinkages()[0].adaptBinding(methods[0])));
|
assertEquals("Class2::~Class2", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(methods[0])));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,12 +235,12 @@ public class PDOMSearchTest extends PDOMTestBase {
|
||||||
IBinding[] fields = pdom.findBindings(Pattern.compile("class1x"), false, INDEX_FILTER, NULL_MONITOR);
|
IBinding[] fields = pdom.findBindings(Pattern.compile("class1x"), false, INDEX_FILTER, NULL_MONITOR);
|
||||||
assertEquals(1, fields.length);
|
assertEquals(1, fields.length);
|
||||||
assertTrue(fields[0] instanceof ICPPField);
|
assertTrue(fields[0] instanceof ICPPField);
|
||||||
assertEquals("namespace1::Class1::class1x", getBindingQualifiedName(pdom.getLinkages()[0].adaptBinding(fields[0])));
|
assertEquals("namespace1::Class1::class1x", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(fields[0])));
|
||||||
|
|
||||||
fields = pdom.findBindings(Pattern.compile("class1y"), false, INDEX_FILTER, NULL_MONITOR);
|
fields = pdom.findBindings(Pattern.compile("class1y"), false, INDEX_FILTER, NULL_MONITOR);
|
||||||
assertEquals(1, fields.length);
|
assertEquals(1, fields.length);
|
||||||
assertTrue(fields[0] instanceof ICPPField);
|
assertTrue(fields[0] instanceof ICPPField);
|
||||||
assertEquals("namespace1::Class1::class1y", getBindingQualifiedName(pdom.getLinkages()[0].adaptBinding(fields[0])));
|
assertEquals("namespace1::Class1::class1y", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(fields[0])));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ public class PDOMSearchTest extends PDOMTestBase {
|
||||||
IBinding[] variables = pdom.findBindings(Pattern.compile("var"), false, INDEX_FILTER, NULL_MONITOR);
|
IBinding[] variables = pdom.findBindings(Pattern.compile("var"), false, INDEX_FILTER, NULL_MONITOR);
|
||||||
assertEquals(1, variables.length);
|
assertEquals(1, variables.length);
|
||||||
assertTrue(variables[0] instanceof ICPPVariable);
|
assertTrue(variables[0] instanceof ICPPVariable);
|
||||||
assertEquals("var", getBindingQualifiedName(pdom.getLinkages()[0].adaptBinding(variables[0])));
|
assertEquals("var", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(variables[0])));
|
||||||
|
|
||||||
/* Variable references */
|
/* Variable references */
|
||||||
IName[] refs = pdom.findNames(variables[0], IIndex.FIND_REFERENCES);
|
IName[] refs = pdom.findNames(variables[0], IIndex.FIND_REFERENCES);
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class PDOMTests extends TestSuite {
|
||||||
suite.addTest(MethodTests.suite());
|
suite.addTest(MethodTests.suite());
|
||||||
suite.addTest(NamespaceTests.suite());
|
suite.addTest(NamespaceTests.suite());
|
||||||
|
|
||||||
suite.addTest(IndexCBindingResolutionTest.suite());
|
IndexCBindingResolutionTest.addTests(suite);
|
||||||
suite.addTest(IndexCPPBindingResolutionTest.suite());
|
IndexCPPBindingResolutionTest.addTests(suite);
|
||||||
suite.addTest(IndexBindingResolutionBugs.suite());
|
suite.addTest(IndexBindingResolutionBugs.suite());
|
||||||
|
|
||||||
suite.addTest(CFunctionTests.suite());
|
suite.addTest(CFunctionTests.suite());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.testplugin.util;
|
package org.eclipse.cdt.core.testplugin.util;
|
||||||
|
@ -20,10 +21,10 @@ import java.io.LineNumberReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
@ -62,14 +63,13 @@ public class TestSourceReader {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static StringBuffer[] getContentsForTest(Bundle bundle, String srcRoot, Class clazz, final String testName, int sections) throws IOException {
|
public static StringBuffer[] getContentsForTest(Bundle bundle, String srcRoot, Class clazz, final String testName, int sections) throws IOException {
|
||||||
IPath filePath= new Path(srcRoot + '/' + clazz.getName().replace('.', '/') + ".java");
|
String fqn = clazz.getName().replace('.', '/');
|
||||||
|
fqn = fqn.indexOf("$")==-1 ? fqn : fqn.substring(0,fqn.indexOf("$"));
|
||||||
|
IPath filePath= new Path(srcRoot + '/' + fqn + ".java");
|
||||||
|
|
||||||
InputStream in= FileLocator.openStream(bundle, filePath, false);
|
InputStream in= FileLocator.openStream(bundle, filePath, false);
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||||
|
|
||||||
final int OUT_COMMENT=0, IN_COMMENT=1;
|
|
||||||
int state = OUT_COMMENT;
|
|
||||||
LinkedList q;
|
|
||||||
List contents = new ArrayList();
|
List contents = new ArrayList();
|
||||||
StringBuffer content = new StringBuffer();
|
StringBuffer content = new StringBuffer();
|
||||||
for(String line = br.readLine(); line!=null; line = br.readLine()) {
|
for(String line = br.readLine(); line!=null; line = br.readLine()) {
|
||||||
|
@ -90,6 +90,9 @@ public class TestSourceReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(clazz.getSuperclass()!=null && !clazz.equals(TestCase.class)) {
|
||||||
|
return getContentsForTest(bundle, srcRoot, clazz.getSuperclass(), testName, sections);
|
||||||
|
}
|
||||||
throw new IOException("Test data not found for "+clazz+" "+testName);
|
throw new IOException("Test data not found for "+clazz+" "+testName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,8 @@ bin.includes = plugin.xml,\
|
||||||
about.html,\
|
about.html,\
|
||||||
.,\
|
.,\
|
||||||
META-INF/,\
|
META-INF/,\
|
||||||
.options
|
.options,\
|
||||||
|
library.jar
|
||||||
src.includes = schema/,\
|
src.includes = schema/,\
|
||||||
.options
|
.options
|
||||||
javadoc.packages = org.eclipse.cdt.core.*,\
|
javadoc.packages = org.eclipse.cdt.core.*,\
|
||||||
|
@ -32,4 +33,9 @@ source.. = src/,\
|
||||||
jre.compilation.profile=J2SE-1.4
|
jre.compilation.profile=J2SE-1.4
|
||||||
javacSource=1.4
|
javacSource=1.4
|
||||||
javacTarget=1.4
|
javacTarget=1.4
|
||||||
|
source.library.jar = model/,\
|
||||||
|
browser/,\
|
||||||
|
src/,\
|
||||||
|
utils/,\
|
||||||
|
parser/
|
||||||
|
|
|
@ -251,15 +251,6 @@ public interface IIndex {
|
||||||
*/
|
*/
|
||||||
public IIndexBinding[] findBindings(char[] name, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
|
public IIndexBinding[] findBindings(char[] name, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Searches the given namespace for all bindings of a given name.
|
|
||||||
* In case a binding exists in multiple projects, no duplicate bindings are returned.
|
|
||||||
* @param nsbinding the namespace to be searched.
|
|
||||||
* @param name a simple (unqualified) name.
|
|
||||||
* @return an array of bindings
|
|
||||||
*/
|
|
||||||
public IBinding[] findInNamespace(IBinding nsbinding, char[] name);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for all bindings with names that start with the given prefix.
|
* Searches for all bindings with names that start with the given prefix.
|
||||||
* @param prefix the prefix with which all returned bindings must start
|
* @param prefix the prefix with which all returned bindings must start
|
||||||
|
@ -267,7 +258,7 @@ public interface IIndex {
|
||||||
* @return an array of bindings with the prefix
|
* @return an array of bindings with the prefix
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public IBinding[] findBindingsForPrefix(char[] prefix, IndexFilter filter) throws CoreException;
|
public IIndexBinding[] findBindingsForPrefix(char[] prefix, IndexFilter filter) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for all names that resolve to the given binding. You can limit the result to references, declarations
|
* Searches for all names that resolve to the given binding. You can limit the result to references, declarations
|
||||||
|
@ -314,4 +305,15 @@ public interface IIndex {
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public IIndexName[] findDefinitions(IBinding binding) throws CoreException;
|
public IIndexName[] findDefinitions(IBinding binding) throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an IIndexBinding for this IIndex that is equivalent to the specified binding,
|
||||||
|
* or null if such a binding does not exist in this index. This is useful for adapting
|
||||||
|
* bindings obtained from IIndex objects that might have been created for a different scope
|
||||||
|
* or for IBinding objects obtained direct from the AST.
|
||||||
|
* @param binding
|
||||||
|
* @return an IIndexBinding for this IIndex that is equivalent to the specified binding
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
public IIndexBinding adaptBinding(IBinding binding);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,8 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - initial API and implementation
|
* Andrew Ferguson (Symbian) - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
package org.eclipse.cdt.core.index;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Each IIndexFragment stores file location representations in an implementation specific manner.
|
* Each IIndexFragment stores file location representations in an implementation specific manner.
|
|
@ -18,6 +18,13 @@ public class Linkage implements ILinkage {
|
||||||
public static final ILinkage NO_LINKAGE = new Linkage(NO_LINKAGE_ID);
|
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 C_LINKAGE = new Linkage(C_LINKAGE_ID);
|
||||||
public static final ILinkage CPP_LINKAGE = new Linkage(CPP_LINKAGE_ID);
|
public static final ILinkage CPP_LINKAGE = new Linkage(CPP_LINKAGE_ID);
|
||||||
|
public static final ILinkage FORTRAN_LINKAGE = new Linkage(FORTRAN_LINKAGE_ID);
|
||||||
|
|
||||||
|
private static final ILinkage[] LINKAGES= {C_LINKAGE, CPP_LINKAGE, FORTRAN_LINKAGE};
|
||||||
|
|
||||||
|
public static final ILinkage[] getAllLinkages() {
|
||||||
|
return LINKAGES;
|
||||||
|
}
|
||||||
|
|
||||||
private String fID;
|
private String fID;
|
||||||
private Linkage(String id) {
|
private Linkage(String id) {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
/*
|
||||||
* Created on Nov 29, 2004
|
* Created on Nov 29, 2004
|
||||||
|
@ -25,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
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.ICPPASTQualifiedName;
|
||||||
|
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.cpp.ICPPScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
|
@ -109,13 +111,16 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
ICPPASTNamespaceDefinition nsdef = (ICPPASTNamespaceDefinition)physicalNode;
|
ICPPASTNamespaceDefinition nsdef = (ICPPASTNamespaceDefinition)physicalNode;
|
||||||
IASTName nsname = nsdef.getName();
|
IASTName nsname = nsdef.getName();
|
||||||
IBinding nsbinding= nsname.resolveBinding();
|
IBinding nsbinding= nsname.resolveBinding();
|
||||||
if (nsbinding != null) {
|
if(nsbinding instanceof ICPPNamespace) {
|
||||||
IBinding[] bindings= index.findInNamespace(nsbinding, name.toCharArray());
|
ICPPNamespace nsbindingAdapted = (ICPPNamespace) index.adaptBinding(nsbinding);
|
||||||
|
if(nsbindingAdapted!=null) {
|
||||||
|
IBinding[] bindings = nsbindingAdapted.getNamespaceScope().find(name.toString());
|
||||||
binding= CPPSemantics.resolveAmbiguities(name, bindings);
|
binding= CPPSemantics.resolveAmbiguities(name, bindings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
/*
|
||||||
* Created on Dec 8, 2004
|
* Created on Dec 8, 2004
|
||||||
|
@ -130,6 +131,7 @@ 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.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1029,7 +1031,7 @@ public class CPPSemantics {
|
||||||
mergeResults( data, b, true );
|
mergeResults( data, b, true );
|
||||||
} else if (data.prefixLookup && data.astName != null) {
|
} else if (data.prefixLookup && data.astName != null) {
|
||||||
IASTNode parent = ASTInternal.getPhysicalNodeOfScope(scope);
|
IASTNode parent = ASTInternal.getPhysicalNodeOfScope(scope);
|
||||||
if (parent == null && scope instanceof IIndexBinding) {
|
if (parent == null && scope instanceof IIndexScope) {
|
||||||
IBinding[] bindings = scope.find(data.astName.toString(), data.prefixLookup);
|
IBinding[] bindings = scope.find(data.astName.toString(), data.prefixLookup);
|
||||||
mergeResults(data, bindings, true);
|
mergeResults(data, bindings, true);
|
||||||
} else if (scope instanceof ICPPNamespaceScope && !(scope instanceof ICPPBlockScope)) {
|
} else if (scope instanceof ICPPNamespaceScope && !(scope instanceof ICPPBlockScope)) {
|
||||||
|
@ -1038,8 +1040,8 @@ public class CPPSemantics {
|
||||||
if (index != null) {
|
if (index != null) {
|
||||||
try {
|
try {
|
||||||
IIndexBinding binding = index.findBinding(ns.getScopeName());
|
IIndexBinding binding = index.findBinding(ns.getScopeName());
|
||||||
if (binding instanceof ICPPNamespaceScope) {
|
if (binding instanceof ICPPNamespace) {
|
||||||
ICPPNamespaceScope indexNs = (ICPPNamespaceScope) binding;
|
ICPPNamespaceScope indexNs = ((ICPPNamespace)binding).getNamespaceScope();
|
||||||
IBinding[] bindings = indexNs.find(data.astName.toString(), data.prefixLookup);
|
IBinding[] bindings = indexNs.find(data.astName.toString(), data.prefixLookup);
|
||||||
mergeResults(data, bindings, true);
|
mergeResults(data, bindings, true);
|
||||||
}
|
}
|
||||||
|
@ -1138,7 +1140,7 @@ public class CPPSemantics {
|
||||||
private static IScope getParentScope(IScope scope, IASTTranslationUnit unit) throws DOMException {
|
private static IScope getParentScope(IScope scope, IASTTranslationUnit unit) throws DOMException {
|
||||||
IScope parentScope= scope.getParent();
|
IScope parentScope= scope.getParent();
|
||||||
// the index cannot return the translation unit as parent scope
|
// the index cannot return the translation unit as parent scope
|
||||||
if (parentScope == null && scope instanceof IIndexBinding) {
|
if (parentScope == null && scope instanceof IIndexScope) {
|
||||||
parentScope= unit.getScope();
|
parentScope= unit.getScope();
|
||||||
}
|
}
|
||||||
return parentScope;
|
return parentScope;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2006 IBM Corporation and others.
|
* Copyright (c) 2004, 2006, 2007 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
/*
|
||||||
* Created on Nov 29, 2004
|
* Created on Nov 29, 2004
|
||||||
|
@ -145,6 +146,7 @@ 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.ASTInternal;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
|
@ -2051,7 +2053,7 @@ public class CPPVisitor {
|
||||||
private static IScope getParentScope(IScope scope, IASTTranslationUnit unit) throws DOMException {
|
private static IScope getParentScope(IScope scope, IASTTranslationUnit unit) throws DOMException {
|
||||||
IScope parentScope= scope.getParent();
|
IScope parentScope= scope.getParent();
|
||||||
// the index cannot return the translation unit as parent scope
|
// the index cannot return the translation unit as parent scope
|
||||||
if (parentScope == null && scope instanceof IIndexBinding) {
|
if (parentScope == null && scope instanceof IIndexScope) {
|
||||||
parentScope= unit.getScope();
|
parentScope= unit.getScope();
|
||||||
}
|
}
|
||||||
return parentScope;
|
return parentScope;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
@ -22,6 +23,7 @@ import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
@ -32,11 +34,22 @@ import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
import org.eclipse.cdt.core.index.IIndexName;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositingNotImplementedError;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.c.CCompositesFactory;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.cpp.CPPCompositesFactory;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
|
|
||||||
public class CIndex implements IIndex {
|
public class CIndex implements IIndex {
|
||||||
|
/**
|
||||||
|
* If this constant is set, for logical index objects with only
|
||||||
|
* one fragment, composite binding wrappers will not be used.
|
||||||
|
*/
|
||||||
|
private static final boolean SPECIALCASE_SINGLES = true;
|
||||||
|
|
||||||
final private IIndexFragment[] fFragments;
|
final private IIndexFragment[] fFragments;
|
||||||
final private int fPrimaryFragmentCount;
|
final private int fPrimaryFragmentCount;
|
||||||
private int fReadLock;
|
private int fReadLock;
|
||||||
|
@ -50,92 +63,19 @@ public class CIndex implements IIndex {
|
||||||
this(fragments, fragments.length);
|
this(fragments, fragments.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragment[] getPrimaryFragments() {
|
|
||||||
IIndexFragment[] result= new IIndexFragment[fPrimaryFragmentCount];
|
|
||||||
System.arraycopy(fFragments, 0, result, 0, fPrimaryFragmentCount);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IIndexBinding adaptBinding(IBinding binding) throws CoreException {
|
|
||||||
if (binding instanceof IIndexFragmentBinding) {
|
|
||||||
IIndexFragmentBinding fragBinding= (IIndexFragmentBinding) binding;
|
|
||||||
if (isFragment(fragBinding.getFragment())) {
|
|
||||||
return fragBinding;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < fFragments.length; i++) {
|
|
||||||
IIndexProxyBinding result= fFragments[i].adaptBinding(binding);
|
|
||||||
if (result instanceof IIndexFragmentBinding) {
|
|
||||||
return (IIndexFragmentBinding) result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IIndexBinding findBinding(IName name) throws CoreException {
|
public IIndexBinding findBinding(IName name) throws CoreException {
|
||||||
if (name instanceof IIndexFragmentName) {
|
if (name instanceof IIndexFragmentName) {
|
||||||
return findBinding((IIndexFragmentName) name);
|
return adaptBinding(((IIndexFragmentName) name).getBinding());
|
||||||
}
|
} else if (name instanceof IASTName) {
|
||||||
if (name instanceof IASTName) {
|
if(SPECIALCASE_SINGLES && fFragments.length==1) {
|
||||||
return findBinding((IASTName) name);
|
return fFragments[0].findBinding((IASTName) name);
|
||||||
}
|
} else {
|
||||||
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++) {
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
if (frag == fFragments[i]) {
|
IIndexFragmentBinding binding= fFragments[i].findBinding((IASTName) name);
|
||||||
return true;
|
if(binding!=null) {
|
||||||
|
return getCompositesFactory(binding.getLinkage().getID()).getCompositeBinding(binding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
return null;
|
||||||
|
@ -146,33 +86,36 @@ public class CIndex implements IIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
|
public IIndexBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
|
||||||
ArrayList result= new ArrayList();
|
if(SPECIALCASE_SINGLES && fFragments.length==1) {
|
||||||
monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length);
|
return fFragments[0].findBindings(patterns, isFullyQualified, filter, monitor);
|
||||||
for (int i = 0; !monitor.isCanceled() && i < fFragments.length; i++) {
|
} else {
|
||||||
result.addAll(Arrays.asList(fFragments[i].findBindings(patterns, isFullyQualified, filter, new SubProgressMonitor(monitor, 1))));
|
List result = new ArrayList();
|
||||||
|
ILinkage[] linkages = Linkage.getAllLinkages();
|
||||||
|
for(int j=0; j < linkages.length; j++) {
|
||||||
|
if(filter.acceptLinkage(linkages[j])) {
|
||||||
|
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
||||||
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
|
try {
|
||||||
|
IBinding[] part = fFragments[i].findBindings(patterns, isFullyQualified, retargetFilter(linkages[j], filter), new SubProgressMonitor(monitor, 1));
|
||||||
|
fragmentBindings[i] = new IIndexFragmentBinding[part.length];
|
||||||
|
System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
|
||||||
}
|
}
|
||||||
monitor.done();
|
|
||||||
return (IIndexBinding[]) result.toArray(new IIndexBinding[result.size()]);
|
|
||||||
}
|
}
|
||||||
|
ICompositesFactory factory = getCompositesFactory(linkages[j].getID());
|
||||||
public IIndexBinding[] findBindings(char[] name, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
|
result.add(factory.getCompositeBindings(fragmentBindings));
|
||||||
return findBindings(new char[][]{name}, filter, monitor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexBinding[] findBindings(char[][] names, 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(names, filter, new SubProgressMonitor(monitor, 1))));
|
|
||||||
}
|
}
|
||||||
monitor.done();
|
return flatten(result);
|
||||||
return (IIndexBinding[]) result.toArray(new IIndexBinding[result.size()]);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexName[] findNames(IBinding binding, int flags) throws CoreException {
|
public IIndexName[] findNames(IBinding binding, int flags) throws CoreException {
|
||||||
ArrayList result= new ArrayList();
|
ArrayList result= new ArrayList();
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
IIndexProxyBinding adaptedBinding= fFragments[i].adaptBinding(binding);
|
IIndexFragmentBinding adaptedBinding= fFragments[i].adaptBinding(binding);
|
||||||
if (adaptedBinding != null) {
|
if (adaptedBinding != null) {
|
||||||
result.addAll(Arrays.asList(fFragments[i].findNames(adaptedBinding, flags)));
|
result.addAll(Arrays.asList(fFragments[i].findNames(adaptedBinding, flags)));
|
||||||
}
|
}
|
||||||
|
@ -193,11 +136,18 @@ public class CIndex implements IIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFile getFile(IIndexFileLocation location) throws CoreException {
|
public IIndexFile getFile(IIndexFileLocation location) throws CoreException {
|
||||||
IIndexFile result= null;
|
IIndexFile result= null, backup= null;
|
||||||
for (int i = 0; result==null && i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; result==null && i < fPrimaryFragmentCount; i++) {
|
||||||
result= fFragments[i].getFile(location);
|
IIndexFragmentFile candidate= fFragments[i].getFile(location);
|
||||||
|
if(candidate!=null) {
|
||||||
|
if(candidate.hasNames()) {
|
||||||
|
result = candidate;
|
||||||
}
|
}
|
||||||
return result;
|
if(backup==null)
|
||||||
|
backup = candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result == null ? backup : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFile resolveInclude(IIndexInclude include) throws CoreException {
|
public IIndexFile resolveInclude(IIndexInclude include) throws CoreException {
|
||||||
|
@ -340,45 +290,166 @@ public class CIndex implements IIndex {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] findInNamespace(IBinding nsbinding, char[] name) {
|
public IIndexBinding[] findBindings(char[][] names, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
|
||||||
ArrayList result= new ArrayList();
|
if(SPECIALCASE_SINGLES && fFragments.length==1) {
|
||||||
for (int i = 0; i < fFragments.length; i++) {
|
|
||||||
try {
|
try {
|
||||||
IBinding[] part = fFragments[i].findInNamespace(nsbinding, name);
|
return fFragments[0].findBindings(names, filter, monitor);
|
||||||
for (int j = 0; j < part.length; j++) {
|
|
||||||
IBinding binding = part[j];
|
|
||||||
if (binding instanceof IIndexBinding) {
|
|
||||||
result.add(binding);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!result.isEmpty()) {
|
|
||||||
return (IIndexBinding[]) result.toArray(new IIndexBinding[result.size()]);
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
List result = new ArrayList();
|
||||||
|
ILinkage[] linkages = Linkage.getAllLinkages();
|
||||||
|
monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length * linkages.length);
|
||||||
|
for(int j=0; j < linkages.length; j++) {
|
||||||
|
if(filter.acceptLinkage(linkages[j])) {
|
||||||
|
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
||||||
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
|
try {
|
||||||
|
IBinding[] part = fFragments[i].findBindings(names, retargetFilter(linkages[j], filter), new SubProgressMonitor(monitor, 1));
|
||||||
|
fragmentBindings[i] = new IIndexFragmentBinding[part.length];
|
||||||
|
System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
|
ICompositesFactory factory = getCompositesFactory(linkages[j].getID());
|
||||||
|
result.add(factory.getCompositeBindings(fragmentBindings));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
monitor.done();
|
||||||
|
return flatten(result);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] findBindingsForPrefix(char[] prefix, IndexFilter filter) throws CoreException {
|
public IIndexBinding adaptBinding(IBinding binding) {
|
||||||
ArrayList result= new ArrayList();
|
|
||||||
for (int i = 0; i < fFragments.length; i++) {
|
|
||||||
try {
|
try {
|
||||||
IBinding[] part = fFragments[i].findBindingsForPrefix(prefix, filter);
|
if(SPECIALCASE_SINGLES && fFragments.length==1) {
|
||||||
for (int j = 0; j < part.length; j++) {
|
return fFragments[0].adaptBinding(binding);
|
||||||
IBinding binding = part[j];
|
} else {
|
||||||
if (binding instanceof IIndexBinding) {
|
return getCompositesFactory(binding.getLinkage().getID()).getCompositeBinding(binding);
|
||||||
result.add(binding);
|
}
|
||||||
|
} catch(CoreException ce) {
|
||||||
|
CCorePlugin.log(ce);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IIndexBinding[] findBindings(char[] name, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
|
||||||
|
return findBindings(new char[][]{name}, filter, monitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Non-API
|
||||||
|
*/
|
||||||
|
|
||||||
|
private IIndexBinding[] flatten(List bindingArrays) {
|
||||||
|
int size = 0;
|
||||||
|
for(int i=0; i<bindingArrays.size(); i++) {
|
||||||
|
size += ((IBinding[])bindingArrays.get(i)).length;
|
||||||
|
}
|
||||||
|
IIndexBinding[] result = new IIndexBinding[size];
|
||||||
|
int offset = 0;
|
||||||
|
for(int i=0; i<bindingArrays.size(); i++) {
|
||||||
|
IBinding[] src = (IBinding[]) bindingArrays.get(i);
|
||||||
|
System.arraycopy(src, 0, result, offset, src.length);
|
||||||
|
offset += src.length;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexFragment[] getPrimaryFragments() {
|
||||||
|
IIndexFragment[] result= new IIndexFragment[fPrimaryFragmentCount];
|
||||||
|
System.arraycopy(fFragments, 0, result, 0, fPrimaryFragmentCount);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPrimaryFragment(IIndexFragment frag) {
|
||||||
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
|
if (frag == fFragments[i]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexFragmentBinding[] findEquivalentBindings(IBinding binding) throws CoreException {
|
||||||
|
List result = new ArrayList();
|
||||||
|
for (int i = 0; i < fFragments.length; i++) {
|
||||||
|
IIndexFragmentBinding adapted = fFragments[i].adaptBinding(binding);
|
||||||
|
if (adapted instanceof IIndexFragmentBinding) {
|
||||||
|
result.add(adapted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (IIndexFragmentBinding[]) result.toArray(new IIndexFragmentBinding[result.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ICompositesFactory cppCF, cCF, fCF;
|
||||||
|
private ICompositesFactory getCompositesFactory(String linkageID) {
|
||||||
|
if(linkageID.equals(ILinkage.CPP_LINKAGE_ID)) {
|
||||||
|
if(cppCF==null) {
|
||||||
|
cppCF = new CPPCompositesFactory(new CIndex(fFragments, fFragments.length));
|
||||||
|
}
|
||||||
|
return cppCF;
|
||||||
|
}
|
||||||
|
if(linkageID.equals(ILinkage.C_LINKAGE_ID)) {
|
||||||
|
if(cCF==null) {
|
||||||
|
cCF = new CCompositesFactory(new CIndex(fFragments, fFragments.length));
|
||||||
|
}
|
||||||
|
return cCF;
|
||||||
|
}
|
||||||
|
if(linkageID.equals(ILinkage.FORTRAN_LINKAGE_ID)) {
|
||||||
|
if(fCF==null) {
|
||||||
|
fCF = new CCompositesFactory(new CIndex(fFragments, fFragments.length));
|
||||||
|
}
|
||||||
|
// This is a placeholder - it will throw CompositingNotImplementedError
|
||||||
|
// if non-empty (non-c) results are returned by a fragment
|
||||||
|
return fCF;
|
||||||
|
}
|
||||||
|
throw new CompositingNotImplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
private IndexFilter retargetFilter(final ILinkage linkage, final IndexFilter filter) {
|
||||||
|
return new IndexFilter() {
|
||||||
|
public boolean acceptBinding(IBinding binding) {
|
||||||
|
return filter.acceptBinding(binding);
|
||||||
|
}
|
||||||
|
public boolean acceptImplicitMethods() {
|
||||||
|
return filter.acceptImplicitMethods();
|
||||||
|
};
|
||||||
|
public boolean acceptLinkage(ILinkage other) {
|
||||||
|
return linkage.getID().equals(other.getID());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexBinding[] findBindingsForPrefix(char[] prefix, IndexFilter filter) throws CoreException {
|
||||||
|
if(SPECIALCASE_SINGLES && fFragments.length==1) {
|
||||||
|
return fFragments[0].findBindingsForPrefix(prefix, filter);
|
||||||
|
} else {
|
||||||
|
List result = new ArrayList();
|
||||||
|
ILinkage[] linkages = Linkage.getAllLinkages();
|
||||||
|
for(int j=0; j < linkages.length; j++) {
|
||||||
|
if(filter.acceptLinkage(linkages[j])) {
|
||||||
|
IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
|
||||||
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
|
try {
|
||||||
|
IBinding[] part = fFragments[i].findBindingsForPrefix(prefix, retargetFilter(linkages[j], filter));
|
||||||
|
fragmentBindings[i] = new IIndexFragmentBinding[part.length];
|
||||||
|
System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!result.isEmpty()) {
|
ICompositesFactory factory = getCompositesFactory(linkages[j].getID());
|
||||||
return (IIndexBinding[]) result.toArray(new IIndexBinding[result.size()]);
|
result.add(factory.getCompositeBindings(fragmentBindings));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flatten(result);
|
||||||
}
|
}
|
||||||
return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
@ -94,11 +95,11 @@ final public class EmptyCIndex implements IIndex {
|
||||||
return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
|
return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] findInNamespace(IBinding nsbinding, char[] name) {
|
public IIndexBinding adaptBinding(IBinding binding) {
|
||||||
return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] findBindingsForPrefix(char[] prefix, IndexFilter filter) {
|
public IIndexBinding[] findBindingsForPrefix(char[] prefix, IndexFilter filter) {
|
||||||
return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
|
return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
@ -18,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexLinkage;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -75,7 +77,7 @@ public interface IIndexFragment {
|
||||||
* @return the binding, or <code>null</code>
|
* @return the binding, or <code>null</code>
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
IIndexProxyBinding adaptBinding(IBinding binding) throws CoreException;
|
IIndexFragmentBinding adaptBinding(IBinding binding) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks for a proxy binding matching the given one. May return <code>null</code>, if no
|
* Looks for a proxy binding matching the given one. May return <code>null</code>, if no
|
||||||
|
@ -84,7 +86,7 @@ public interface IIndexFragment {
|
||||||
* @return the binding, or <code>null</code>
|
* @return the binding, or <code>null</code>
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
IIndexProxyBinding adaptBinding(IIndexProxyBinding proxy) throws CoreException;
|
IIndexFragmentBinding adaptBinding(IIndexFragmentBinding proxy) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks for a binding of the given name from the AST. May return <code>null</code>, if no
|
* Looks for a binding of the given name from the AST. May return <code>null</code>, if no
|
||||||
|
@ -93,7 +95,7 @@ public interface IIndexFragment {
|
||||||
* @return the binding for the name, or <code>null</code>
|
* @return the binding for the name, or <code>null</code>
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
IIndexProxyBinding findBinding(IASTName astName) throws CoreException;
|
IIndexFragmentBinding findBinding(IASTName astName) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for all bindings with qualified names that seen as an array of simple names match the given array
|
* Searches for all bindings with qualified names that seen as an array of simple names match the given array
|
||||||
|
@ -127,7 +129,7 @@ public interface IIndexFragment {
|
||||||
* @return an array of names
|
* @return an array of names
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
IIndexFragmentName[] findNames(IIndexProxyBinding binding, int flags) throws CoreException;
|
IIndexFragmentName[] findNames(IIndexFragmentBinding binding, int flags) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acquires a read lock.
|
* Acquires a read lock.
|
||||||
|
@ -145,13 +147,14 @@ public interface IIndexFragment {
|
||||||
*/
|
*/
|
||||||
long getLastWriteAccess();
|
long getLastWriteAccess();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all bindings with the given name in the given namespace
|
|
||||||
*/
|
|
||||||
IBinding[] findInNamespace(IBinding nsbinding, char[] name) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all bindings with the given prefix, accepted by the given filter
|
* Returns all bindings with the given prefix, accepted by the given filter
|
||||||
*/
|
*/
|
||||||
IBinding[] findBindingsForPrefix(char[] prefix, IndexFilter filter) throws CoreException;
|
IIndexFragmentBinding[] findBindingsForPrefix(char[] prefix, IndexFilter filter) throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the linkages that are contained in this fragment
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IIndexLinkage[] getLinkages();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,12 +7,31 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public interface IIndexFragmentBinding extends IIndexBinding, IIndexProxyBinding {
|
public interface IIndexFragmentBinding extends Comparable, IIndexBinding {
|
||||||
IIndexFragmentBinding[] EMPTY_INDEX_BINDING_ARRAY= new IIndexFragmentBinding[0];
|
IIndexFragmentBinding[] EMPTY_INDEX_BINDING_ARRAY= new IIndexFragmentBinding[0];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the owner of the binding.
|
||||||
|
*/
|
||||||
|
IIndexFragment getFragment();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the linkage the binding belongs to.
|
||||||
|
*/
|
||||||
|
ILinkage getLinkage() throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this binding has any definitions associated with it
|
||||||
|
* in its associated fragment.
|
||||||
|
*/
|
||||||
|
boolean hasDefinition() throws CoreException;
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
@ -27,4 +28,12 @@ public interface IIndexFragmentFile extends IIndexFile {
|
||||||
*/
|
*/
|
||||||
void setTimestamp(long timestamp) throws CoreException;
|
void setTimestamp(long timestamp) throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether any names are associated with this file object
|
||||||
|
* in this fragment - i.e. whether this file contains content in its
|
||||||
|
* associated fragment
|
||||||
|
* @return whether any names are associated with this file object
|
||||||
|
* in this fragment
|
||||||
|
*/
|
||||||
|
boolean hasNames() throws CoreException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
@ -26,5 +27,5 @@ public interface IIndexFragmentName extends IIndexName {
|
||||||
/**
|
/**
|
||||||
* Returns the (proxy) binding the name resolves to.
|
* Returns the (proxy) binding the name resolves to.
|
||||||
*/
|
*/
|
||||||
IIndexProxyBinding getBinding() throws CoreException;
|
IIndexFragmentBinding getBinding() throws CoreException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,27 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ILinkage;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
|
||||||
public interface IIndexProxyBinding {
|
|
||||||
/**
|
/**
|
||||||
* Returns the owner of the binding.
|
* Interface for scopes returned via the index
|
||||||
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
IIndexFragment getFragment();
|
public interface IIndexScope extends IScope {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the linkage the binding belongs to.
|
* Get the binding associated with scope
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
ILinkage getLinkage() throws CoreException;
|
IIndexBinding getScopeBinding();
|
||||||
|
|
||||||
}
|
}
|
|
@ -90,6 +90,7 @@ public class IndexFactory {
|
||||||
ICProject cproject = projects[i];
|
ICProject cproject = projects[i];
|
||||||
IProject project= cproject.getProject();
|
IProject project= cproject.getProject();
|
||||||
checkAddProject(project, map, projectsToSearch, markWith);
|
checkAddProject(project, map, projectsToSearch, markWith);
|
||||||
|
projectsToSearch.add(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addDependencies || addDependent) {
|
if (addDependencies || addDependent) {
|
||||||
|
@ -156,11 +157,24 @@ public class IndexFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selectedProjects= getProjects(new ICProject[] {project}, true, false, new HashMap(), new Integer(1));
|
||||||
|
selectedProjects.remove(project);
|
||||||
|
ArrayList readOnly= new ArrayList();
|
||||||
|
for (Iterator iter = selectedProjects.iterator(); iter.hasNext(); ) {
|
||||||
|
ICProject cproject = (ICProject) iter.next();
|
||||||
|
IWritableIndexFragment pdom= (IWritableIndexFragment) fPDOMManager.getPDOM(cproject);
|
||||||
|
if (pdom != null) {
|
||||||
|
readOnly.add(pdom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (pdoms.isEmpty()) {
|
if (pdoms.isEmpty()) {
|
||||||
throw new CoreException(CCorePlugin.createStatus(
|
throw new CoreException(CCorePlugin.createStatus(
|
||||||
MessageFormat.format(Messages.IndexFactory_errorNoSuchPDOM0, new Object[]{project.getElementName()})));
|
MessageFormat.format(Messages.IndexFactory_errorNoSuchPDOM0, new Object[]{project.getElementName()})));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new WritableCIndex((IWritableIndexFragment[]) pdoms.toArray(new IWritableIndexFragment[pdoms.size()]), new IIndexFragment[0]);
|
return new WritableCIndex((IWritableIndexFragment[]) pdoms.toArray(new IWritableIndexFragment[pdoms.size()]),
|
||||||
|
(IIndexFragment[]) readOnly.toArray(new IIndexFragment[readOnly.size()]) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite;
|
||||||
|
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
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.internal.core.index.CIndex;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commonality between composite factories
|
||||||
|
*/
|
||||||
|
public abstract class AbstractCompositeFactory implements ICompositesFactory {
|
||||||
|
protected IIndex index;
|
||||||
|
|
||||||
|
public AbstractCompositeFactory(IIndex index) {
|
||||||
|
this.index = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.index.composite.ICompositesFactory#getCompositeBindings(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.internal.core.index.IIndexFragmentBinding[])
|
||||||
|
*/
|
||||||
|
public final IIndexBinding[] getCompositeBindings(IBinding[] bindings) {
|
||||||
|
IIndexBinding[] result = new IIndexBinding[bindings.length];
|
||||||
|
for(int i=0; i<result.length; i++)
|
||||||
|
result[i] = getCompositeBinding(bindings[i]);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getComposites(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.internal.core.index.IIndexFragmentBinding[][])
|
||||||
|
*/
|
||||||
|
public final IIndexBinding[] getCompositeBindings(IIndexFragmentBinding[][] fragmentBindings) {
|
||||||
|
return getCompositeBindings(mergeBindingArrays(fragmentBindings));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method for taking a group of binding arrays, and returning a single array
|
||||||
|
* with the each binding appearing once
|
||||||
|
* @param fragmentBindings
|
||||||
|
* @return an array of unique bindings
|
||||||
|
*/
|
||||||
|
protected static IIndexFragmentBinding[] mergeBindingArrays(IIndexFragmentBinding[][] fragmentBindings) {
|
||||||
|
TreeSet ts = new TreeSet();
|
||||||
|
for(int i=0; i<fragmentBindings.length; i++)
|
||||||
|
for(int j=0; j<fragmentBindings[i].length; j++)
|
||||||
|
ts.add(fragmentBindings[i][j]);
|
||||||
|
return (IIndexFragmentBinding[]) ts.toArray(new IIndexFragmentBinding[ts.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method for finding a binding with a definition in the specified index
|
||||||
|
* context, which is equivalent to the specified binding
|
||||||
|
* @param index
|
||||||
|
* @param binding
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IIndexFragmentBinding findOneDefinition(IBinding binding) {
|
||||||
|
try{
|
||||||
|
CIndex cindex = (CIndex) index;
|
||||||
|
IIndexFragmentBinding[] ibs = cindex.findEquivalentBindings(binding);
|
||||||
|
IBinding def = ibs[0];
|
||||||
|
for(int i=0; i<ibs.length; i++) {
|
||||||
|
if(ibs[i].hasDefinition()) {
|
||||||
|
def = ibs[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (IIndexFragmentBinding) def;
|
||||||
|
} catch(CoreException ce) {
|
||||||
|
CCorePlugin.log(ce);
|
||||||
|
}
|
||||||
|
throw new CompositingNotImplementedError();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
|
|
||||||
|
public class CompositeArrayType extends CompositeType implements IArrayType, ITypeContainer {
|
||||||
|
public CompositeArrayType(IArrayType arrayType, ICompositesFactory cf) {
|
||||||
|
super((ITypeContainer) arrayType, cf);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTExpression getArraySizeExpression() throws DOMException {
|
||||||
|
fail(); return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a binding which is split over several index fragments.
|
||||||
|
* <p>
|
||||||
|
* Like the component IIndexBinding objects that make up a CompositeIndexBinding, the
|
||||||
|
* it is only valid to call methods and obtain information while a read-lock is held on the
|
||||||
|
* associated IIndex
|
||||||
|
*/
|
||||||
|
public abstract class CompositeIndexBinding implements IIndexBinding {
|
||||||
|
/**
|
||||||
|
* The factory used for obtaining further composite bindings
|
||||||
|
*/
|
||||||
|
protected final ICompositesFactory cf;
|
||||||
|
/**
|
||||||
|
* The representative binding for this composite binding. Most cases are simple
|
||||||
|
* enough that this becomes a delegate, some need to use it as a search key over fragments,
|
||||||
|
* and some ignore it as a representative binding from each fragment is needed to meet interface
|
||||||
|
* contracts.
|
||||||
|
*/
|
||||||
|
protected final IBinding rbinding;
|
||||||
|
|
||||||
|
public CompositeIndexBinding(ICompositesFactory cf, IBinding rbinding) {
|
||||||
|
if(rbinding == null || cf == null)
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
this.cf = cf;
|
||||||
|
this.rbinding = rbinding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ILinkage getLinkage() throws CoreException {
|
||||||
|
return rbinding.getLinkage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return rbinding.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public char[] getNameCharArray() {
|
||||||
|
return rbinding.getNameCharArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getAdapter(Class adapter) {
|
||||||
|
fail();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getQualifiedName() {
|
||||||
|
return new String[] {getName()};
|
||||||
|
}
|
||||||
|
|
||||||
|
public IScope getScope() throws DOMException {
|
||||||
|
return cf.getCompositeScope(rbinding.getScope());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasDefinition() throws CoreException {
|
||||||
|
fail(); return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void fail() {
|
||||||
|
throw new CompositingNotImplementedError("Compositing feature not implemented"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return rbinding.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFileLocal() throws CoreException {
|
||||||
|
return rbinding instanceof IIndexBinding ? ((IIndexBinding)rbinding).isFileLocal() : true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
|
|
||||||
|
public class CompositePointerType extends CompositeType implements IPointerType, ITypeContainer {
|
||||||
|
public CompositePointerType(IPointerType pointerType, ICompositesFactory cf) throws DOMException {
|
||||||
|
super((ITypeContainer) pointerType, cf);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isConst() throws DOMException {
|
||||||
|
return ((IPointerType)type).isConst();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVolatile() throws DOMException {
|
||||||
|
return ((IPointerType)type).isVolatile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSameType(IType other) {
|
||||||
|
return ((IPointerType)type).isSameType(other);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
|
|
||||||
|
public class CompositeQualifierType extends CompositeType implements IQualifierType, ITypeContainer {
|
||||||
|
public CompositeQualifierType(IQualifierType qualifierType, ICompositesFactory cf) throws DOMException {
|
||||||
|
super((ITypeContainer) qualifierType, cf);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isConst() throws DOMException {
|
||||||
|
return ((IQualifierType)type).isConst();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVolatile() throws DOMException {
|
||||||
|
return ((IQualifierType)type).isVolatile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSameType(IType other) {
|
||||||
|
return ((IQualifierType)type).isSameType(other);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||||
|
|
||||||
|
public abstract class CompositeScope implements IIndexScope {
|
||||||
|
/**
|
||||||
|
* The factory used for obtaining further composite bindings
|
||||||
|
*/
|
||||||
|
protected final ICompositesFactory cf;
|
||||||
|
/**
|
||||||
|
* The representative binding for this composite binding. Most cases are simple
|
||||||
|
* enough that this becomes a delegate, some need to use it as a search key over fragments,
|
||||||
|
* and some ignore it as a representative binding from each fragment is needed to meet interface
|
||||||
|
* contracts.
|
||||||
|
*/
|
||||||
|
protected final IBinding rbinding;
|
||||||
|
|
||||||
|
public CompositeScope(ICompositesFactory cf, IBinding rbinding) {
|
||||||
|
if(cf==null || rbinding==null)
|
||||||
|
throw new NullPointerException();
|
||||||
|
this.cf = cf;
|
||||||
|
this.rbinding = rbinding;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public IScope getParent() throws DOMException {
|
||||||
|
IScope rscope = rbinding.getScope();
|
||||||
|
if(rscope!=null) {
|
||||||
|
return cf.getCompositeScope(rscope);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: for c++ namespaces we are returning an arbitrary name
|
||||||
|
final public IName getScopeName() throws DOMException {
|
||||||
|
IScope scope = rbinding.getScope();
|
||||||
|
if(scope==null)
|
||||||
|
return null;
|
||||||
|
return scope.getScopeName();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void fail() {
|
||||||
|
throw new CompositingNotImplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public IBinding getRawScopeBinding() {
|
||||||
|
return rbinding;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an index-contexting carrying type
|
||||||
|
*/
|
||||||
|
public abstract class CompositeType implements IType, IIndexType, ITypeContainer {
|
||||||
|
protected final ITypeContainer type;
|
||||||
|
protected final ICompositesFactory cf;
|
||||||
|
|
||||||
|
protected CompositeType(ITypeContainer rtype, ICompositesFactory cf) {
|
||||||
|
this.type = rtype;
|
||||||
|
this.cf = cf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSameType(IType other) {
|
||||||
|
return type.isSameType(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object clone() {
|
||||||
|
fail(); return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setType(IType type) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final IType getType() throws DOMException {
|
||||||
|
return cf.getCompositeType(type.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fail() {
|
||||||
|
throw new CompositingNotImplementedError("Compositing feature (for IType) not implemented"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite;
|
||||||
|
|
||||||
|
public class CompositingNotImplementedError extends Error {
|
||||||
|
private static final long serialVersionUID = -7296443480526626589L;
|
||||||
|
|
||||||
|
public CompositingNotImplementedError() {
|
||||||
|
super();
|
||||||
|
printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompositingNotImplementedError(String msg) {
|
||||||
|
super(msg);
|
||||||
|
printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
|
||||||
|
public interface ICompositesFactory {
|
||||||
|
|
||||||
|
public IScope getCompositeScope(IScope rscope) throws DOMException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a composite (in the sense of potentially spanning multiple index fragments - i.e. not to be confused
|
||||||
|
* with ICompositeType) type for the specified type.
|
||||||
|
* @param index
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IType getCompositeType(IType rtype) throws DOMException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a composite (index context carrying) binding for the specified binding. It does not
|
||||||
|
* matter which fragment the specified binding comes from
|
||||||
|
* @param index the context to construct the composite binding for
|
||||||
|
* @param binding a binding that will be used when searching for information to return from the composite
|
||||||
|
* binding methods
|
||||||
|
* @return a composite (index context carrying) binding for the specified binding
|
||||||
|
*/
|
||||||
|
public IIndexBinding getCompositeBinding(IBinding binding);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A convenience method that operates as getCompositeBinding but over the contents of an array
|
||||||
|
* @param index the context to construct the composite binding for
|
||||||
|
* @param bindings an array of composite bindings to use when pair-wise constructing the result via getCompositeBinding
|
||||||
|
* @return an array of composite bindings pair-wise constructed via getCompositeBinding
|
||||||
|
*/
|
||||||
|
public IIndexBinding[] getCompositeBindings(IBinding[] bindings);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifies common bindings, calls getCompositeBindings
|
||||||
|
* @param index
|
||||||
|
* @param bindings
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IIndexBinding[] getCompositeBindings(IIndexFragmentBinding[][] bindings);
|
||||||
|
}
|
|
@ -0,0 +1,125 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
|
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.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
|
||||||
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.AbstractCompositeFactory;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositeArrayType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositePointerType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositeQualifierType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositingNotImplementedError;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
public class CCompositesFactory extends AbstractCompositeFactory implements ICompositesFactory {
|
||||||
|
|
||||||
|
public CCompositesFactory(IIndex index) {
|
||||||
|
super(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeScope(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IScope)
|
||||||
|
*/
|
||||||
|
public IScope getCompositeScope(IScope rscope) {
|
||||||
|
if(rscope==null)
|
||||||
|
return null;
|
||||||
|
if(rscope instanceof ICCompositeTypeScope) {
|
||||||
|
try {
|
||||||
|
ICCompositeTypeScope cscope = (ICCompositeTypeScope) rscope;
|
||||||
|
IIndexFragmentBinding rbinding = (IIndexFragmentBinding) cscope.getCompositeType();
|
||||||
|
return ((ICompositeType)getCompositeBinding(rbinding)).getCompositeScope();
|
||||||
|
} catch(DOMException de) {
|
||||||
|
CCorePlugin.log(de);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new CompositingNotImplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeType(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IType)
|
||||||
|
*/
|
||||||
|
public IType getCompositeType(IType rtype) throws DOMException {
|
||||||
|
IType result;
|
||||||
|
|
||||||
|
if(rtype==null) {
|
||||||
|
result = null;
|
||||||
|
} else if(rtype instanceof ICompositeType) {
|
||||||
|
result = (ICompositeType) getCompositeBinding((IIndexFragmentBinding) rtype);
|
||||||
|
} else if (rtype instanceof IEnumeration) {
|
||||||
|
result = (IEnumeration) getCompositeBinding((IIndexFragmentBinding) rtype);
|
||||||
|
} else if(rtype instanceof IPointerType) {
|
||||||
|
result = new CompositePointerType((IPointerType)rtype, this);
|
||||||
|
} else if(rtype instanceof IQualifierType) {
|
||||||
|
result = new CompositeQualifierType((IQualifierType) rtype, this);
|
||||||
|
} else if(rtype instanceof IArrayType) {
|
||||||
|
result = new CompositeArrayType((IArrayType) rtype, this);
|
||||||
|
} else if(rtype instanceof ITypedef) {
|
||||||
|
result = new CompositeCTypedef(this, (IIndexFragmentBinding) rtype);
|
||||||
|
} else if(rtype instanceof IBasicType) {
|
||||||
|
result = rtype; // no context required its a leaf with no way to traverse upward
|
||||||
|
} else {
|
||||||
|
throw new CompositingNotImplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeBinding(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IBinding)
|
||||||
|
*/
|
||||||
|
public IIndexBinding getCompositeBinding(IBinding rbinding) {
|
||||||
|
IIndexBinding result;
|
||||||
|
|
||||||
|
if(rbinding==null) {
|
||||||
|
result = null;
|
||||||
|
} else if(rbinding instanceof IParameter) {
|
||||||
|
result = new CompositeCParameter(this, rbinding);
|
||||||
|
} else if(rbinding instanceof IField) {
|
||||||
|
result = new CompositeCField(this, rbinding);
|
||||||
|
} else if(rbinding instanceof IVariable) {
|
||||||
|
result = new CompositeCVariable(this, rbinding);
|
||||||
|
} else if(rbinding instanceof ICompositeType) {
|
||||||
|
result = new CompositeCStructure(this, findOneDefinition(rbinding));
|
||||||
|
} else if(rbinding instanceof IEnumeration) {
|
||||||
|
result = new CompositeCEnumeration(this, findOneDefinition(rbinding));
|
||||||
|
} else if(rbinding instanceof IFunction) {
|
||||||
|
result = new CompositeCFunction(this, rbinding);
|
||||||
|
} else if(rbinding instanceof IEnumerator) {
|
||||||
|
result = new CompositeCEnumerator(this, rbinding);
|
||||||
|
} else if(rbinding instanceof ITypedef) {
|
||||||
|
result = new CompositeCTypedef(this, rbinding);
|
||||||
|
} else {
|
||||||
|
throw new CompositingNotImplementedError("composite binding unavailable for "+rbinding+" "+rbinding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositeIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
abstract class CompositeCBinding extends CompositeIndexBinding {
|
||||||
|
public CompositeCBinding(ICompositesFactory cf, IBinding rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositeScope;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositingNotImplementedError;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCCompositeScope extends CompositeScope implements ICCompositeTypeScope {
|
||||||
|
|
||||||
|
public CompositeCCompositeScope(ICompositesFactory cf, IBinding rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding getBinding(char[] name) throws DOMException {
|
||||||
|
fail(); return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICompositeType getCompositeType() {
|
||||||
|
return (ICompositeType) cf.getCompositeBinding(rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
|
||||||
|
IBinding binding = ((ICompositeType)rbinding).getCompositeScope().getBinding(name, resolve);
|
||||||
|
if(binding instanceof IIndexFragmentBinding) {
|
||||||
|
IIndexFragmentBinding preresult = (IIndexFragmentBinding) binding;
|
||||||
|
return cf.getCompositeBinding(preresult);
|
||||||
|
}
|
||||||
|
if(binding!=null && !(binding instanceof IProblemBinding)) {
|
||||||
|
throw new CompositingNotImplementedError(binding.getClass().toString());
|
||||||
|
}
|
||||||
|
return binding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding[] find(String name, boolean prefixLookup)
|
||||||
|
throws DOMException {
|
||||||
|
IBinding[] preresult = ((ICompositeType)rbinding).getCompositeScope().find(name, prefixLookup);
|
||||||
|
return cf.getCompositeBindings(preresult);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding[] find(String name) throws DOMException {
|
||||||
|
IBinding[] preresult = ((ICompositeType)rbinding).getCompositeScope().find(name);
|
||||||
|
return cf.getCompositeBindings(preresult);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexBinding getScopeBinding() {
|
||||||
|
return (IIndexBinding) getCompositeType();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCEnumeration extends CompositeCBinding implements IIndexBinding, IEnumeration, IIndexType {
|
||||||
|
public CompositeCEnumeration(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator[] getEnumerators() throws DOMException {
|
||||||
|
IEnumerator[] result = ((IEnumeration)rbinding).getEnumerators();
|
||||||
|
for(int i=0; i<result.length; i++)
|
||||||
|
result[i] = (IEnumerator) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSameType(IType type) {
|
||||||
|
return ((IEnumeration)rbinding).isSameType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object clone() {fail(); return null;}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCEnumerator extends CompositeCBinding implements IIndexBinding, IEnumerator {
|
||||||
|
public CompositeCEnumerator(ICompositesFactory cf, IBinding rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IType getType() throws DOMException {
|
||||||
|
return cf.getCompositeType(((IEnumerator)rbinding).getType());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||||
|
|
||||||
|
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.IField;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCField extends CompositeCVariable implements IIndexBinding, IField {
|
||||||
|
public CompositeCField(ICompositesFactory cf, IBinding rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICompositeType getCompositeTypeOwner() throws DOMException {
|
||||||
|
IBinding preresult = ((IField)rbinding).getCompositeTypeOwner();
|
||||||
|
return (ICompositeType) cf.getCompositeBinding(preresult);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCFunction extends CompositeCBinding implements IIndexBinding, IFunction {
|
||||||
|
|
||||||
|
public CompositeCFunction(ICompositesFactory cf, IBinding rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IScope getFunctionScope() throws DOMException {fail(); return null;}
|
||||||
|
|
||||||
|
public IParameter[] getParameters() throws DOMException {
|
||||||
|
IParameter[] preResult = ((IFunction)rbinding).getParameters();
|
||||||
|
IParameter[] result = new IParameter[preResult.length];
|
||||||
|
for(int i=0; i<preResult.length; i++) {
|
||||||
|
result[i] = (IParameter) cf.getCompositeBinding((IIndexFragmentBinding) preResult[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IFunctionType getType() throws DOMException {
|
||||||
|
/* @see PDOMCFunction.getType() */
|
||||||
|
return new IFunctionType() {
|
||||||
|
public IType[] getParameterTypes() throws DOMException {
|
||||||
|
IType[] preresult = ((IFunctionType)rbinding).getParameterTypes();
|
||||||
|
IType[] result = new IType[preresult.length];
|
||||||
|
for(int i=0; i<preresult.length; i++) {
|
||||||
|
assert preresult!=null;
|
||||||
|
result[i] = cf.getCompositeType(preresult[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IType getReturnType() throws DOMException {
|
||||||
|
IType type = ((IFunctionType)rbinding).getReturnType();
|
||||||
|
return cf.getCompositeType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSameType(IType type) {
|
||||||
|
return ((IFunctionType)rbinding).isSameType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object clone() {fail(); return null;}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAuto() throws DOMException {
|
||||||
|
return ((IFunction)rbinding).isAuto();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExtern() throws DOMException {
|
||||||
|
return ((IFunction)rbinding).isExtern();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInline() throws DOMException {
|
||||||
|
return ((IFunction)rbinding).isInline();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRegister() throws DOMException {
|
||||||
|
return ((IFunction)rbinding).isRegister();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStatic() throws DOMException {
|
||||||
|
return ((IFunction)rbinding).isStatic();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean takesVarArgs() throws DOMException {
|
||||||
|
return ((IFunction)rbinding).takesVarArgs();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCParameter extends CompositeCBinding implements IIndexBinding, IParameter {
|
||||||
|
|
||||||
|
public CompositeCParameter(ICompositesFactory cf, IBinding rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IType getType() throws DOMException {
|
||||||
|
IType rtype = ((IEnumerator)rbinding).getType();
|
||||||
|
return cf.getCompositeType(rtype);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAuto() throws DOMException {
|
||||||
|
return ((IParameter)rbinding).isAuto();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExtern() throws DOMException {
|
||||||
|
return ((IParameter)rbinding).isExtern();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRegister() throws DOMException {
|
||||||
|
return ((IParameter)rbinding).isRegister();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStatic() throws DOMException {
|
||||||
|
return ((IParameter)rbinding).isStatic();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||||
|
|
||||||
|
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.IField;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCStructure extends CompositeCBinding implements IIndexBinding, ICompositeType, IIndexType {
|
||||||
|
|
||||||
|
public CompositeCStructure(ICompositesFactory cf, IBinding rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IField findField(String name) throws DOMException {
|
||||||
|
IField preresult = ((ICompositeType)rbinding).findField(name);
|
||||||
|
return (IField) cf.getCompositeBinding((IIndexFragmentBinding) preresult);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IScope getCompositeScope() throws DOMException {
|
||||||
|
return new CompositeCCompositeScope(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IField[] getFields() throws DOMException {
|
||||||
|
IField[] result = ((ICompositeType)rbinding).getFields();
|
||||||
|
for(int i=0; i<result.length; i++)
|
||||||
|
result[i] = (IField) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getKey() throws DOMException {
|
||||||
|
return ((ICompositeType)rbinding).getKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSameType(IType type) {
|
||||||
|
return ((ICompositeType)rbinding).isSameType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object clone() {fail(); return null;}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCTypedef extends CompositeCBinding implements ITypedef, IIndexType, ITypeContainer {
|
||||||
|
public CompositeCTypedef(ICompositesFactory cf, IBinding rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IType getType() throws DOMException {
|
||||||
|
IType type = ((ITypedef)rbinding).getType();
|
||||||
|
return cf.getCompositeType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSameType(IType type) {
|
||||||
|
return ((ITypedef)rbinding).isSameType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object clone() {
|
||||||
|
fail(); return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(IType type) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCVariable extends CompositeCBinding implements IIndexBinding, IVariable {
|
||||||
|
|
||||||
|
public CompositeCVariable(ICompositesFactory cf, IBinding rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IType getType() throws DOMException {
|
||||||
|
IType rtype = ((IVariable)rbinding).getType();
|
||||||
|
return cf.getCompositeType(rtype);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAuto() throws DOMException {
|
||||||
|
return ((IVariable)rbinding).isAuto();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExtern() throws DOMException {
|
||||||
|
return ((IVariable)rbinding).isExtern();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRegister() throws DOMException {
|
||||||
|
return ((IVariable)rbinding).isRegister();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStatic() throws DOMException {
|
||||||
|
return ((IVariable)rbinding).isStatic();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,175 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||||
|
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.ICPPConstructor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||||
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.CIndex;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentName;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.AbstractCompositeFactory;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositeArrayType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositePointerType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositeQualifierType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositingNotImplementedError;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
public class CPPCompositesFactory extends AbstractCompositeFactory implements ICompositesFactory {
|
||||||
|
|
||||||
|
public CPPCompositesFactory(IIndex index) {
|
||||||
|
super(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeScope(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IScope)
|
||||||
|
*/
|
||||||
|
public IScope getCompositeScope(IScope rscope) throws DOMException {
|
||||||
|
IScope result;
|
||||||
|
|
||||||
|
if(rscope == null) {
|
||||||
|
return null;
|
||||||
|
} else if(rscope instanceof ICPPClassScope) {
|
||||||
|
ICPPClassScope classScope = (ICPPClassScope) rscope;
|
||||||
|
result = new CompositeCPPClassScope(this,
|
||||||
|
findOneDefinition(classScope.getClassType()));
|
||||||
|
} else if(rscope instanceof ICPPNamespaceScope) {
|
||||||
|
ICPPNamespaceScope nScope = (ICPPNamespaceScope) rscope;
|
||||||
|
try {
|
||||||
|
IBinding binding = ((IIndexFragmentName) nScope.getScopeName()).getBinding();
|
||||||
|
result = ((ICPPNamespace)binding).getNamespaceScope();
|
||||||
|
} catch(CoreException ce) {
|
||||||
|
CCorePlugin.log(ce);
|
||||||
|
throw new CompositingNotImplementedError(ce.getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new CompositingNotImplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeType(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IType)
|
||||||
|
*/
|
||||||
|
public IType getCompositeType(IType rtype) throws DOMException {
|
||||||
|
IType result;
|
||||||
|
|
||||||
|
if(rtype instanceof ICPPClassType) {
|
||||||
|
result = (ICPPClassType) getCompositeBinding((IIndexFragmentBinding) rtype);
|
||||||
|
} else if(rtype instanceof ITypedef) {
|
||||||
|
result = new CompositeCPPTypedef(this, (ICPPBinding) rtype);
|
||||||
|
} else if (rtype instanceof IEnumeration) {
|
||||||
|
result = (IEnumeration) getCompositeBinding((IIndexFragmentBinding) rtype);
|
||||||
|
} else if(rtype instanceof ICPPPointerToMemberType) {
|
||||||
|
result = new CompositeCPPPointerToMemberType(this, (ICPPPointerToMemberType)rtype);
|
||||||
|
} else if(rtype instanceof IPointerType) {
|
||||||
|
result = new CompositePointerType((IPointerType)rtype, this);
|
||||||
|
} else if(rtype instanceof ICPPReferenceType) {
|
||||||
|
result = new CompositeCPPReferenceType((ICPPReferenceType)rtype, this);
|
||||||
|
} else if(rtype instanceof IQualifierType) {
|
||||||
|
result = new CompositeQualifierType((IQualifierType) rtype, this);
|
||||||
|
} else if(rtype instanceof IArrayType) {
|
||||||
|
result = new CompositeArrayType((IArrayType) rtype, this);
|
||||||
|
} else if(rtype == null) {
|
||||||
|
result = null;
|
||||||
|
} else if(rtype instanceof IBasicType) {
|
||||||
|
result = rtype; // no context required its a leaf with no way to traverse upward
|
||||||
|
} else {
|
||||||
|
throw new CompositingNotImplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ICPPNamespace[] getNamespaces(IBinding rbinding) throws CoreException {
|
||||||
|
CIndex cindex = (CIndex) index;
|
||||||
|
IIndexBinding[] ibs = cindex.findEquivalentBindings(rbinding);
|
||||||
|
ICPPNamespace[] namespaces = new ICPPNamespace[ibs.length];
|
||||||
|
for(int i=0; i<namespaces.length; i++)
|
||||||
|
namespaces[i] = (ICPPNamespace) ibs[i];
|
||||||
|
return namespaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeBinding(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IBinding)
|
||||||
|
*/
|
||||||
|
public IIndexBinding getCompositeBinding(IBinding binding) {
|
||||||
|
IIndexBinding result;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(binding==null) {
|
||||||
|
result = null;
|
||||||
|
} else if(binding instanceof ICPPParameter) {
|
||||||
|
result = new CompositeCPPParameter(this, (ICPPParameter) binding);
|
||||||
|
} else if(binding instanceof ICPPField) {
|
||||||
|
result = new CompositeCPPField(this, (ICPPField) binding);
|
||||||
|
} else if(binding instanceof ICPPVariable) {
|
||||||
|
result = new CompositeCPPVariable(this, (ICPPVariable) binding);
|
||||||
|
} else if(binding instanceof ICPPClassType) {
|
||||||
|
ICPPClassType def = (ICPPClassType) findOneDefinition(binding);
|
||||||
|
result = def == null ? null : new CompositeCPPClassType(this, def);
|
||||||
|
} else if(binding instanceof ICPPConstructor) {
|
||||||
|
result = new CompositeCPPConstructor(this, (ICPPConstructor) binding);
|
||||||
|
} else if(binding instanceof ICPPMethod) {
|
||||||
|
result = new CompositeCPPMethod(this, (ICPPMethod) binding);
|
||||||
|
} else if(binding instanceof ICPPNamespaceAlias) {
|
||||||
|
result = new CompositeCPPNamespaceAlias(this, (ICPPNamespaceAlias) binding);
|
||||||
|
} else if(binding instanceof ICPPNamespace) {
|
||||||
|
ICPPNamespace[] ns = getNamespaces(binding);
|
||||||
|
result = ns.length == 0 ? null : new CompositeCPPNamespace(this, ns);
|
||||||
|
} else if(binding instanceof IEnumeration) {
|
||||||
|
IEnumeration def = (IEnumeration) findOneDefinition(binding);
|
||||||
|
result = def == null ? null : new CompositeCPPEnumeration(this, def);
|
||||||
|
} else if(binding instanceof ICPPFunction) {
|
||||||
|
result = new CompositeCPPFunction(this, (ICPPFunction) binding);
|
||||||
|
} else if(binding instanceof IEnumerator) {
|
||||||
|
result = new CompositeCPPEnumerator(this, (IEnumerator) binding);
|
||||||
|
} else if(binding instanceof ITypedef) {
|
||||||
|
result = new CompositeCPPTypedef(this, (ICPPBinding) binding);
|
||||||
|
} else {
|
||||||
|
throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
} catch(CoreException ce) {
|
||||||
|
CCorePlugin.log(ce);
|
||||||
|
throw new CompositingNotImplementedError(ce.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositeIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
abstract class CompositeCPPBinding extends CompositeIndexBinding implements ICPPBinding {
|
||||||
|
public CompositeCPPBinding(ICompositesFactory cf, ICPPBinding rbinding) {
|
||||||
|
super(cf, (IIndexFragmentBinding) rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasQualifiedName(char[][] qname) {
|
||||||
|
boolean result = true;
|
||||||
|
try {
|
||||||
|
char[][] myQN = getQualifiedNameCharArray();
|
||||||
|
result &= qname.length == myQN.length;
|
||||||
|
for(int i=0; result && i<qname.length; i++) {
|
||||||
|
char[] qnamePart = qname[i];
|
||||||
|
result &= Arrays.equals(qnamePart, myQN[i]);
|
||||||
|
}
|
||||||
|
} catch(DOMException de) {
|
||||||
|
CCorePlugin.log(de);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getQualifiedName() {
|
||||||
|
try {
|
||||||
|
return ((ICPPBinding)rbinding).getQualifiedName();
|
||||||
|
} catch(DOMException de) {
|
||||||
|
CCorePlugin.log(de);
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||||
|
return ((ICPPBinding)rbinding).getQualifiedNameCharArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGloballyQualified() throws DOMException {
|
||||||
|
return ((ICPPBinding)rbinding).isGloballyQualified();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
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.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
|
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.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPCompositeBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositeScope;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositingNotImplementedError;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPClassScope extends CompositeScope implements ICPPClassScope {
|
||||||
|
public CompositeCPPClassScope(ICompositesFactory cf, IBinding rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPClassType getClassType() {
|
||||||
|
return (ICPPClassType) cf.getCompositeBinding(rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getImplicitMethods() {
|
||||||
|
try {
|
||||||
|
ICPPClassScope rscope = (ICPPClassScope) ((ICPPClassType)rbinding).getCompositeScope();
|
||||||
|
ICPPMethod[] result = rscope.getImplicitMethods();
|
||||||
|
for(int i=0; i<result.length; i++) {
|
||||||
|
result[i] = (ICPPMethod) cf.getCompositeBinding(result[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} catch (DOMException de) {
|
||||||
|
CCorePlugin.log(de);
|
||||||
|
}
|
||||||
|
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
|
||||||
|
IBinding binding = ((ICPPClassType)rbinding).getCompositeScope().getBinding(name, resolve);
|
||||||
|
if(binding instanceof IIndexFragmentBinding) {
|
||||||
|
return cf.getCompositeBinding((IIndexFragmentBinding) binding);
|
||||||
|
}
|
||||||
|
if(binding instanceof CPPCompositeBinding /* AST composite */) {
|
||||||
|
return new CPPCompositeBinding(
|
||||||
|
cf.getCompositeBindings(((CPPCompositeBinding)binding).getBindings())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if(binding!=null && !(binding instanceof IProblemBinding)) {
|
||||||
|
throw new CompositingNotImplementedError(binding.getClass().toString());
|
||||||
|
}
|
||||||
|
return binding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding[] find(String name, boolean prefixLookup)
|
||||||
|
throws DOMException {
|
||||||
|
IBinding[] preresult = ((ICPPClassType)rbinding).getCompositeScope().find(name, prefixLookup);
|
||||||
|
return cf.getCompositeBindings(preresult);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding[] find(String name) throws DOMException {
|
||||||
|
IBinding[] preresult = ((ICPPClassType)rbinding).getCompositeScope().find(name);
|
||||||
|
return cf.getCompositeBindings(preresult);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexBinding getScopeBinding() {
|
||||||
|
return (IIndexBinding) getClassType();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,149 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType, IIndexType {
|
||||||
|
public CompositeCPPClassType(ICompositesFactory cf, ICPPClassType rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object clone() {
|
||||||
|
fail(); return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IField findField(String name) throws DOMException {
|
||||||
|
IField preResult = ((ICPPClassType)rbinding).findField(name);
|
||||||
|
return (IField) cf.getCompositeBinding(preResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
|
||||||
|
ICPPMethod[] preResult = ((ICPPClassType)rbinding).getAllDeclaredMethods();
|
||||||
|
ICPPMethod[] result = new ICPPMethod[preResult.length];
|
||||||
|
for(int i=0; i<preResult.length; i++) {
|
||||||
|
result[i] = (ICPPMethod) cf.getCompositeBinding(preResult[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPBase[] getBases() throws DOMException {
|
||||||
|
final ICPPBase[] preresult = ((ICPPClassType)rbinding).getBases();
|
||||||
|
ICPPBase[] result = new ICPPBase[preresult.length];
|
||||||
|
for(int i=0; i<preresult.length; i++) {
|
||||||
|
final int n = i;
|
||||||
|
result[i] = new ICPPBase() {
|
||||||
|
public IBinding getBaseClass() throws DOMException {
|
||||||
|
return cf.getCompositeBinding(preresult[n].getBaseClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVisibility() throws DOMException {
|
||||||
|
return preresult[n].getVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVirtual() throws DOMException {
|
||||||
|
return preresult[n].isVirtual();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IName getBaseClassSpecifierName() {
|
||||||
|
return preresult[n].getBaseClassSpecifierName();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPConstructor[] getConstructors() throws DOMException {
|
||||||
|
ICPPConstructor[] preResult = ((ICPPClassType)rbinding).getConstructors();
|
||||||
|
ICPPConstructor[] result = new ICPPConstructor[preResult.length];
|
||||||
|
for(int i=0; i<preResult.length; i++) {
|
||||||
|
result[i] = (ICPPConstructor) cf.getCompositeBinding(preResult[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPField[] getDeclaredFields() throws DOMException {
|
||||||
|
ICPPField[] preResult = ((ICPPClassType)rbinding).getDeclaredFields();
|
||||||
|
ICPPField[] result = new ICPPField[preResult.length];
|
||||||
|
for(int i=0; i<preResult.length; i++) {
|
||||||
|
result[i] = (ICPPField) cf.getCompositeBinding(preResult[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getDeclaredMethods() throws DOMException {
|
||||||
|
ICPPMethod[] preResult = ((ICPPClassType)rbinding).getDeclaredMethods();
|
||||||
|
ICPPMethod[] result = new ICPPMethod[preResult.length];
|
||||||
|
for(int i=0; i<preResult.length; i++) {
|
||||||
|
result[i] = (ICPPMethod) cf.getCompositeBinding(preResult[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IField[] getFields() throws DOMException {
|
||||||
|
IField[] preResult = ((ICPPClassType)rbinding).getFields();
|
||||||
|
IField[] result = new IField[preResult.length];
|
||||||
|
for(int i=0; i<preResult.length; i++) {
|
||||||
|
result[i] = (IField) cf.getCompositeBinding(preResult[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding[] getFriends() throws DOMException {
|
||||||
|
IBinding[] preResult = ((ICPPClassType)rbinding).getFriends();
|
||||||
|
IBinding[] result = new IBinding[preResult.length];
|
||||||
|
for(int i=0; i<preResult.length; i++) {
|
||||||
|
result[i] = cf.getCompositeBinding(preResult[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getMethods() throws DOMException {
|
||||||
|
ICPPMethod[] result = ((ICPPClassType)rbinding).getMethods();
|
||||||
|
for(int i=0; i<result.length; i++) {
|
||||||
|
result[i] = (ICPPMethod) cf.getCompositeBinding(result[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPClassType[] getNestedClasses() throws DOMException {
|
||||||
|
ICPPClassType[] preResult = ((ICPPClassType)rbinding).getNestedClasses();
|
||||||
|
ICPPClassType[] result = new ICPPClassType[preResult.length];
|
||||||
|
for(int i=0; i<preResult.length; i++) {
|
||||||
|
result[i] = (ICPPClassType) cf.getCompositeBinding(preResult[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IScope getCompositeScope() throws DOMException {
|
||||||
|
return new CompositeCPPClassScope(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getKey() throws DOMException {
|
||||||
|
return ((ICPPClassType)rbinding).getKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSameType(IType type) {
|
||||||
|
return ((ICPPClassType)rbinding).isSameType(type);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPConstructor extends CompositeCPPMethod implements ICPPConstructor {
|
||||||
|
public CompositeCPPConstructor(ICompositesFactory cf, ICPPFunction rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExplicit() throws DOMException {
|
||||||
|
return ((ICPPConstructor)rbinding).isExplicit();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPEnumeration extends CompositeCPPBinding implements IEnumeration, IIndexType {
|
||||||
|
public CompositeCPPEnumeration(ICompositesFactory cf, IEnumeration rbinding) {
|
||||||
|
super(cf, (ICPPBinding) rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator[] getEnumerators() throws DOMException {
|
||||||
|
IEnumerator[] result = ((IEnumeration)rbinding).getEnumerators();
|
||||||
|
for(int i=0; i<result.length; i++)
|
||||||
|
result[i] = (IEnumerator) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSameType(IType type) {
|
||||||
|
return ((IEnumeration)rbinding).isSameType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object clone() { fail(); return null; }
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPEnumerator extends CompositeCPPBinding implements IEnumerator {
|
||||||
|
public CompositeCPPEnumerator(ICompositesFactory cf, IEnumerator rbinding) {
|
||||||
|
super(cf, (ICPPBinding) rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IType getType() throws DOMException {
|
||||||
|
IType type = ((IEnumerator)rbinding).getType();
|
||||||
|
return cf.getCompositeType(type);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
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.IField;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPField extends CompositeCPPVariable implements ICPPField {
|
||||||
|
public CompositeCPPField(ICompositesFactory cf, ICPPField rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPClassType getClassOwner() throws DOMException {
|
||||||
|
IIndexFragmentBinding rowner = (IIndexFragmentBinding) ((ICPPField)rbinding).getClassOwner();
|
||||||
|
return (ICPPClassType) cf.getCompositeBinding(rowner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVisibility() throws DOMException {
|
||||||
|
return ((ICPPField)rbinding).getVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICompositeType getCompositeTypeOwner() throws DOMException {
|
||||||
|
IBinding preresult = ((IField)rbinding).getCompositeTypeOwner();
|
||||||
|
return (ICompositeType) cf.getCompositeBinding(preresult);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction, ICPPFunctionType, IIndexType {
|
||||||
|
|
||||||
|
public CompositeCPPFunction(ICompositesFactory cf, ICPPFunction rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInline() throws DOMException {
|
||||||
|
return ((ICPPFunction)rbinding).isInline();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMutable() throws DOMException {
|
||||||
|
return ((ICPPFunction)rbinding).isMutable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IScope getFunctionScope() throws DOMException {
|
||||||
|
fail(); return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IParameter[] getParameters() throws DOMException {
|
||||||
|
IParameter[] result = ((ICPPFunction)rbinding).getParameters();
|
||||||
|
for(int i=0; i<result.length; i++) {
|
||||||
|
result[i] = (IParameter) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IFunctionType getType() throws DOMException {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAuto() throws DOMException {
|
||||||
|
return ((ICPPFunction)rbinding).isAuto();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExtern() throws DOMException {
|
||||||
|
return ((ICPPFunction)rbinding).isExtern();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRegister() throws DOMException {
|
||||||
|
return ((ICPPFunction)rbinding).isRegister();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStatic() throws DOMException {
|
||||||
|
return ((ICPPFunction)rbinding).isStatic();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean takesVarArgs() throws DOMException {
|
||||||
|
return ((ICPPFunction)rbinding).takesVarArgs();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isConst() {
|
||||||
|
return ((ICPPFunctionType)rbinding).isConst();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVolatile() {
|
||||||
|
return ((ICPPFunctionType)rbinding).isVolatile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IType[] getParameterTypes() throws DOMException {
|
||||||
|
IType[] result = ((ICPPFunctionType)rbinding).getParameterTypes();
|
||||||
|
for(int i=0; i<result.length; i++) {
|
||||||
|
result[i] = cf.getCompositeType(result[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IType getReturnType() throws DOMException {
|
||||||
|
return cf.getCompositeType(((ICPPFunctionType)rbinding).getReturnType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSameType(IType type) {
|
||||||
|
return ((ICPPFunctionType)rbinding).isSameType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object clone() {
|
||||||
|
fail(); return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer result = new StringBuffer();
|
||||||
|
try {
|
||||||
|
result.append(getName()+" "+ASTTypeUtil.getParameterTypeString(getType())); //$NON-NLS-1$
|
||||||
|
} catch(DOMException de) {
|
||||||
|
result.append(de);
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPMethod extends CompositeCPPFunction implements ICPPMethod {
|
||||||
|
|
||||||
|
public CompositeCPPMethod(ICompositesFactory cf, ICPPFunction rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDestructor() throws DOMException {
|
||||||
|
return ((ICPPMethod)rbinding).isDestructor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isImplicit() {
|
||||||
|
return ((ICPPMethod)rbinding).isImplicit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVirtual() throws DOMException {
|
||||||
|
return ((ICPPMethod)rbinding).isVirtual();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPClassType getClassOwner() throws DOMException {
|
||||||
|
IIndexFragmentBinding rowner = (IIndexFragmentBinding) ((ICPPMethod)rbinding).getClassOwner();
|
||||||
|
return (ICPPClassType) cf.getCompositeBinding(rowner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVisibility() throws DOMException {
|
||||||
|
return ((ICPPMethod)rbinding).getVisibility();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPNamespace extends CompositeCPPBinding implements ICPPNamespace {
|
||||||
|
ICPPNamespace[] namespaces;
|
||||||
|
public CompositeCPPNamespace(ICompositesFactory cf, ICPPNamespace[] namespaces) {
|
||||||
|
super(cf, namespaces[0]);
|
||||||
|
this.namespaces = namespaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding[] getMemberBindings() throws DOMException {
|
||||||
|
IIndexFragmentBinding[][] memberBindings = new IIndexFragmentBinding[namespaces.length][];
|
||||||
|
for(int i=0; i<namespaces.length; i++) {
|
||||||
|
IBinding[] bindings = namespaces[i].getMemberBindings();
|
||||||
|
memberBindings[i] = new IIndexFragmentBinding[bindings.length];
|
||||||
|
System.arraycopy(bindings, 0, memberBindings[i], 0, bindings.length);
|
||||||
|
}
|
||||||
|
return cf.getCompositeBindings(memberBindings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPNamespaceScope getNamespaceScope() throws DOMException {
|
||||||
|
return new CompositeCPPNamespaceScope(cf, namespaces);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPNamespaceAlias extends CompositeCPPBinding implements ICPPNamespaceAlias {
|
||||||
|
public CompositeCPPNamespaceAlias(ICompositesFactory cf, ICPPNamespaceAlias alias) {
|
||||||
|
super(cf, alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding[] getMemberBindings() throws DOMException {
|
||||||
|
fail(); return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPNamespaceScope getNamespaceScope() throws DOMException {
|
||||||
|
fail(); return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding getBinding() {
|
||||||
|
IIndexFragmentBinding ns = (IIndexFragmentBinding) ((ICPPNamespaceAlias)rbinding).getBinding();
|
||||||
|
return cf.getCompositeBinding(ns);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDelegateType() {
|
||||||
|
fail(); return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositeScope;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPNamespaceScope extends CompositeScope implements ICPPNamespaceScope {
|
||||||
|
ICPPNamespace[] namespaces;
|
||||||
|
|
||||||
|
public CompositeCPPNamespaceScope(ICompositesFactory cf, ICPPNamespace[] namespaces) {
|
||||||
|
super(cf, namespaces[0]);
|
||||||
|
this.namespaces = namespaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addUsingDirective(IASTNode directive) throws DOMException {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTNode[] getUsingDirectives() throws DOMException {
|
||||||
|
return new IASTNode[0]; // same behaviour as PDOMCPPNamespace
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding getBinding(IASTName name, boolean resolve)
|
||||||
|
throws DOMException {
|
||||||
|
IIndexFragmentBinding preresult = null;
|
||||||
|
for(int i=0; preresult==null && i<namespaces.length; i++) {
|
||||||
|
preresult = (IIndexFragmentBinding) namespaces[i].getNamespaceScope().getBinding(name, resolve);
|
||||||
|
}
|
||||||
|
return cf.getCompositeBinding(preresult);
|
||||||
|
}
|
||||||
|
|
||||||
|
final public IBinding[] find(String name) throws DOMException {
|
||||||
|
IIndexFragmentBinding[][] preresult = new IIndexFragmentBinding[namespaces.length][];
|
||||||
|
for(int i=0; i<namespaces.length; i++) {
|
||||||
|
IBinding[] raw = namespaces[i].getNamespaceScope().find(name);
|
||||||
|
preresult[i] = new IIndexFragmentBinding[raw.length];
|
||||||
|
System.arraycopy(raw, 0, preresult[i], 0, raw.length);
|
||||||
|
}
|
||||||
|
return cf.getCompositeBindings(preresult);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding[] find(String name, boolean prefixLookup) throws DOMException {
|
||||||
|
IIndexFragmentBinding[][] preresult = new IIndexFragmentBinding[namespaces.length][];
|
||||||
|
for(int i=0; i<namespaces.length; i++) {
|
||||||
|
IBinding[] raw = namespaces[i].getNamespaceScope().find(name, prefixLookup);
|
||||||
|
preresult[i] = new IIndexFragmentBinding[raw.length];
|
||||||
|
System.arraycopy(raw, 0, preresult[i], 0, raw.length);
|
||||||
|
}
|
||||||
|
return cf.getCompositeBindings(preresult);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexBinding getScopeBinding() {
|
||||||
|
return cf.getCompositeBinding(rbinding);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPParameter extends CompositeCPPVariable implements ICPPParameter {
|
||||||
|
public CompositeCPPParameter(ICompositesFactory cf, ICPPVariable rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasDefaultValue() {
|
||||||
|
return ((ICPPParameter)rbinding).hasDefaultValue();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositePointerType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPPointerToMemberType extends CompositePointerType implements IIndexType, ICPPPointerToMemberType {
|
||||||
|
CompositeCPPPointerToMemberType(ICompositesFactory cf, ICPPPointerToMemberType pointerToMemberType) throws DOMException {
|
||||||
|
super(pointerToMemberType, cf);
|
||||||
|
}
|
||||||
|
public ICPPClassType getMemberOfClass() {
|
||||||
|
IIndexFragmentBinding rbinding = (IIndexFragmentBinding) ((ICPPPointerToMemberType) type).getMemberOfClass();
|
||||||
|
return (ICPPClassType) cf.getCompositeBinding(rbinding);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositeType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPReferenceType extends CompositeType implements ICPPReferenceType {
|
||||||
|
public CompositeCPPReferenceType(ICPPReferenceType referenceType, ICompositesFactory cf) throws DOMException {
|
||||||
|
super((ITypeContainer) referenceType, cf);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPTypedef extends CompositeCPPBinding implements ITypedef, IIndexType, ITypeContainer {
|
||||||
|
public CompositeCPPTypedef(ICompositesFactory cf, ICPPBinding delegate) {
|
||||||
|
super(cf, delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IType getType() throws DOMException {
|
||||||
|
IType type = ((ITypedef)rbinding).getType();
|
||||||
|
return cf.getCompositeType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSameType(IType type) {
|
||||||
|
return ((ITypedef)rbinding).isSameType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object clone() {
|
||||||
|
fail(); return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(IType type) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
class CompositeCPPVariable extends CompositeCPPBinding implements ICPPVariable {
|
||||||
|
|
||||||
|
public CompositeCPPVariable(ICompositesFactory cf, ICPPVariable delegate) {
|
||||||
|
super(cf, delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMutable() throws DOMException {
|
||||||
|
return ((ICPPVariable)rbinding).isMutable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IType getType() throws DOMException {
|
||||||
|
IType rtype = ((ICPPVariable)rbinding).getType();
|
||||||
|
return cf.getCompositeType(rtype);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAuto() throws DOMException {
|
||||||
|
return ((ICPPVariable)rbinding).isAuto();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExtern() throws DOMException {
|
||||||
|
return ((ICPPVariable)rbinding).isExtern();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRegister() throws DOMException {
|
||||||
|
return ((ICPPVariable)rbinding).isRegister();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStatic() throws DOMException {
|
||||||
|
return ((ICPPVariable)rbinding).isStatic();
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom;
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
|
@ -24,20 +25,18 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.core.dom.ILinkage;
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
import org.eclipse.cdt.core.dom.IPDOM;
|
import org.eclipse.cdt.core.dom.IPDOM;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
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.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexLinkage;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexLocationConverter;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
import org.eclipse.cdt.core.index.IIndexName;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
import org.eclipse.cdt.core.model.LanguageManager;
|
import org.eclipse.cdt.core.model.LanguageManager;
|
||||||
|
@ -46,11 +45,9 @@ import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentInclude;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentInclude;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentName;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentName;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexProxyBinding;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.BindingCollector;
|
import org.eclipse.cdt.internal.core.pdom.dom.BindingCollector;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.IIndexLocationConverter;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
||||||
|
@ -236,7 +233,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
return IIndexFragmentName.EMPTY_NAME_ARRAY;
|
return IIndexFragmentName.EMPTY_NAME_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexProxyBinding findBinding(IASTName name) throws CoreException {
|
public IIndexFragmentBinding findBinding(IASTName name) throws CoreException {
|
||||||
PDOMLinkage linkage= adaptLinkage(name.getLinkage());
|
PDOMLinkage linkage= adaptLinkage(name.getLinkage());
|
||||||
if (linkage != null) {
|
if (linkage != null) {
|
||||||
return linkage.resolveBinding(name);
|
return linkage.resolveBinding(name);
|
||||||
|
@ -419,7 +416,12 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
return db.getInt(LINKAGES);
|
return db.getInt(LINKAGES);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMLinkage[] getLinkages() {
|
public IIndexLinkage[] getLinkages() {
|
||||||
|
Collection values = fLinkageIDCache.values();
|
||||||
|
return (IIndexLinkage[]) values.toArray(new IIndexLinkage[values.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PDOMLinkage[] getLinkageImpls() {
|
||||||
Collection values = fLinkageIDCache.values();
|
Collection values = fLinkageIDCache.values();
|
||||||
return (PDOMLinkage[]) values.toArray(new PDOMLinkage[values.size()]);
|
return (PDOMLinkage[]) values.toArray(new PDOMLinkage[values.size()]);
|
||||||
}
|
}
|
||||||
|
@ -445,6 +447,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
private int lockCount;
|
private int lockCount;
|
||||||
private int waitingReaders;
|
private int waitingReaders;
|
||||||
private long lastWriteAccess= 0;
|
private long lastWriteAccess= 0;
|
||||||
|
private long lastReadAccess= 0;
|
||||||
|
|
||||||
public void acquireReadLock() throws InterruptedException {
|
public void acquireReadLock() throws InterruptedException {
|
||||||
synchronized (mutex) {
|
synchronized (mutex) {
|
||||||
|
@ -459,6 +462,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
public void releaseReadLock() {
|
public void releaseReadLock() {
|
||||||
synchronized (mutex) {
|
synchronized (mutex) {
|
||||||
assert lockCount > 0: "No lock to release"; //$NON-NLS-1$
|
assert lockCount > 0: "No lock to release"; //$NON-NLS-1$
|
||||||
|
lastReadAccess= System.currentTimeMillis();
|
||||||
if (lockCount > 0)
|
if (lockCount > 0)
|
||||||
--lockCount;
|
--lockCount;
|
||||||
mutex.notifyAll();
|
mutex.notifyAll();
|
||||||
|
@ -509,11 +513,15 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
return lastWriteAccess;
|
return lastWriteAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getLastReadAccess() {
|
||||||
|
return lastReadAccess;
|
||||||
|
}
|
||||||
|
|
||||||
protected PDOMLinkage adaptLinkage(ILinkage linkage) throws CoreException {
|
protected PDOMLinkage adaptLinkage(ILinkage linkage) throws CoreException {
|
||||||
return (PDOMLinkage) fLinkageIDCache.get(linkage.getID());
|
return (PDOMLinkage) fLinkageIDCache.get(linkage.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexProxyBinding adaptBinding(IBinding binding) throws CoreException {
|
public IIndexFragmentBinding adaptBinding(IBinding binding) throws CoreException {
|
||||||
if (binding instanceof PDOMBinding) {
|
if (binding instanceof PDOMBinding) {
|
||||||
PDOMBinding pdomBinding= (PDOMBinding) binding;
|
PDOMBinding pdomBinding= (PDOMBinding) binding;
|
||||||
if (pdomBinding.getPDOM() == this) {
|
if (pdomBinding.getPDOM() == this) {
|
||||||
|
@ -528,7 +536,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexProxyBinding adaptBinding(IIndexProxyBinding binding) throws CoreException {
|
public IIndexFragmentBinding adaptBinding(IIndexFragmentBinding binding) throws CoreException {
|
||||||
if (binding instanceof IBinding) {
|
if (binding instanceof IBinding) {
|
||||||
return adaptBinding((IBinding) binding);
|
return adaptBinding((IBinding) binding);
|
||||||
}
|
}
|
||||||
|
@ -544,14 +552,14 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragmentName[] findNames(IBinding binding, int options) throws CoreException {
|
public IIndexFragmentName[] findNames(IBinding binding, int options) throws CoreException {
|
||||||
IIndexProxyBinding proxyBinding= adaptBinding(binding);
|
IIndexFragmentBinding proxyBinding= adaptBinding(binding);
|
||||||
if (proxyBinding != null) {
|
if (proxyBinding != null) {
|
||||||
return findNames(proxyBinding, options);
|
return findNames(proxyBinding, options);
|
||||||
}
|
}
|
||||||
return IIndexFragmentName.EMPTY_NAME_ARRAY;
|
return IIndexFragmentName.EMPTY_NAME_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragmentName[] findNames(IIndexProxyBinding binding, int options) throws CoreException {
|
public IIndexFragmentName[] findNames(IIndexFragmentBinding binding, int options) throws CoreException {
|
||||||
PDOMBinding pdomBinding = (PDOMBinding) adaptBinding(binding);
|
PDOMBinding pdomBinding = (PDOMBinding) adaptBinding(binding);
|
||||||
|
|
||||||
if (pdomBinding != null) {
|
if (pdomBinding != null) {
|
||||||
|
@ -601,20 +609,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
return fPath;
|
return fPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] findInNamespace(IBinding nsbinding, char[] name) throws CoreException {
|
public IIndexFragmentBinding[] findBindingsForPrefix(char[] prefix, IndexFilter filter) throws CoreException {
|
||||||
IIndexProxyBinding ns= adaptBinding(nsbinding);
|
|
||||||
if (ns instanceof ICPPNamespace) {
|
|
||||||
try {
|
|
||||||
ICPPNamespaceScope scope = ((ICPPNamespace)ns).getNamespaceScope();
|
|
||||||
return scope.find(new String(name));
|
|
||||||
} catch(DOMException de) {
|
|
||||||
CCorePlugin.log(de);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBinding[] findBindingsForPrefix(char[] prefix, IndexFilter filter) throws CoreException {
|
|
||||||
ArrayList result = new ArrayList();
|
ArrayList result = new ArrayList();
|
||||||
for (Iterator iter = fLinkageIDCache.values().iterator(); iter.hasNext();) {
|
for (Iterator iter = fLinkageIDCache.values().iterator(); iter.hasNext();) {
|
||||||
PDOMLinkage linkage = (PDOMLinkage) iter.next();
|
PDOMLinkage linkage = (PDOMLinkage) iter.next();
|
||||||
|
@ -625,6 +620,6 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (IBinding[]) result.toArray(new IBinding[result.size()]);
|
return (IIndexFragmentBinding[]) result.toArray(new IIndexFragmentBinding[result.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom;
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
@ -19,9 +20,9 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexLocationConverter;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndexFragment;
|
import org.eclipse.cdt.internal.core.index.IWritableIndexFragment;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.IIndexLocationConverter;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.IString;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -238,4 +239,44 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
|
||||||
final public boolean isFileLocal() throws CoreException {
|
final public boolean isFileLocal() throws CoreException {
|
||||||
return getParentNode() instanceof PDOMFileLocalScope;
|
return getParentNode() instanceof PDOMFileLocalScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasDefinition() throws CoreException {
|
||||||
|
return getFirstDefinition()!=null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int comparePDOMBindingQNs(PDOMBinding b0, PDOMBinding b1) {
|
||||||
|
try {
|
||||||
|
int cmp = 0;
|
||||||
|
do {
|
||||||
|
IString s0 = b0.getDBName(), s1 = b1.getDBName();
|
||||||
|
cmp = s0.compare(s1);
|
||||||
|
if(cmp==0) {
|
||||||
|
b0 = (PDOMBinding) b0.getParentBinding();
|
||||||
|
b1 = (PDOMBinding) b1.getParentBinding();
|
||||||
|
if(b0==null || b1==null) {
|
||||||
|
cmp = b0==b1 ? 0 : (b0==null ? -1 : 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while(cmp==0 && b1!=null && b0!=null);
|
||||||
|
return cmp;
|
||||||
|
} catch(CoreException ce) {
|
||||||
|
CCorePlugin.log(ce);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo(Object other) {
|
||||||
|
if(other instanceof PDOMBinding) {
|
||||||
|
PDOMBinding otherBinding = (PDOMBinding) other;
|
||||||
|
int cmp = comparePDOMBindingQNs(this, otherBinding);
|
||||||
|
if(cmp==0) {
|
||||||
|
int t1 = getNodeType();
|
||||||
|
int t2 = otherBinding.getNodeType();
|
||||||
|
return t1 < t2 ? -1 : (t1 > t2 ? 1 : 0);
|
||||||
|
}
|
||||||
|
return cmp;
|
||||||
|
}
|
||||||
|
throw new PDOMNotImplementedError();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexLocationConverter;
|
||||||
import org.eclipse.cdt.core.index.IIndexMacro;
|
import org.eclipse.cdt.core.index.IIndexMacro;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
import org.eclipse.cdt.core.index.IIndexName;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||||
|
@ -262,14 +263,14 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
PDOMInclude lastInclude= null;
|
PDOMInclude lastInclude= null;
|
||||||
for (int i = 0; i < includes.length; i++) {
|
for (int i = 0; i < includes.length; i++) {
|
||||||
IASTPreprocessorIncludeStatement statement = includes[i];
|
IASTPreprocessorIncludeStatement statement = includes[i];
|
||||||
PDOMFile file= (PDOMFile) files[i];
|
PDOMFile thisIncludes= (PDOMFile) files[i];
|
||||||
assert file.getIndexFragment() instanceof IWritableIndexFragment;
|
assert thisIncludes.getIndexFragment() instanceof IWritableIndexFragment;
|
||||||
|
|
||||||
PDOMInclude pdomInclude = new PDOMInclude(pdom, statement);
|
PDOMInclude pdomInclude = new PDOMInclude(pdom, statement);
|
||||||
pdomInclude.setIncludedBy(this);
|
pdomInclude.setIncludedBy(this);
|
||||||
pdomInclude.setIncludes(file);
|
pdomInclude.setIncludes(thisIncludes);
|
||||||
|
|
||||||
file.addIncludedBy(pdomInclude);
|
thisIncludes.addIncludedBy(pdomInclude);
|
||||||
if (lastInclude == null) {
|
if (lastInclude == null) {
|
||||||
setFirstInclude(pdomInclude);
|
setFirstInclude(pdomInclude);
|
||||||
}
|
}
|
||||||
|
@ -378,4 +379,8 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
throw new CoreException(CCorePlugin.createStatus(Messages.getString("PDOMFile.toExternalProblem")+raw)); //$NON-NLS-1$
|
throw new CoreException(CCorePlugin.createStatus(Messages.getString("PDOMFile.toExternalProblem")+raw)); //$NON-NLS-1$
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasNames() throws CoreException {
|
||||||
|
return getFirstName()!=null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@ import org.eclipse.cdt.core.index.IIndexLinkage;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
import org.eclipse.cdt.internal.core.Util;
|
import org.eclipse.cdt.internal.core.Util;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositeScope;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
|
@ -205,8 +207,12 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scope instanceof IIndexBinding) {
|
if(scope instanceof IIndexScope) {
|
||||||
return adaptBinding((IBinding) scope);
|
if(scope instanceof CompositeScope) { // we special case for performance
|
||||||
|
return adaptBinding(((CompositeScope)scope).getRawScopeBinding());
|
||||||
|
} else {
|
||||||
|
return adaptBinding(((IIndexScope) scope).getScopeBinding());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// the scope is from the ast
|
// the scope is from the ast
|
||||||
|
|
|
@ -20,8 +20,8 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
import org.eclipse.cdt.core.index.IIndexName;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentName;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentName;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexProxyBinding;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -326,7 +326,7 @@ public class PDOMName implements IIndexFragmentName, IASTFileLocation {
|
||||||
return pdom;
|
return pdom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexProxyBinding getBinding() throws CoreException {
|
public IIndexFragmentBinding getBinding() throws CoreException {
|
||||||
return getPDOMBinding();
|
return getPDOMBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexLocationConverter;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexFileLocation;
|
import org.eclipse.cdt.internal.core.index.IndexFileLocation;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
|
|
@ -28,8 +28,10 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
|
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.Util;
|
import org.eclipse.cdt.internal.core.Util;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||||
|
@ -45,7 +47,7 @@ import org.eclipse.core.runtime.Status;
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCompositeTypeScope, IPDOMMemberOwner, IIndexType {
|
public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCompositeTypeScope, IPDOMMemberOwner, IIndexType, IIndexScope {
|
||||||
private static final int MEMBERLIST = PDOMBinding.RECORD_SIZE;
|
private static final int MEMBERLIST = PDOMBinding.RECORD_SIZE;
|
||||||
private static final int KEY = MEMBERLIST + 4; // byte
|
private static final int KEY = MEMBERLIST + 4; // byte
|
||||||
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 8;
|
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 8;
|
||||||
|
@ -243,4 +245,8 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IIndexBinding getScopeBinding() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||||
|
@ -49,14 +52,21 @@ abstract class PDOMCPPBinding extends PDOMBinding implements ICPPBinding {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: performance?
|
|
||||||
final public char[][] getQualifiedNameCharArray() throws DOMException {
|
final public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||||
String[] preResult = getQualifiedName();
|
List result = new ArrayList();
|
||||||
char[][] result = new char[preResult.length][];
|
try {
|
||||||
for(int i=0; i<preResult.length; i++) {
|
PDOMNode node = this;
|
||||||
result[i] = preResult[i].toCharArray();
|
while (node != null) {
|
||||||
|
if (node instanceof PDOMBinding) {
|
||||||
|
result.add(0, ((PDOMBinding)node).getName().toCharArray());
|
||||||
|
}
|
||||||
|
node = node.getParentNode();
|
||||||
|
}
|
||||||
|
return (char[][]) result.toArray(new char[result.size()][]);
|
||||||
|
} catch(CoreException ce) {
|
||||||
|
CCorePlugin.log(ce);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGloballyQualified() throws DOMException {
|
public boolean isGloballyQualified() throws DOMException {
|
||||||
|
|
|
@ -35,11 +35,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.Util;
|
import org.eclipse.cdt.internal.core.Util;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||||
|
@ -55,7 +57,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
||||||
ICPPClassScope, IPDOMMemberOwner, IIndexType {
|
ICPPClassScope, IPDOMMemberOwner, IIndexType, IIndexScope {
|
||||||
|
|
||||||
private static final int FIRSTBASE = PDOMCPPBinding.RECORD_SIZE + 0;
|
private static final int FIRSTBASE = PDOMCPPBinding.RECORD_SIZE + 0;
|
||||||
private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 4; // byte
|
private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 4; // byte
|
||||||
|
@ -491,4 +493,8 @@ ICPPClassScope, IPDOMMemberOwner, IIndexType {
|
||||||
base.delete();
|
base.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IIndexBinding getScopeBinding() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,7 +285,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements IIndexType, ICPPFunction
|
||||||
if(types[0] instanceof IBasicType) {
|
if(types[0] instanceof IBasicType) {
|
||||||
if(((IBasicType)types[0]).getType()==IBasicType.t_void) {
|
if(((IBasicType)types[0]).getType()==IBasicType.t_void) {
|
||||||
types = new IType[0];
|
types = new IType[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer();
|
||||||
|
@ -304,4 +304,33 @@ class PDOMCPPFunction extends PDOMCPPBinding implements IIndexType, ICPPFunction
|
||||||
IType[] params = type.getParameterTypes();
|
IType[] params = type.getParameterTypes();
|
||||||
return getSignatureMemento(params);
|
return getSignatureMemento(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int compareTo(Object other) {
|
||||||
|
int cmp = super.compareTo(other);
|
||||||
|
if(cmp==0) {
|
||||||
|
if(other instanceof PDOMCPPFunction) {
|
||||||
|
try {
|
||||||
|
PDOMCPPFunction otherFunction = (PDOMCPPFunction) other;
|
||||||
|
int mySM = getSignatureMemento();
|
||||||
|
int otherSM = otherFunction.getSignatureMemento();
|
||||||
|
return mySM == otherSM ? 0 : mySM < otherSM ? -1 : 1;
|
||||||
|
} catch(CoreException ce) {
|
||||||
|
CCorePlugin.log(ce);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new PDOMNotImplementedError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer result = new StringBuffer();
|
||||||
|
try {
|
||||||
|
result.append(getName()+" "+ASTTypeUtil.getParameterTypeString(getType())); //$NON-NLS-1$
|
||||||
|
} catch(DOMException de) {
|
||||||
|
result.append(de);
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||||
|
@ -39,7 +40,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class PDOMCPPNamespace extends PDOMCPPBinding implements ICPPNamespace, ICPPNamespaceScope {
|
class PDOMCPPNamespace extends PDOMCPPBinding implements ICPPNamespace, ICPPNamespaceScope, IIndexScope {
|
||||||
|
|
||||||
private static final int INDEX_OFFSET = PDOMBinding.RECORD_SIZE + 0;
|
private static final int INDEX_OFFSET = PDOMBinding.RECORD_SIZE + 0;
|
||||||
|
|
||||||
|
@ -157,4 +158,8 @@ class PDOMCPPNamespace extends PDOMCPPBinding implements ICPPNamespace, ICPPName
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addUsingDirective(IASTNode directive) throws DOMException {fail();}
|
public void addUsingDirective(IASTNode directive) throws DOMException {fail();}
|
||||||
|
|
||||||
|
public IIndexBinding getScopeBinding() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,10 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
import org.eclipse.cdt.internal.core.Util;
|
import org.eclipse.cdt.internal.core.Util;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode;
|
||||||
|
@ -33,7 +34,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
*
|
*
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*/
|
*/
|
||||||
class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter {
|
class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IIndexFragmentBinding {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offset of pointer to the next parameter (relative to the
|
* Offset of pointer to the next parameter (relative to the
|
||||||
|
@ -114,7 +115,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter {
|
||||||
return rec != 0 ? new PDOMCPPParameter(pdom, rec) : null;
|
return rec != 0 ? new PDOMCPPParameter(pdom, rec) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getQualifiedName() throws DOMException {
|
public String[] getQualifiedName() {
|
||||||
throw new PDOMNotImplementedError();
|
throw new PDOMNotImplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,4 +194,21 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter {
|
||||||
}
|
}
|
||||||
return defValue;
|
return defValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IIndexFragment getFragment() {
|
||||||
|
return pdom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasDefinition() throws CoreException {
|
||||||
|
// parameter bindings do not span index fragments
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo(Object arg0) {
|
||||||
|
throw new PDOMNotImplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFileLocal() throws CoreException {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,12 +58,16 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
||||||
if (typeNode != null)
|
if (typeNode != null)
|
||||||
db.putInt(record + TYPE_OFFSET, typeNode.getRecord());
|
db.putInt(record + TYPE_OFFSET, typeNode.getRecord());
|
||||||
|
|
||||||
db.putByte(record + ANNOTATIONS, PDOMCPPAnnotation.encodeAnnotation(variable));
|
db.putByte(record + ANNOTATIONS, encodeFlags(variable));
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
throw new CoreException(Util.createStatus(e));
|
throw new CoreException(Util.createStatus(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected byte encodeFlags(ICPPVariable variable) throws DOMException {
|
||||||
|
return PDOMCPPAnnotation.encodeAnnotation(variable);
|
||||||
|
}
|
||||||
|
|
||||||
public PDOMCPPVariable(PDOM pdom, int record) {
|
public PDOMCPPVariable(PDOM pdom, int record) {
|
||||||
super(pdom, record);
|
super(pdom, record);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,9 @@ package org.eclipse.cdt.ui.tests.typehierarchy;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IProjectDescription;
|
||||||
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.swt.widgets.Tree;
|
import org.eclipse.swt.widgets.Tree;
|
||||||
import org.eclipse.swt.widgets.TreeItem;
|
import org.eclipse.swt.widgets.TreeItem;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
@ -47,6 +50,10 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
fCProject2= CProjectHelper.createCCProject("__thTest_2__", "bin", IPDOMManager.ID_FAST_INDEXER);
|
fCProject2= CProjectHelper.createCCProject("__thTest_2__", "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||||
|
IProjectDescription desc= fCProject2.getProject().getDescription();
|
||||||
|
desc.setReferencedProjects(new IProject[]{fCProject.getProject()});
|
||||||
|
fCProject2.getProject().setDescription(desc, new NullProgressMonitor());
|
||||||
|
|
||||||
CCoreInternals.getPDOMManager().reindex(fCProject2);
|
CCoreInternals.getPDOMManager().reindex(fCProject2);
|
||||||
fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {fCProject, fCProject2});
|
fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {fCProject, fCProject2});
|
||||||
TestScannerProvider.sIncludes= new String[]{fCProject.getProject().getLocation().toOSString(), fCProject2.getProject().getLocation().toOSString()};
|
TestScannerProvider.sIncludes= new String[]{fCProject.getProject().getLocation().toOSString(), fCProject2.getProject().getLocation().toOSString()};
|
||||||
|
@ -82,7 +89,7 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest {
|
||||||
// int field4;
|
// int field4;
|
||||||
// int method4();
|
// int method4();
|
||||||
// };
|
// };
|
||||||
public void _testSimpleInheritanceAcross() throws Exception {
|
public void testSimpleInheritanceAcross() throws Exception {
|
||||||
StringBuffer[] content= getContentsForTest(2);
|
StringBuffer[] content= getContentsForTest(2);
|
||||||
String header= content[0].toString();
|
String header= content[0].toString();
|
||||||
String source = content[1].toString();
|
String source = content[1].toString();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2006 QNX Software Systems and others.
|
* Copyright (c) 2005, 2006, 2007 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.indexview;
|
package org.eclipse.cdt.internal.ui.indexview;
|
||||||
|
@ -190,7 +191,7 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
|
||||||
return new Object[0];
|
return new Object[0];
|
||||||
}
|
}
|
||||||
PDOM pdom = (PDOM)CCoreInternals.getPDOMManager().getPDOM(cproject);
|
PDOM pdom = (PDOM)CCoreInternals.getPDOMManager().getPDOM(cproject);
|
||||||
PDOMLinkage[] linkages= pdom.getLinkages();
|
PDOMLinkage[] linkages= pdom.getLinkageImpls();
|
||||||
if (linkages.length == 1) {
|
if (linkages.length == 1) {
|
||||||
// Skip linkages in hierarchy if there is only one
|
// Skip linkages in hierarchy if there is only one
|
||||||
return getChildren(linkages[0]);
|
return getChildren(linkages[0]);
|
||||||
|
@ -224,7 +225,7 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PDOM pdom = (PDOM)CCoreInternals.getPDOMManager().getPDOM(cproject);
|
PDOM pdom = (PDOM)CCoreInternals.getPDOMManager().getPDOM(cproject);
|
||||||
PDOMLinkage[] linkages = pdom.getLinkages();
|
PDOMLinkage[] linkages = pdom.getLinkageImpls();
|
||||||
if (linkages.length == 0)
|
if (linkages.length == 0)
|
||||||
return false;
|
return false;
|
||||||
else if (linkages.length == 1)
|
else if (linkages.length == 1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue