mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Correct modeling of template-scopes, bug 237026.
This commit is contained in:
parent
c9b8e80699
commit
8152453880
28 changed files with 207 additions and 610 deletions
|
@ -5526,11 +5526,8 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
// namespace ns { typedef int ns::TINT; } // illegal, still no CCE is expected.
|
// namespace ns { typedef int ns::TINT; } // illegal, still no CCE is expected.
|
||||||
public void testQualifiedTypedefs_Bug222093() throws Exception{
|
public void testQualifiedTypedefs_Bug222093() throws Exception{
|
||||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||||
IBinding td= bh.assertNonProblem("TINT", 4);
|
IBinding td= bh.assertProblem("TINT", 4);
|
||||||
bh.assertProblem("ns::", 2);
|
bh.assertProblem("ns::", 2);
|
||||||
|
|
||||||
assertTrue(td instanceof ITypedef);
|
|
||||||
assertTrue(((ITypedef) td).getType() instanceof ICPPBasicType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// void func() {
|
// void func() {
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2005, 2008 IBM Corporation 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:
|
|
||||||
* IBM Corporation - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author dsteffle
|
|
||||||
* mstodo- the class should be removed
|
|
||||||
*/
|
|
||||||
public class AST2CSpecFailingTest extends AST2SpecBaseTest {
|
|
||||||
|
|
||||||
public AST2CSpecFailingTest() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public AST2CSpecFailingTest(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
[--Start Example(C 6.7.7-6):
|
|
||||||
typedef signed int t;
|
|
||||||
typedef int plain;
|
|
||||||
struct tag {
|
|
||||||
unsigned t:4;
|
|
||||||
const t:5;
|
|
||||||
plain r:5;
|
|
||||||
};
|
|
||||||
t f(t (t));
|
|
||||||
long t;
|
|
||||||
--End Example]
|
|
||||||
*/
|
|
||||||
public void test6_7_7s6() throws Exception {
|
|
||||||
// test is no longer failing, was moved to AST2CSpecTest
|
|
||||||
// StringBuffer buffer = new StringBuffer();
|
|
||||||
// buffer.append("typedef signed int t;\n"); //$NON-NLS-1$
|
|
||||||
// buffer.append("typedef int plain;\n"); //$NON-NLS-1$
|
|
||||||
// buffer.append("struct tag {\n"); //$NON-NLS-1$
|
|
||||||
// buffer.append("unsigned t:4;\n"); //$NON-NLS-1$
|
|
||||||
// buffer.append("const t:5;\n"); //$NON-NLS-1$
|
|
||||||
// buffer.append("plain r:5;\n"); //$NON-NLS-1$
|
|
||||||
// buffer.append("};\n"); //$NON-NLS-1$
|
|
||||||
// buffer.append("t f(t (t));\n"); //$NON-NLS-1$
|
|
||||||
// buffer.append("long t;\n"); //$NON-NLS-1$
|
|
||||||
// try {
|
|
||||||
// parse(buffer.toString(), ParserLanguage.C, true, 0);
|
|
||||||
// assertTrue(false);
|
|
||||||
// } catch (Exception e) {}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3110,5 +3110,13 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
public void testBug239586_ClassCast() throws Exception {
|
public void testBug239586_ClassCast() throws Exception {
|
||||||
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
|
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename T1> class CT {
|
||||||
|
// static int x;
|
||||||
|
// };
|
||||||
|
// template<typename T> int CT<T>::x = sizeof(T);
|
||||||
|
public void testUsingTemplParamInInitializerOfStaticField() throws Exception {
|
||||||
|
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
||||||
|
ICPPTemplateTypeParameter t= ba.assertNonProblem("T)", 1, ICPPTemplateTypeParameter.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||||
|
@ -1064,13 +1063,8 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
||||||
ICPPClassType sc1= assertInstance(b1.getSpecializedBinding(), ICPPClassType.class);
|
ICPPClassType sc1= assertInstance(b1.getSpecializedBinding(), ICPPClassType.class);
|
||||||
assertTrue(sc0.isSameType(sc1));
|
assertTrue(sc0.isSameType(sc1));
|
||||||
|
|
||||||
IIndexScope sc2= assertInstance(sc0.getScope(), IIndexScope.class, ICPPTemplateScope.class);
|
assertNull(sc0.getScope());
|
||||||
assertNull(b0.getScope());
|
assertNull(b0.getScope());
|
||||||
assertEquals(sc2.getScopeBinding(), sc1);
|
|
||||||
|
|
||||||
// template scopes will not be supported in the future, see bug 237026
|
|
||||||
// assertInstance(b0.getScope(), ICPPTemplateScope.class);
|
|
||||||
// assertNotSame(sc2, b0.getScope());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<typename T>
|
// template<typename T>
|
||||||
|
@ -1176,7 +1170,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
||||||
ICPPClassScope s1= assertInstance(b1.getScope(), ICPPClassScope.class);
|
ICPPClassScope s1= assertInstance(b1.getScope(), ICPPClassScope.class);
|
||||||
assertInstance(s1.getClassType(), ICPPTemplateDefinition.class);
|
assertInstance(s1.getClassType(), ICPPTemplateDefinition.class);
|
||||||
|
|
||||||
assertInstance(s1.getClassType().getScope(), ICPPTemplateScope.class);
|
assertNull(s1.getClassType().getScope());
|
||||||
}
|
}
|
||||||
|
|
||||||
// typedef signed int SI;
|
// typedef signed int SI;
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* 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)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -16,7 +16,10 @@ import org.eclipse.cdt.core.dom.IName;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* Scopes can be used to look-up names. With the exception of template-scopes the scopes
|
||||||
|
* can be arranged in a hierarchy.
|
||||||
|
*
|
||||||
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IScope {
|
public interface IScope {
|
||||||
|
|
||||||
|
@ -28,10 +31,11 @@ public interface IScope {
|
||||||
public IName getScopeName() throws DOMException;
|
public IName getScopeName() throws DOMException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scopes are arranged hierarchically. Lookups will generally
|
* The method returns the first enclosing non-template scope, or <code>null</code> if this
|
||||||
* flow upward to find resolution.
|
* is the global scope.
|
||||||
*
|
* <p>
|
||||||
* @return The parent scope.
|
* For scopes obtained from an index, <code>null</code> is returned to indicate that the
|
||||||
|
* scope is only enclosed by the global scope.
|
||||||
*/
|
*/
|
||||||
public IScope getParent() throws DOMException;
|
public IScope getParent() throws DOMException;
|
||||||
|
|
||||||
|
|
|
@ -6,24 +6,30 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
|
||||||
* Created on Mar 11, 2005
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* A separate template scope is used for each template declaration. This leads to a
|
||||||
|
* non-hierarchical structure of scopes. E.g. for a method of a class-template the
|
||||||
|
* declaration and definition will nests in different template-scopes. Therefore
|
||||||
|
* {@link IScope#getParent()} will never return a template scope unless the method is
|
||||||
|
* called for a template-scope that directly nests in another one.
|
||||||
|
*
|
||||||
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ICPPTemplateScope extends ICPPScope {
|
public interface ICPPTemplateScope extends ICPPScope {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the template that this scope represents
|
* Returns the corresponding template declaration
|
||||||
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
public ICPPTemplateDefinition getTemplateDefinition() throws DOMException;
|
public ICPPASTTemplateDeclaration getTemplateDeclaration();
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public ICPPTemplateDefinition getTemplateDefinition() throws DOMException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,18 +11,18 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||||
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.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -127,8 +127,17 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
||||||
if (scope != null)
|
if (scope != null)
|
||||||
return scope;
|
return scope;
|
||||||
|
|
||||||
ASTNodeProperty prop = getPropertyInParent();
|
// introduce a scope for function declarations and definitions, only.
|
||||||
if (prop == IASTSimpleDeclaration.DECLARATOR || prop == IASTFunctionDefinition.DECLARATOR) {
|
IASTNode node= getParent();
|
||||||
|
while(!(node instanceof IASTDeclaration)) {
|
||||||
|
if (node==null)
|
||||||
|
return null;
|
||||||
|
node= node.getParent();
|
||||||
|
}
|
||||||
|
if (node instanceof IASTParameterDeclaration)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (CPPVisitor.findTypeRelevantDeclarator(this) == this) {
|
||||||
scope = new CPPFunctionScope(this);
|
scope = new CPPFunctionScope(this);
|
||||||
}
|
}
|
||||||
return scope;
|
return scope;
|
||||||
|
|
|
@ -146,11 +146,8 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
||||||
@Override
|
@Override
|
||||||
public IScope getParent() {
|
public IScope getParent() {
|
||||||
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
||||||
IASTName compName = compType.getName();
|
IASTName compName = compType.getName().getLastName();
|
||||||
if (compName instanceof ICPPASTQualifiedName) {
|
return CPPVisitor.getContainingNonTemplateScope(compName);
|
||||||
compName = ((ICPPASTQualifiedName) compName).getLastName();
|
|
||||||
}
|
|
||||||
return CPPVisitor.getContainingScope(compName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -10,9 +10,6 @@
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
|
||||||
* Created on Dec 1, 2004
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -30,10 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ILabel;
|
import org.eclipse.cdt.core.dom.ast.ILabel;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
|
@ -102,25 +96,8 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
|
||||||
//we can't just resolve the function and get its parent scope, since there are cases where that
|
//we can't just resolve the function and get its parent scope, since there are cases where that
|
||||||
//could loop since resolving functions requires resolving their parameter types
|
//could loop since resolving functions requires resolving their parameter types
|
||||||
IASTFunctionDeclarator fdtor = (IASTFunctionDeclarator) getPhysicalNode();
|
IASTFunctionDeclarator fdtor = (IASTFunctionDeclarator) getPhysicalNode();
|
||||||
IASTName name = fdtor.getName();
|
IASTName name = fdtor.getName().getLastName();
|
||||||
if (name instanceof ICPPASTQualifiedName) {
|
return CPPVisitor.getContainingNonTemplateScope(name);
|
||||||
ICPPASTQualifiedName qual = (ICPPASTQualifiedName) name;
|
|
||||||
IASTName[] ns = qual.getNames();
|
|
||||||
if (ns.length > 1) {
|
|
||||||
IBinding binding = ns[ ns.length - 2 ].resolveBinding();
|
|
||||||
if (binding == null)
|
|
||||||
return null;
|
|
||||||
else if (binding instanceof ICPPClassType)
|
|
||||||
return ((ICPPClassType)binding).getCompositeScope();
|
|
||||||
else if (binding instanceof ICPPNamespace)
|
|
||||||
return ((ICPPNamespace)binding).getNamespaceScope();
|
|
||||||
return binding.getScope();
|
|
||||||
} else if (qual.isFullyQualified()) {
|
|
||||||
return qual.getTranslationUnit().getScope();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return CPPVisitor.getContainingScope(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -64,11 +64,8 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
this.physicalNode = physicalNode;
|
this.physicalNode = physicalNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IScope#getParent()
|
|
||||||
*/
|
|
||||||
public IScope getParent() throws DOMException {
|
public IScope getParent() throws DOMException {
|
||||||
return CPPVisitor.getContainingScope(physicalNode);
|
return CPPVisitor.getContainingNonTemplateScope(physicalNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTNode getPhysicalNode() {
|
public IASTNode getPhysicalNode() {
|
||||||
|
|
|
@ -12,17 +12,9 @@
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||||
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.ICPPScope;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||||
|
@ -33,27 +25,17 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
*/
|
*/
|
||||||
public class CPPTemplateScope extends CPPScope implements ICPPTemplateScope {
|
public class CPPTemplateScope extends CPPScope implements ICPPTemplateScope {
|
||||||
|
|
||||||
//private ICPPTemplateDefinition primaryDefinition;
|
|
||||||
/**
|
|
||||||
* @param physicalNode
|
|
||||||
*/
|
|
||||||
public CPPTemplateScope(IASTNode physicalNode) {
|
public CPPTemplateScope(IASTNode physicalNode) {
|
||||||
super(physicalNode);
|
super(physicalNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope#getTemplateDefinition()
|
|
||||||
*/
|
|
||||||
public ICPPTemplateDefinition getTemplateDefinition() {
|
public ICPPTemplateDefinition getTemplateDefinition() {
|
||||||
// if (primaryDefinition == null) {
|
|
||||||
// //primaryDefinition = CPPTemplates.getTemplateDefinition(this);
|
|
||||||
// ICPPASTTemplateDeclaration template = (ICPPASTTemplateDeclaration) getPhysicalNode();
|
|
||||||
// IASTDeclaration decl = template.getDeclaration();
|
|
||||||
// return new CPPTemplateDefinition(decl);
|
|
||||||
// }
|
|
||||||
// return primaryDefinition;
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICPPASTTemplateDeclaration getTemplateDeclaration() {
|
||||||
|
return (ICPPASTTemplateDeclaration) getPhysicalNode();
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
|
||||||
|
@ -66,46 +48,6 @@ public class CPPTemplateScope extends CPPScope implements ICPPTemplateScope {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IScope getParent() {
|
public IScope getParent() {
|
||||||
ICPPASTTemplateDeclaration templateDecl = (ICPPASTTemplateDeclaration) getPhysicalNode();
|
return CPPVisitor.getContainingNonTemplateScope(getPhysicalNode());
|
||||||
IASTName name = CPPTemplates.getTemplateName(templateDecl);
|
|
||||||
IASTNode p = name != null ? name.getParent() : null;
|
|
||||||
if (p instanceof ICPPASTQualifiedName) {
|
|
||||||
ICPPASTQualifiedName qual = (ICPPASTQualifiedName) p;
|
|
||||||
IASTName[] names = qual.getNames();
|
|
||||||
int i = 0;
|
|
||||||
for (; i < names.length; i++) {
|
|
||||||
if (names[i] == name)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i > 0) {
|
|
||||||
try {
|
|
||||||
IBinding binding = names[i - 1].resolveBinding();
|
|
||||||
if (binding instanceof ICPPClassType) {
|
|
||||||
return ((ICPPClassType) binding).getCompositeScope();
|
|
||||||
} else if (binding instanceof ICPPNamespace) {
|
|
||||||
return ((ICPPNamespace) binding).getNamespaceScope();
|
|
||||||
} else if (binding instanceof ICPPUnknownBinding) {
|
|
||||||
return ((ICPPUnknownBinding) binding).getUnknownScope();
|
|
||||||
} else if (binding instanceof IProblemBinding) {
|
|
||||||
if (binding instanceof ICPPScope)
|
|
||||||
return (IScope) binding;
|
|
||||||
return new CPPScope.CPPScopeProblem(names[i - 1], IProblemBinding.SEMANTIC_BAD_SCOPE,
|
|
||||||
names[i - 1].toCharArray());
|
|
||||||
}
|
|
||||||
} catch (DOMException e) {
|
|
||||||
IScope result = e.getProblem();
|
|
||||||
if (result instanceof ICPPScope) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return new CPPScope.CPPScopeProblem(names[i - 1], IProblemBinding.SEMANTIC_BAD_SCOPE,
|
|
||||||
names[i - 1].toCharArray());
|
|
||||||
}
|
|
||||||
} else if (qual.isFullyQualified()) {
|
|
||||||
return qual.getTranslationUnit().getScope();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (templateDecl.getParent() instanceof ICPPASTTemplateDeclaration)
|
|
||||||
templateDecl = (ICPPASTTemplateDeclaration) templateDecl.getParent();
|
|
||||||
return CPPVisitor.getContainingScope(templateDecl);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,6 +129,7 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFieldReference;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFieldReference;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
|
||||||
|
@ -633,33 +634,56 @@ public class CPPSemantics {
|
||||||
static protected void lookup(LookupData data, Object start) throws DOMException{
|
static protected void lookup(LookupData data, Object start) throws DOMException{
|
||||||
final IIndexFileSet fileSet= getIndexFileSet(data);
|
final IIndexFileSet fileSet= getIndexFileSet(data);
|
||||||
final boolean isIndexBased= fileSet != IIndexFileSet.EMPTY;
|
final boolean isIndexBased= fileSet != IIndexFileSet.EMPTY;
|
||||||
|
|
||||||
IASTNode node = data.astName;
|
IASTNode blockItem= data.astName;
|
||||||
ICPPScope scope = null;
|
if (blockItem == null)
|
||||||
if (start instanceof ICPPScope)
|
|
||||||
scope = (ICPPScope) start;
|
|
||||||
else if (start instanceof IASTName)
|
|
||||||
scope = getLookupScope((IASTName) start);
|
|
||||||
else
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (data.astName == null)
|
ICPPScope nextScope= null;
|
||||||
|
if (start instanceof ICPPScope) {
|
||||||
|
nextScope= (ICPPScope) start;
|
||||||
|
} else if (start instanceof IASTName) {
|
||||||
|
nextScope= getLookupScope((IASTName) start);
|
||||||
|
}
|
||||||
|
if (nextScope == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boolean friendInLocalClass = false;
|
boolean friendInLocalClass = false;
|
||||||
if (scope instanceof ICPPClassScope && data.forFriendship()) {
|
if (nextScope instanceof ICPPClassScope && data.forFriendship()) {
|
||||||
try {
|
try {
|
||||||
ICPPClassType cls = ((ICPPClassScope)scope).getClassType();
|
ICPPClassType cls = ((ICPPClassScope)nextScope).getClassType();
|
||||||
friendInLocalClass = !cls.isGloballyQualified();
|
friendInLocalClass = !cls.isGloballyQualified();
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ICPPTemplateScope nextTmplScope;
|
||||||
|
if (nextScope instanceof ICPPTemplateScope) {
|
||||||
|
nextTmplScope= (ICPPTemplateScope) nextScope;
|
||||||
|
nextScope= getParentScope(nextScope, data.tu);
|
||||||
|
} else {
|
||||||
|
nextTmplScope= enclosingTemplateScope(data.astName);
|
||||||
|
}
|
||||||
|
|
||||||
while (scope != null) {
|
|
||||||
|
while (nextScope != null || nextTmplScope != null) {
|
||||||
|
// when the non-template scope is no longer contained within the first template scope,
|
||||||
|
// we use the template scope for the next iteration.
|
||||||
|
boolean useTemplScope= false;
|
||||||
|
if (nextTmplScope != null) {
|
||||||
|
useTemplScope= true;
|
||||||
|
if (nextScope instanceof IASTInternalScope) {
|
||||||
|
final IASTNode node= ((IASTInternalScope) nextScope).getPhysicalNode();
|
||||||
|
if (node != null && nextTmplScope.getTemplateDeclaration().contains(node)) {
|
||||||
|
useTemplScope= false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ICPPScope scope= useTemplScope ? nextTmplScope : nextScope;
|
||||||
if (scope instanceof IIndexScope && data.tu != null) {
|
if (scope instanceof IIndexScope && data.tu != null) {
|
||||||
scope= (ICPPScope) data.tu.mapToASTScope(((IIndexScope) scope));
|
scope= (ICPPScope) data.tu.mapToASTScope(((IIndexScope) scope));
|
||||||
}
|
}
|
||||||
IASTNode blockItem = CPPVisitor.getContainingBlockItem(node);
|
blockItem = CPPVisitor.getContainingBlockItem(blockItem);
|
||||||
|
|
||||||
if (!data.usingDirectivesOnly) {
|
if (!data.usingDirectivesOnly) {
|
||||||
if (data.contentAssist) {
|
if (data.contentAssist) {
|
||||||
|
@ -737,29 +761,37 @@ public class CPPSemantics {
|
||||||
data.usingDirectivesOnly = true;
|
data.usingDirectivesOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockItem != null)
|
// compute next scopes
|
||||||
node = blockItem;
|
if (useTemplScope && nextTmplScope != null) {
|
||||||
|
nextTmplScope= enclosingTemplateScope(nextTmplScope.getTemplateDeclaration());
|
||||||
ICPPScope parentScope = (ICPPScope) getParentScope(scope, data.tu);
|
} else {
|
||||||
if (parentScope instanceof ICPPTemplateScope) {
|
nextScope= getParentScope(scope, data.tu);
|
||||||
IASTNode declNode = node;
|
|
||||||
while (declNode != null && !(declNode instanceof ICPPASTTemplateDeclaration)) {
|
|
||||||
node = declNode;
|
|
||||||
declNode = declNode.getParent();
|
|
||||||
}
|
|
||||||
if (declNode != null) {
|
|
||||||
ICPPASTTemplateDeclaration templateDecl = (ICPPASTTemplateDeclaration) declNode;
|
|
||||||
ICPPTemplateScope templateScope = templateDecl.getScope();
|
|
||||||
if (templateScope.getTemplateDefinition() == ((ICPPTemplateScope)parentScope).getTemplateDefinition()) {
|
|
||||||
parentScope = templateScope;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
scope = parentScope;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IScope getParentScope(IScope scope, CPPASTTranslationUnit unit) throws DOMException {
|
private static ICPPTemplateScope enclosingTemplateScope(IASTNode node) {
|
||||||
|
IASTNode parent= node.getParent();
|
||||||
|
if (parent instanceof IASTName) {
|
||||||
|
if (parent instanceof ICPPASTTemplateId) {
|
||||||
|
node= parent;
|
||||||
|
parent= node.getParent();
|
||||||
|
}
|
||||||
|
if (parent instanceof ICPPASTQualifiedName) {
|
||||||
|
ICPPASTQualifiedName qname= (ICPPASTQualifiedName) parent;
|
||||||
|
if (qname.isFullyQualified() || qname.getNames()[0] != node)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (!(parent instanceof ICPPASTTemplateDeclaration)) {
|
||||||
|
if (parent == null)
|
||||||
|
return null;
|
||||||
|
parent= parent.getParent();
|
||||||
|
}
|
||||||
|
return ((ICPPASTTemplateDeclaration) parent).getScope();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ICPPScope getParentScope(IScope scope, CPPASTTranslationUnit 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 != null) {
|
if (unit != null) {
|
||||||
|
@ -770,7 +802,7 @@ public class CPPSemantics {
|
||||||
parentScope= unit.mapToASTScope((IIndexScope) parentScope);
|
parentScope= unit.mapToASTScope((IIndexScope) parentScope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return parentScope;
|
return (ICPPScope) parentScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object lookupInParents(LookupData data, ICPPScope lookIn) throws DOMException{
|
private static Object lookupInParents(LookupData data, ICPPScope lookIn) throws DOMException{
|
||||||
|
|
|
@ -369,36 +369,25 @@ public class CPPVisitor {
|
||||||
if (mustBeSimple && elabType.getName() instanceof ICPPASTQualifiedName)
|
if (mustBeSimple && elabType.getName() instanceof ICPPASTQualifiedName)
|
||||||
return binding;
|
return binding;
|
||||||
|
|
||||||
boolean template = false;
|
|
||||||
ICPPScope scope = (ICPPScope) getContainingScope(name);
|
|
||||||
if (scope instanceof ICPPTemplateScope) {
|
|
||||||
ICPPScope parentScope = null;
|
|
||||||
try {
|
|
||||||
template = true;
|
|
||||||
parentScope = (ICPPScope) getParentScope(scope, elabType.getTranslationUnit());
|
|
||||||
} catch (DOMException e1) {
|
|
||||||
}
|
|
||||||
scope = parentScope;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mustBeSimple) {
|
|
||||||
//3.3.1-5 ... the identifier is declared in the smallest non-class non-function-prototype scope that contains
|
|
||||||
//the declaration
|
|
||||||
while (scope instanceof ICPPClassScope || scope instanceof ICPPFunctionScope) {
|
|
||||||
try {
|
|
||||||
scope = (ICPPScope) getParentScope(scope, elabType.getTranslationUnit());
|
|
||||||
} catch (DOMException e1) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (scope instanceof ICPPClassScope && isFriend && !qualified) {
|
|
||||||
try {
|
|
||||||
while (scope instanceof ICPPClassScope)
|
|
||||||
scope = (ICPPScope) getParentScope(scope, elabType.getTranslationUnit());
|
|
||||||
} catch (DOMException e1) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
|
boolean template = false;
|
||||||
|
ICPPScope scope = (ICPPScope) getContainingScope(name);
|
||||||
|
while (scope instanceof ICPPTemplateScope) {
|
||||||
|
template = true;
|
||||||
|
scope= (ICPPScope) scope.getParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mustBeSimple) {
|
||||||
|
//3.3.1-5 ... the identifier is declared in the smallest non-class non-function-prototype scope that contains
|
||||||
|
//the declaration
|
||||||
|
while (scope instanceof ICPPClassScope || scope instanceof ICPPFunctionScope) {
|
||||||
|
scope = (ICPPScope) getParentScope(scope, elabType.getTranslationUnit());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (scope instanceof ICPPClassScope && isFriend && !qualified) {
|
||||||
|
while (scope instanceof ICPPClassScope)
|
||||||
|
scope = (ICPPScope) getParentScope(scope, elabType.getTranslationUnit());
|
||||||
|
}
|
||||||
if (scope != null) {
|
if (scope != null) {
|
||||||
binding = scope.getBinding(elabType.getName(), false);
|
binding = scope.getBinding(elabType.getName(), false);
|
||||||
}
|
}
|
||||||
|
@ -426,19 +415,15 @@ public class CPPVisitor {
|
||||||
IASTName[] ns = ((ICPPASTQualifiedName)name).getNames();
|
IASTName[] ns = ((ICPPASTQualifiedName)name).getNames();
|
||||||
name = ns[ns.length - 1];
|
name = ns[ns.length - 1];
|
||||||
}
|
}
|
||||||
ICPPScope scope = (ICPPScope) getContainingScope(name);
|
|
||||||
boolean template = false;
|
IBinding binding = null;
|
||||||
if (scope instanceof ICPPTemplateScope) {
|
ICPPScope scope = (ICPPScope) getContainingScope(name);
|
||||||
template = true;
|
|
||||||
ICPPScope parentScope = null;
|
|
||||||
try {
|
|
||||||
parentScope = (ICPPScope) getParentScope(scope, compType.getTranslationUnit());
|
|
||||||
} catch (DOMException e1) {
|
|
||||||
}
|
|
||||||
scope = parentScope;
|
|
||||||
}
|
|
||||||
IBinding binding = null;
|
|
||||||
try {
|
try {
|
||||||
|
boolean template = false;
|
||||||
|
while (scope instanceof ICPPTemplateScope) {
|
||||||
|
template = true;
|
||||||
|
scope= (ICPPScope) scope.getParent();
|
||||||
|
}
|
||||||
if (name instanceof ICPPASTTemplateId) {
|
if (name instanceof ICPPASTTemplateId) {
|
||||||
return CPPTemplates.createExplicitClassSpecialization(compType);
|
return CPPTemplates.createExplicitClassSpecialization(compType);
|
||||||
}
|
}
|
||||||
|
@ -550,32 +535,27 @@ public class CPPVisitor {
|
||||||
return CPPTemplates.createBinding((ICPPASTTemplateParameter) parent);
|
return CPPTemplates.createBinding((ICPPASTTemplateParameter) parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean template = false;
|
|
||||||
ICPPScope scope = (ICPPScope) getContainingScope((IASTNode) name);
|
|
||||||
if (scope instanceof ICPPTemplateScope) {
|
|
||||||
ICPPScope parentScope = null;
|
|
||||||
try {
|
|
||||||
template = true;
|
|
||||||
parentScope = (ICPPScope) getParentScope(scope, name.getTranslationUnit());
|
|
||||||
} catch (DOMException e1) {
|
|
||||||
}
|
|
||||||
scope = parentScope;
|
|
||||||
}
|
|
||||||
if (parent instanceof IASTSimpleDeclaration && scope instanceof ICPPClassScope) {
|
|
||||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)parent).getDeclSpecifier();
|
|
||||||
if (declSpec.isFriend()) {
|
|
||||||
try {
|
|
||||||
scope = (ICPPScope) getParentScope(scope, name.getTranslationUnit());
|
|
||||||
} catch (DOMException e1) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IBinding binding;
|
IBinding binding;
|
||||||
try {
|
ICPPScope scope = (ICPPScope) getContainingScope((IASTNode) name);
|
||||||
|
|
||||||
|
boolean template = false;
|
||||||
|
try {
|
||||||
|
while (scope instanceof ICPPTemplateScope) {
|
||||||
|
template = true;
|
||||||
|
scope= (ICPPScope) scope.getParent();
|
||||||
|
}
|
||||||
|
if (parent instanceof IASTSimpleDeclaration && scope instanceof ICPPClassScope) {
|
||||||
|
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)parent).getDeclSpecifier();
|
||||||
|
if (declSpec.isFriend()) {
|
||||||
|
try {
|
||||||
|
scope = (ICPPScope) getParentScope(scope, name.getTranslationUnit());
|
||||||
|
} catch (DOMException e1) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
binding = (scope != null) ? scope.getBinding(name, false) : null;
|
binding = (scope != null) ? scope.getBinding(name, false) : null;
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
binding = null;
|
return e.getProblem();
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTSimpleDeclaration simpleDecl = (parent instanceof IASTSimpleDeclaration) ?
|
IASTSimpleDeclaration simpleDecl = (parent instanceof IASTSimpleDeclaration) ?
|
||||||
|
@ -754,6 +734,14 @@ public class CPPVisitor {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IScope getContainingNonTemplateScope(final IASTNode inputNode) {
|
||||||
|
IScope scope= getContainingScope(inputNode);
|
||||||
|
while (scope instanceof ICPPTemplateScope) {
|
||||||
|
scope= CPPVisitor.getContainingScope(((ICPPTemplateScope) scope).getTemplateDeclaration());
|
||||||
|
}
|
||||||
|
return scope;
|
||||||
|
}
|
||||||
|
|
||||||
public static IScope getContainingScope(final IASTNode inputNode) {
|
public static IScope getContainingScope(final IASTNode inputNode) {
|
||||||
if (inputNode == null || inputNode instanceof IASTTranslationUnit)
|
if (inputNode == null || inputNode instanceof IASTTranslationUnit)
|
||||||
return null;
|
return null;
|
||||||
|
@ -787,27 +775,19 @@ public class CPPVisitor {
|
||||||
return getContainingScope((IASTStatement) node);
|
return getContainingScope((IASTStatement) node);
|
||||||
} else if (node instanceof IASTTypeId) {
|
} else if (node instanceof IASTTypeId) {
|
||||||
if (node.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) {
|
if (node.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) {
|
||||||
ICPPASTTemplateDeclaration decl = CPPTemplates.getTemplateDeclaration((IASTName) node.getParent());
|
node= node.getParent(); // template-id
|
||||||
if (decl == null) {
|
while(node instanceof IASTName) {
|
||||||
node = node.getParent();
|
node= node.getParent();
|
||||||
while (node instanceof IASTName)
|
}
|
||||||
node = node.getParent();
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (node instanceof IASTParameterDeclaration) {
|
} else if (node instanceof IASTParameterDeclaration) {
|
||||||
IASTNode parent = node.getParent();
|
IASTNode parent = node.getParent();
|
||||||
if (parent instanceof ICPPASTFunctionDeclarator) {
|
if (parent instanceof ICPPASTFunctionDeclarator) {
|
||||||
ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) parent;
|
ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) parent;
|
||||||
if (dtor.getNestedDeclarator() == null || dtor.getNestedDeclarator().getPointerOperators().length == 0) {
|
IScope scope= dtor.getFunctionScope();
|
||||||
while (parent.getParent() instanceof IASTDeclarator)
|
if (scope != null)
|
||||||
parent = parent.getParent();
|
return scope;
|
||||||
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) {
|
} else if (parent instanceof ICPPASTTemplateDeclaration) {
|
||||||
return CPPTemplates.getContainingScope(node);
|
return CPPTemplates.getContainingScope(node);
|
||||||
}
|
}
|
||||||
|
@ -890,9 +870,6 @@ public class CPPVisitor {
|
||||||
name = (IASTName) parent;
|
name = (IASTName) parent;
|
||||||
parent = name.getParent();
|
parent = name.getParent();
|
||||||
}
|
}
|
||||||
ICPPASTTemplateDeclaration tmplDecl = CPPTemplates.getTemplateDeclaration(name);
|
|
||||||
if (tmplDecl != null)
|
|
||||||
return tmplDecl.getScope();
|
|
||||||
|
|
||||||
if (parent instanceof ICPPASTQualifiedName) {
|
if (parent instanceof ICPPASTQualifiedName) {
|
||||||
final ICPPASTQualifiedName qname= (ICPPASTQualifiedName) parent;
|
final ICPPASTQualifiedName qname= (ICPPASTQualifiedName) parent;
|
||||||
|
@ -905,12 +882,6 @@ public class CPPVisitor {
|
||||||
if (qname.isFullyQualified()) {
|
if (qname.isFullyQualified()) {
|
||||||
return parent.getTranslationUnit().getScope();
|
return parent.getTranslationUnit().getScope();
|
||||||
}
|
}
|
||||||
for (int j=1; j < names.length; j++) {
|
|
||||||
tmplDecl = CPPTemplates.getTemplateDeclaration(names[j]);
|
|
||||||
if (tmplDecl != null) {
|
|
||||||
return getContainingScope(tmplDecl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
IBinding binding = names[i-1].resolveBinding();
|
IBinding binding = names[i-1].resolveBinding();
|
||||||
|
@ -1768,8 +1739,9 @@ public class CPPVisitor {
|
||||||
funcName = ns[ns.length - 1];
|
funcName = ns[ns.length - 1];
|
||||||
}
|
}
|
||||||
IScope s = getContainingScope(funcName);
|
IScope s = getContainingScope(funcName);
|
||||||
if (s instanceof ICPPTemplateScope)
|
while (s instanceof ICPPTemplateScope) {
|
||||||
s = getParentScope(s, funcName.getTranslationUnit());
|
s = s.getParent();
|
||||||
|
}
|
||||||
if (s instanceof ICPPClassScope) {
|
if (s instanceof ICPPClassScope) {
|
||||||
ICPPClassScope cScope = (ICPPClassScope) s;
|
ICPPClassScope cScope = (ICPPClassScope) s;
|
||||||
IType type = cScope.getClassType();
|
IType type = cScope.getClassType();
|
||||||
|
|
|
@ -46,7 +46,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||||
|
@ -102,9 +101,6 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
||||||
}
|
}
|
||||||
return new CompositeCPPNamespaceScope(this, namespaces);
|
return new CompositeCPPNamespaceScope(this, namespaces);
|
||||||
}
|
}
|
||||||
if (rscope instanceof ICPPTemplateScope) {
|
|
||||||
return new CompositeCPPTemplateScope(this, (ICPPTemplateScope) rscope);
|
|
||||||
}
|
|
||||||
if (rscope instanceof ICPPInternalUnknownScope) {
|
if (rscope instanceof ICPPInternalUnknownScope) {
|
||||||
ICPPInternalUnknownScope uscope= (ICPPInternalUnknownScope) rscope;
|
ICPPInternalUnknownScope uscope= (ICPPInternalUnknownScope) rscope;
|
||||||
final ICPPBinding binding = uscope.getScopeBinding();
|
final ICPPBinding binding = uscope.getScopeBinding();
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2007, 2008 Symbian Software Systems and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
|
||||||
* Markus Schorn (Wind River Systems)
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
|
||||||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
|
||||||
import org.eclipse.cdt.internal.core.index.composite.CompositeScope;
|
|
||||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
|
||||||
|
|
||||||
public class CompositeCPPTemplateScope extends CompositeScope implements ICPPTemplateScope {
|
|
||||||
public CompositeCPPTemplateScope(ICompositesFactory cf,
|
|
||||||
ICPPTemplateScope rbinding) {
|
|
||||||
super(cf, (IIndexFragmentBinding) ((IIndexScope)rbinding).getScopeBinding());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICPPTemplateDefinition getTemplateDefinition() throws DOMException {
|
|
||||||
ICPPTemplateDefinition preresult= (getTemplateScope()).getTemplateDefinition();
|
|
||||||
return (ICPPTemplateDefinition) processUncertainBinding(preresult);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ICPPTemplateScope getTemplateScope() {
|
|
||||||
if (rbinding instanceof ICPPTemplateScope)
|
|
||||||
return (ICPPTemplateScope) rbinding;
|
|
||||||
return (ICPPTemplateScope) rbinding.getScope();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBinding[] find(String name) throws DOMException {
|
|
||||||
IBinding[] preresult = (getTemplateScope()).find(name);
|
|
||||||
return processUncertainBindings(preresult);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException {
|
|
||||||
IBinding binding = (getTemplateScope()).getBinding(name, resolve, fileSet);
|
|
||||||
return processUncertainBinding(binding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) throws DOMException {
|
|
||||||
IBinding[] bindings = (getTemplateScope()).getBindings(name, resolve, prefixLookup, fileSet);
|
|
||||||
return processUncertainBindings(bindings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IIndexBinding getScopeBinding() {
|
|
||||||
return cf.getCompositeBinding(rbinding);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIndexScope getParent() {
|
|
||||||
// the binding is the binding for both the composite and the template scope, so
|
|
||||||
// make sure to use the parent of the scope.
|
|
||||||
final IIndexScope templateScope= rbinding.getScope();
|
|
||||||
return cf.getCompositeScope(templateScope.getParent());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -198,7 +198,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexScope getScope() {
|
public final IIndexScope getScope() {
|
||||||
// The parent node in the binding hierarchy is the scope.
|
// The parent node in the binding hierarchy is the scope.
|
||||||
try {
|
try {
|
||||||
IBinding parent= getParentBinding();
|
IBinding parent= getParentBinding();
|
||||||
|
|
|
@ -19,32 +19,21 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
|
||||||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.BindingCollector;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
@ -141,77 +130,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType implements ICPPClassT
|
||||||
return new ICPPClassTemplatePartialSpecialization[0];
|
return new ICPPClassTemplatePartialSpecialization[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PDOMCPPTemplateScope implements ICPPTemplateScope, IIndexScope {
|
|
||||||
public IBinding[] find(String name) throws DOMException {
|
|
||||||
return CPPSemantics.findBindings(this, name, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
|
|
||||||
return getBinding(name, resolve, IIndexFileSet.EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) throws DOMException {
|
|
||||||
return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet)
|
|
||||||
throws DOMException {
|
|
||||||
try {
|
|
||||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray());
|
|
||||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + PARAMETERS, getLinkageImpl());
|
|
||||||
list.accept(visitor);
|
|
||||||
|
|
||||||
return CPPSemantics.resolveAmbiguities(name, visitor.getBindings());
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet)
|
|
||||||
throws DOMException {
|
|
||||||
IBinding[] result = null;
|
|
||||||
try {
|
|
||||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null,
|
|
||||||
prefixLookup, !prefixLookup);
|
|
||||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + PARAMETERS, getLinkageImpl());
|
|
||||||
list.accept(visitor);
|
|
||||||
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, visitor.getBindings());
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
}
|
|
||||||
return (IBinding[]) ArrayUtil.trim(IBinding.class, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IIndexScope getParent() {
|
|
||||||
return PDOMCPPClassTemplate.this.getParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICPPTemplateDefinition getTemplateDefinition()
|
|
||||||
throws DOMException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IIndexName getScopeName() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IIndexBinding getScopeBinding() {
|
|
||||||
return PDOMCPPClassTemplate.this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private PDOMCPPTemplateScope scope;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIndexScope getScope() {
|
|
||||||
if (scope == null) {
|
|
||||||
scope = new PDOMCPPTemplateScope();
|
|
||||||
}
|
|
||||||
return scope;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(IPDOMVisitor visitor) throws CoreException {
|
public void accept(IPDOMVisitor visitor) throws CoreException {
|
||||||
super.accept(visitor);
|
super.accept(visitor);
|
||||||
|
|
|
@ -10,10 +10,8 @@
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
|
@ -50,12 +48,7 @@ class PDOMCPPField extends PDOMCPPVariable implements ICPPField {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPClassType getClassOwner() {
|
public ICPPClassType getClassOwner() {
|
||||||
try {
|
return (ICPPClassType) getOwner();
|
||||||
return (ICPPClassType)getParentNode();
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVisibility() {
|
public int getVisibility() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 QNX Software Systems and others.
|
* Copyright (c) 2007, 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -111,7 +111,7 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPClassType getClassOwner() throws DOMException {
|
public ICPPClassType getClassOwner() throws DOMException {
|
||||||
return getField().getClassOwner();
|
return (ICPPClassType) getOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVisibility() throws DOMException {
|
public int getVisibility() throws DOMException {
|
||||||
|
|
|
@ -23,10 +23,8 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
|
||||||
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;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
@ -46,7 +44,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* @author Bryan Wilkinson
|
* @author Bryan Wilkinson
|
||||||
*/
|
*/
|
||||||
class PDOMCPPFunctionTemplate extends PDOMCPPFunction
|
class PDOMCPPFunctionTemplate extends PDOMCPPFunction
|
||||||
implements ICPPFunctionTemplate, ICPPInstanceCache, IPDOMMemberOwner, ICPPTemplateScope, IIndexScope {
|
implements ICPPFunctionTemplate, ICPPInstanceCache, IPDOMMemberOwner, IIndexScope {
|
||||||
|
|
||||||
private static final int TEMPLATE_PARAMS = PDOMCPPFunction.RECORD_SIZE + 0;
|
private static final int TEMPLATE_PARAMS = PDOMCPPFunction.RECORD_SIZE + 0;
|
||||||
|
|
||||||
|
@ -122,10 +120,6 @@ class PDOMCPPFunctionTemplate extends PDOMCPPFunction
|
||||||
list.accept(visitor);
|
list.accept(visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPTemplateDefinition getTemplateDefinition() throws DOMException {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBinding[] find(String name) throws DOMException {
|
public IBinding[] find(String name) throws DOMException {
|
||||||
return CPPSemantics.findBindings( this, name, false );
|
return CPPSemantics.findBindings( this, name, false );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 QNX Software Systems and others.
|
* Copyright (c) 2007, 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
@ -40,11 +41,6 @@ class PDOMCPPFunctionTemplateSpecialization extends PDOMCPPFunctionSpecializatio
|
||||||
super(pdom, bindingRecord);
|
super(pdom, bindingRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getRecordSize() {
|
|
||||||
return RECORD_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNodeType() {
|
public int getNodeType() {
|
||||||
return IIndexCPPBindingConstants.CPP_FUNCTION_TEMPLATE_SPECIALIZATION;
|
return IIndexCPPBindingConstants.CPP_FUNCTION_TEMPLATE_SPECIALIZATION;
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
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.IASTFunctionCallExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||||
|
@ -151,12 +150,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPClassType getClassOwner() throws DOMException {
|
public ICPPClassType getClassOwner() throws DOMException {
|
||||||
try {
|
return (ICPPClassType) getOwner();
|
||||||
return (ICPPClassType) getParentNode();
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -70,7 +70,7 @@ class PDOMCPPMethodInstance extends PDOMCPPFunctionInstance implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPClassType getClassOwner() throws DOMException {
|
public ICPPClassType getClassOwner() throws DOMException {
|
||||||
return ((ICPPMethod)getTemplateDefinition()).getClassOwner();
|
return (ICPPClassType) getOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVisibility() throws DOMException {
|
public int getVisibility() throws DOMException {
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
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.IScope;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
|
@ -103,11 +101,7 @@ class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPClassType getClassOwner() throws DOMException {
|
public ICPPClassType getClassOwner() throws DOMException {
|
||||||
IScope scope= getScope();
|
return (ICPPClassType) getOwner();
|
||||||
if (scope instanceof ICPPClassScope) {
|
|
||||||
return ((ICPPClassScope) scope).getClassType();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVisibility() throws DOMException {
|
public int getVisibility() throws DOMException {
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||||
|
@ -92,12 +91,7 @@ class PDOMCPPMethodTemplate extends PDOMCPPFunctionTemplate implements ICPPMetho
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPClassType getClassOwner() throws DOMException {
|
public ICPPClassType getClassOwner() throws DOMException {
|
||||||
try {
|
return (ICPPClassType) getOwner();
|
||||||
return (ICPPClassType) getParentNode();
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVisibility() throws DOMException {
|
public int getVisibility() throws DOMException {
|
||||||
|
|
|
@ -13,12 +13,9 @@ 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.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
|
@ -31,12 +28,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
*/
|
*/
|
||||||
class PDOMCPPMethodTemplateSpecialization extends
|
class PDOMCPPMethodTemplateSpecialization extends
|
||||||
PDOMCPPFunctionTemplateSpecialization implements ICPPMethod {
|
PDOMCPPFunctionTemplateSpecialization implements ICPPMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* The size in bytes of a PDOMCPPMethodTemplateSpecialization record in the database.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("hiding")
|
|
||||||
protected static final int RECORD_SIZE = PDOMCPPFunctionTemplateSpecialization.RECORD_SIZE + 0;
|
|
||||||
|
|
||||||
public PDOMCPPMethodTemplateSpecialization(PDOM pdom, PDOMNode parent, ICPPMethod method, PDOMBinding specialized)
|
public PDOMCPPMethodTemplateSpecialization(PDOM pdom, PDOMNode parent, ICPPMethod method, PDOMBinding specialized)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
|
@ -47,11 +38,6 @@ class PDOMCPPMethodTemplateSpecialization extends
|
||||||
super(pdom, bindingRecord);
|
super(pdom, bindingRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getRecordSize() {
|
|
||||||
return RECORD_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNodeType() {
|
public int getNodeType() {
|
||||||
return IIndexCPPBindingConstants.CPP_METHOD_TEMPLATE_SPECIALIZATION;
|
return IIndexCPPBindingConstants.CPP_METHOD_TEMPLATE_SPECIALIZATION;
|
||||||
|
@ -82,14 +68,7 @@ class PDOMCPPMethodTemplateSpecialization extends
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPClassType getClassOwner() throws DOMException {
|
public ICPPClassType getClassOwner() throws DOMException {
|
||||||
IScope scope= getScope();
|
return (ICPPClassType) getOwner();
|
||||||
if (scope instanceof ICPPTemplateScope) {
|
|
||||||
scope= scope.getParent();
|
|
||||||
}
|
|
||||||
if( scope instanceof ICPPClassScope ){
|
|
||||||
return ((ICPPClassScope)scope).getClassType();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVisibility() throws DOMException {
|
public int getVisibility() throws DOMException {
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2006, 2008 IBM Corporation 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:
|
|
||||||
* IBM Corporation - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.core.lrparser.tests;
|
|
||||||
|
|
||||||
import junit.framework.AssertionFailedError;
|
|
||||||
import junit.framework.TestSuite;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
|
||||||
import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
|
|
||||||
import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
|
|
||||||
import org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage;
|
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
|
||||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2CSpecFailingTest;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
|
||||||
|
|
||||||
@SuppressWarnings("restriction")
|
|
||||||
public class LRCSpecFailingTest extends AST2CSpecFailingTest {
|
|
||||||
|
|
||||||
public static TestSuite suite() {
|
|
||||||
return suite(LRCSpecFailingTest.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LRCSpecFailingTest() { }
|
|
||||||
public LRCSpecFailingTest(String name) { super(name); }
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void parseCandCPP( String code, boolean checkBindings, int expectedProblemBindings ) throws ParserException {
|
|
||||||
parse(code, ParserLanguage.C, checkBindings, expectedProblemBindings);
|
|
||||||
parse(code, ParserLanguage.CPP, checkBindings, expectedProblemBindings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean checkBindings, int expectedProblemBindings ) throws ParserException {
|
|
||||||
ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
|
|
||||||
return ParseHelper.parse(code, language, true, checkBindings, expectedProblemBindings );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IASTTranslationUnit parse(String code, ParserLanguage lang, String[] problems) throws ParserException {
|
|
||||||
ILanguage language = lang.isCPP() ? getCPPLanguage() : getCLanguage();
|
|
||||||
return ParseHelper.parse(code, language, problems);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BaseExtensibleLanguage getCLanguage() {
|
|
||||||
return C99Language.getDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BaseExtensibleLanguage getCPPLanguage() {
|
|
||||||
return ISOCPPLanguage.getDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void test6_7_7s6() throws Exception { // this test actually passes, yay!
|
|
||||||
try {
|
|
||||||
super.test6_7_7s6();
|
|
||||||
} catch (AssertionFailedError e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -36,7 +36,6 @@ public class LRParserTestSuite extends TestSuite {
|
||||||
addTestSuite(LRCPPSpecFailingTest.class);
|
addTestSuite(LRCPPSpecFailingTest.class);
|
||||||
addTestSuite(LRCPPSpecTest.class);
|
addTestSuite(LRCPPSpecTest.class);
|
||||||
addTestSuite(LRCPPTests.class);
|
addTestSuite(LRCPPTests.class);
|
||||||
addTestSuite(LRCSpecFailingTest.class);
|
|
||||||
addTestSuite(LRCSpecTests.class); // a couple of failures
|
addTestSuite(LRCSpecTests.class); // a couple of failures
|
||||||
addTestSuite(LRDigraphTrigraphTests.class);
|
addTestSuite(LRDigraphTrigraphTests.class);
|
||||||
addTestSuite(LRDOMLocationInclusionTests.class);
|
addTestSuite(LRDOMLocationInclusionTests.class);
|
||||||
|
|
Loading…
Add table
Reference in a new issue