1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Static variables shown as global in search, bug 255192.

This commit is contained in:
Markus Schorn 2008-12-17 16:18:50 +00:00
parent a036483c18
commit eea81e9d95
3 changed files with 18 additions and 7 deletions

View file

@ -51,7 +51,7 @@ import org.eclipse.core.runtime.Path;
/**
* @author Doug Schaefer
*
* @noextend This class is not intended to be subclassed by clients.
*/
public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
private static int hashCode(String[] array) {
@ -562,4 +562,11 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
return false;
return true;
}
/**
* @since 5.1
*/
public boolean isFileLocal() {
return fileLocal != null;
}
}

View file

@ -17,6 +17,7 @@ package org.eclipse.cdt.internal.core.browser;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
@ -27,8 +28,6 @@ import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
@ -141,7 +140,7 @@ public class IndexModelUtil {
scope = binding.getScope();
} catch (DOMException e) {
}
if (scope instanceof ICPPBlockScope || scope instanceof ICFunctionScope) {
if (scope != null && scope.getKind() == EScopeKind.eLocal) {
elementType= ICElement.C_VARIABLE_LOCAL;
} else {
elementType = ICElement.C_VARIABLE;

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.core.browser.IFunctionInfo;
import org.eclipse.cdt.core.browser.IQualifiedTypeName;
import org.eclipse.cdt.core.browser.ITypeInfo;
import org.eclipse.cdt.core.browser.ITypeReference;
import org.eclipse.cdt.core.browser.IndexTypeInfo;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
@ -91,9 +92,13 @@ public class TypeInfoLabelProvider extends LabelProvider {
buf.append(TypeInfoMessages.TypeInfoLabelProvider_globalScope);
}
} else if (isSet(SHOW_FULLY_QUALIFIED)) {
if (typeInfo.getCElementType() != ICElement.C_VARIABLE_LOCAL && qualifiedName.isGlobal()) {
buf.append(TypeInfoMessages.TypeInfoLabelProvider_globalScope);
buf.append(' ');
final int elemType = typeInfo.getCElementType();
if (elemType != ICElement.C_VARIABLE_LOCAL && qualifiedName.isGlobal()) {
if ((elemType != ICElement.C_FUNCTION && elemType != ICElement.C_VARIABLE) ||
!(typeInfo instanceof IndexTypeInfo && ((IndexTypeInfo) typeInfo).isFileLocal())) {
buf.append(TypeInfoMessages.TypeInfoLabelProvider_globalScope);
buf.append(' ');
}
}
buf.append(qualifiedName.getFullyQualifiedName());
}