mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
- remove IBinding.getPhysicalNode, add private interfaces ICBinding & ICPPBinding
- constructor references in new expressions - get bindings from scope as shortcut
This commit is contained in:
parent
fe3c4a2eea
commit
06739b170f
22 changed files with 315 additions and 52 deletions
|
@ -836,11 +836,12 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
ICPPClassType C = (ICPPClassType) collector.getName( 2 ).resolveBinding();
|
ICPPClassType C = (ICPPClassType) collector.getName( 2 ).resolveBinding();
|
||||||
ICPPClassType B = (ICPPClassType) collector.getName( 4 ).resolveBinding();
|
ICPPClassType B = (ICPPClassType) collector.getName( 4 ).resolveBinding();
|
||||||
ICPPClassType A = (ICPPClassType) collector.getName( 6 ).resolveBinding();
|
ICPPClassType A = (ICPPClassType) collector.getName( 6 ).resolveBinding();
|
||||||
|
ICPPConstructor ctor = A.getConstructors()[0];
|
||||||
assertInstances( collector, D, 3 );
|
assertInstances( collector, D, 3 );
|
||||||
assertInstances( collector, C, 2 );
|
assertInstances( collector, C, 2 );
|
||||||
assertInstances( collector, B, 2 );
|
assertInstances( collector, B, 2 );
|
||||||
assertInstances( collector, A, 3 );
|
assertInstances( collector, A, 2 );
|
||||||
|
assertInstances( collector, ctor, 1 );
|
||||||
assertInstances( collector, x, 2 );
|
assertInstances( collector, x, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -866,14 +867,15 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
ICPPClassType C = (ICPPClassType) collector.getName( 2 ).resolveBinding();
|
ICPPClassType C = (ICPPClassType) collector.getName( 2 ).resolveBinding();
|
||||||
ICPPClassType B = (ICPPClassType) collector.getName( 4 ).resolveBinding();
|
ICPPClassType B = (ICPPClassType) collector.getName( 4 ).resolveBinding();
|
||||||
ICPPClassType A = (ICPPClassType) collector.getName( 6 ).resolveBinding();
|
ICPPClassType A = (ICPPClassType) collector.getName( 6 ).resolveBinding();
|
||||||
|
ICPPConstructor ctor = A.getConstructors()[0];
|
||||||
IProblemBinding x2 = (IProblemBinding) collector.getName( 14 ).resolveBinding();
|
IProblemBinding x2 = (IProblemBinding) collector.getName( 14 ).resolveBinding();
|
||||||
assertEquals( x2.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP );
|
assertEquals( x2.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP );
|
||||||
|
|
||||||
assertInstances( collector, D, 3 );
|
assertInstances( collector, D, 3 );
|
||||||
assertInstances( collector, C, 2 );
|
assertInstances( collector, C, 2 );
|
||||||
assertInstances( collector, B, 2 );
|
assertInstances( collector, B, 2 );
|
||||||
assertInstances( collector, A, 3 );
|
assertInstances( collector, A, 2 );
|
||||||
|
assertInstances( collector, ctor, 1 );
|
||||||
assertInstances( collector, x1, 1 );
|
assertInstances( collector, x1, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.CKnRParameter;
|
import org.eclipse.cdt.internal.core.dom.parser.c.CKnRParameter;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.c.ICBinding;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
|
@ -453,7 +454,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
||||||
IASTName A_struct_name1 = ((IASTCompositeTypeSpecifier)A_struct.getDeclSpecifier()).getName();
|
IASTName A_struct_name1 = ((IASTCompositeTypeSpecifier)A_struct.getDeclSpecifier()).getName();
|
||||||
assertEquals( A_struct_name1.toString(), "A_struct" ); //$NON-NLS-1$
|
assertEquals( A_struct_name1.toString(), "A_struct" ); //$NON-NLS-1$
|
||||||
ICompositeType A_struct_type1 = (ICompositeType)A_struct_name1.resolveBinding();
|
ICompositeType A_struct_type1 = (ICompositeType)A_struct_name1.resolveBinding();
|
||||||
assertEquals( A_struct_type1.getPhysicalNode(), A_struct.getDeclSpecifier() );
|
assertEquals( ((ICBinding)A_struct_type1).getPhysicalNode(), A_struct.getDeclSpecifier() );
|
||||||
List fields = A_struct_type1.getFields();
|
List fields = A_struct_type1.getFields();
|
||||||
IField a1 = (IField)fields.get(0);
|
IField a1 = (IField)fields.get(0);
|
||||||
IField c1 = (IField)fields.get(1);
|
IField c1 = (IField)fields.get(1);
|
||||||
|
@ -515,7 +516,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
||||||
IASTExpressionStatement stmt1 = (IASTExpressionStatement)f_def_body.getStatements()[0];
|
IASTExpressionStatement stmt1 = (IASTExpressionStatement)f_def_body.getStatements()[0];
|
||||||
IASTExpressionStatement stmt2 = (IASTExpressionStatement)f_def_body.getStatements()[1];
|
IASTExpressionStatement stmt2 = (IASTExpressionStatement)f_def_body.getStatements()[1];
|
||||||
IASTName a2 = ((IASTFieldReference)((IASTBinaryExpression)stmt1.getExpression()).getOperand1()).getFieldName();
|
IASTName a2 = ((IASTFieldReference)((IASTBinaryExpression)stmt1.getExpression()).getOperand1()).getFieldName();
|
||||||
assertEquals( ((IASTName)a1.getPhysicalNode()).resolveBinding(), a2.resolveBinding() );
|
assertEquals( ((IASTName)((ICBinding)a1).getPhysicalNode()).resolveBinding(), a2.resolveBinding() );
|
||||||
IASTName x3 = ((IASTIdExpression)((IASTFieldReference)((IASTBinaryExpression)stmt1.getExpression()).getOperand1()).getFieldOwner()).getName();
|
IASTName x3 = ((IASTIdExpression)((IASTFieldReference)((IASTBinaryExpression)stmt1.getExpression()).getOperand1()).getFieldOwner()).getName();
|
||||||
assertEquals( x2.resolveBinding(), x3.resolveBinding() );
|
assertEquals( x2.resolveBinding(), x3.resolveBinding() );
|
||||||
assertEquals( ((IASTBinaryExpression)stmt1.getExpression()).getOperand2().toString(), "0" ); //$NON-NLS-1$
|
assertEquals( ((IASTBinaryExpression)stmt1.getExpression()).getOperand2().toString(), "0" ); //$NON-NLS-1$
|
||||||
|
@ -525,8 +526,8 @@ public class AST2KnRTests extends AST2BaseTest {
|
||||||
IASTName x4 = ((IASTIdExpression)((IASTFieldReference)((IASTArraySubscriptExpression)((IASTBinaryExpression)stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
|
IASTName x4 = ((IASTIdExpression)((IASTFieldReference)((IASTArraySubscriptExpression)((IASTBinaryExpression)stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
|
||||||
IASTName c3 = ((IASTFieldReference)((IASTArraySubscriptExpression)((IASTBinaryExpression)stmt2.getExpression()).getOperand2()).getArrayExpression()).getFieldName();
|
IASTName c3 = ((IASTFieldReference)((IASTArraySubscriptExpression)((IASTBinaryExpression)stmt2.getExpression()).getOperand2()).getArrayExpression()).getFieldName();
|
||||||
IASTName x5 = ((IASTIdExpression)((IASTFieldReference)((IASTArraySubscriptExpression)((IASTBinaryExpression)stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
|
IASTName x5 = ((IASTIdExpression)((IASTFieldReference)((IASTArraySubscriptExpression)((IASTBinaryExpression)stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
|
||||||
assertEquals( ((IASTName)c1.getPhysicalNode()).resolveBinding(), c2.resolveBinding() );
|
assertEquals( ((IASTName)((ICBinding)c1).getPhysicalNode()).resolveBinding(), c2.resolveBinding() );
|
||||||
assertEquals( ((IASTName)c1.getPhysicalNode()).resolveBinding(), c3.resolveBinding() );
|
assertEquals( ((IASTName)((ICBinding)c1).getPhysicalNode()).resolveBinding(), c3.resolveBinding() );
|
||||||
assertEquals( x3.resolveBinding(), x4.resolveBinding() );
|
assertEquals( x3.resolveBinding(), x4.resolveBinding() );
|
||||||
assertEquals( x4.resolveBinding(), x5.resolveBinding() );
|
assertEquals( x4.resolveBinding(), x5.resolveBinding() );
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,8 @@ import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||||
|
@ -1095,10 +1095,11 @@ public class CompleteParser2Tests extends TestCase {
|
||||||
CPPVisitor.visitTranslationUnit( tu, col );
|
CPPVisitor.visitTranslationUnit( tu, col );
|
||||||
|
|
||||||
assertEquals( col.size(), 8 );
|
assertEquals( col.size(), 8 );
|
||||||
ICompositeType SD_01 = (ICompositeType) col.getName(0).resolveBinding();
|
ICPPClassType SD_01 = (ICPPClassType) col.getName(0).resolveBinding();
|
||||||
ICPPMethod f_SD_01 = (ICPPMethod) col.getName(1).resolveBinding();
|
ICPPMethod f_SD_01 = (ICPPMethod) col.getName(1).resolveBinding();
|
||||||
|
ICPPConstructor ctor = SD_01.getConstructors()[0];
|
||||||
assertInstances( col, SD_01, 3 );
|
assertInstances( col, SD_01, 2 );
|
||||||
|
assertInstances( col, ctor, 1 );
|
||||||
assertInstances( col, f_SD_01, 2 );
|
assertInstances( col, f_SD_01, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1194,13 +1195,15 @@ public class CompleteParser2Tests extends TestCase {
|
||||||
assertEquals( col.size(), 17 );
|
assertEquals( col.size(), 17 );
|
||||||
ICompositeType SD_02 = (ICompositeType) col.getName(0).resolveBinding();
|
ICompositeType SD_02 = (ICompositeType) col.getName(0).resolveBinding();
|
||||||
ICPPMethod f_SD_02 = (ICPPMethod) col.getName(1).resolveBinding();
|
ICPPMethod f_SD_02 = (ICPPMethod) col.getName(1).resolveBinding();
|
||||||
ICompositeType SD_01 = (ICompositeType) col.getName(2).resolveBinding();
|
ICPPClassType SD_01 = (ICPPClassType) col.getName(2).resolveBinding();
|
||||||
ICPPField next = (ICPPField) col.getName(4).resolveBinding();
|
ICPPField next = (ICPPField) col.getName(4).resolveBinding();
|
||||||
ICPPMethod f_SD_01 = (ICPPMethod) col.getName(5).resolveBinding();
|
ICPPMethod f_SD_01 = (ICPPMethod) col.getName(5).resolveBinding();
|
||||||
|
ICPPConstructor ctor = SD_01.getConstructors()[0];
|
||||||
|
|
||||||
assertInstances( col, SD_02, 2 );
|
assertInstances( col, SD_02, 2 );
|
||||||
assertInstances( col, f_SD_02, 2 );
|
assertInstances( col, f_SD_02, 2 );
|
||||||
assertInstances( col, SD_01, 4 );
|
assertInstances( col, SD_01, 3 );
|
||||||
|
assertInstances( col, ctor, 1 );
|
||||||
assertInstances( col, next, 2 );
|
assertInstances( col, next, 2 );
|
||||||
assertInstances( col, f_SD_01, 4 );
|
assertInstances( col, f_SD_01, 4 );
|
||||||
}
|
}
|
||||||
|
@ -1237,11 +1240,38 @@ public class CompleteParser2Tests extends TestCase {
|
||||||
|
|
||||||
public void testBug43951() throws Exception
|
public void testBug43951() throws Exception
|
||||||
{
|
{
|
||||||
parse( "class B{ B(); ~B(); }; B::B(){} B::~B(){}" ); //$NON-NLS-1$
|
IASTTranslationUnit tu = parse( "class B{ B(); ~B(); }; B::B(){} B::~B(){}" ); //$NON-NLS-1$
|
||||||
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
|
CPPVisitor.visitTranslationUnit( tu, col );
|
||||||
|
|
||||||
|
assertEquals( col.size(), 9 );
|
||||||
|
ICPPClassType B = (ICPPClassType) col.getName(0).resolveBinding();
|
||||||
|
ICPPConstructor constructor = (ICPPConstructor) col.getName(1).resolveBinding();
|
||||||
|
ICPPMethod destructor = (ICPPMethod) col.getName(2).resolveBinding();
|
||||||
|
|
||||||
|
assertInstances( col, B, 3 );
|
||||||
|
assertInstances( col, constructor, 3 );
|
||||||
|
assertInstances( col, destructor, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug44342() throws Exception {
|
public void testBug44342() throws Exception {
|
||||||
parse("class A { void f(){} void f(int){} }; int main(){ A * a = new A(); a->f();} "); //$NON-NLS-1$
|
IASTTranslationUnit tu = parse("class A { void f(){} void f(int){} }; int main(){ A * a = new A(); a->f();} "); //$NON-NLS-1$
|
||||||
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
|
CPPVisitor.visitTranslationUnit( tu, col );
|
||||||
|
|
||||||
|
assertEquals( col.size(), 10 );
|
||||||
|
ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
|
||||||
|
ICPPMethod f1 = (ICPPMethod) col.getName(1).resolveBinding();
|
||||||
|
ICPPMethod f2 = (ICPPMethod) col.getName(2).resolveBinding();
|
||||||
|
|
||||||
|
ICPPConstructor ctor = A.getConstructors()[0];
|
||||||
|
IVariable a = (IVariable) col.getName( 6 ).resolveBinding();
|
||||||
|
|
||||||
|
assertInstances( col, A, 2 );
|
||||||
|
assertInstances( col, f1, 2 );
|
||||||
|
assertInstances( col, f2, 1 );
|
||||||
|
assertInstances( col, ctor, 1 );
|
||||||
|
assertInstances( col, a, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,5 +30,4 @@ public interface IBinding {
|
||||||
*/
|
*/
|
||||||
public IScope getScope();
|
public IScope getScope();
|
||||||
|
|
||||||
public IASTNode getPhysicalNode();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
* Created on Nov 5, 2004
|
* Created on Nov 5, 2004
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CFunction implements IFunction {
|
public class CFunction implements IFunction, ICBinding {
|
||||||
private IASTFunctionDeclarator [] declarators = null;
|
private IASTFunctionDeclarator [] declarators = null;
|
||||||
private IASTFunctionDeclarator definition;
|
private IASTFunctionDeclarator definition;
|
||||||
IFunctionType type = null;
|
IFunctionType type = null;
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
|
||||||
* Created on Nov 8, 2004
|
* Created on Nov 8, 2004
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CStructure implements ICompositeType {
|
public class CStructure implements ICompositeType, ICBinding {
|
||||||
private IASTElaboratedTypeSpecifier[] declarations = null;
|
private IASTElaboratedTypeSpecifier[] declarations = null;
|
||||||
private ICASTCompositeTypeSpecifier definition;
|
private ICASTCompositeTypeSpecifier definition;
|
||||||
//final private IASTDeclSpecifier declSpecifier;
|
//final private IASTDeclSpecifier declSpecifier;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
* Created on Nov 5, 2004
|
* Created on Nov 5, 2004
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CVariable implements IVariable {
|
public class CVariable implements IVariable, ICBinding {
|
||||||
final IASTName name;
|
final IASTName name;
|
||||||
private IType type = null;
|
private IType type = null;
|
||||||
|
|
||||||
|
|
|
@ -681,7 +681,7 @@ public class CVisitor {
|
||||||
|
|
||||||
if ( fDtor.getName().resolveBinding() instanceof IFunction ) { // possible to have IASTParameterDeclaration whose parent is an IVariable
|
if ( fDtor.getName().resolveBinding() instanceof IFunction ) { // possible to have IASTParameterDeclaration whose parent is an IVariable
|
||||||
IFunction function = (IFunction) fDtor.getName().resolveBinding();
|
IFunction function = (IFunction) fDtor.getName().resolveBinding();
|
||||||
if( function.getPhysicalNode() != fDtor ) {
|
if( ((ICBinding)function).getPhysicalNode() != fDtor ) {
|
||||||
IASTParameterDeclaration [] ps = fDtor.getParameters();
|
IASTParameterDeclaration [] ps = fDtor.getParameters();
|
||||||
int index = -1;
|
int index = -1;
|
||||||
for( index = 0; index < ps.length; index++ )
|
for( index = 0; index < ps.length; index++ )
|
||||||
|
@ -1699,7 +1699,7 @@ public class CVisitor {
|
||||||
|
|
||||||
if ( declarator.getName().resolveBinding() instanceof IFunction ) { // possible to have IASTParameterDeclaration whose parent is an IVariable
|
if ( declarator.getName().resolveBinding() instanceof IFunction ) { // possible to have IASTParameterDeclaration whose parent is an IVariable
|
||||||
IFunction function = (IFunction) declarator.getName().resolveBinding();
|
IFunction function = (IFunction) declarator.getName().resolveBinding();
|
||||||
if( function.getPhysicalNode() != declarator ) {
|
if( ((ICBinding)function).getPhysicalNode() != declarator ) {
|
||||||
IASTDeclaration [] ps = declarator.getParameterDeclarations();
|
IASTDeclaration [] ps = declarator.getParameterDeclarations();
|
||||||
int index = -1;
|
int index = -1;
|
||||||
outerLoop: for( index = 0; index < ps.length; index++ )
|
outerLoop: for( index = 0; index < ps.length; index++ )
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Corporation - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Created on Jan 24, 2005
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author aniefer
|
||||||
|
*/
|
||||||
|
public interface ICBinding {
|
||||||
|
//methods needed by CVisitor but not meant for public interface
|
||||||
|
public IASTNode getPhysicalNode();
|
||||||
|
}
|
|
@ -20,11 +20,13 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
|
@ -169,9 +171,12 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
||||||
private boolean isConstructorReference( IASTName name ){
|
private boolean isConstructorReference( IASTName name ){
|
||||||
IASTNode node = name.getParent();
|
IASTNode node = name.getParent();
|
||||||
|
|
||||||
if( node instanceof IASTDeclSpecifier )
|
if( node instanceof IASTDeclSpecifier ){
|
||||||
|
IASTNode parent = node.getParent();
|
||||||
|
if( parent instanceof IASTTypeId && parent.getParent() instanceof ICPPASTNewExpression )
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPClassType implements ICPPClassType {
|
public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||||
private ICPPASTCompositeTypeSpecifier definition;
|
private ICPPASTCompositeTypeSpecifier definition;
|
||||||
private ICPPASTElaboratedTypeSpecifier [] declarations;
|
private ICPPASTElaboratedTypeSpecifier [] declarations;
|
||||||
|
|
||||||
|
@ -55,6 +55,20 @@ public class CPPClassType implements ICPPClassType {
|
||||||
declarations = new ICPPASTElaboratedTypeSpecifier[] { (ICPPASTElaboratedTypeSpecifier) declSpec };
|
declarations = new ICPPASTElaboratedTypeSpecifier[] { (ICPPASTElaboratedTypeSpecifier) declSpec };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
|
||||||
|
*/
|
||||||
|
public IASTNode[] getDeclarations() {
|
||||||
|
return declarations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
||||||
|
*/
|
||||||
|
public IASTNode getDefinition() {
|
||||||
|
return definition;
|
||||||
|
}
|
||||||
|
|
||||||
private class FindDefinitionAction extends CPPVisitor.CPPBaseVisitorAction {
|
private class FindDefinitionAction extends CPPVisitor.CPPBaseVisitorAction {
|
||||||
private char [] nameArray = CPPClassType.this.getNameCharArray();
|
private char [] nameArray = CPPClassType.this.getNameCharArray();
|
||||||
public ICPPASTCompositeTypeSpecifier result = null;
|
public ICPPASTCompositeTypeSpecifier result = null;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPEnumeration implements IEnumeration {
|
public class CPPEnumeration implements IEnumeration, ICPPBinding {
|
||||||
private IASTEnumerationSpecifier enumSpecifier;
|
private IASTEnumerationSpecifier enumSpecifier;
|
||||||
/**
|
/**
|
||||||
* @param specifier
|
* @param specifier
|
||||||
|
@ -32,6 +32,20 @@ public class CPPEnumeration implements IEnumeration {
|
||||||
this.enumSpecifier = specifier;
|
this.enumSpecifier = specifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
|
||||||
|
*/
|
||||||
|
public IASTNode[] getDeclarations() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
||||||
|
*/
|
||||||
|
public IASTNode getDefinition() {
|
||||||
|
return enumSpecifier;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPEnumerator implements IEnumerator {
|
public class CPPEnumerator implements IEnumerator, ICPPBinding {
|
||||||
private IASTEnumerator enumerator;
|
private IASTEnumerator enumerator;
|
||||||
/**
|
/**
|
||||||
* @param enumerator
|
* @param enumerator
|
||||||
|
@ -34,6 +34,20 @@ public class CPPEnumerator implements IEnumerator {
|
||||||
this.enumerator = enumerator;
|
this.enumerator = enumerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
|
||||||
|
*/
|
||||||
|
public IASTNode[] getDeclarations() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
||||||
|
*/
|
||||||
|
public IASTNode getDefinition() {
|
||||||
|
return enumerator;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPField extends CPPVariable implements ICPPField {
|
public class CPPField extends CPPVariable implements ICPPField, ICPPBinding {
|
||||||
public CPPField( IASTDeclarator declarator ){
|
public CPPField( IASTDeclarator declarator ){
|
||||||
super( declarator );
|
super( declarator );
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPFunction implements IFunction {
|
public class CPPFunction implements IFunction, ICPPBinding {
|
||||||
protected ICPPASTFunctionDeclarator [] declarations;
|
protected ICPPASTFunctionDeclarator [] declarations;
|
||||||
protected ICPPASTFunctionDeclarator definition;
|
protected ICPPASTFunctionDeclarator definition;
|
||||||
protected IFunctionType type = null;
|
protected IFunctionType type = null;
|
||||||
|
@ -43,6 +43,20 @@ public class CPPFunction implements IFunction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
|
||||||
|
*/
|
||||||
|
public IASTNode[] getDeclarations() {
|
||||||
|
return declarations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
||||||
|
*/
|
||||||
|
public IASTNode getDefinition() {
|
||||||
|
return definition;
|
||||||
|
}
|
||||||
|
|
||||||
public void addDefinition( ICPPASTFunctionDeclarator dtor ){
|
public void addDefinition( ICPPASTFunctionDeclarator dtor ){
|
||||||
updateParameterBindings( dtor );
|
updateParameterBindings( dtor );
|
||||||
definition = dtor;
|
definition = dtor;
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPLabel implements ILabel {
|
public class CPPLabel implements ILabel, ICPPBinding {
|
||||||
private IASTStatement statement;
|
private IASTStatement statement;
|
||||||
/**
|
/**
|
||||||
* @param gotoStatement
|
* @param gotoStatement
|
||||||
|
@ -33,6 +33,20 @@ public class CPPLabel implements ILabel {
|
||||||
this.statement = statement;
|
this.statement = statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
|
||||||
|
*/
|
||||||
|
public IASTNode[] getDeclarations() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
||||||
|
*/
|
||||||
|
public IASTNode getDefinition() {
|
||||||
|
return statement;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ILabel#getLabelStatement()
|
* @see org.eclipse.cdt.core.dom.ast.ILabel#getLabelStatement()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPNamespace implements ICPPNamespace {
|
public class CPPNamespace implements ICPPNamespace, ICPPBinding {
|
||||||
private static final char[] EMPTY_CHAR_ARRAY = { };
|
private static final char[] EMPTY_CHAR_ARRAY = { };
|
||||||
|
|
||||||
IASTName [] namespaceDefinitions = null;
|
IASTName [] namespaceDefinitions = null;
|
||||||
|
@ -42,6 +42,20 @@ public class CPPNamespace implements ICPPNamespace {
|
||||||
findAllDefinitions( nsDef );
|
findAllDefinitions( nsDef );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
|
||||||
|
*/
|
||||||
|
public IASTNode[] getDeclarations() {
|
||||||
|
return namespaceDefinitions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
||||||
|
*/
|
||||||
|
public IASTNode getDefinition() {
|
||||||
|
return ( tu != null ) ? tu : (IASTNode) namespaceDefinitions[0];
|
||||||
|
}
|
||||||
|
|
||||||
static private class NamespaceCollector extends CPPVisitor.CPPBaseVisitorAction {
|
static private class NamespaceCollector extends CPPVisitor.CPPBaseVisitorAction {
|
||||||
private char [] name;
|
private char [] name;
|
||||||
public List namespaces = Collections.EMPTY_LIST;
|
public List namespaces = Collections.EMPTY_LIST;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPParameter implements IParameter {
|
public class CPPParameter implements IParameter, ICPPBinding {
|
||||||
private IType type = null;
|
private IType type = null;
|
||||||
private IASTName [] declarations = null;
|
private IASTName [] declarations = null;
|
||||||
|
|
||||||
|
@ -36,6 +36,20 @@ public class CPPParameter implements IParameter {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
|
||||||
|
*/
|
||||||
|
public IASTNode[] getDeclarations() {
|
||||||
|
return declarations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
||||||
|
*/
|
||||||
|
public IASTNode getDefinition() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void addDeclaration( IASTName name ){
|
public void addDeclaration( IASTName name ){
|
||||||
if( declarations == null ){
|
if( declarations == null ){
|
||||||
declarations = new IASTName [] { name };
|
declarations = new IASTName [] { name };
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
|
@ -56,7 +57,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
|
||||||
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.ICPPASTNamedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||||
|
@ -264,6 +267,15 @@ public class CPPSemantics {
|
||||||
|
|
||||||
//3: resolve ambiguities
|
//3: resolve ambiguities
|
||||||
IBinding binding = resolveAmbiguities( data, name );
|
IBinding binding = resolveAmbiguities( data, name );
|
||||||
|
|
||||||
|
//4: post processing
|
||||||
|
if( data.considerConstructors && binding instanceof ICPPClassType ){
|
||||||
|
ICPPClassType cls = (ICPPClassType) binding;
|
||||||
|
//force resolution of constructor bindings
|
||||||
|
cls.getConstructors();
|
||||||
|
//then use the class scope to resolve which one.
|
||||||
|
binding = ((ICPPClassScope)cls.getCompositeScope()).getBinding( name );
|
||||||
|
}
|
||||||
if( binding != null && data.forDefinition && !( binding instanceof IProblemBinding ) ){
|
if( binding != null && data.forDefinition && !( binding instanceof IProblemBinding ) ){
|
||||||
addDefinition( binding, name );
|
addDefinition( binding, name );
|
||||||
}
|
}
|
||||||
|
@ -333,6 +345,17 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
} else if( parent instanceof ICPPASTUsingDeclaration ){
|
} else if( parent instanceof ICPPASTUsingDeclaration ){
|
||||||
data.forUsingDeclaration = true;
|
data.forUsingDeclaration = true;
|
||||||
|
} else if( parent instanceof ICPPASTNamedTypeSpecifier ){
|
||||||
|
if( parent.getParent() instanceof IASTTypeId ){
|
||||||
|
IASTTypeId typeId = (IASTTypeId) parent.getParent();
|
||||||
|
if( typeId.getAbstractDeclarator() instanceof IASTFunctionDeclarator ){
|
||||||
|
ICPPASTFunctionDeclarator fdtor = (ICPPASTFunctionDeclarator) typeId.getAbstractDeclarator();
|
||||||
|
data.functionParameters = fdtor.getParameters();
|
||||||
|
}
|
||||||
|
if( typeId.getParent() instanceof ICPPASTNewExpression ){
|
||||||
|
data.considerConstructors = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -364,8 +387,14 @@ public class CPPSemantics {
|
||||||
|
|
||||||
List directives = null;
|
List directives = null;
|
||||||
if( !data.usingDirectivesOnly ){
|
if( !data.usingDirectivesOnly ){
|
||||||
directives = new ArrayList(2);
|
IBinding binding = scope.getBinding( name );
|
||||||
data.foundItems = lookupInScope( data, scope, blockItem, directives );
|
if( binding == null ){
|
||||||
|
directives = new ArrayList(2);
|
||||||
|
data.foundItems = lookupInScope( data, scope, blockItem, directives );
|
||||||
|
} else {
|
||||||
|
data.foundItems = new ArrayList();
|
||||||
|
data.foundItems.add( binding );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -749,10 +778,6 @@ public class CPPSemantics {
|
||||||
//check the function itself
|
//check the function itself
|
||||||
IASTName declName = declarator.getName();
|
IASTName declName = declarator.getName();
|
||||||
if( data.considerConstructors || !CPPVisitor.isConstructor( scope, declarator ) ){
|
if( data.considerConstructors || !CPPVisitor.isConstructor( scope, declarator ) ){
|
||||||
if( declName instanceof ICPPASTQualifiedName ){
|
|
||||||
IASTName [] names = ((ICPPASTQualifiedName)declName).getNames();
|
|
||||||
declName = names[ names.length - 1 ];
|
|
||||||
}
|
|
||||||
if( CharArrayUtils.equals( declName.toCharArray(), data.name ) ){
|
if( CharArrayUtils.equals( declName.toCharArray(), data.name ) ){
|
||||||
return declName;
|
return declName;
|
||||||
}
|
}
|
||||||
|
@ -802,6 +827,20 @@ public class CPPSemantics {
|
||||||
return resolveAmbiguities( data, name );
|
return resolveAmbiguities( data, name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static private boolean declaredBefore( IBinding binding, IASTNode node ){
|
||||||
|
if( binding instanceof ICPPBinding ){
|
||||||
|
ICPPBinding cpp = (ICPPBinding) binding;
|
||||||
|
IASTNode[] n = cpp.getDeclarations();
|
||||||
|
if( n != null && n.length > 0 )
|
||||||
|
return (((ASTNode) n[0]).getOffset() < ((ASTNode)node).getOffset() );
|
||||||
|
else if( cpp.getDefinition() != null )
|
||||||
|
return (((ASTNode) cpp.getDefinition()).getOffset() < ((ASTNode)node).getOffset() );
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static private IBinding resolveAmbiguities( CPPSemantics.LookupData data, IASTName name ) {
|
static private IBinding resolveAmbiguities( CPPSemantics.LookupData data, IASTName name ) {
|
||||||
if( data.foundItems == null || data.foundItems.size() == 0 )
|
if( data.foundItems == null || data.foundItems.size() == 0 )
|
||||||
return null;
|
return null;
|
||||||
|
@ -815,13 +854,13 @@ public class CPPSemantics {
|
||||||
Object o = data.foundItems.get( i );
|
Object o = data.foundItems.get( i );
|
||||||
if( o instanceof IASTName )
|
if( o instanceof IASTName )
|
||||||
temp = ((IASTName) o).resolveBinding();
|
temp = ((IASTName) o).resolveBinding();
|
||||||
else if( o instanceof IBinding )
|
else if( o instanceof IBinding ){
|
||||||
temp = (IBinding) o;
|
temp = (IBinding) o;
|
||||||
else
|
if( !declaredBefore( temp, name ) )
|
||||||
|
continue;
|
||||||
|
} else
|
||||||
continue;
|
continue;
|
||||||
//IASTName n = (IASTName)
|
|
||||||
|
|
||||||
//temp = n.resolveBinding();
|
|
||||||
if( temp instanceof ICPPCompositeBinding ){
|
if( temp instanceof ICPPCompositeBinding ){
|
||||||
IBinding [] bindings = ((ICPPCompositeBinding) temp).getBindings();
|
IBinding [] bindings = ((ICPPCompositeBinding) temp).getBindings();
|
||||||
for( int j = 0; j < bindings.length; j++ )
|
for( int j = 0; j < bindings.length; j++ )
|
||||||
|
@ -847,7 +886,7 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
|
|
||||||
if( type != null ) {
|
if( type != null ) {
|
||||||
if( obj == null && fns == null )
|
if( data.typesOnly || (obj == null && fns == null) )
|
||||||
return type;
|
return type;
|
||||||
IScope typeScope = type.getScope();
|
IScope typeScope = type.getScope();
|
||||||
if( obj != null && obj.getScope() != typeScope ){
|
if( obj != null && obj.getScope() != typeScope ){
|
||||||
|
@ -893,8 +932,13 @@ public class CPPSemantics {
|
||||||
int size = functions.size();
|
int size = functions.size();
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
fName = (IFunction) functions.get(i);
|
fName = (IFunction) functions.get(i);
|
||||||
function = (ICPPASTFunctionDeclarator) fName.getPhysicalNode();
|
function = (ICPPASTFunctionDeclarator) ((ICPPBinding)fName).getDefinition();
|
||||||
|
if( function == null ){
|
||||||
|
IASTNode [] nodes = ((ICPPBinding) fName).getDeclarations();
|
||||||
|
if( nodes != null && nodes.length > 0 )
|
||||||
|
function = (ICPPASTFunctionDeclarator) nodes[0];
|
||||||
|
}
|
||||||
|
|
||||||
if( function == null ){
|
if( function == null ){
|
||||||
//implicit member function, for now, not supporting default values or var args
|
//implicit member function, for now, not supporting default values or var args
|
||||||
num = fName.getParameters().length;
|
num = fName.getParameters().length;
|
||||||
|
@ -1015,7 +1059,12 @@ public class CPPSemantics {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ICPPASTFunctionDeclarator currDtor = (ICPPASTFunctionDeclarator) currFn.getPhysicalNode();
|
ICPPASTFunctionDeclarator currDtor = (ICPPASTFunctionDeclarator) ((ICPPBinding)currFn).getDefinition();
|
||||||
|
if( currDtor == null ){
|
||||||
|
IASTNode[] nodes = ((ICPPBinding) currFn).getDeclarations();
|
||||||
|
if( nodes != null && nodes.length > 0 )
|
||||||
|
currDtor = (ICPPASTFunctionDeclarator) nodes[0];
|
||||||
|
}
|
||||||
targetParameters = ( currDtor != null ) ? currDtor.getParameters() : null;
|
targetParameters = ( currDtor != null ) ? currDtor.getParameters() : null;
|
||||||
|
|
||||||
if( targetParameters == null ){
|
if( targetParameters == null ){
|
||||||
|
@ -1252,9 +1301,8 @@ public class CPPSemantics {
|
||||||
|
|
||||||
static private boolean isCompleteType( IType type ){
|
static private boolean isCompleteType( IType type ){
|
||||||
type = getUltimateType( type );
|
type = getUltimateType( type );
|
||||||
if( type instanceof ICPPClassType ){
|
if( type instanceof ICPPClassType && ((ICPPBinding)type).getDefinition() == null ){
|
||||||
if( ((ICPPClassType) type).getPhysicalNode() instanceof ICPPASTElaboratedTypeSpecifier )
|
return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPTypedef implements ITypedef, ITypeContainer {
|
public class CPPTypedef implements ITypedef, ITypeContainer, ICPPBinding {
|
||||||
private IASTDeclarator declarator = null;
|
private IASTDeclarator declarator = null;
|
||||||
private IType type = null;
|
private IType type = null;
|
||||||
|
|
||||||
|
@ -36,6 +36,20 @@ public class CPPTypedef implements ITypedef, ITypeContainer {
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
|
||||||
|
*/
|
||||||
|
public IASTNode[] getDeclarations() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
||||||
|
*/
|
||||||
|
public IASTNode getDefinition() {
|
||||||
|
return declarator;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean equals( Object o ){
|
public boolean equals( Object o ){
|
||||||
if( o instanceof ITypedef )
|
if( o instanceof ITypedef )
|
||||||
return getType().equals( ((ITypedef)o).getType());
|
return getType().equals( ((ITypedef)o).getType());
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPVariable implements IVariable {
|
public class CPPVariable implements IVariable, ICPPBinding {
|
||||||
private IASTDeclarator declarator = null;
|
private IASTDeclarator declarator = null;
|
||||||
private IType type = null;
|
private IType type = null;
|
||||||
|
|
||||||
|
@ -30,6 +30,20 @@ public class CPPVariable implements IVariable {
|
||||||
declarator = dtor;
|
declarator = dtor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
|
||||||
|
*/
|
||||||
|
public IASTNode[] getDeclarations() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
||||||
|
*/
|
||||||
|
public IASTNode getDefinition() {
|
||||||
|
return declarator;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#getType()
|
* @see org.eclipse.cdt.core.dom.ast.IVariable#getType()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Corporation - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Created on Jan 24, 2005
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author aniefer
|
||||||
|
*/
|
||||||
|
public interface ICPPBinding {
|
||||||
|
//methods required by the CPPVisitor but not meant for the public interface
|
||||||
|
|
||||||
|
IASTNode [] getDeclarations();
|
||||||
|
IASTNode getDefinition();
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue