1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-31 04:45:38 +02:00

Introduces a classification for scopes, bug 237026

This commit is contained in:
Markus Schorn 2008-07-31 15:05:55 +00:00
parent 8152453880
commit 1cd6b6c8a9
35 changed files with 197 additions and 24 deletions

View file

@ -0,0 +1,36 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
/**
* Enumerates various kinds of scopes
* @since 5.1
*
* @noextend This class is not intended to be subclassed by clients.
*/
public enum EScopeKind {
/**
* Used for local scope, but also for function-scope (labels) and
* function-prototype scope (parameters in function prototypes).
*/
eLocal,
eNamespace,
/**
* For classes, structs or unions.
*/
eClassType,
eGlobal,
/**
* For each template declaration a scope is created in which the template
* parameters can be looked up.
*/
eTemplateDeclaration
}

View file

@ -22,6 +22,12 @@ import org.eclipse.cdt.core.index.IIndexFileSet;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IScope {
/**
* Classifies the scope.
* @since 5.1
*/
EScopeKind getKind();
/**
* Get the IName for this scope, may be null

View file

@ -17,6 +17,7 @@ import java.text.MessageFormat;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -45,6 +46,10 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I
this.node = node;
}
public EScopeKind getKind() {
return EScopeKind.eLocal;
}
public IASTNode getASTNode() {
return node;
}

View file

@ -12,6 +12,7 @@
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
@ -43,7 +44,7 @@ public class CASTCompoundStatement extends CASTNode implements IASTCompoundState
public IScope getScope() {
if( scope == null )
scope = new CScope( this );
scope = new CScope( this, EScopeKind.eClassType);
return scope;
}

View file

@ -12,6 +12,7 @@
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -90,7 +91,7 @@ public class CASTForStatement extends CASTNode implements IASTForStatement, IAST
public IScope getScope() {
if( scope == null )
scope = new CScope( this );
scope = new CScope( this, EScopeKind.eLocal);
return scope;
}

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
@ -36,7 +37,7 @@ public class CASTTranslationUnit extends ASTTranslationUnit {
*/
public IScope getScope() {
if (compilationUnit == null)
compilationUnit = new CScope(this);
compilationUnit = new CScope(this, EScopeKind.eGlobal);
return compilationUnit;
}

View file

@ -16,6 +16,7 @@
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
@ -29,7 +30,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
*/
public class CCompositeTypeScope extends CScope implements ICCompositeTypeScope {
public CCompositeTypeScope( ICASTCompositeTypeSpecifier compTypeSpec ){
super( compTypeSpec );
super( compTypeSpec, EScopeKind.eClassType);
}
/* (non-Javadoc)

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
@ -29,7 +30,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
*/
public class CFunctionScope extends CScope implements ICFunctionScope {
public CFunctionScope( IASTFunctionDefinition function ){
super( function );
super( function, EScopeKind.eLocal);
}
/* (non-Javadoc)

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
@ -95,11 +96,17 @@ public class CScope implements ICScope, IASTInternalScope {
private CharArrayObjectMap[] mapsToNameOrBinding = { CharArrayObjectMap.EMPTY_MAP, CharArrayObjectMap.EMPTY_MAP };
private ObjectMap reuseBindings= null;
private final EScopeKind kind;
public CScope( IASTNode physical ){
public CScope( IASTNode physical, EScopeKind eKind){
physicalNode = physical;
kind= eKind;
}
public EScopeKind getKind() {
return kind;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#getParent()
*/

View file

@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
@ -158,4 +159,8 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
IName name = getScopeName();
return name != null ? name.toString() : String.valueOf(specialClass);
}
public EScopeKind getKind() {
return EScopeKind.eClassType;
}
}

View file

@ -16,6 +16,7 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
@ -31,6 +32,11 @@ public class CPPBlockScope extends CPPNamespaceScope implements ICPPBlockScope {
super( physicalNode );
}
@Override
public EScopeKind getKind() {
return EScopeKind.eLocal;
}
@Override
public IName getScopeName(){
IASTNode node = getPhysicalNode();

View file

@ -19,6 +19,7 @@ import java.util.List;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
@ -71,6 +72,10 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
createImplicitMembers();
}
public EScopeKind getKind() {
return EScopeKind.eClassType;
}
// 12.1 The default constructor, copy constructor, copy assignment operator, and destructor are
//special member functions. The implementation will implicitly declare these member functions
//for a class type when the program does not declare them.

View file

@ -17,6 +17,7 @@ import java.util.List;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
@ -46,6 +47,10 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
super(physicalNode);
}
public EScopeKind getKind() {
return EScopeKind.eLocal;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#addBinding(org.eclipse.cdt.core.dom.ast.IBinding)
*/

View file

@ -13,8 +13,10 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
@ -35,6 +37,13 @@ public class CPPNamespaceScope extends CPPScope implements ICPPNamespaceScope{
super( physicalNode );
}
public EScopeKind getKind() {
if (getPhysicalNode() instanceof IASTTranslationUnit)
return EScopeKind.eGlobal;
return EScopeKind.eNamespace;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope#getUsingDirectives()
*/

View file

@ -18,6 +18,7 @@ import java.util.Map;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
@ -44,6 +45,10 @@ public class CPPScopeMapper {
fScope= scope;
}
public EScopeKind getKind() {
return fScope.getKind();
}
public IBinding[] find(String name) throws DOMException {
return fScope.find(name);
}

View file

@ -12,6 +12,7 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
@ -29,6 +30,10 @@ public class CPPTemplateScope extends CPPScope implements ICPPTemplateScope {
super(physicalNode);
}
public EScopeKind getKind() {
return EScopeKind.eTemplateDeclaration;
}
public ICPPTemplateDefinition getTemplateDefinition() {
return null;
}

View file

@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
@ -43,6 +44,10 @@ public class CPPUnknownScope implements ICPPScope, ICPPInternalUnknownScope {
this.binding = binding;
}
public EScopeKind getKind() {
return EScopeKind.eClassType;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#getScopeName()
*/

View file

@ -785,9 +785,15 @@ public class CPPVisitor {
IASTNode parent = node.getParent();
if (parent instanceof ICPPASTFunctionDeclarator) {
ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) parent;
IScope scope= dtor.getFunctionScope();
if (scope != null)
return scope;
if (CPPVisitor.findTypeRelevantDeclarator(dtor) == dtor) {
while (parent.getParent() instanceof IASTDeclarator)
parent = parent.getParent();
ASTNodeProperty prop = parent.getPropertyInParent();
if (prop == IASTSimpleDeclaration.DECLARATOR)
return dtor.getFunctionScope();
else if (prop == IASTFunctionDefinition.DECLARATOR)
return ((IASTCompoundStatement)((IASTFunctionDefinition)parent.getParent()).getBody()).getScope();
}
} else if (parent instanceof ICPPASTTemplateDeclaration) {
return CPPTemplates.getContainingScope(node);
}

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.core.index.composite.c;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
@ -53,4 +54,8 @@ class CompositeCCompositeScope extends CompositeScope implements ICCompositeType
public IIndexBinding getScopeBinding() {
return (IIndexBinding) getCompositeType();
}
public EScopeKind getKind() {
return EScopeKind.eClassType;
}
}

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
@ -28,6 +29,10 @@ class CompositeCPPClassScope extends CompositeScope implements ICPPClassScope {
super(cf, rbinding);
}
public EScopeKind getKind() {
return EScopeKind.eClassType;
}
public ICPPClassType getClassType() {
return (ICPPClassType) cf.getCompositeBinding(rbinding);
}

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
@ -40,6 +41,10 @@ public class CompositeCPPClassSpecializationScope extends CompositeScope impleme
return specialization().getSpecializedBinding();
}
public EScopeKind getKind() {
return EScopeKind.eClassType;
}
public ICPPClassSpecialization getClassType() {
return (ICPPClassSpecialization) cf.getCompositeBinding(rbinding);
}

View file

@ -12,6 +12,7 @@
package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
@ -33,6 +34,10 @@ class CompositeCPPNamespaceScope extends CompositeScope implements ICPPNamespace
this.namespaces = namespaces;
}
public EScopeKind getKind() {
return EScopeKind.eNamespace;
}
public void addUsingDirective(ICPPUsingDirective directive) throws DOMException {
fail();
}

View file

@ -20,6 +20,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
@ -68,6 +69,10 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
super(pdom, record);
}
public EScopeKind getKind() {
return EScopeKind.eClassType;
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
if (newBinding instanceof ICompositeType) {

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
@ -53,6 +54,10 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope {
public PDOMCPPClassScope(IPDOMCPPClassType binding) {
fBinding= binding;
}
public EScopeKind getKind() {
return EScopeKind.eClassType;
}
public ICPPClassType getClassType() {
return fBinding;

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
@ -63,6 +64,10 @@ class PDOMCPPFunctionTemplate extends PDOMCPPFunction
super(pdom, bindingRecord);
}
public EScopeKind getKind() {
return EScopeKind.eLocal;
}
@Override
public void update(PDOMLinkage linkage, IBinding name) {
// no support for updating templates, yet.

View file

@ -19,6 +19,7 @@ import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
@ -60,6 +61,10 @@ class PDOMCPPNamespace extends PDOMCPPBinding
super(pdom, record);
}
public EScopeKind getKind() {
return EScopeKind.eNamespace;
}
@Override
protected int getRecordSize() {
return RECORD_SIZE;

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField;
@ -69,6 +70,10 @@ class PDOMCPPUnknownClassType extends PDOMCPPBinding implements ICPPClassScope,
super(pdom, bindingRecord);
}
public EScopeKind getKind() {
return EScopeKind.eClassType;
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
if (newBinding instanceof ICPPClassType) {

View file

@ -145,11 +145,11 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
openCallHierarchy(editor);
TreeViewer tv = getCHTreeViewer();
TreeItem item= checkTreeNode(tv.getTree(), 0, "MyClass::method3()");
TreeItem nextItem= checkTreeNode(tv.getTree(), 0, 0, "MyClass::method2()");
checkTreeNode(item, 1, null); item= nextItem;
checkTreeNode(tv.getTree(), 0, "MyClass::method3()");
TreeItem item= checkTreeNode(tv.getTree(), 0, 0, "MyClass::method2()");
checkTreeNode(tv.getTree(), 0, 1, null);
tv.setExpandedState(item.getData(), true);
nextItem= checkTreeNode(item, 0, "MyClass::method1()");
TreeItem nextItem = checkTreeNode(item, 0, "MyClass::method1()");
checkTreeNode(item, 1, null); item= nextItem;
tv.setExpandedState(item.getData(), true);
checkTreeNode(item, 0, null);

View file

@ -38,6 +38,7 @@ public class CompletionTest_MacroRef_NoPrefix extends CompletionProposalsBaseTe
"__TIME__",
"__builtin_constant_p(exp)",
"__builtin_va_arg(ap, type)",
"__builtin_types_compatible_p(x, y)",
"__complex__",
"__cplusplus",
"__extension__",

View file

@ -368,6 +368,7 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest {
"__TIME__",
"__builtin_constant_p(exp)",
"__builtin_va_arg(ap, type)",
"__builtin_types_compatible_p(x, y)",
"__complex__",
"__extension__",
"__imag__",

View file

@ -13,6 +13,8 @@ package org.eclipse.cdt.internal.ui.refactoring.rename;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
public abstract class ASTSpecificNameVisitor extends ASTNameVisitor {
private String fSearchForName;
@ -24,6 +26,9 @@ public abstract class ASTSpecificNameVisitor extends ASTNameVisitor {
@Override
final public int visitName(IASTName name) {
if (name instanceof ICPPASTTemplateId || name instanceof ICPPASTQualifiedName)
return PROCESS_CONTINUE;
String nameStr= name.toString();
if (nameStr != null) {
final int len= nameStr.length();

View file

@ -11,7 +11,9 @@
package org.eclipse.cdt.internal.core.dom.lrparser.c99.action.deprecated;
import static org.eclipse.cdt.core.parser.util.CollectionUtils.reverseIterable;
import static org.eclipse.cdt.internal.core.dom.lrparser.symboltable.CNamespace.*;
import static org.eclipse.cdt.internal.core.dom.lrparser.symboltable.CNamespace.GOTO_LABEL;
import static org.eclipse.cdt.internal.core.dom.lrparser.symboltable.CNamespace.IDENTIFIER;
import static org.eclipse.cdt.internal.core.dom.lrparser.symboltable.CNamespace.STRUCT_TAG;
import java.util.LinkedList;
import java.util.List;
@ -19,6 +21,7 @@ import java.util.List;
import lpg.lpgjavaruntime.IToken;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
@ -137,7 +140,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
public C99ResolveParserAction(IParserActionTokenProvider parser) {
this.parser = parser;
bindingScopeStack.add(new C99Scope()); // the global scope
bindingScopeStack.add(new C99Scope(EScopeKind.eGlobal)); // the global scope
System.out.println();
}
@ -187,7 +190,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
if(DEBUG) DebugUtil.printMethodTrace();
symbolTableScopeStack.add(symbolTable);
bindingScopeStack.add(new C99Scope());
bindingScopeStack.add(new C99Scope(EScopeKind.eLocal));
undoStack.add(new IUndoAction() {
public void undo() {

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
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.c.ICCompositeTypeScope;
@ -22,6 +23,7 @@ public class C99CompositeTypeScope extends C99Scope implements ICCompositeTypeSc
public C99CompositeTypeScope(ICompositeType struct) {
super(EScopeKind.eClassType);
this.struct = struct;
}
@ -32,7 +34,4 @@ public class C99CompositeTypeScope extends C99Scope implements ICCompositeTypeSc
public IBinding getBinding(@SuppressWarnings("unused") char[] name) throws DOMException {
throw new UnsupportedOperationException();
}
}

View file

@ -11,13 +11,17 @@
package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
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.IScope;
import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope;
public class C99FunctionScope extends C99Scope implements ICFunctionScope {
public C99FunctionScope() {
super(EScopeKind.eLocal);
}
/**
* Scope that represents the compound statement of the body of this scope.
* Does not include the parameters which are part of this function scope.
@ -37,5 +41,4 @@ public class C99FunctionScope extends C99Scope implements ICFunctionScope {
public IScope getBodyScope() throws DOMException {
return bodyScope;
}
}

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
@ -31,10 +32,11 @@ public class C99Scope implements IC99Scope, IASTInternalScope {
private IScope parent;
private IASTNode physicalNode;
private IName scopeName;
private final EScopeKind kind;
public C99Scope(EScopeKind eKind) {
kind= eKind;
}
public IScope getParent() {
return parent;
@ -51,6 +53,10 @@ public class C99Scope implements IC99Scope, IASTInternalScope {
public void setPhysicalNode(IASTNode physicalNode) {
this.physicalNode = physicalNode;
}
public final EScopeKind getKind() {
return kind;
}
public IName getScopeName() {
return scopeName;