1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-08 16:55:38 +02:00

Improved robustness of global scope handling.

Change-Id: Id0222766e8c5e258f866f9a4c8b3307a06bdf4c7
This commit is contained in:
Sergey Prigogin 2015-06-08 12:44:29 -07:00
parent e4d106f6d1
commit e27ca67746
34 changed files with 386 additions and 275 deletions

View file

@ -29,8 +29,6 @@ import java.io.StringReader;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.IName; import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.EScopeKind;
@ -153,6 +151,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil; import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.ParserException;
import junit.framework.TestSuite;
public class AST2CPPTests extends AST2TestBase { public class AST2CPPTests extends AST2TestBase {
public AST2CPPTests() { public AST2CPPTests() {
@ -3408,16 +3408,16 @@ public class AST2CPPTests extends AST2TestBase {
ICPPVariable v2 = (ICPPVariable) col.getName(3).resolveBinding(); ICPPVariable v2 = (ICPPVariable) col.getName(3).resolveBinding();
String[] s = v1.getQualifiedName(); String[] s = v1.getQualifiedName();
assertEquals(s[0], "v1"); assertEquals("v1", s[0]);
assertFalse(v1.isGloballyQualified()); assertFalse(v1.isGloballyQualified());
s = v2.getQualifiedName(); s = v2.getQualifiedName();
assertEquals(s[0], "v2"); assertEquals("v2", s[0]);
assertFalse(v2.isGloballyQualified()); assertFalse(v2.isGloballyQualified());
ICPPBlockScope scope = (ICPPBlockScope) v2.getScope(); ICPPBlockScope scope = (ICPPBlockScope) v2.getScope();
IBinding[] bs = scope.find("v1"); IBinding[] bs = scope.find("v1", tu);
assertEquals(bs.length, 1); assertEquals(1, bs.length);
assertSame(bs[0], v1); assertSame(bs[0], v1);
} }
@ -3437,17 +3437,17 @@ public class AST2CPPTests extends AST2TestBase {
ICPPMethod f = (ICPPMethod) col.getName(7).resolveBinding(); ICPPMethod f = (ICPPMethod) col.getName(7).resolveBinding();
IScope scope = f.getFunctionScope(); IScope scope = f.getFunctionScope();
IBinding[] bs = scope.find("a"); IBinding[] bs = scope.find("a", tu);
assertEquals(bs.length, 1); assertEquals(1, bs.length);
assertSame(bs[0], a); assertSame(bs[0], a);
bs = scope.find("~B"); bs = scope.find("~B", tu);
assertEquals(bs.length, 1); assertEquals(1, bs.length);
assertTrue(bs[0] instanceof ICPPMethod); assertTrue(bs[0] instanceof ICPPMethod);
assertTrue(bs[0].getName().equals("~B")); assertTrue(bs[0].getName().equals("~B"));
bs = scope.find("A"); bs = scope.find("A", tu);
assertEquals(bs.length, 1); assertEquals(1, bs.length);
assertSame(bs[0], A); assertSame(bs[0], A);
} }
@ -3470,16 +3470,16 @@ public class AST2CPPTests extends AST2TestBase {
IASTFunctionDefinition def = (IASTFunctionDefinition) col.getName(5).getParent().getParent(); IASTFunctionDefinition def = (IASTFunctionDefinition) col.getName(5).getParent().getParent();
IScope scope = ((IASTCompoundStatement) def.getBody()).getScope(); IScope scope = ((IASTCompoundStatement) def.getBody()).getScope();
IBinding[] bs = scope.find("f"); IBinding[] bs = scope.find("f", tu);
assertEquals(3, bs.length); assertEquals(3, bs.length);
assertSame(bs[0], f3); assertSame(bs[0], f3);
assertSame(bs[1], f1); assertSame(bs[1], f1);
assertSame(bs[2], f2); assertSame(bs[2], f2);
String[] s = ((ICPPBinding) bs[1]).getQualifiedName(); String[] s = ((ICPPBinding) bs[1]).getQualifiedName();
assertEquals(s.length, 2); assertEquals(2, s.length);
assertEquals(s[0], "A"); assertEquals("A", s[0]);
assertEquals(s[1], "f"); assertEquals("f", s[1]);
assertTrue(((ICPPBinding) bs[1]).isGloballyQualified()); assertTrue(((ICPPBinding) bs[1]).isGloballyQualified());
} }
@ -3508,7 +3508,7 @@ public class AST2CPPTests extends AST2TestBase {
IASTFunctionDefinition def = (IASTFunctionDefinition) col.getName(8).getParent().getParent(); IASTFunctionDefinition def = (IASTFunctionDefinition) col.getName(8).getParent().getParent();
IScope scope = ((IASTCompoundStatement) def.getBody()).getScope(); IScope scope = ((IASTCompoundStatement) def.getBody()).getScope();
IBinding[] bs = scope.find("f"); IBinding[] bs = scope.find("f", tu);
assertEquals(3, bs.length); assertEquals(3, bs.length);
assertSame(bs[0], f); assertSame(bs[0], f);
assertSame(bs[1], f1); assertSame(bs[1], f1);
@ -3533,21 +3533,21 @@ public class AST2CPPTests extends AST2TestBase {
IFunction f1 = (IFunction) col.getName(6).resolveBinding(); IFunction f1 = (IFunction) col.getName(6).resolveBinding();
IScope classScope= f1.getScope(); IScope classScope= f1.getScope();
assertTrue(classScope instanceof ICPPClassScope); assertTrue(classScope instanceof ICPPClassScope);
IBinding[] bindings = classScope.find("bf"); IBinding[] bindings = classScope.find("bf", tu);
ICPPMethod method= extractSingleMethod(bindings); ICPPMethod method= extractSingleMethod(bindings);
assertEquals(method.getQualifiedName()[0], "B"); assertEquals("B", method.getQualifiedName()[0]);
bindings= classScope.find("f"); bindings= classScope.find("f", tu);
method= extractSingleMethod(bindings); method= extractSingleMethod(bindings);
assertEquals(method.getQualifiedName()[0], "A"); assertEquals("A", method.getQualifiedName()[0]);
bindings= classScope.find("B"); bindings= classScope.find("B", tu);
ICPPClassType classType= extractSingleClass(bindings); ICPPClassType classType= extractSingleClass(bindings);
assertEquals(classType.getQualifiedName()[0], "B"); assertEquals("B", classType.getQualifiedName()[0]);
bindings= classScope.find("A"); bindings= classScope.find("A", tu);
classType= extractSingleClass(bindings); classType= extractSingleClass(bindings);
assertEquals(classType.getQualifiedName()[0], "A"); assertEquals("A", classType.getQualifiedName()[0]);
} }
// class A { // class A {
@ -3571,39 +3571,39 @@ public class AST2CPPTests extends AST2TestBase {
ICPPMethod fb = (ICPPMethod) col.getName(6).resolveBinding(); ICPPMethod fb = (ICPPMethod) col.getName(6).resolveBinding();
Object[] result = B.getDeclaredFields(); Object[] result = B.getDeclaredFields();
assertEquals(result.length, 1); assertEquals(1, result.length);
assertSame(result[0], b); assertSame(result[0], b);
result = B.getFields(); result = B.getFields();
assertEquals(result.length, 2); assertEquals(2, result.length);
assertSame(result[0], b); assertSame(result[0], b);
assertSame(result[1], a); assertSame(result[1], a);
result = B.getDeclaredMethods(); result = B.getDeclaredMethods();
assertEquals(result.length, 1); assertEquals(1, result.length);
assertSame(result[0], fb); assertSame(result[0], fb);
result = B.getAllDeclaredMethods(); result = B.getAllDeclaredMethods();
assertEquals(result.length, 2); assertEquals(2, result.length);
assertSame(result[0], fb); assertSame(result[0], fb);
assertSame(result[1], fa); assertSame(result[1], fa);
ICPPMethod[] B_implicit = ((ICPPClassScope) B.getCompositeScope()).getImplicitMethods(); ICPPMethod[] B_implicit = ((ICPPClassScope) B.getCompositeScope()).getImplicitMethods();
assertEquals(B_implicit.length, 4); assertEquals(4, B_implicit.length);
assertTrue(B_implicit[0].getName().equals("B")); assertTrue(B_implicit[0].getName().equals("B"));
assertTrue(B_implicit[1].getName().equals("B")); assertTrue(B_implicit[1].getName().equals("B"));
assertTrue(B_implicit[2].getName().equals("operator =")); assertTrue(B_implicit[2].getName().equals("operator ="));
assertTrue(B_implicit[3].getName().equals("~B")); assertTrue(B_implicit[3].getName().equals("~B"));
ICPPMethod[] A_implicit = ((ICPPClassScope) A.getCompositeScope()).getImplicitMethods(); ICPPMethod[] A_implicit = ((ICPPClassScope) A.getCompositeScope()).getImplicitMethods();
assertEquals(A_implicit.length, 4); assertEquals(4, A_implicit.length);
assertTrue(A_implicit[0].getName().equals("A")); assertTrue(A_implicit[0].getName().equals("A"));
assertTrue(A_implicit[1].getName().equals("A")); assertTrue(A_implicit[1].getName().equals("A"));
assertTrue(A_implicit[2].getName().equals("operator =")); assertTrue(A_implicit[2].getName().equals("operator ="));
assertTrue(A_implicit[3].getName().equals("~A")); assertTrue(A_implicit[3].getName().equals("~A"));
result = B.getMethods(); result = B.getMethods();
assertEquals(result.length, 10); assertEquals(10, result.length);
assertSame(result[0], fb); assertSame(result[0], fb);
assertSame(result[1], B_implicit[0]); assertSame(result[1], B_implicit[0]);
assertSame(result[2], B_implicit[1]); assertSame(result[2], B_implicit[1]);
@ -3617,8 +3617,7 @@ public class AST2CPPTests extends AST2TestBase {
} }
public void testBug87424() throws Exception { public void testBug87424() throws Exception {
IASTTranslationUnit tu = parse( IASTTranslationUnit tu = parse("int * __restrict x;", CPP, true);
"int * __restrict x;", CPP, true);
NameCollector col = new NameCollector(); NameCollector col = new NameCollector();
tu.accept(col); tu.accept(col);
@ -3638,8 +3637,7 @@ public class AST2CPPTests extends AST2TestBase {
} }
public void testBug87705() throws Exception { public void testBug87705() throws Exception {
IASTTranslationUnit tu = parse( IASTTranslationUnit tu = parse("class A { friend class B::C; };", CPP, true);
"class A { friend class B::C; };", CPP, true);
NameCollector col = new NameCollector(); NameCollector col = new NameCollector();
tu.accept(col); tu.accept(col);
@ -3659,8 +3657,7 @@ public class AST2CPPTests extends AST2TestBase {
} }
public void testBug88501_1() throws Exception { public void testBug88501_1() throws Exception {
IASTTranslationUnit tu = parse( IASTTranslationUnit tu = parse("void f(); void f(int); struct f;", CPP);
"void f(); void f(int); struct f;", CPP);
NameCollector col = new NameCollector(); NameCollector col = new NameCollector();
tu.accept(col); tu.accept(col);
@ -3679,7 +3676,6 @@ public class AST2CPPTests extends AST2TestBase {
// IProblemBinding p = (IProblemBinding) col.getName(1).resolveBinding(); // IProblemBinding p = (IProblemBinding) col.getName(1).resolveBinding();
// assertEquals(p.getID(), IProblemBinding.SEMANTIC_INVALID_REDEFINITION); // assertEquals(p.getID(), IProblemBinding.SEMANTIC_INVALID_REDEFINITION);
// } // }
public void testBug8342_2() throws Exception { public void testBug8342_2() throws Exception {
IASTTranslationUnit tu = parse("extern int a; extern char a;", CPP); IASTTranslationUnit tu = parse("extern int a; extern char a;", CPP);
NameCollector col = new NameCollector(); NameCollector col = new NameCollector();
@ -3770,7 +3766,7 @@ public class AST2CPPTests extends AST2TestBase {
IFunction f2 = (IFunction) col.getName(3).resolveBinding(); IFunction f2 = (IFunction) col.getName(3).resolveBinding();
IScope scope = tu.getScope(); IScope scope = tu.getScope();
IBinding[] bs = scope.find("f"); IBinding[] bs = scope.find("f", tu);
assertEquals(bs.length, 2); assertEquals(bs.length, 2);
assertSame(bs[0], f1); assertSame(bs[0], f1);
assertSame(bs[1], f2); assertSame(bs[1], f2);

View file

@ -20,8 +20,6 @@ import static org.eclipse.cdt.core.parser.ParserLanguage.CPP;
import java.io.IOException; import java.io.IOException;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.EScopeKind;
@ -132,6 +130,8 @@ import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalBinding;
import org.eclipse.cdt.internal.core.model.ASTStringUtil; import org.eclipse.cdt.internal.core.model.ASTStringUtil;
import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.ParserException;
import junit.framework.TestSuite;
/** /**
* Test cases on the AST. * Test cases on the AST.
*/ */
@ -3080,8 +3080,7 @@ public class AST2Tests extends AST2TestBase {
} }
public void testBug90253() throws Exception { public void testBug90253() throws Exception {
IASTTranslationUnit tu = parse( IASTTranslationUnit tu = parse("void f(int par) { int v1; };", C); //$NON-NLS-1$
"void f(int par) { int v1; };", C); //$NON-NLS-1$
NameCollector col = new NameCollector(); NameCollector col = new NameCollector();
tu.accept(col); tu.accept(col);
@ -3092,11 +3091,11 @@ public class AST2Tests extends AST2TestBase {
IASTFunctionDefinition fdef= getDeclaration(tu, 0); IASTFunctionDefinition fdef= getDeclaration(tu, 0);
IScope scope = ((IASTCompoundStatement) fdef.getBody()).getScope(); IScope scope = ((IASTCompoundStatement) fdef.getBody()).getScope();
IBinding[] bs = scope.find("par"); //$NON-NLS-1$ IBinding[] bs = scope.find("par", tu); //$NON-NLS-1$
assertEquals(1, bs.length); assertEquals(1, bs.length);
assertSame(bs[0], p); assertSame(bs[0], p);
bs = scope.find("v1"); //$NON-NLS-1$ bs = scope.find("v1", tu); //$NON-NLS-1$
assertEquals(bs.length, 1); assertEquals(bs.length, 1);
assertSame(bs[0], v1); assertSame(bs[0], v1);
} }
@ -3123,7 +3122,7 @@ public class AST2Tests extends AST2TestBase {
IASTFunctionDefinition fdef= getDeclaration(tu, 2); IASTFunctionDefinition fdef= getDeclaration(tu, 2);
IScope scope = ((IASTCompoundStatement) fdef.getBody()).getScope(); IScope scope = ((IASTCompoundStatement) fdef.getBody()).getScope();
IBinding[] bs = scope.find("S"); //$NON-NLS-1$ IBinding[] bs = scope.find("S", tu); //$NON-NLS-1$
assertNotNull(S2); assertNotNull(S2);
assertEquals(bs.length, 3); assertEquals(bs.length, 3);

View file

@ -6,15 +6,13 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.index.tests; package org.eclipse.cdt.internal.index.tests;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
@ -36,6 +34,8 @@ import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
import junit.framework.TestSuite;
public class Bug246129 extends IndexTestBase { public class Bug246129 extends IndexTestBase {
public static TestSuite suite() { public static TestSuite suite() {
@ -45,29 +45,18 @@ public class Bug246129 extends IndexTestBase {
} }
private ICProject fProject; private ICProject fProject;
private IFile fSource;
private IFile fSource;
private IFolder fWrapperIncludeFolder; private IFolder fWrapperIncludeFolder;
private IFolder fIncludeFolder; private IFolder fIncludeFolder;
private File fTmpDir; private File fTmpDir;
private File fExternalWrapperIncludeFolder; private File fExternalWrapperIncludeFolder;
private File fExternalWrapperHeader; private File fExternalWrapperHeader;
private File fExternalIncludeFolder; private File fExternalIncludeFolder;
private File fExternalHeader; private File fExternalHeader;
private File fExternalExtFolder; private File fExternalExtFolder;
IIndex fIndex; IIndex fIndex;
boolean fFalseFriendsAccepted; boolean fFalseFriendsAccepted;
public Bug246129(String name) { public Bug246129(String name) {
super(name); super(name);
} }
@ -76,26 +65,22 @@ public class Bug246129 extends IndexTestBase {
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
if (fProject == null) { if (fProject == null) {
// Populate workspace // Populate workspace
fProject = createProject(true, "resources/indexTests/bug246129"); fProject = createProject(true, "resources/indexTests/bug246129");
fSource = fProject.getProject().getFile("source.cpp"); fSource = fProject.getProject().getFile("source.cpp");
fWrapperIncludeFolder = fProject.getProject().getFolder( fWrapperIncludeFolder = fProject.getProject().getFolder("wrapper_include");
"wrapper_include");
fIncludeFolder = fProject.getProject().getFolder("include"); fIncludeFolder = fProject.getProject().getFolder("include");
// Create header files external to the workspace. // Create header files external to the workspace.
fTmpDir = CProjectHelper.freshDir(); fTmpDir = CProjectHelper.freshDir();
fExternalWrapperIncludeFolder = new File(fTmpDir, fExternalWrapperIncludeFolder = new File(fTmpDir, "wrapper_include");
"wrapper_include");
fExternalWrapperIncludeFolder.mkdir(); fExternalWrapperIncludeFolder.mkdir();
fExternalWrapperHeader = new File( fExternalWrapperHeader = new File(fExternalWrapperIncludeFolder, "external_type.h");
fExternalWrapperIncludeFolder, "external_type.h");
fExternalWrapperHeader.createNewFile(); fExternalWrapperHeader.createNewFile();
FileWriter writer = new FileWriter(fExternalWrapperHeader); FileWriter writer = new FileWriter(fExternalWrapperHeader);
writer.write("#ifndef EXTERNAL_WRAPPER_TYPE_H_\n"); writer.write("#ifndef EXTERNAL_WRAPPER_TYPE_H_\n");
@ -105,15 +90,14 @@ public class Bug246129 extends IndexTestBase {
writer.write("};\n"); writer.write("};\n");
writer.write("#endif\n"); writer.write("#endif\n");
writer.close(); writer.close();
fExternalIncludeFolder = new File(fTmpDir, "include"); fExternalIncludeFolder = new File(fTmpDir, "include");
fExternalIncludeFolder.mkdir(); fExternalIncludeFolder.mkdir();
fExternalExtFolder = new File(fExternalIncludeFolder, "ext"); fExternalExtFolder = new File(fExternalIncludeFolder, "ext");
fExternalExtFolder.mkdir(); fExternalExtFolder.mkdir();
fExternalHeader = new File(fExternalIncludeFolder, fExternalHeader = new File(fExternalIncludeFolder, "external_type.h");
"external_type.h");
fExternalHeader.createNewFile(); fExternalHeader.createNewFile();
writer = new FileWriter(fExternalHeader); writer = new FileWriter(fExternalHeader);
writer.write("#ifndef EXTERNAL_TYPE_H_\n"); writer.write("#ifndef EXTERNAL_TYPE_H_\n");
@ -125,12 +109,10 @@ public class Bug246129 extends IndexTestBase {
// The indexer needs non-empty build info in order to index // The indexer needs non-empty build info in order to index
// source files if index-all-files is turned off. // source files if index-all-files is turned off.
IPathEntry[] entries = new IPathEntry[] { CoreModel IPathEntry[] entries = new IPathEntry[] {
.newIncludeEntry(fProject.getPath(), null, CoreModel.newIncludeEntry(fProject.getPath(), null, fWrapperIncludeFolder.getLocation()),
fWrapperIncludeFolder.getLocation()), CoreModel.newIncludeEntry(fProject.getPath(), null, fIncludeFolder.getLocation()) };
CoreModel.newIncludeEntry(fProject.getPath(), null,
fIncludeFolder.getLocation()) };
fProject.setRawPathEntries(entries, npm()); fProject.setRawPathEntries(entries, npm());
// However, the scanner info provider used by the unit tests // However, the scanner info provider used by the unit tests
@ -144,12 +126,10 @@ public class Bug246129 extends IndexTestBase {
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.set(fProject.getProject(),
IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "false"); IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "false");
File falseFriendDirectory = new File(fWrapperIncludeFolder File falseFriendDirectory = new File(fWrapperIncludeFolder.getLocation().toOSString() + "/ext/..");
.getLocation().toOSString()
+ "/ext/..");
fFalseFriendsAccepted = falseFriendDirectory.exists(); fFalseFriendsAccepted = falseFriendDirectory.exists();
CCorePlugin.getIndexManager().reindex(fProject); CCorePlugin.getIndexManager().reindex(fProject);
waitForIndexer(fProject); waitForIndexer(fProject);
fIndex = CCorePlugin.getIndexManager().getIndex(fProject); fIndex = CCorePlugin.getIndexManager().getIndex(fProject);
@ -160,27 +140,23 @@ public class Bug246129 extends IndexTestBase {
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
fExternalWrapperHeader.delete(); fExternalWrapperHeader.delete();
fExternalWrapperIncludeFolder.delete(); fExternalWrapperIncludeFolder.delete();
fExternalHeader.delete(); fExternalHeader.delete();
fExternalExtFolder.delete(); fExternalExtFolder.delete();
fExternalIncludeFolder.delete(); fExternalIncludeFolder.delete();
fTmpDir.delete(); fTmpDir.delete();
super.tearDown(); super.tearDown();
} }
private void assertSymbolInIndex(String symbolName) throws Exception { private void assertSymbolInIndex(String symbolName) throws Exception {
IIndexBinding[] bindings = fIndex.findBindings( IIndexBinding[] bindings = fIndex.findBindings(symbolName.toCharArray(), false, IndexFilter.ALL, npm());
symbolName assertTrue(bindings.length != 0);
.toCharArray(), false, IndexFilter.ALL, npm());
assertTrue(bindings.length > 0);
} }
public void testIndex() throws Exception { public void testIndex() throws Exception {
try { try {
fIndex.acquireReadLock(); fIndex.acquireReadLock();
IIndexFile[] indexFiles = fIndex.getAllFiles(); IIndexFile[] indexFiles = fIndex.getAllFiles();
@ -191,10 +167,9 @@ public class Bug246129 extends IndexTestBase {
} else { } else {
assertEquals(5, indexFiles.length); assertEquals(5, indexFiles.length);
} }
// The wrapper classes are found regardless whether false friends // The wrapper classes are found regardless whether false friends
// are // are accepted or not.
// accepted or not.
assertSymbolInIndex("Wrapper"); assertSymbolInIndex("Wrapper");
assertSymbolInIndex("ExternalWrapper"); assertSymbolInIndex("ExternalWrapper");
@ -204,18 +179,16 @@ public class Bug246129 extends IndexTestBase {
assertSymbolInIndex("Type"); assertSymbolInIndex("Type");
assertSymbolInIndex("ExternalType"); assertSymbolInIndex("ExternalType");
} }
// Check that all paths are normalized. // Check that all paths are normalized.
for (IIndexFile indexFile : indexFiles) { for (IIndexFile indexFile : indexFiles) {
IIndexInclude[] includes = indexFile.getIncludes(); IIndexInclude[] includes = indexFile.getIncludes();
for (IIndexInclude i : includes) { for (IIndexInclude i : includes) {
IIndexFileLocation location = i.getIncludesLocation(); IIndexFileLocation location = i.getIncludesLocation();
assertNotNull(location); assertNotNull(location);
assertFalse(location.getURI().toASCIIString() assertFalse(location.getURI().toASCIIString().contains(".."));
.contains(".."));
String fullPath = location.getFullPath(); String fullPath = location.getFullPath();
if (fullPath != null) { if (fullPath != null) {
@ -223,41 +196,38 @@ public class Bug246129 extends IndexTestBase {
} }
} }
} }
} finally { } finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
private void assertSymbolInAst(IScope scope, String symbolName) private void assertSymbolInAst(IScope scope, String symbolName, IASTTranslationUnit ast) throws Exception {
throws Exception { IBinding[] bindings = scope.find(symbolName, ast);
IBinding[] bindings = scope.find(symbolName);
assertTrue(bindings.length > 0); assertTrue(bindings.length > 0);
} }
public void testAst() throws Exception { public void testAst() throws Exception {
ITranslationUnit tu = CoreModel.getDefault().createTranslationUnitFrom( ITranslationUnit tu =
fProject, fSource.getLocation()); CoreModel.getDefault().createTranslationUnitFrom(fProject, fSource.getLocation());
IASTTranslationUnit ast = tu.getAST(); IASTTranslationUnit ast = tu.getAST();
// The wrapper classes are found regardless whether false friends // The wrapper classes are found regardless whether false friends
// are // are
// accepted or not. // accepted or not.
IScope topLevel = ast.getScope(); IScope topLevel = ast.getScope();
assertSymbolInAst(topLevel, "Wrapper"); assertSymbolInAst(topLevel, "Wrapper", ast);
assertSymbolInAst(topLevel, "ExternalWrapper"); assertSymbolInAst(topLevel, "ExternalWrapper", ast);
// The Type class is only known on platforms with a File // The Type class is only known on platforms with a File
// implementation sorting out the false friends. // implementation sorting out the false friends.
if (!fFalseFriendsAccepted) { if (!fFalseFriendsAccepted) {
assertSymbolInAst(topLevel, "Type"); assertSymbolInAst(topLevel, "Type", ast);
assertSymbolInAst(topLevel, "ExternalType"); assertSymbolInAst(topLevel, "ExternalType", ast);
} }
// Check that all paths are normalized. // Check that all paths are normalized.
IASTPreprocessorIncludeStatement[] includes = ast IASTPreprocessorIncludeStatement[] includes = ast.getIncludeDirectives();
.getIncludeDirectives();
for (IASTPreprocessorIncludeStatement i : includes) { for (IASTPreprocessorIncludeStatement i : includes) {
String includedPath = i.getPath(); String includedPath = i.getPath();

View file

@ -15,8 +15,6 @@ package org.eclipse.cdt.internal.pdom.tests;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.IName; import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
@ -36,12 +34,12 @@ import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName; import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import junit.framework.Test;
/** /**
* @author Doug Schaefer * @author Doug Schaefer
*
*/ */
public class ClassTests extends PDOMTestBase { public class ClassTests extends PDOMTestBase {
protected PDOM pdom; protected PDOM pdom;
public static Test suite() { public static Test suite() {
@ -61,11 +59,11 @@ public class ClassTests extends PDOMTestBase {
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
pdom.releaseReadLock(); pdom.releaseReadLock();
} }
public void test1() throws Exception { public void test1() throws Exception {
IBinding[] Bs = pdom.findBindings(Pattern.compile("B"), true, IndexFilter.ALL, npm()); IBinding[] Bs = pdom.findBindings(Pattern.compile("B"), true, IndexFilter.ALL, npm());
assertEquals(1, Bs.length); assertEquals(1, Bs.length);
ICPPClassType B = (ICPPClassType)Bs[0]; ICPPClassType B = (ICPPClassType) Bs[0];
ICPPMethod[] Bmethods = B.getAllDeclaredMethods(); ICPPMethod[] Bmethods = B.getAllDeclaredMethods();
assertEquals(4, Bmethods.length); assertEquals(4, Bmethods.length);
assertNotNull(findMethod(Bmethods, "B")); assertNotNull(findMethod(Bmethods, "B"));
@ -78,7 +76,7 @@ public class ClassTests extends PDOMTestBase {
IASTFileLocation loc = Bf_refs[0].getFileLocation(); IASTFileLocation loc = Bf_refs[0].getFileLocation();
assertEquals(offset("class.cpp", "b.f()") + 2, loc.getNodeOffset()); assertEquals(offset("class.cpp", "b.f()") + 2, loc.getNodeOffset());
} }
private ICPPMethod findMethod(ICPPMethod[] bmethods, String name) { private ICPPMethod findMethod(ICPPMethod[] bmethods, String name) {
for (ICPPMethod method : bmethods) { for (ICPPMethod method : bmethods) {
if (method.getName().equals(name)) { if (method.getName().equals(name)) {
@ -99,30 +97,30 @@ public class ClassTests extends PDOMTestBase {
IField[] fields = NestedB.getFields(); IField[] fields = NestedB.getFields();
assertEquals(1, fields.length); assertEquals(1, fields.length);
IField NestedB_x = fields[0]; IField NestedB_x = fields[0];
IName[] refs = pdom.findNames(NestedB, IIndex.FIND_REFERENCES); IName[] refs = pdom.findNames(NestedB, IIndex.FIND_REFERENCES);
assertEquals(1, refs.length); assertEquals(1, refs.length);
IASTFileLocation loc = refs[0].getFileLocation(); IASTFileLocation loc = refs[0].getFileLocation();
assertEquals(offset("nested.cpp", "::NestedB") + 2, loc.getNodeOffset()); assertEquals(offset("nested.cpp", "::NestedB") + 2, loc.getNodeOffset());
refs = pdom.findNames(NestedB_x, IIndex.FIND_REFERENCES); refs = pdom.findNames(NestedB_x, IIndex.FIND_REFERENCES);
assertEquals(1, refs.length); assertEquals(1, refs.length);
loc = refs[0].getFileLocation(); loc = refs[0].getFileLocation();
assertEquals(offset("nested.cpp", "x.x") + 2, loc.getNodeOffset()); assertEquals(offset("nested.cpp", "x.x") + 2, loc.getNodeOffset());
} }
public void test147903() throws Exception { public void test147903() throws Exception {
IBinding[] bindings = pdom.findBindings(Pattern.compile("pr147903"), false, IndexFilter.ALL, npm()); IBinding[] bindings = pdom.findBindings(Pattern.compile("pr147903"), false, IndexFilter.ALL, npm());
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
ICPPNamespaceScope ns = ((ICPPNamespace)bindings[0]).getNamespaceScope(); ICPPNamespaceScope ns = ((ICPPNamespace) bindings[0]).getNamespaceScope();
bindings = ns.find("testRef"); bindings = ns.find("testRef", null);
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
IName[] refs = pdom.findNames(bindings[0], IIndex.FIND_REFERENCES); IName[] refs = pdom.findNames(bindings[0], IIndex.FIND_REFERENCES);
// for (int i = 0; i < refs.length; ++i) // for (int i = 0; i < refs.length; ++i)
// System.out.println(refs[i].getFileLocation().getNodeOffset()); // System.out.println(refs[i].getFileLocation().getNodeOffset());
assertEquals(5, refs.length); assertEquals(5, refs.length);
} }
/* Test friend relationships between classes */ /* Test friend relationships between classes */
public void testFriend() throws Exception { public void testFriend() throws Exception {
IBinding[] bindings = pdom.findBindings(Pattern.compile("ClassA"), true, IndexFilter.ALL_DECLARED, npm()); IBinding[] bindings = pdom.findBindings(Pattern.compile("ClassA"), true, IndexFilter.ALL_DECLARED, npm());
@ -140,40 +138,40 @@ public class ClassTests extends PDOMTestBase {
IBinding[] friends = classA.getFriends(); IBinding[] friends = classA.getFriends();
assertEquals(1, friends.length); assertEquals(1, friends.length);
assertEquals(classC, friends[0]); //ClassC is a friend class of ClassA assertEquals(classC, friends[0]); //ClassC is a friend class of ClassA
friends = classC.getFriends(); friends = classC.getFriends();
assertEquals(1, friends.length); assertEquals(1, friends.length);
assertEquals(funcB, friends[0]); //functionB is a friend of ClassC assertEquals(funcB, friends[0]); //functionB is a friend of ClassC
} }
public void noTest_testConstructor() throws Exception { public void noTest_testConstructor() throws Exception {
// the source does not define Class1, so it is no surprise that the test is failing. // the source does not define Class1, so it is no surprise that the test is failing.
//TODO PDOM doesn't have information on constructor // TODO PDOM doesn't have information on constructor
IBinding[] bindings = pdom.findBindings(Pattern.compile("Class1"), false, IndexFilter.ALL, npm()); IBinding[] bindings = pdom.findBindings(Pattern.compile("Class1"), false, IndexFilter.ALL, npm());
assertEquals(2, bindings.length); assertEquals(2, bindings.length);
assertTrue(bindings[0] instanceof ICPPClassType); assertTrue(bindings[0] instanceof ICPPClassType);
assertTrue(bindings[1] instanceof ICPPMethod); assertTrue(bindings[1] instanceof ICPPMethod);
IName[] decls = pdom.findNames(bindings[1], IIndex.FIND_DECLARATIONS_DEFINITIONS); IName[] decls = pdom.findNames(bindings[1], IIndex.FIND_DECLARATIONS_DEFINITIONS);
assertEquals(2, decls.length); assertEquals(2, decls.length);
IASTFileLocation loc = decls[0].getFileLocation(); IASTFileLocation loc = decls[0].getFileLocation();
assertEquals(offset("constructor.cpp","Class1(int num);"), loc.getNodeOffset()); //character offset assertEquals(offset("constructor.cpp","Class1(int num);"), loc.getNodeOffset()); //character offset
loc = decls[1].getFileLocation(); loc = decls[1].getFileLocation();
assertEquals(offset("constructor.cpp","Class1::Class1") + 8, loc.getNodeOffset()); //character offset assertEquals(offset("constructor.cpp","Class1::Class1") + 8, loc.getNodeOffset()); //character offset
/* Member initialization */ /* Member initialization */
bindings = pdom.findBindings(Pattern.compile("number"), false, IndexFilter.ALL, npm()); bindings = pdom.findBindings(Pattern.compile("number"), false, IndexFilter.ALL, npm());
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
IName[] refs = pdom.findNames(bindings[0], IIndex.FIND_REFERENCES); IName[] refs = pdom.findNames(bindings[0], IIndex.FIND_REFERENCES);
assertEquals(1, refs.length); assertEquals(1, refs.length);
loc = refs[0].getFileLocation(); loc = refs[0].getFileLocation();
assertEquals(offset("constructor.cpp","number(num)"), loc.getNodeOffset()); //character offset assertEquals(offset("constructor.cpp", "number(num)"), loc.getNodeOffset()); //character offset
assertEquals(bindings[0], ((PDOMName)refs[0]).getBinding()); assertEquals(bindings[0], ((PDOMName)refs[0]).getBinding());
} }
public void testAbsenceOfDefaultConstructorWhenExplicitNonDefaultPresentA() throws Exception { public void testAbsenceOfDefaultConstructorWhenExplicitNonDefaultPresentA() throws Exception {
IndexFilter JUST_CONSTRUCTORS= new IndexFilter() { IndexFilter JUST_CONSTRUCTORS= new IndexFilter() {
@Override @Override
@ -185,7 +183,7 @@ public class ClassTests extends PDOMTestBase {
// expecting C(int) and C(const C &) // expecting C(int) and C(const C &)
assertEquals(2, bindings.length); assertEquals(2, bindings.length);
} }
public void testAbsenceOfDefaultConstructorWhenExplicitNonDefaultPresentB() throws Exception { public void testAbsenceOfDefaultConstructorWhenExplicitNonDefaultPresentB() throws Exception {
IndexFilter JUST_CONSTRUCTORS= new IndexFilter() { IndexFilter JUST_CONSTRUCTORS= new IndexFilter() {
@Override @Override
@ -197,40 +195,40 @@ public class ClassTests extends PDOMTestBase {
// expecting just D(D &) // expecting just D(D &)
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
} }
public void testClassScope_bug185408() throws Exception { public void testClassScope_bug185408() throws Exception {
char[][] name= {"B".toCharArray(), "bf".toCharArray()}; char[][] name= {"B".toCharArray(), "bf".toCharArray()};
IBinding[] bindings= pdom.findBindings(name, IndexFilter.ALL, npm()); IBinding[] bindings= pdom.findBindings(name, IndexFilter.ALL, npm());
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
IScope classScope= bindings[0].getScope(); IScope classScope= bindings[0].getScope();
assertTrue(classScope instanceof ICPPClassScope); assertTrue(classScope instanceof ICPPClassScope);
bindings= classScope.find("bf"); bindings= classScope.find("bf", null);
ICPPMethod method= extractSingleMethod(bindings); ICPPMethod method= extractSingleMethod(bindings);
assertEquals(method.getQualifiedName()[0], "B"); assertEquals("B", method.getQualifiedName()[0]);
bindings= classScope.find("f"); bindings= classScope.find("f", null);
method= extractSingleMethod(bindings); method= extractSingleMethod(bindings);
assertEquals(method.getQualifiedName()[0], "A"); assertEquals("A", method.getQualifiedName()[0]);
bindings= classScope.find("B"); bindings= classScope.find("B", null);
ICPPClassType classType= extractSingleClass(bindings); ICPPClassType classType= extractSingleClass(bindings);
assertEquals(classType.getQualifiedName()[0], "B"); assertEquals("B", classType.getQualifiedName()[0]);
bindings= classScope.find("A"); bindings= classScope.find("A", null);
classType= extractSingleClass(bindings); classType= extractSingleClass(bindings);
assertEquals(classType.getQualifiedName()[0], "A"); assertEquals("A", classType.getQualifiedName()[0]);
} }
private ICPPMethod extractSingleMethod(IBinding[] bindings) { private ICPPMethod extractSingleMethod(IBinding[] bindings) {
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof ICPPMethod); assertInstance(bindings[0], ICPPMethod.class);
return (ICPPMethod) bindings[0]; return (ICPPMethod) bindings[0];
} }
private ICPPClassType extractSingleClass(IBinding[] bindings) { private ICPPClassType extractSingleClass(IBinding[] bindings) {
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof ICPPClassType); assertInstance(bindings[0], ICPPClassType.class);
return (ICPPClassType) bindings[0]; return (ICPPClassType) bindings[0];
} }

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: %pluginName Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.core; singleton:=true Bundle-SymbolicName: org.eclipse.cdt.core; singleton:=true
Bundle-Version: 5.10.0.qualifier Bundle-Version: 5.11.0.qualifier
Bundle-Activator: org.eclipse.cdt.core.CCorePlugin Bundle-Activator: org.eclipse.cdt.core.CCorePlugin
Bundle-Vendor: %providerName Bundle-Vendor: %providerName
Bundle-Localization: plugin Bundle-Localization: plugin

View file

@ -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)
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
@ -19,7 +20,7 @@ import org.eclipse.cdt.core.index.IIndexFileSet;
/** /**
* Scopes can be used to look-up names. With the exception of template-scopes the scopes * Scopes can be used to look-up names. With the exception of template-scopes the scopes
* can be arranged in a hierarchy. * can be arranged in a hierarchy.
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
@ -31,46 +32,53 @@ public interface IScope {
EScopeKind getKind(); EScopeKind getKind();
/** /**
* Returns the IName for this scope, may be {@code null} * Returns the IName for this scope, may be {@code null}.
*
* @return The name of this scope. * @return The name of this scope.
*/ */
public IName getScopeName(); public IName getScopeName();
/** /**
* Returns the first enclosing non-template scope, or {@code null} if this is the global scope. * Returns the first enclosing non-template scope, or {@code null} if this is the global scope.
*/ */
public IScope getParent() throws DOMException; public IScope getParent() throws DOMException;
/** /**
* This is the general lookup entry point. It returns the list of valid bindings for a given * This is the general lookup entry point. It returns the list of valid bindings for a given name in this
* name. The lookup proceeds as an unqualified lookup. Constructors are not considered during * scope and its enclosing scopes. The name is treated as unqualified. Constructors are not considered
* this lookup and won't be returned. No attempt is made to resolve potential ambiguities or * during this lookup and won't be returned. No attempt is made to resolve potential ambiguities or
* perform access checking. * perform access checking.
* *
* @param name the name of the bindings * @param name the name of the bindings
* @return An array of bindings. * @param tu the translation unit determining the context for the lookup
* @return An array of bindings
* @since 5.11
*/ */
public IBinding[] find(String name); public IBinding[] find(String name, IASTTranslationUnit tu);
/** /**
* Returns the binding in this scope that the given name would resolve to. Could * @deprecated Use {{@link #find(String, IASTTranslationUnit)}
* return null if there is no matching binding in this scope, if the binding has not */
* yet been cached in this scope, or if resolve is {@code false} and the appropriate binding @Deprecated
* has not yet been resolved. public IBinding[] find(String name);
*
/**
* Returns the binding in this scope that the given name would resolve to. Could return {@code null}
* if there is no matching binding in this scope, if the binding has not yet been cached in this scope,
* or if resolve is {@code false} and the appropriate binding has not yet been resolved.
*
* @param name the name of the binding * @param name the name of the binding
* @param resolve whether or not to resolve the matching binding if it has not been so already * @param resolve whether or not to resolve the matching binding if it has not been so already
* @return the binding in this scope that matches the name, or {@code null} * @return the binding in this scope that matches the name, or {@code null}
*/ */
public IBinding getBinding(IASTName name, boolean resolve); public IBinding getBinding(IASTName name, boolean resolve);
/** /**
* Returns the binding in this scope that the given name would resolve to. Could * Returns the binding in this scope that the given name would resolve to. Could return {@code null}
* return null if there is no matching binding in this scope, if the binding has not * if there is no matching binding in this scope, if the binding has not yet been cached in this scope,
* yet been cached in this scope, or if resolve is {@code false} and the appropriate binding * or if resolve is {@code false} and the appropriate binding has not yet been resolved. Accepts file
* has not yet been resolved. Accepts file local bindings from the index for the files * local bindings from the index for the files in the given set, only.
* in the given set, only. *
*
* @param name the name of the binding * @param name the name of the binding
* @param resolve whether or not to resolve the matching binding if it has not been so already * @param resolve whether or not to resolve the matching binding if it has not been so already
* @param acceptLocalBindings a set of files for which to accept local bindings * @param acceptLocalBindings a set of files for which to accept local bindings
@ -88,9 +96,9 @@ public interface IScope {
* @deprecated Use {@link #getBindings(ScopeLookupData)} instead * @deprecated Use {@link #getBindings(ScopeLookupData)} instead
*/ */
@Deprecated @Deprecated
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet acceptLocalBindings); public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup,
IIndexFileSet acceptLocalBindings);
/** /**
* @since 5.5 * @since 5.5
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
@ -103,7 +111,7 @@ public interface IScope {
private boolean fResolve= true; private boolean fResolve= true;
private boolean fPrefixLookup; private boolean fPrefixLookup;
private boolean fIgnorePointOfDeclaration; private boolean fIgnorePointOfDeclaration;
public ScopeLookupData(IASTName name, boolean resolve, boolean prefixLookup) { public ScopeLookupData(IASTName name, boolean resolve, boolean prefixLookup) {
if (name == null) if (name == null)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@ -129,6 +137,17 @@ public interface IScope {
} }
} }
/**
* @since 5.11
*/
public ScopeLookupData(char[] name, IASTTranslationUnit tu) {
fLookupPoint= null;
fLookupPointIsName= false;
fLookupKey= name;
fIgnorePointOfDeclaration= true;
fTu= tu;
}
public final void setPrefixLookup(boolean prefixLookup) { public final void setPrefixLookup(boolean prefixLookup) {
fPrefixLookup = prefixLookup; fPrefixLookup = prefixLookup;
} }
@ -183,11 +202,10 @@ public interface IScope {
} }
/** /**
* Returns the bindings in this scope that the given name or prefix could resolve to. Could * Returns the bindings in this scope that the given name or prefix could resolve to. Could return
* return null if there is no matching bindings in this scope, if the bindings have not * {@code null} if there is no matching bindings in this scope, if the bindings have not yet been cached
* yet been cached in this scope, or if resolve == false and the appropriate bindings * in this scope, or if resolve is {@code false} and the appropriate bindings have not yet been resolved.
* have not yet been resolved. *
*
* @return the bindings in this scope that match the name or prefix, or {@code null} * @return the bindings in this scope that match the name or prefix, or {@code null}
* @since 5.5 * @since 5.5
*/ */

View file

@ -174,6 +174,11 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I
throw new DOMException(this); throw new DOMException(this);
} }
@Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
return IBinding.EMPTY_BINDING_ARRAY;
}
@Override @Override
public IBinding[] find(String name) { public IBinding[] find(String name) {
return IBinding.EMPTY_BINDING_ARRAY; return IBinding.EMPTY_BINDING_ARRAY;

View file

@ -164,6 +164,11 @@ public class CScope implements ICScope, IASTInternalScope {
} }
} }
@Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
return find(name);
}
@Override @Override
public IBinding[] find(String name) { public IBinding[] find(String name) {
return CVisitor.findBindings(this, name); return CVisitor.findBindings(this, name);

View file

@ -685,7 +685,7 @@ public class CVisitor extends ASTQueries {
static IType getPtrDiffType(IASTBinaryExpression expr) { static IType getPtrDiffType(IASTBinaryExpression expr) {
IScope scope = getContainingScope(expr); IScope scope = getContainingScope(expr);
IBinding[] bs = scope.find(PTRDIFF_T); IBinding[] bs = scope.find(PTRDIFF_T, expr.getTranslationUnit());
for (IBinding b : bs) { for (IBinding b : bs) {
if (b instanceof IType) { if (b instanceof IType) {
if (!(b instanceof ICInternalBinding) || if (!(b instanceof ICInternalBinding) ||
@ -701,7 +701,7 @@ public class CVisitor extends ASTQueries {
static IType get_SIZE_T(IASTExpression expr) { static IType get_SIZE_T(IASTExpression expr) {
IASTTranslationUnit tu= expr.getTranslationUnit(); IASTTranslationUnit tu= expr.getTranslationUnit();
if (tu != null) { if (tu != null) {
IBinding[] bs = tu.getScope().find(SIZE_T); IBinding[] bs = tu.getScope().find(SIZE_T, expr.getTranslationUnit());
for (IBinding b : bs) { for (IBinding b : bs) {
if (b instanceof IType) { if (b instanceof IType) {
if (!(b instanceof ICInternalBinding) || if (!(b instanceof ICInternalBinding) ||
@ -1650,7 +1650,7 @@ public class CVisitor extends ASTQueries {
} }
// label names // label names
List<ILabel> b3 = new ArrayList<ILabel>(); List<ILabel> b3 = new ArrayList<>();
do { do {
char[] n = name.toCharArray(); char[] n = name.toCharArray();
if (scope instanceof ICFunctionScope) { if (scope instanceof ICFunctionScope) {

View file

@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
@ -337,6 +338,11 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
return getOriginalClassType().getScope(); return getOriginalClassType().getScope();
} }
@Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
return find(name);
}
@Override @Override
public IBinding[] find(String name) { public IBinding[] find(String name) {
return CPPSemantics.findBindings(this, name, false); return CPPSemantics.findBindings(this, name, false);

View file

@ -35,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFieldReference; import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
@ -429,6 +430,11 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY; return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
} }
@Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
return find(name);
}
@Override @Override
public IBinding[] find(String name) { public IBinding[] find(String name) {
char[] n = name.toCharArray(); char[] n = name.toCharArray();

View file

@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement; import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IField;
@ -386,7 +387,7 @@ public class CPPClosureType extends PlatformObject implements ICPPClassType, ICP
} }
private IBinding[] getPrefixBindings(char[] name) { private IBinding[] getPrefixBindings(char[] name) {
List<IBinding> result= new ArrayList<IBinding>(); List<IBinding> result= new ArrayList<>();
IContentAssistMatcher matcher = ContentAssistMatcherFactory.getInstance().createMatcher(name); IContentAssistMatcher matcher = ContentAssistMatcherFactory.getInstance().createMatcher(name);
for (ICPPMethod m : getMethods()) { for (ICPPMethod m : getMethods()) {
if (!(m instanceof ICPPConstructor)) { if (!(m instanceof ICPPConstructor)) {
@ -398,6 +399,11 @@ public class CPPClosureType extends PlatformObject implements ICPPClassType, ICP
return result.toArray(new IBinding[result.size()]); return result.toArray(new IBinding[result.size()]);
} }
@Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
return find(name);
}
@Override @Override
public IBinding[] find(String name) { public IBinding[] find(String name) {
return getBindings(name.toCharArray()); return getBindings(name.toCharArray());
@ -427,8 +433,8 @@ public class CPPClosureType extends PlatformObject implements ICPPClassType, ICP
@Override @Override
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup,
IIndexFileSet acceptLocalBindings) { IIndexFileSet acceptLocalBindings) {
return getBindings(new ScopeLookupData(name, resolve, prefixLookup)); return getBindings(new ScopeLookupData(name, resolve, prefixLookup));
} }
@Override @Override
public IBinding[] getBindings(ScopeLookupData lookup) { public IBinding[] getBindings(ScopeLookupData lookup) {

View file

@ -336,6 +336,11 @@ abstract public class CPPScope implements ICPPASTInternalScope {
} }
} }
@Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
return find(name);
}
@Override @Override
public IBinding[] find(String name) { public IBinding[] find(String name) {
return CPPSemantics.findBindings(this, name, false); return CPPSemantics.findBindings(this, name, false);

View file

@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
@ -97,6 +98,11 @@ public class CPPScopeMapper {
} }
@Override @Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
return fScope.find(name, tu);
}
@Override @Deprecated
public IBinding[] find(String name) { public IBinding[] find(String name) {
return fScope.find(name); return fScope.find(name);
} }

View file

@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression; import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; 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.IType; import org.eclipse.cdt.core.dom.ast.IType;
@ -78,6 +79,11 @@ public class CPPUnknownTypeScope implements ICPPInternalUnknownScope {
return null; return null;
} }
@Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
return IBinding.EMPTY_BINDING_ARRAY;
}
@Override @Override
public IBinding[] find(String name) { public IBinding[] find(String name) {
return IBinding.EMPTY_BINDING_ARRAY; return IBinding.EMPTY_BINDING_ARRAY;

View file

@ -229,7 +229,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates.TypeS
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.Context; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.Context;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.UDCMode; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.UDCMode;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Cost.Rank; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Cost.Rank;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
@ -734,7 +733,8 @@ public class CPPSemantics {
if (parent != null) if (parent != null)
parent= parent.getParent(); // the loop parent= parent.getParent(); // the loop
if (parent instanceof ICPPASTRangeBasedForStatement) { if (parent instanceof ICPPASTRangeBasedForStatement) {
IBinding[] std= parent.getTranslationUnit().getScope().find(CPPVisitor.STD); IASTTranslationUnit tu = parent.getTranslationUnit();
IBinding[] std= tu.getScope().find(CPPVisitor.STD, tu);
for (IBinding binding : std) { for (IBinding binding : std) {
if (binding instanceof ICPPNamespace) { if (binding instanceof ICPPNamespace) {
namespaces.add(((ICPPNamespace) binding).getNamespaceScope()); namespaces.add(((ICPPNamespace) binding).getNamespaceScope());
@ -815,9 +815,7 @@ public class CPPSemantics {
if (binding == null) if (binding == null)
return null; return null;
IScope scope = binding.getScope(); IScope scope = binding.getScope();
if (tu != null) { scope = SemanticUtil.mapToAST(scope, tu);
scope= tu.mapToASTScope(scope);
}
while (scope != null && !(scope instanceof ICPPNamespaceScope)) { while (scope != null && !(scope instanceof ICPPNamespaceScope)) {
scope = getParentScope(scope, tu); scope = getParentScope(scope, tu);
} }
@ -997,10 +995,7 @@ public class CPPSemantics {
} }
} }
ICPPScope scope= useTemplScope ? nextTmplScope : nextScope; ICPPScope scope= useTemplScope ? nextTmplScope : nextScope;
CPPASTTranslationUnit tu = data.getTranslationUnit(); scope = (ICPPScope) SemanticUtil.mapToAST(scope, data.getTranslationUnit());
if (tu != null) {
scope= (ICPPScope) tu.mapToASTScope((scope));
}
if (!data.usingDirectivesOnly && !(data.ignoreMembers && scope instanceof ICPPClassScope)) { if (!data.usingDirectivesOnly && !(data.ignoreMembers && scope instanceof ICPPClassScope)) {
mergeResults(data, getBindingsFromScope(scope, data), true); mergeResults(data, getBindingsFromScope(scope, data), true);
@ -1367,16 +1362,14 @@ public class CPPSemantics {
return ((ICPPASTTemplateDeclaration) parent).getScope(); return ((ICPPASTTemplateDeclaration) parent).getScope();
} }
static ICPPScope getParentScope(IScope scope, ICPPASTTranslationUnit unit) throws DOMException { static ICPPScope 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 (unit instanceof CPPASTTranslationUnit) { if (parentScope == null && scope instanceof ICPPClassSpecializationScope
if (parentScope == null && unit instanceof CPPASTTranslationUnit) {
&& (scope instanceof IIndexScope || scope instanceof ICPPClassSpecializationScope)) { parentScope = unit.getScope();
parentScope = unit.getScope(); } else {
} else { parentScope = SemanticUtil.mapToAST(parentScope, unit);
parentScope = ((CPPASTTranslationUnit) unit).mapToASTScope(parentScope);
}
} }
return (ICPPScope) parentScope; return (ICPPScope) parentScope;
} }
@ -3586,6 +3579,11 @@ public class CPPSemantics {
return type instanceof ICPPClassType || type instanceof IEnumeration || type instanceof ICPPUnknownType; return type instanceof ICPPClassType || type instanceof IEnumeration || type instanceof ICPPUnknownType;
} }
public static IBinding[] findBindingsInScope(IScope scope, String name, IASTTranslationUnit tu) {
LookupData data = new LookupData(name.toCharArray(), null, tu);
return standardLookup(data, scope);
}
public static IBinding[] findBindings(IScope scope, String name, boolean qualified) { public static IBinding[] findBindings(IScope scope, String name, boolean qualified) {
return findBindings(scope, name.toCharArray(), qualified, null); return findBindings(scope, name.toCharArray(), qualified, null);
} }

View file

@ -220,7 +220,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
import org.eclipse.cdt.internal.core.index.IIndexScope;
/** /**
* Collection of methods to extract information from a C++ translation unit. * Collection of methods to extract information from a C++ translation unit.
@ -542,15 +541,15 @@ public class CPPVisitor extends ASTQueries {
} }
if (mustBeSimple) { if (mustBeSimple) {
// 3.3.1-5 ... the identifier is declared in the smallest non-class non-function-prototype scope that contains // 3.3.1-5 ... the identifier is declared in the smallest non-class non-function-prototype
// the declaration // scope that contains the declaration.
while (scope instanceof ICPPClassScope || scope instanceof ICPPFunctionScope) { while (scope instanceof ICPPClassScope || scope instanceof ICPPFunctionScope) {
scope = (ICPPScope) getParentScope(scope, elabType.getTranslationUnit()); scope = CPPSemantics.getParentScope(scope, elabType.getTranslationUnit());
} }
} }
if (scope instanceof ICPPClassScope && isFriend && !qualified) { if (scope instanceof ICPPClassScope && isFriend && !qualified) {
while (scope instanceof ICPPClassScope) { while (scope instanceof ICPPClassScope) {
scope = (ICPPScope) getParentScope(scope, elabType.getTranslationUnit()); scope = CPPSemantics.getParentScope(scope, elabType.getTranslationUnit());
} }
} }
if (scope != null) { if (scope != null) {
@ -820,7 +819,7 @@ public class CPPVisitor extends ASTQueries {
if (isFriendDecl) { if (isFriendDecl) {
try { try {
while (scope.getKind() == EScopeKind.eClassType) { while (scope.getKind() == EScopeKind.eClassType) {
scope = (ICPPScope) getParentScope(scope, name.getTranslationUnit()); scope = CPPSemantics.getParentScope(scope, name.getTranslationUnit());
} }
} catch (DOMException e1) { } catch (DOMException e1) {
} }
@ -2369,7 +2368,7 @@ public class CPPVisitor extends ASTQueries {
if (node == null) if (node == null)
return null; return null;
ASTTranslationUnit ast = (ASTTranslationUnit) node.getTranslationUnit(); ASTTranslationUnit ast = (ASTTranslationUnit) node.getTranslationUnit();
IBinding[] std= ast.getScope().find(STD); IBinding[] std= ast.getScope().find(STD, ast);
for (IBinding binding : std) { for (IBinding binding : std) {
if (binding instanceof ICPPNamespace) { if (binding instanceof ICPPNamespace) {
final ICPPNamespaceScope scope = ((ICPPNamespace) binding).getNamespaceScope(); final ICPPNamespaceScope scope = ((ICPPNamespace) binding).getNamespaceScope();
@ -2499,16 +2498,6 @@ public class CPPVisitor extends ASTQueries {
return ns; return ns;
} }
private static IScope getParentScope(IScope scope, IASTTranslationUnit unit) throws DOMException {
IScope parentScope= scope.getParent();
// Replace the global scope from index with the global scope of the translation unit.
if ((parentScope == null || parentScope.getKind() == EScopeKind.eGlobal) &&
scope instanceof IIndexScope && unit != null) {
parentScope= unit.getScope();
}
return parentScope;
}
public static boolean isExternC(IASTNode node) { public static boolean isExternC(IASTNode node) {
while (node != null) { while (node != null) {
node= node.getParent(); node= node.getParent();

View file

@ -40,6 +40,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IScope.ScopeLookupData; import org.eclipse.cdt.core.dom.ast.IScope.ScopeLookupData;
@ -135,6 +136,11 @@ public class LookupData extends ScopeLookupData {
fTemplateArguments= templateArgs; fTemplateArguments= templateArgs;
} }
public LookupData(char[] name, ICPPTemplateArgument[] templateArgs, IASTTranslationUnit tu) {
super(name, tu);
fTemplateArguments= templateArgs;
}
@Override @Override
public CPPASTTranslationUnit getTranslationUnit() { public CPPASTTranslationUnit getTranslationUnit() {
return (CPPASTTranslationUnit) super.getTranslationUnit(); return (CPPASTTranslationUnit) super.getTranslationUnit();

View file

@ -27,7 +27,9 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
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.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer; import org.eclipse.cdt.core.dom.ast.IASTInitializer;
@ -81,6 +83,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper; import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator; import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
import org.eclipse.cdt.internal.core.index.IIndexScope;
/** /**
* Collection of static methods operating on C++ bindings. * Collection of static methods operating on C++ bindings.
@ -540,10 +543,15 @@ public class SemanticUtil {
} }
public static IScope mapToAST(IScope scope, IASTNode point) { public static IScope mapToAST(IScope scope, IASTNode point) {
if (point != null) { if (scope instanceof IIndexScope) {
IASTTranslationUnit ast = point.getTranslationUnit(); if (point != null) {
if (ast instanceof ASTTranslationUnit) { IASTTranslationUnit ast = point.getTranslationUnit();
return ((ASTTranslationUnit) ast).mapToASTScope(scope); if (ast instanceof ASTTranslationUnit) {
return ((ASTTranslationUnit) ast).mapToASTScope(scope);
}
} else if (scope.getKind() == EScopeKind.eGlobal) {
CCorePlugin.log(new Exception(
"The point argument was not provided. Returning the global index scope.")); //$NON-NLS-1$
} }
} }
return scope; return scope;

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.index.composite.c;
import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope; import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
@ -55,6 +56,12 @@ class CompositeCCompositeScope extends CompositeScope implements ICCompositeType
} }
@Override @Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
IBinding[] preresult = ((ICompositeType) rbinding).getCompositeScope().find(name, tu);
return processUncertainBindings(preresult);
}
@Override @Deprecated
public IBinding[] find(String name) { public IBinding[] find(String name) {
IBinding[] preresult = ((ICompositeType) rbinding).getCompositeScope().find(name); IBinding[] preresult = ((ICompositeType) rbinding).getCompositeScope().find(name);
return processUncertainBindings(preresult); return processUncertainBindings(preresult);

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; 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;
@ -77,6 +78,12 @@ class CompositeCPPClassScope extends CompositeScope implements ICPPClassScope {
} }
@Override @Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
IBinding[] preresult = ((ICPPClassType) rbinding).getCompositeScope().find(name, tu);
return processUncertainBindings(preresult);
}
@Override @Deprecated
public IBinding[] find(String name) { public IBinding[] find(String name) {
IBinding[] preresult = ((ICPPClassType) rbinding).getCompositeScope().find(name); IBinding[] preresult = ((ICPPClassType) rbinding).getCompositeScope().find(name);
return processUncertainBindings(preresult); return processUncertainBindings(preresult);

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
@ -81,6 +82,12 @@ public class CompositeCPPClassSpecializationScope extends CompositeScope impleme
} }
@Override @Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
createDelegate();
return fDelegate.find(name, tu);
}
@Override @Deprecated
public IBinding[] find(String name) { public IBinding[] find(String name) {
createDelegate(); createDelegate();
return fDelegate.find(name); return fDelegate.find(name);

View file

@ -6,12 +6,13 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
@ -44,16 +45,22 @@ class CompositeCPPEnumScope extends CompositeScope implements ICPPEnumScope {
@Override @Override
public IBinding[] getBindings(ScopeLookupData lookup) { public IBinding[] getBindings(ScopeLookupData lookup) {
IBinding[] bindings = ((ICPPEnumeration)rbinding).asScope().getBindings(lookup); IBinding[] bindings = ((ICPPEnumeration) rbinding).asScope().getBindings(lookup);
return processUncertainBindings(bindings); return processUncertainBindings(bindings);
} }
@Override @Override
public IBinding[] find(String name) { public IBinding[] find(String name, IASTTranslationUnit tu) {
IBinding[] preresult = ((ICPPEnumeration)rbinding).asScope().find(name); IBinding[] preresult = ((ICPPEnumeration) rbinding).asScope().find(name, tu);
return processUncertainBindings(preresult); return processUncertainBindings(preresult);
} }
@Override @Deprecated
public IBinding[] find(String name) {
IBinding[] preresult = ((ICPPEnumeration) rbinding).asScope().find(name);
return processUncertainBindings(preresult);
}
@Override @Override
public IIndexBinding getScopeBinding() { public IIndexBinding getScopeBinding() {
return cf.getCompositeBinding(rbinding); return cf.getCompositeBinding(rbinding);

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.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.ICPPNamespaceScope;
@ -74,6 +75,17 @@ class CompositeCPPNamespaceScope extends CompositeScope implements ICPPNamespace
} }
@Override @Override
final public IBinding[] find(String name, IASTTranslationUnit tu) {
IIndexFragmentBinding[][] preresult = new IIndexFragmentBinding[namespaces.length][];
for (int i= 0; i < namespaces.length; i++) {
IBinding[] raw = namespaces[i].getNamespaceScope().find(name, tu);
preresult[i] = new IIndexFragmentBinding[raw.length];
System.arraycopy(raw, 0, preresult[i], 0, raw.length);
}
return cf.getCompositeBindings(preresult);
}
@Override @Deprecated
final public IBinding[] find(String name) { final public IBinding[] find(String name) {
IIndexFragmentBinding[][] preresult = new IIndexFragmentBinding[namespaces.length][]; IIndexFragmentBinding[][] preresult = new IIndexFragmentBinding[namespaces.length][];
for (int i= 0; i < namespaces.length; i++) { for (int i= 0; i < namespaces.length; i++) {

View file

@ -10,8 +10,10 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom; package org.eclipse.cdt.internal.core.pdom.dom;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.index.IIndexFileSet;
@ -27,35 +29,47 @@ public abstract class PDOMGlobalScope implements IIndexScope {
return EScopeKind.eGlobal; return EScopeKind.eGlobal;
} }
@Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
logInvalidCallError();
return IBinding.EMPTY_BINDING_ARRAY;
}
@Override @Override
public IBinding[] find(String name) { public IBinding[] find(String name) {
throw new UnsupportedOperationException(); logInvalidCallError();
return IBinding.EMPTY_BINDING_ARRAY;
} }
@Override @Override
public IBinding getBinding(IASTName name, boolean resolve) { public IBinding getBinding(IASTName name, boolean resolve) {
throw new UnsupportedOperationException(); logInvalidCallError();
return null;
} }
@Override @Override
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet acceptLocalBindings) { public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet acceptLocalBindings) {
throw new UnsupportedOperationException(); logInvalidCallError();
return null;
} }
@Override @Override
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup) { public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup) {
throw new UnsupportedOperationException(); logInvalidCallError();
return IBinding.EMPTY_BINDING_ARRAY;
} }
@Override @Override
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup,
IIndexFileSet acceptLocalBindings) { IIndexFileSet acceptLocalBindings) {
throw new UnsupportedOperationException(); logInvalidCallError();
return IBinding.EMPTY_BINDING_ARRAY;
} }
@Override @Override
public IBinding[] getBindings(ScopeLookupData lookup) { public IBinding[] getBindings(ScopeLookupData lookup) {
throw new UnsupportedOperationException(); logInvalidCallError();
return IBinding.EMPTY_BINDING_ARRAY;
} }
@Override @Override
@ -77,4 +91,9 @@ public abstract class PDOMGlobalScope implements IIndexScope {
public String toString() { public String toString() {
return "<global scope>"; //$NON-NLS-1$ return "<global scope>"; //$NON-NLS-1$
} }
private void logInvalidCallError() {
CCorePlugin.log(new UnsupportedOperationException(
"Global index scope has to be mapped to the global scope of a particular translation unit.")); //$NON-NLS-1$
}
} }

View file

@ -20,6 +20,7 @@ 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.EScopeKind; import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IField;
@ -292,6 +293,11 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
} }
@Override @Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
return getBindings(name.toCharArray());
}
@Override @Deprecated
public IBinding[] find(String name) { public IBinding[] find(String name) {
return getBindings(name.toCharArray()); return getBindings(name.toCharArray());
} }

View file

@ -26,6 +26,7 @@ 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.EScopeKind; import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
@ -258,6 +259,11 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope {
} }
@Override @Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
return CPPSemantics.findBindingsInScope(this, name, tu);
}
@Override @Deprecated
public IBinding[] find(String name) { public IBinding[] find(String name) {
return CPPSemantics.findBindings(this, name, false); return CPPSemantics.findBindings(this, name, false);
} }

View file

@ -11,10 +11,13 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.internal.core.dom.parser.cpp.AbstractCPPClassSpecializationScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.AbstractCPPClassSpecializationScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.index.IIndexScope;
/** /**
@ -43,4 +46,9 @@ public class PDOMCPPClassSpecializationScope extends AbstractCPPClassSpecializat
public IIndexName getScopeName() { public IIndexName getScopeName() {
return null; return null;
} }
@Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
return CPPSemantics.findBindingsInScope(this, name, tu);
}
} }

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMVisitor; import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumScope;
@ -105,6 +106,11 @@ class PDOMCPPEnumScope implements ICPPEnumScope, IIndexScope {
} }
@Override @Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
return CPPSemantics.findBindingsInScope(this, name, tu);
}
@Override @Deprecated
public IBinding[] find(String name) { public IBinding[] find(String name) {
return CPPSemantics.findBindings(this, name, false); return CPPSemantics.findBindings(this, name, false);
} }

View file

@ -22,6 +22,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMVisitor; import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.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.ICPPNamespaceScope;
@ -166,6 +167,11 @@ class PDOMCPPNamespace extends PDOMCPPBinding
return ICPPUsingDirective.EMPTY_ARRAY; return ICPPUsingDirective.EMPTY_ARRAY;
} }
@Override
public IBinding[] find(String name, IASTTranslationUnit tu) {
return find(name);
}
@Override @Override
public IBinding[] find(String name) { public IBinding[] find(String name) {
try { try {

View file

@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<version>5.10.0-SNAPSHOT</version> <version>5.11.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.core</artifactId> <artifactId>org.eclipse.cdt.core</artifactId>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
</project> </project>

View file

@ -691,10 +691,10 @@ public class ASTManager implements IDisposable {
} }
} }
public static IBinding[] findInScope(final IScope scope, String name, boolean removeGlobalsWhenClassScope) public static IBinding[] findInScope(final IScope scope, String name, IASTTranslationUnit tu,
throws DOMException { boolean removeGlobalsWhenClassScope) throws DOMException {
IBinding[] result= null; IBinding[] result= null;
result = scope.find(name); result = scope.find(name, tu);
if (result == null || result.length == 0) { if (result == null || result.length == 0) {
return result; return result;
} }
@ -706,7 +706,7 @@ public class ASTManager implements IDisposable {
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
IBinding binding = result[i]; IBinding binding = result[i];
IScope bscope= binding.getScope(); IScope bscope= binding.getScope();
if (! (bscope instanceof ICPPClassScope || bscope instanceof ICCompositeTypeScope)) { if (!(bscope instanceof ICPPClassScope || bscope instanceof ICCompositeTypeScope)) {
result[i]= null; result[i]= null;
} else { } else {
count++; count++;
@ -1197,7 +1197,7 @@ public class ASTManager implements IDisposable {
if (scope != null) { if (scope != null) {
IBinding[] conflicting= null; IBinding[] conflicting= null;
try { try {
conflicting= findInScope(scope, fRenameTo, true); conflicting= findInScope(scope, fRenameTo, name.getTranslationUnit(), true);
} catch (Exception e) { } catch (Exception e) {
CUIPlugin.log(e); CUIPlugin.log(e);
} }
@ -1445,7 +1445,7 @@ public class ASTManager implements IDisposable {
try { try {
oldBindingsScope = oldBinding.getScope(); oldBindingsScope = oldBinding.getScope();
if (oldBindingsScope != null) { if (oldBindingsScope != null) {
newBindingsAboverOrEqual = ASTManager.findInScope(oldBindingsScope, fRenameTo, false); newBindingsAboverOrEqual = ASTManager.findInScope(oldBindingsScope, fRenameTo, null, false);
} }
} catch (DOMException e) { } catch (DOMException e) {
handleDOMException(tu, e, status); handleDOMException(tu, e, status);

View file

@ -96,10 +96,10 @@ public class CRenameClassProcessor extends CRenameTypeProcessor {
if (ctors != null) { if (ctors != null) {
ArrayUtil.addAll(bindings, ctors); ArrayUtil.addAll(bindings, ctors);
} }
IScope scope= ctype.getCompositeScope(); IScope scope= ctype.getCompositeScope();
if (scope != null) { if (scope != null) {
IBinding[] dtors= scope.find("~" + argument.getName()); //$NON-NLS-1$ IBinding[] dtors= scope.find("~" + argument.getName(), argument.getTranslationUnit()); //$NON-NLS-1$
if (dtors != null) { if (dtors != null) {
ArrayUtil.addAll(bindings, dtors); ArrayUtil.addAll(bindings, dtors);
} }

View file

@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; 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.index.IIndexFileSet; import org.eclipse.cdt.core.index.IIndexFileSet;
@ -25,9 +26,6 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
*/ */
@SuppressWarnings({"restriction","unused"}) @SuppressWarnings({"restriction","unused"})
public class C99Scope implements IC99Scope, IASTInternalScope { public class C99Scope implements IC99Scope, IASTInternalScope {
private IScope parent; private IScope parent;
private IASTNode physicalNode; private IASTNode physicalNode;
private IName scopeName; private IName scopeName;
@ -72,9 +70,13 @@ public class C99Scope implements IC99Scope, IASTInternalScope {
this.scopeName = scopeName; this.scopeName = scopeName;
} }
@Override @Override
public IBinding[] find( String name) { public IBinding[] find(String name, IASTTranslationUnit tu) {
throw new UnsupportedOperationException();
}
@Override @Deprecated
public IBinding[] find(String name) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@ -87,9 +89,6 @@ public class C99Scope implements IC99Scope, IASTInternalScope {
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup) { public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override @Override
public void addBinding(IBinding binding) { public void addBinding(IBinding binding) {
@ -110,9 +109,7 @@ public class C99Scope implements IC99Scope, IASTInternalScope {
} }
@Override @Override
public IBinding getBinding(IASTName name, boolean resolve, public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet acceptLocalBindings) {
IIndexFileSet acceptLocalBindings) {
// TODO Auto-generated method stub
return null; return null;
} }
@ -123,15 +120,11 @@ public class C99Scope implements IC99Scope, IASTInternalScope {
@Deprecated @Deprecated
public IBinding[] getBindings(IASTName name, boolean resolve, public IBinding[] getBindings(IASTName name, boolean resolve,
boolean prefixLookup, IIndexFileSet acceptLocalBindings) { boolean prefixLookup, IIndexFileSet acceptLocalBindings) {
return getBindings(new ScopeLookupData(name, resolve, prefixLookup)); return getBindings(new ScopeLookupData(name, resolve, prefixLookup));
} }
@Override @Override
public IBinding[] getBindings(ScopeLookupData lookup) { public IBinding[] getBindings(ScopeLookupData lookup) {
// TODO Auto-generated method stub return IBinding.EMPTY_BINDING_ARRAY;
return null;
} }
} }