1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Static variables/functions in Open Element and Search (bug 193057 and 196414).

This commit is contained in:
Markus Schorn 2007-11-22 15:57:17 +00:00
parent 41e74e8cbf
commit 9b07ea66db
20 changed files with 195 additions and 103 deletions

View file

@ -234,18 +234,18 @@ public class IndexSearchTest extends IndexTestBase {
checkIsEnumeration(bindings[0]);
}
public void _testFindStatic_161216() throws CoreException {
public void testFindStatic_161216() throws CoreException {
Pattern pFunc= Pattern.compile("staticFunc20061017");
Pattern pVar= Pattern.compile("staticVar20061017");
IIndexBinding[] bindings;
bindings= fIndex.findBindings(pFunc, true, INDEX_FILTER, NPM);
bindings= fIndex.findBindings(pFunc, false, INDEX_FILTER, NPM);
assertEquals(2, bindings.length);
checkIsFunction(bindings[0]);
checkIsFunction(bindings[1]);
bindings= fIndex.findBindings(pVar, true, INDEX_FILTER, NPM);
bindings= fIndex.findBindings(pVar, false, INDEX_FILTER, NPM);
assertEquals(2, bindings.length);
checkIsVariable(bindings[0]);
checkIsVariable(bindings[1]);

View file

@ -57,9 +57,9 @@ public class CFunctionTests extends PDOMTestBase {
public void testStaticCFunction() throws Exception {
// static elements cannot be found on global scope, see bug 161216
IBinding[] bindings = findQualifiedName(pdom, "staticCFunction");
assertEquals(0, bindings.length);
// assertTrue(((IFunction) bindings[0]).isStatic());
IBinding[] bindings = findUnqualifiedName(pdom, "staticCFunction");
assertEquals(1, bindings.length);
assertTrue(((IFunction) bindings[0]).isStatic());
}
public void testInlineCFunction() throws Exception {

View file

@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.pdom.tests;
@ -117,9 +118,9 @@ public class CPPFunctionTests extends PDOMTestBase {
public void testStaticCPPFunction() throws Exception {
// static elements cannot be found on global scope, see bug 161216
IBinding[] bindings = findQualifiedName(pdom, "staticCPPFunction");
assertEquals(0, bindings.length);
// assertTrue(((ICPPFunction) bindings[0]).isStatic());
IBinding[] bindings = findUnqualifiedName(pdom, "staticCPPFunction");
assertEquals(1, bindings.length);
assertTrue(((ICPPFunction) bindings[0]).isStatic());
}
public void testInlineCPPFunction() throws Exception {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006 IBM Corporation.
* Copyright (c) 2006, 2007 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.pdom.tests;
@ -70,9 +71,9 @@ public class CPPVariableTests extends PDOMTestBase {
public void testCPPStaticVariable() throws Exception {
// static elements cannot be found on global scope, see bug 161216
IBinding[] bindings = findQualifiedName(pdom, "staticCPPVariable");
assertEquals(0, bindings.length);
// ICPPVariable variable = (ICPPVariable) bindings[0];
// assertTrue(variable.isStatic());
IBinding[] bindings = findUnqualifiedName(pdom, "staticCPPVariable");
assertEquals(1, bindings.length);
ICPPVariable variable = (ICPPVariable) bindings[0];
assertTrue(variable.isStatic());
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006 IBM Corporation.
* Copyright (c) 2006, 2007 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.pdom.tests;
@ -70,10 +71,10 @@ public class CVariableTests extends PDOMTestBase {
public void testCStaticVariable() throws Exception {
// static elements cannot be found on global scope, see bug 161216
IBinding[] bindings = findQualifiedName(pdom, "staticCVariable");
assertEquals(0, bindings.length);
// IVariable variable = (IVariable) bindings[0];
// assertTrue(variable.isStatic());
IBinding[] bindings = findUnqualifiedName(pdom, "staticCVariable");
assertEquals(1, bindings.length);
IVariable variable = (IVariable) bindings[0];
assertTrue(variable.isStatic());
}
}

View file

@ -6,10 +6,10 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* IBM Corporation
* Symbian - Fix a race condition (157992)
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* IBM Corporation
* Symbian - Fix a race condition (157992)
*******************************************************************************/
package org.eclipse.cdt.internal.pdom.tests;
@ -121,6 +121,15 @@ public class PDOMTestBase extends BaseTestCase {
return pdom.findBindings(pattern, true, IndexFilter.ALL, PROGRESS);
}
protected IBinding[] findUnqualifiedName(PDOM pdom, String name) throws CoreException {
String[] segments = name.split("::");
Pattern[] pattern = new Pattern[segments.length];
for (int i = 0; i < segments.length; i++) {
pattern[i] = Pattern.compile(segments[i]);
}
return pdom.findBindings(pattern, false, IndexFilter.ALL, PROGRESS);
}
/**
* Convenience method for checking the number of PDOM references for a
* particular name.

View file

@ -66,6 +66,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
}
private final String[] fqn;
private final String fileLocal;
private final int elementType;
private final IIndex index;
private final String[] params;
@ -81,6 +82,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
public static IndexTypeInfo create(IIndex index, IIndexBinding binding) {
String[] fqn;
int elementType;
String flsq= null;
try {
elementType = IndexModelUtil.getElementType(binding);
if (binding instanceof ICPPBinding) {
@ -94,18 +96,22 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
else {
fqn= new String[] {binding.getName()};
}
try {
flsq = binding.getFileLocalScopeQualifier();
} catch (CoreException e) {
}
if (binding instanceof IFunction) {
final IFunction function= (IFunction)binding;
final String[] paramTypes= IndexModelUtil.extractParameterTypes(function);
final String returnType= IndexModelUtil.extractReturnType(function);
return new IndexTypeInfo(fqn, elementType, paramTypes, returnType, index);
return new IndexTypeInfo(fqn, flsq, elementType, index, paramTypes, returnType, null);
}
} catch (DOMException e) {
// index bindings don't throw DOMExceptions.
throw new AssertionError();
}
return new IndexTypeInfo(fqn, elementType, index);
return new IndexTypeInfo(fqn, flsq, elementType, index, null, null, null);
}
/**
@ -119,9 +125,10 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
return new IndexTypeInfo(new String[] {new String(name)}, ICElement.C_MACRO, index);
}
private IndexTypeInfo(String[] fqn, int elementType, IIndex index, String[] params, String returnType, ITypeReference reference) {
private IndexTypeInfo(String[] fqn, String fileLocal, int elementType, IIndex index, String[] params, String returnType, ITypeReference reference) {
Assert.isTrue(index != null);
this.fqn= fqn;
this.fileLocal= fileLocal;
this.elementType= elementType;
this.index= index;
this.params= params;
@ -133,18 +140,18 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
* @deprecated, use {@link #create(IIndex, IBinding)}.
*/
public IndexTypeInfo(String[] fqn, int elementType, IIndex index) {
this(fqn, elementType, index, null, null, null);
this(fqn, null, elementType, index, null, null, null);
}
/**
* @deprecated, use {@link #create(IIndex, IBinding)}.
*/
public IndexTypeInfo(String[] fqn, int elementType, String[] params, String returnType, IIndex index) {
this(fqn, elementType, index, params, returnType, null);
this(fqn, null, elementType, index, params, returnType, null);
}
public IndexTypeInfo(IndexTypeInfo rhs, ITypeReference ref) {
this(rhs.fqn, rhs.elementType, rhs.index, rhs.params, rhs.returnType, ref);
this(rhs.fqn, rhs.fileLocal, rhs.elementType, rhs.index, rhs.params, rhs.returnType, ref);
}
public void addDerivedReference(ITypeReference location) {
@ -337,11 +344,19 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
List references= new ArrayList();
try {
index.acquireReadLock();
char[][] cfqn = new char[fqn.length][];
for(int i=0; i<fqn.length; i++)
cfqn[i] = fqn[i].toCharArray();
int j= 0;
char[][] cfqn;
if (fileLocal != null) {
cfqn = new char[fqn.length+1][];
cfqn[j++]= fileLocal.toCharArray();
}
else {
cfqn = new char[fqn.length][];
}
for(int i=0; i<fqn.length; i++) {
cfqn[j++] = fqn[i].toCharArray();
}
IIndexBinding[] ibs = index.findBindings(cfqn, new IndexFilter() {
public boolean acceptBinding(IBinding binding) {
boolean sameType= IndexModelUtil.bindingHasCElementType(binding, new int[]{elementType});
@ -366,7 +381,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
if (names.length == 0) {
names= index.findNames(binding, IIndex.FIND_DECLARATIONS);
}
for (int j = 0; j < names.length; j++) {
for (j = 0; j < names.length; j++) {
IIndexName indexName = names[j];
if (checkFile(iflMap, indexName.getFile())) {
IndexTypeReference ref= createReference(binding, indexName);

View file

@ -250,6 +250,9 @@ public interface IIndex {
/**
* Searches for all bindings in global scope with a given name. In case a binding exists in multiple projects, no duplicate bindings are returned.
* This method makes use of the BTree and is faster than the methods using patterns.
* <p>
* To find bindings for file-local (static) variables or functions you need to provide an additional qualifier. It can be obtained by calling
* {@link #getFileLocalScopeQualifier()} or {@link IndexLocationFactory#getFileLocalQualifier(IIndexLocation)}.
* @param names an array of names, which has to be matched by the qualified name of the bindings.
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor to report progress, may be <code>null</code>.
@ -342,4 +345,11 @@ public interface IIndex {
* @throws CoreException
*/
public IIndexBinding adaptBinding(IBinding binding);
/**
* Returns the additional qualifier with which you can search for static (file-local) functions and
* variables.
* @see #findBindings(char[][], IndexFilter, IProgressMonitor).
*/
public String getFileLocalScopeQualifier(IIndexFileLocation loc);
}

View file

@ -43,4 +43,11 @@ public interface IIndexBinding extends IBinding {
* in another index.
*/
boolean isFileLocal() throws CoreException;
/**
* Returns the qualifier that can be used to search for file local bindings using
* {@link IIndex#findBindings(char[][], IndexFilter, org.eclipse.core.runtime.IProgressMonitor)}.
* In case the binding is not file-local, <code>null</code> is returned.
*/
String getFileLocalScopeQualifier() throws CoreException;
}

View file

@ -558,4 +558,32 @@ public class CIndex implements IIndex {
fFragments[i].resetCacheCounters();
}
}
public String getFileLocalScopeQualifier(IIndexFileLocation loc) {
return new String(getFileLocalScopeQualifier(loc.getFullPath()));
}
public static char[] getFileLocalScopeQualifier(String fullPath) {
char[] fname= fullPath.toCharArray();
int fnamestart= findFileNameStart(fname);
StringBuffer buf= new StringBuffer();
buf.append('{');
buf.append(fname, fnamestart, fname.length-fnamestart);
buf.append(':');
buf.append(fullPath.hashCode());
buf.append('}');
fname= buf.toString().toCharArray();
return fname;
}
private static int findFileNameStart(char[] fname) {
for (int i= fname.length-2; i>=0; i--) {
switch (fname[i]) {
case '/':
case '\\':
return i+1;
}
}
return 0;
}
}

View file

@ -121,4 +121,8 @@ final public class EmptyCIndex implements IIndex {
public IIndexMacro[] findMacrosForPrefix(char[] prefix, IndexFilter filter, IProgressMonitor monitor) {
return IIndexMacro.EMPTY_INDEX_MACRO_ARRAY;
}
public String getFileLocalScopeQualifier(IIndexFileLocation loc) {
return new String(CIndex.getFileLocalScopeQualifier(loc.getFullPath()));
}
}

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems)
* Bryan Wilkinson (QNX)
* Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems)
* Bryan Wilkinson (QNX)
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite;
@ -87,9 +87,13 @@ public abstract class CompositeIndexBinding implements IIndexBinding {
}
public boolean isFileLocal() throws CoreException {
return rbinding instanceof IIndexBinding ? ((IIndexBinding)rbinding).isFileLocal() : true;
return rbinding != null ? rbinding.isFileLocal() : false;
}
public String getFileLocalScopeQualifier() throws CoreException {
return rbinding != null ? rbinding.getFileLocalScopeQualifier() : null;
}
public boolean equals(Object obj) {
if (obj == this)
return true;

View file

@ -54,12 +54,14 @@ import org.eclipse.cdt.internal.core.pdom.dom.BindingCollector;
import org.eclipse.cdt.internal.core.pdom.dom.FindBinding;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
import org.eclipse.cdt.internal.core.pdom.dom.MacroCollector;
import org.eclipse.cdt.internal.core.pdom.dom.NamedNodeCollector;
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.PDOMInclude;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMacro;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@ -372,20 +374,20 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
if (monitor.isCanceled())
throw new CoreException(Status.OK_STATUS);
if (node instanceof PDOMBinding) {
PDOMBinding binding = (PDOMBinding)node;
String name = binding.getName();
if (node instanceof PDOMNamedNode) {
PDOMNamedNode nnode = (PDOMNamedNode)node;
String name = new String(nnode.getNameCharArray());
// check if we have a complete match.
final int lastIdx = pattern.length-1;
if (matchesUpToLevel.get(lastIdx) && pattern[lastIdx].matcher(name).matches()) {
if (filter.acceptBinding(binding)) {
bindings.add(binding);
if (nnode instanceof IBinding && filter.acceptBinding((IBinding) nnode)) {
bindings.add(nnode);
}
}
// check if we have a partial match
if (binding.mayHaveChildren()) {
if (nnode.mayHaveChildren()) {
boolean visitNextLevel= false;
BitSet updatedMatchesUpToLevel= new BitSet();
if (!isFullyQualified) {
@ -401,7 +403,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
if (visitNextLevel) {
matchStack.add(matchesUpToLevel);
matchesUpToLevel= updatedMatchesUpToLevel;
currentPath.add(binding);
currentPath.add(nnode);
return true;
}
}
@ -449,24 +451,33 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
}
public IIndexFragmentBinding[] findBindings(char[][] names, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
if (names.length == 0) {
return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
}
ArrayList result= new ArrayList();
ArrayList nodes= new ArrayList();
for (Iterator iter = fLinkageIDCache.values().iterator(); iter.hasNext();) {
PDOMLinkage linkage = (PDOMLinkage) iter.next();
if (filter.acceptLinkage(linkage)) {
ArrayList bindings= new ArrayList();
bindings.add(linkage);
for (int i=0; i < names.length; i++) {
nodes.add(linkage);
for (int i=0; i < names.length-1; i++) {
char[] name= names[i];
IndexFilter levelFilter= i==names.length-1 ? filter : IndexFilter.ALL;
BindingCollector collector= new BindingCollector(linkage, name, levelFilter, false, true);
for (Iterator in = bindings.iterator(); in.hasNext();) {
NamedNodeCollector collector= new NamedNodeCollector(linkage, name, false, true);
for (Iterator in = nodes.iterator(); in.hasNext();) {
PDOMNode node= (PDOMNode) in.next();
node.accept(collector);
}
bindings.clear();
bindings.addAll(Arrays.asList(collector.getBindings()));
nodes.clear();
nodes.addAll(Arrays.asList(collector.getNodes()));
}
result.addAll(bindings);
char[] name= names[names.length-1];
BindingCollector collector= new BindingCollector(linkage, name, filter, false, true);
for (Iterator in = nodes.iterator(); in.hasNext();) {
PDOMNode node= (PDOMNode) in.next();
node.accept(collector);
}
nodes.clear();
result.addAll(Arrays.asList(collector.getBindings()));
}
}
return (IIndexFragmentBinding[]) result.toArray(new IIndexFragmentBinding[result.size()]);

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Andrew Ferguson (Symbian)
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Andrew Ferguson (Symbian)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
@ -242,10 +242,6 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
* Convenience method to shorten subclass file length
*/
protected final void fail() { throw new PDOMNotImplementedError(); }
public boolean mayHaveChildren() {
return false;
}
public IName getScopeName() throws DOMException {
try {
@ -279,7 +275,15 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
final public boolean isFileLocal() throws CoreException {
return getParentNode() instanceof PDOMFileLocalScope;
}
final public String getFileLocalScopeQualifier() throws CoreException {
final PDOMNode parentNode = getParentNode();
if (parentNode instanceof PDOMFileLocalScope) {
return ((PDOMFileLocalScope) parentNode).getDBName().getString();
}
return null;
}
public boolean hasDefinition() throws CoreException {
return getFirstDefinition()!=null;

View file

@ -56,4 +56,8 @@ public class PDOMFileLocalScope extends PDOMNamedNode implements IPDOMMemberOwne
// no support for deleting bindings and their scopes.
assert false;
}
public boolean mayHaveChildren() {
return true;
}
}

View file

@ -41,6 +41,7 @@ import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexLinkage;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.index.CIndex;
import org.eclipse.cdt.internal.core.index.IIndexBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.index.composite.CompositeScope;
@ -130,11 +131,11 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
return 0;
}
public boolean visit(int record) throws CoreException {
PDOMBinding binding = pdom.getBinding(record);
if (binding != null) {
if (visitor.visit(binding))
binding.accept(visitor);
visitor.leave(binding);
PDOMNode node= getNode(record);
if (node != null) {
if (visitor.visit(node))
node.accept(visitor);
visitor.leave(node);
}
return true;
}
@ -372,15 +373,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
* @since 4.0
*/
final protected PDOMFileLocalScope findFileLocalScope(String fileName, boolean create) throws CoreException {
char[] fname= fileName.toCharArray();
int fnamestart= findFileNameStart(fname);
StringBuffer buf= new StringBuffer();
buf.append('{');
buf.append(fname, fnamestart, fname.length-fnamestart);
buf.append(':');
buf.append(fileName.hashCode());
buf.append('}');
fname= buf.toString().toCharArray();
char[] fname = CIndex.getFileLocalScopeQualifier(fileName);
final PDOMFileLocalScope[] fls= new PDOMFileLocalScope[] {null};
NamedNodeCollector collector= new NamedNodeCollector(this, fname) {
@ -399,17 +392,6 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
}
return fls[0];
}
private static int findFileNameStart(char[] fname) {
for (int i= fname.length-2; i>=0; i--) {
switch (fname[i]) {
case '/':
case '\\':
return i+1;
}
}
return 0;
}
public void deleteType(IType type, int ownerRec) throws CoreException {
if (type instanceof PDOMNode) {

View file

@ -6,9 +6,10 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX - Initial API and implementation
* IBM Corporation
* Andrew Ferguson (Symbian)
* QNX - Initial API and implementation
* IBM Corporation
* Andrew Ferguson (Symbian)
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
@ -75,4 +76,8 @@ public abstract class PDOMNamedNode extends PDOMNode {
}
super.delete(linkage);
}
public boolean mayHaveChildren() {
return false;
}
}

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX - Initial API and implementation
* Andrew Ferguson (Symbian)
* QNX - Initial API and implementation
* Andrew Ferguson (Symbian)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.c;
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.pdom.PDOM;
@ -74,7 +75,7 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter, IIndexFragment
}
public int getNodeType() {
return PDOMCLinkage.CPARAMETER;
return IIndexCBindingConstants.CPARAMETER;
}
public void setNextParameter(PDOMCParameter nextParam) throws CoreException {
@ -161,6 +162,9 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter, IIndexFragment
public boolean isFileLocal() throws CoreException {
return true;
}
public String getFileLocalScopeQualifier() throws CoreException {
return null;
}
public String[] getQualifiedName() {
throw new PDOMNotImplementedError();

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* IBM Corporation
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameter;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDelegateCreator;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.pdom.PDOM;
@ -121,7 +122,7 @@ class PDOMCPPParameter extends PDOMNamedNode
}
public int getNodeType() {
return PDOMCPPLinkage.CPPPARAMETER;
return IIndexCPPBindingConstants.CPPPARAMETER;
}
public void setNextParameter(PDOMCPPParameter nextParam) throws CoreException {
@ -236,6 +237,10 @@ class PDOMCPPParameter extends PDOMNamedNode
return true;
}
public String getFileLocalScopeQualifier() throws CoreException {
return null;
}
public int getBindingConstant() {
return getNodeType();
}

View file

@ -271,10 +271,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
final IndexFilter filter= new IndexFilter() {
public boolean acceptBinding(IBinding binding) throws CoreException {
if (isVisibleType(IndexModelUtil.getElementType(binding))) {
if (IndexFilter.ALL_DECLARED.acceptBinding(binding)) {
// until we have correctly modeled file-local variables and functions, don't show them.
return !((IIndexBinding) binding).isFileLocal();
}
return IndexFilter.ALL_DECLARED.acceptBinding(binding);
}
return false;
}