mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
- visiting the C++ AST
- Namespaces and Using directives
This commit is contained in:
parent
df1737f4f0
commit
c50120a815
27 changed files with 697 additions and 224 deletions
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
|
@ -31,7 +32,6 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
|
@ -52,6 +52,7 @@ import org.eclipse.cdt.internal.core.parser2.c.CVisitor;
|
|||
import org.eclipse.cdt.internal.core.parser2.c.GNUCSourceParser;
|
||||
import org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser2.cpp.ANSICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser2.cpp.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.parser2.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration;
|
||||
|
||||
|
@ -190,7 +191,7 @@ public class AST2BaseTest extends TestCase {
|
|||
return s.getExpression();
|
||||
}
|
||||
|
||||
static protected class NameCollector extends CVisitor.BaseVisitorAction {
|
||||
static protected class CNameCollector extends CVisitor.CBaseVisitorAction {
|
||||
{
|
||||
processNames = true;
|
||||
}
|
||||
|
@ -207,7 +208,33 @@ public class AST2BaseTest extends TestCase {
|
|||
public int size() { return nameList.size(); }
|
||||
}
|
||||
|
||||
protected void assertInstances( NameCollector collector, IBinding binding, int num ) throws Exception {
|
||||
protected void assertInstances( CNameCollector collector, IBinding binding, int num ) throws Exception {
|
||||
int count = 0;
|
||||
for( int i = 0; i < collector.size(); i++ )
|
||||
if( collector.getName( i ).resolveBinding() == binding )
|
||||
count++;
|
||||
|
||||
assertEquals( count, num );
|
||||
}
|
||||
|
||||
static protected class CPPNameCollector extends CPPVisitor.CPPBaseVisitorAction {
|
||||
{
|
||||
processNames = true;
|
||||
}
|
||||
public List nameList = new ArrayList();
|
||||
public boolean processName( IASTName name ){
|
||||
nameList.add( name );
|
||||
return true;
|
||||
}
|
||||
public IASTName getName( int idx ){
|
||||
if( idx < 0 || idx >= nameList.size() )
|
||||
return null;
|
||||
return (IASTName) nameList.get( idx );
|
||||
}
|
||||
public int size() { return nameList.size(); }
|
||||
}
|
||||
|
||||
protected void assertInstances( CPPNameCollector collector, IBinding binding, int num ) throws Exception {
|
||||
int count = 0;
|
||||
for( int i = 0; i < collector.size(); i++ )
|
||||
if( collector.getName( i ).resolveBinding() == binding )
|
||||
|
|
|
@ -27,14 +27,17 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
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.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.internal.core.parser2.cpp.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
@ -298,29 +301,44 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertSame( f2, f3 );
|
||||
}
|
||||
|
||||
// public void testNamespaces() throws Exception {
|
||||
// StringBuffer buffer = new StringBuffer();
|
||||
// buffer.append( "namespace A{ \n"); //$NON-NLS-1$
|
||||
// buffer.append( " int a; \n"); //$NON-NLS-1$
|
||||
// buffer.append( "} \n"); //$NON-NLS-1$
|
||||
// buffer.append( "namespace B{ \n"); //$NON-NLS-1$
|
||||
// buffer.append( " using namespace A; \n"); //$NON-NLS-1$
|
||||
// buffer.append( "} \n"); //$NON-NLS-1$
|
||||
// buffer.append( "namespace C{ \n"); //$NON-NLS-1$
|
||||
// buffer.append( " using namespace A; \n"); //$NON-NLS-1$
|
||||
// buffer.append( "} \n"); //$NON-NLS-1$
|
||||
// buffer.append( " \n"); //$NON-NLS-1$
|
||||
// buffer.append( "namespace BC{ \n"); //$NON-NLS-1$
|
||||
// buffer.append( " using namespace B; \n"); //$NON-NLS-1$
|
||||
// buffer.append( " using namespace C; \n"); //$NON-NLS-1$
|
||||
// buffer.append( "} \n"); //$NON-NLS-1$
|
||||
// buffer.append( " \n"); //$NON-NLS-1$
|
||||
// buffer.append( "void f(){ \n"); //$NON-NLS-1$
|
||||
// buffer.append( " BC::a++; //ok \n"); //$NON-NLS-1$
|
||||
// buffer.append( "} \n"); //$NON-NLS-1$
|
||||
//
|
||||
// IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
|
||||
//
|
||||
// //CPPVisitor.visitTranslationUnit( tu )
|
||||
// }
|
||||
public void testNamespaces() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( "namespace A{ \n"); //$NON-NLS-1$
|
||||
buffer.append( " int a; \n"); //$NON-NLS-1$
|
||||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
buffer.append( "namespace B{ \n"); //$NON-NLS-1$
|
||||
buffer.append( " using namespace A; \n"); //$NON-NLS-1$
|
||||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
buffer.append( "namespace C{ \n"); //$NON-NLS-1$
|
||||
buffer.append( " using namespace A; \n"); //$NON-NLS-1$
|
||||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
buffer.append( " \n"); //$NON-NLS-1$
|
||||
buffer.append( "namespace BC{ \n"); //$NON-NLS-1$
|
||||
buffer.append( " using namespace B; \n"); //$NON-NLS-1$
|
||||
buffer.append( " using namespace C; \n"); //$NON-NLS-1$
|
||||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
buffer.append( " \n"); //$NON-NLS-1$
|
||||
buffer.append( "void f(){ \n"); //$NON-NLS-1$
|
||||
buffer.append( " BC::a++; //ok \n"); //$NON-NLS-1$
|
||||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
|
||||
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
CPPVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 13 );
|
||||
ICPPNamespace A = (ICPPNamespace) collector.getName( 0 ).resolveBinding();
|
||||
IVariable a = (IVariable) collector.getName( 1 ).resolveBinding();
|
||||
ICPPNamespace B = (ICPPNamespace) collector.getName( 2 ).resolveBinding();
|
||||
ICPPNamespace C = (ICPPNamespace) collector.getName( 4 ).resolveBinding();
|
||||
ICPPNamespace BC = (ICPPNamespace) collector.getName( 6 ).resolveBinding();
|
||||
IFunction f = (IFunction) collector.getName( 9 ).resolveBinding();
|
||||
assertInstances( collector, A, 3 );
|
||||
assertInstances( collector, a, 3 );
|
||||
assertInstances( collector, B, 2 );
|
||||
assertInstances( collector, C, 2 );
|
||||
assertInstances( collector, BC, 2 );
|
||||
assertInstances( collector, f ,1 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -699,7 +699,7 @@ public class AST2Tests extends AST2BaseTest {
|
|||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 3 );
|
||||
|
|
|
@ -51,7 +51,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 33 );
|
||||
|
@ -92,7 +92,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 5 );
|
||||
|
@ -119,7 +119,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 12 );
|
||||
|
@ -157,7 +157,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 16 );
|
||||
|
@ -191,7 +191,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 11 );
|
||||
|
@ -219,7 +219,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 11 );
|
||||
|
@ -249,7 +249,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 19 );
|
||||
|
@ -284,7 +284,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 9 );
|
||||
|
@ -310,7 +310,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n" ); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 16 );
|
||||
|
@ -348,7 +348,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "unsigned long bb[] = { (1UL << (sizeof(long) *8 - 1)) = 0xfff }; \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 37 );
|
||||
|
@ -390,7 +390,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n" ); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 11 );
|
||||
|
@ -419,7 +419,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 15 );
|
||||
|
@ -459,7 +459,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 36 );
|
||||
|
@ -504,7 +504,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 43 );
|
||||
|
@ -550,7 +550,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 10 );
|
||||
|
@ -579,7 +579,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 25 );
|
||||
|
@ -621,7 +621,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append("} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 7 );
|
||||
|
@ -663,7 +663,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append("} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 95 );
|
||||
|
@ -703,7 +703,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 23 );
|
||||
|
@ -741,7 +741,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 28 );
|
||||
|
@ -779,7 +779,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 14 );
|
||||
|
@ -810,7 +810,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
buffer.append( "} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
||||
NameCollector collector = new NameCollector();
|
||||
CNameCollector collector = new CNameCollector();
|
||||
CVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 11 );
|
||||
|
|
|
@ -13,7 +13,8 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
* @author jcamelon
|
||||
*/
|
||||
public interface IASTTypeId extends IASTNode {
|
||||
|
||||
public static final IASTTypeId [] EMPTY_TYPEID_ARRAY = new IASTTypeId[0];
|
||||
|
||||
public static final ASTNodeProperty DECL_SPECIFIER = new ASTNodeProperty( "Decl Specifier"); //$NON-NLS-1$
|
||||
public static final ASTNodeProperty ABSTRACT_DECLARATOR = new ASTNodeProperty( "Abstract Declarator"); //$NON-NLS-1$
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
|||
*/
|
||||
public interface ICPPASTCatchHandler extends IASTStatement {
|
||||
|
||||
public static final ICPPASTCatchHandler [] EMPTY_CATCHHANDLER_ARRAY = new ICPPASTCatchHandler[0];
|
||||
|
||||
public static final ASTNodeProperty DECLARATION = new ASTNodeProperty( "Declaration"); //$NON-NLS-1$
|
||||
public static final ASTNodeProperty CATCH_BODY = new ASTNodeProperty( "Catch Body"); //$NON-NLS-1$
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
* @author jcamelon
|
||||
*/
|
||||
public interface ICPPASTConstructorChainInitializer extends IASTNode {
|
||||
public static final ICPPASTConstructorChainInitializer [] EMPTY_CONSTRUCTORCHAININITIALIZER_ARRAY = new ICPPASTConstructorChainInitializer[0];
|
||||
|
||||
public static final ASTNodeProperty MEMBER_ID = new ASTNodeProperty( "Member Initializer Id"); //$NON-NLS-1$
|
||||
public IASTName getMemberInitializerId();
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
|
@ -31,7 +29,7 @@ public interface ICPPASTFunctionDeclarator extends IASTFunctionDeclarator {
|
|||
public void setVolatile( boolean value );
|
||||
|
||||
public static final ASTNodeProperty EXCEPTION_TYPEID = new ASTNodeProperty( "Exception TypeId"); //$NON-NLS-1$
|
||||
public List getExceptionSpecification();
|
||||
public IASTTypeId [] getExceptionSpecification();
|
||||
public void addExceptionSpecificationTypeId( IASTTypeId typeId );
|
||||
/**
|
||||
* @param isPureVirtual
|
||||
|
@ -40,7 +38,7 @@ public interface ICPPASTFunctionDeclarator extends IASTFunctionDeclarator {
|
|||
public void setPureVirtual(boolean isPureVirtual);
|
||||
|
||||
public static final ASTNodeProperty CONSTRUCTOR_CHAIN_MEMBER = new ASTNodeProperty( "Constructor Chain Member"); //$NON-NLS-1$
|
||||
public List getConstructorChain();
|
||||
public ICPPASTConstructorChainInitializer[] getConstructorChain();
|
||||
public void addConstructorToChain( ICPPASTConstructorChainInitializer initializer );
|
||||
|
||||
}
|
||||
|
|
|
@ -10,10 +10,7 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -22,6 +19,6 @@ public interface ICPPASTFunctionTryBlockDeclarator extends
|
|||
ICPPASTFunctionDeclarator {
|
||||
|
||||
public static final ASTNodeProperty CATCH_HANDLER = new ASTNodeProperty( "Catch Handler"); //$NON-NLS-1$
|
||||
public void addCatchHandler( IASTStatement statement );
|
||||
public List getCatchHandlers();
|
||||
public void addCatchHandler( ICPPASTCatchHandler statement );
|
||||
public ICPPASTCatchHandler [] getCatchHandlers();
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
|
||||
|
@ -24,6 +22,6 @@ public interface ICPPASTLinkageSpecification extends IASTDeclaration {
|
|||
public void setLiteral( String value );
|
||||
|
||||
public static final ASTNodeProperty OWNED_DECLARATION = new ASTNodeProperty( "Owned Declaration"); //$NON-NLS-1$
|
||||
public List getDeclarations();
|
||||
public IASTDeclaration [] getDeclarations();
|
||||
public void addDeclaration( IASTDeclaration declaration );
|
||||
}
|
||||
|
|
|
@ -10,11 +10,10 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -33,8 +32,8 @@ public interface ICPPASTNamespaceDefinition extends IASTDeclaration {
|
|||
*
|
||||
* @return List of IASTDeclaration
|
||||
*/
|
||||
public List getDeclarations();
|
||||
public IASTDeclaration [] getDeclarations();
|
||||
|
||||
public void addDeclaration( IASTDeclaration declaration );
|
||||
|
||||
public IScope getScope();
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
|
@ -40,7 +38,7 @@ public interface ICPPASTNewExpression extends IASTExpression {
|
|||
public void setIsNewTypeId( boolean value );
|
||||
|
||||
public static final ASTNodeProperty NEW_TYPEID_ARRAY_EXPRESSION = new ASTNodeProperty( "Array Size Expression"); //$NON-NLS-1$
|
||||
public List getNewTypeIdArrayExpressions();
|
||||
public IASTExpression [] getNewTypeIdArrayExpressions();
|
||||
public void addNewTypeIdArrayExpression( IASTExpression expression );
|
||||
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
|
||||
|
@ -28,6 +26,6 @@ public interface ICPPASTTemplateDeclaration extends IASTDeclaration {
|
|||
public void setDeclaration( IASTDeclaration declaration );
|
||||
|
||||
public static final ASTNodeProperty PARAMETER = new ASTNodeProperty( "Template Parameter"); //$NON-NLS-1$
|
||||
public List getTemplateParameters();
|
||||
public ICPPASTTemplateParameter [] getTemplateParameters();
|
||||
public void addTemplateParamter( ICPPASTTemplateParameter parm );
|
||||
}
|
||||
|
|
|
@ -16,5 +16,6 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
* @author jcamelon
|
||||
*/
|
||||
public interface ICPPASTTemplateParameter extends IASTNode {
|
||||
public static final ICPPASTTemplateParameter [] EMPTY_TEMPLATEPARAMETER_ARRAY = new ICPPASTTemplateParameter[0];
|
||||
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||
|
||||
|
@ -36,6 +34,6 @@ public interface ICPPASTTryBlockStatement extends IASTStatement {
|
|||
* @param handler
|
||||
*/
|
||||
public void addCatchHandler(ICPPASTCatchHandler handler);
|
||||
public List getCatchHandlers();
|
||||
public ICPPASTCatchHandler [] getCatchHandlers();
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICScope;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser2.c.CVisitor.BaseVisitorAction;
|
||||
import org.eclipse.cdt.internal.core.parser2.c.CVisitor.CBaseVisitorAction;
|
||||
|
||||
/**
|
||||
* Created on Nov 8, 2004
|
||||
|
@ -98,7 +98,7 @@ public class CFunctionScope implements ICFunctionScope {
|
|||
return list;
|
||||
}
|
||||
|
||||
static private class FindLabelsAction extends BaseVisitorAction {
|
||||
static private class FindLabelsAction extends CBaseVisitorAction {
|
||||
public List labels = new ArrayList();
|
||||
public boolean ambiguous = false;
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
|||
* @author aniefer
|
||||
*/
|
||||
public class CVisitor {
|
||||
public static abstract class BaseVisitorAction {
|
||||
public static abstract class CBaseVisitorAction {
|
||||
public boolean processNames = false;
|
||||
public boolean processDeclarations = false;
|
||||
public boolean processInitializers = false;
|
||||
|
@ -106,7 +106,7 @@ public class CVisitor {
|
|||
public boolean processEnumerator( IASTEnumerator enumerator ) { return true; }
|
||||
}
|
||||
|
||||
public static class ClearBindingAction extends BaseVisitorAction {
|
||||
public static class ClearBindingAction extends CBaseVisitorAction {
|
||||
{
|
||||
processNames = true;
|
||||
}
|
||||
|
@ -661,20 +661,20 @@ public class CVisitor {
|
|||
visitTranslationUnit( tu, new ClearBindingAction() );
|
||||
}
|
||||
|
||||
public static void visitTranslationUnit( IASTTranslationUnit tu, BaseVisitorAction action ){
|
||||
public static void visitTranslationUnit( IASTTranslationUnit tu, CBaseVisitorAction action ){
|
||||
IASTDeclaration[] decls = tu.getDeclarations();
|
||||
for( int i = 0; i < decls.length; i++ ){
|
||||
if( !visitDeclaration( decls[i], action ) ) return;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean visitName( IASTName name, BaseVisitorAction action ){
|
||||
public static boolean visitName( IASTName name, CBaseVisitorAction action ){
|
||||
if( action.processNames )
|
||||
return action.processName( name );
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean visitDeclaration( IASTDeclaration declaration, BaseVisitorAction action ){
|
||||
public static boolean visitDeclaration( IASTDeclaration declaration, CBaseVisitorAction action ){
|
||||
if( action.processDeclarations )
|
||||
if( !action.processDeclaration( declaration ) ) return false;
|
||||
|
||||
|
@ -693,7 +693,7 @@ public class CVisitor {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
public static boolean visitDeclarator( IASTDeclarator declarator, BaseVisitorAction action ){
|
||||
public static boolean visitDeclarator( IASTDeclarator declarator, CBaseVisitorAction action ){
|
||||
if( action.processDeclarators )
|
||||
if( !action.processDeclarator( declarator ) ) return false;
|
||||
|
||||
|
@ -716,7 +716,7 @@ public class CVisitor {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean visitInitializer( IASTInitializer initializer, BaseVisitorAction action ){
|
||||
public static boolean visitInitializer( IASTInitializer initializer, CBaseVisitorAction action ){
|
||||
if( initializer == null )
|
||||
return true;
|
||||
if( action.processInitializers )
|
||||
|
@ -731,7 +731,7 @@ public class CVisitor {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
public static boolean visitParameterDeclaration( IASTParameterDeclaration parameterDeclaration, BaseVisitorAction action ){
|
||||
public static boolean visitParameterDeclaration( IASTParameterDeclaration parameterDeclaration, CBaseVisitorAction action ){
|
||||
if( action.processParameterDeclarations )
|
||||
if( !action.processParameterDeclaration( parameterDeclaration ) ) return false;
|
||||
|
||||
|
@ -740,7 +740,7 @@ public class CVisitor {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean visitDeclSpecifier( IASTDeclSpecifier declSpec, BaseVisitorAction action ){
|
||||
public static boolean visitDeclSpecifier( IASTDeclSpecifier declSpec, CBaseVisitorAction action ){
|
||||
if( action.processDeclSpecifiers )
|
||||
if( !action.processDeclSpecifier( declSpec ) ) return false;
|
||||
|
||||
|
@ -766,7 +766,7 @@ public class CVisitor {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
public static boolean visitEnumerator( IASTEnumerator enumerator, BaseVisitorAction action ){
|
||||
public static boolean visitEnumerator( IASTEnumerator enumerator, CBaseVisitorAction action ){
|
||||
if( action.processEnumerators )
|
||||
if( !action.processEnumerator( enumerator ) ) return false;
|
||||
|
||||
|
@ -775,7 +775,7 @@ public class CVisitor {
|
|||
if( !visitExpression( enumerator.getValue(), action ) ) return false;
|
||||
return true;
|
||||
}
|
||||
public static boolean visitStatement( IASTStatement statement, BaseVisitorAction action ){
|
||||
public static boolean visitStatement( IASTStatement statement, CBaseVisitorAction action ){
|
||||
if( action.processStatements )
|
||||
if( !action.processStatement( statement ) ) return false;
|
||||
|
||||
|
@ -822,7 +822,7 @@ public class CVisitor {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
public static boolean visitTypeId( IASTTypeId typeId, BaseVisitorAction action ){
|
||||
public static boolean visitTypeId( IASTTypeId typeId, CBaseVisitorAction action ){
|
||||
if( action.processTypeIds )
|
||||
if( !action.processTypeId( typeId ) ) return false;
|
||||
|
||||
|
@ -830,7 +830,7 @@ public class CVisitor {
|
|||
if( !visitDeclSpecifier( typeId.getDeclSpecifier(), action ) ) return false;
|
||||
return true;
|
||||
}
|
||||
public static boolean visitExpression( IASTExpression expression, BaseVisitorAction action ){
|
||||
public static boolean visitExpression( IASTExpression expression, CBaseVisitorAction action ){
|
||||
if( action.processExpressions )
|
||||
if( !action.processExpression( expression ) ) return false;
|
||||
|
||||
|
|
|
@ -10,10 +10,6 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
||||
|
@ -145,10 +141,10 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator#getExceptionSpecification()
|
||||
*/
|
||||
public List getExceptionSpecification() {
|
||||
if( typeIds == null ) return Collections.EMPTY_LIST;
|
||||
public IASTTypeId[] getExceptionSpecification() {
|
||||
if( typeIds == null ) return IASTTypeId.EMPTY_TYPEID_ARRAY;
|
||||
removeNullTypeIds();
|
||||
return Arrays.asList( typeIds );
|
||||
return typeIds;
|
||||
}
|
||||
|
||||
|
||||
|
@ -210,10 +206,10 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator#getConstructorChain()
|
||||
*/
|
||||
public List getConstructorChain() {
|
||||
if( constructorChain == null ) return Collections.EMPTY_LIST;
|
||||
public ICPPASTConstructorChainInitializer[] getConstructorChain() {
|
||||
if( constructorChain == null ) return ICPPASTConstructorChainInitializer.EMPTY_CONSTRUCTORCHAININITIALIZER_ARRAY;
|
||||
removeNullConstructors();
|
||||
return Arrays.asList( constructorChain );
|
||||
return constructorChain;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,11 +10,7 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionTryBlockDeclarator;
|
||||
|
||||
/**
|
||||
|
@ -26,16 +22,16 @@ public class CPPASTFunctionTryBlockDeclarator extends CPPASTFunctionDeclarator
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionTryBlockDeclarator#addCatchHandler(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||
*/
|
||||
public void addCatchHandler(IASTStatement statement) {
|
||||
public void addCatchHandler(ICPPASTCatchHandler statement) {
|
||||
if( catchHandlers == null )
|
||||
{
|
||||
catchHandlers = new IASTStatement[ DEFAULT_CATCH_HANDLER_LIST_SIZE ];
|
||||
catchHandlers = new ICPPASTCatchHandler[ DEFAULT_CATCH_HANDLER_LIST_SIZE ];
|
||||
currentIndex = 0;
|
||||
}
|
||||
if( catchHandlers.length == currentIndex )
|
||||
{
|
||||
IASTStatement [] old = catchHandlers;
|
||||
catchHandlers = new IASTStatement[ old.length * 2 ];
|
||||
ICPPASTCatchHandler [] old = catchHandlers;
|
||||
catchHandlers = new ICPPASTCatchHandler[ old.length * 2 ];
|
||||
for( int i = 0; i < old.length; ++i )
|
||||
catchHandlers[i] = old[i];
|
||||
}
|
||||
|
@ -44,10 +40,10 @@ public class CPPASTFunctionTryBlockDeclarator extends CPPASTFunctionDeclarator
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionTryBlockDeclarator#getCatchHandlers()
|
||||
*/
|
||||
public List getCatchHandlers() {
|
||||
if( catchHandlers == null ) return Collections.EMPTY_LIST;
|
||||
public ICPPASTCatchHandler [] getCatchHandlers() {
|
||||
if( catchHandlers == null ) return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY;
|
||||
removeNullCatchHandlers();
|
||||
return Arrays.asList( catchHandlers );
|
||||
return catchHandlers;
|
||||
}
|
||||
|
||||
private void removeNullCatchHandlers() {
|
||||
|
@ -56,16 +52,16 @@ public class CPPASTFunctionTryBlockDeclarator extends CPPASTFunctionDeclarator
|
|||
if( catchHandlers[i] == null )
|
||||
++nullCount;
|
||||
if( nullCount == 0 ) return;
|
||||
IASTStatement [] old = catchHandlers;
|
||||
ICPPASTCatchHandler [] old = catchHandlers;
|
||||
int newSize = old.length - nullCount;
|
||||
catchHandlers = new IASTStatement[ newSize ];
|
||||
catchHandlers = new ICPPASTCatchHandler[ newSize ];
|
||||
for( int i = 0; i < newSize; ++i )
|
||||
catchHandlers[i] = old[i];
|
||||
currentIndex = newSize;
|
||||
}
|
||||
|
||||
private int currentIndex = 0;
|
||||
private IASTStatement [] catchHandlers = null;
|
||||
private ICPPASTCatchHandler [] catchHandlers = null;
|
||||
private static final int DEFAULT_CATCH_HANDLER_LIST_SIZE = 4;
|
||||
|
||||
}
|
||||
|
|
|
@ -10,10 +10,6 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
|
||||
|
||||
|
@ -41,10 +37,10 @@ public class CPPASTLinkageSpecification extends CPPASTNode implements
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification#getDeclarations()
|
||||
*/
|
||||
public List getDeclarations() {
|
||||
if( declarations == null ) return Collections.EMPTY_LIST;
|
||||
public IASTDeclaration [] getDeclarations() {
|
||||
if( declarations == null ) return IASTDeclaration.EMPTY_DECLARATION_ARRAY;
|
||||
removeNullDeclarations();
|
||||
return Arrays.asList( declarations );
|
||||
return declarations;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -10,13 +10,11 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -43,10 +41,10 @@ public class CPPASTNamespaceDefinition extends CPPASTNode implements
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition#getDeclarations()
|
||||
*/
|
||||
public List getDeclarations() {
|
||||
if( declarations == null ) return Collections.EMPTY_LIST;
|
||||
public IASTDeclaration [] getDeclarations() {
|
||||
if( declarations == null ) return IASTDeclaration.EMPTY_DECLARATION_ARRAY;
|
||||
removeNullDeclarations();
|
||||
return Arrays.asList( declarations );
|
||||
return declarations;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -85,5 +83,16 @@ public class CPPASTNamespaceDefinition extends CPPASTNode implements
|
|||
private int currentIndex = 0;
|
||||
private IASTDeclaration [] declarations = null;
|
||||
private static final int DEFAULT_DECLARATIONS_LIST_SIZE = 4;
|
||||
private ICPPNamespaceScope scope = null;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
if(scope == null )
|
||||
scope = new CPPNamespaceScope( this );
|
||||
|
||||
return scope;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,10 +10,6 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||
|
@ -103,10 +99,10 @@ public class CPPASTNewExpression extends CPPASTNode implements
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression#getNewTypeIdArrayExpressions()
|
||||
*/
|
||||
public List getNewTypeIdArrayExpressions() {
|
||||
if( arrayExpressions == null ) return Collections.EMPTY_LIST;
|
||||
public IASTExpression [] getNewTypeIdArrayExpressions() {
|
||||
if( arrayExpressions == null ) return IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
||||
removeNullExpressions();
|
||||
return Arrays.asList( arrayExpressions );
|
||||
return arrayExpressions;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -10,10 +10,6 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
|
@ -58,10 +54,10 @@ public class CPPASTTemplateDeclaration extends CPPASTNode implements
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration#getTemplateParameters()
|
||||
*/
|
||||
public List getTemplateParameters() {
|
||||
if( parameters == null ) return Collections.EMPTY_LIST;
|
||||
public ICPPASTTemplateParameter [] getTemplateParameters() {
|
||||
if( parameters == null ) return ICPPASTTemplateParameter.EMPTY_TEMPLATEPARAMETER_ARRAY;
|
||||
removeNullParameters();
|
||||
return Arrays.asList( parameters );
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -10,10 +10,6 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
|
||||
|
@ -30,13 +26,13 @@ public class CPPASTTryBlockStatement extends CPPASTNode implements
|
|||
public void addCatchHandler(ICPPASTCatchHandler statement) {
|
||||
if( catchHandlers == null )
|
||||
{
|
||||
catchHandlers = new IASTStatement[ DEFAULT_CATCH_HANDLER_LIST_SIZE ];
|
||||
catchHandlers = new ICPPASTCatchHandler[ DEFAULT_CATCH_HANDLER_LIST_SIZE ];
|
||||
currentIndex = 0;
|
||||
}
|
||||
if( catchHandlers.length == currentIndex )
|
||||
{
|
||||
IASTStatement [] old = catchHandlers;
|
||||
catchHandlers = new IASTStatement[ old.length * 2 ];
|
||||
ICPPASTCatchHandler [] old = catchHandlers;
|
||||
catchHandlers = new ICPPASTCatchHandler[ old.length * 2 ];
|
||||
for( int i = 0; i < old.length; ++i )
|
||||
catchHandlers[i] = old[i];
|
||||
}
|
||||
|
@ -45,10 +41,10 @@ public class CPPASTTryBlockStatement extends CPPASTNode implements
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionTryBlockDeclarator#getCatchHandlers()
|
||||
*/
|
||||
public List getCatchHandlers() {
|
||||
if( catchHandlers == null ) return Collections.EMPTY_LIST;
|
||||
public ICPPASTCatchHandler[] getCatchHandlers() {
|
||||
if( catchHandlers == null ) return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY;
|
||||
removeNullCatchHandlers();
|
||||
return Arrays.asList( catchHandlers );
|
||||
return catchHandlers;
|
||||
}
|
||||
|
||||
private void removeNullCatchHandlers() {
|
||||
|
@ -57,16 +53,16 @@ public class CPPASTTryBlockStatement extends CPPASTNode implements
|
|||
if( catchHandlers[i] == null )
|
||||
++nullCount;
|
||||
if( nullCount == 0 ) return;
|
||||
IASTStatement [] old = catchHandlers;
|
||||
ICPPASTCatchHandler [] old = catchHandlers;
|
||||
int newSize = old.length - nullCount;
|
||||
catchHandlers = new IASTStatement[ newSize ];
|
||||
catchHandlers = new ICPPASTCatchHandler[ newSize ];
|
||||
for( int i = 0; i < newSize; ++i )
|
||||
catchHandlers[i] = old[i];
|
||||
currentIndex = newSize;
|
||||
}
|
||||
|
||||
private int currentIndex = 0;
|
||||
private IASTStatement [] catchHandlers = null;
|
||||
private ICPPASTCatchHandler [] catchHandlers = null;
|
||||
private static final int DEFAULT_CATCH_HANDLER_LIST_SIZE = 4;
|
||||
private IASTStatement tryBody;
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.parser2.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
|
||||
|
@ -22,45 +23,57 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
|||
* @author aniefer
|
||||
*/
|
||||
public class CPPNamespace implements ICPPNamespace {
|
||||
ICPPASTNamespaceDefinition [] namespaceDefinitions = null;
|
||||
|
||||
public CPPNamespace( ICPPASTNamespaceDefinition nsDef ){
|
||||
namespaceDefinitions = new ICPPASTNamespaceDefinition[] { nsDef };
|
||||
}
|
||||
|
||||
public void addDefinition( ICPPASTNamespaceDefinition nsDef ){
|
||||
for( int i = 0; i < namespaceDefinitions.length; i++ ){
|
||||
if( namespaceDefinitions[i] == null ){
|
||||
namespaceDefinitions[i] = nsDef;
|
||||
return;
|
||||
}
|
||||
}
|
||||
ICPPASTNamespaceDefinition [] temp = new ICPPASTNamespaceDefinition[ namespaceDefinitions.length * 2 ];
|
||||
System.arraycopy( namespaceDefinitions, 0, temp, 0, namespaceDefinitions.length );
|
||||
temp[ namespaceDefinitions.length ] = nsDef;
|
||||
namespaceDefinitions = temp;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace#getNamespaceScope()
|
||||
*/
|
||||
public ICPPNamespaceScope getNamespaceScope() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return (ICPPNamespaceScope) namespaceDefinitions[0].getScope();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return namespaceDefinitions[0].getName().toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return namespaceDefinitions[0].getName().toCharArray();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return CPPVisitor.getContainingScope( namespaceDefinitions[0] );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode()
|
||||
*/
|
||||
public IASTNode getPhysicalNode() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return namespaceDefinitions[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.util.List;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
|
@ -25,7 +24,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
|||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPNamespaceScope extends CPPScope implements ICPPNamespaceScope, IBinding{
|
||||
public class CPPNamespaceScope extends CPPScope implements ICPPNamespaceScope{
|
||||
private CharArrayObjectMap bindings = CharArrayObjectMap.EMPTY_MAP;
|
||||
|
||||
public CPPNamespaceScope( IASTNode physicalNode ) {
|
||||
|
@ -61,25 +60,4 @@ public class CPPNamespaceScope extends CPPScope implements ICPPNamespaceScope, I
|
|||
// TODO Auto-generated method stub
|
||||
return ICPPASTUsingDirective.EMPTY_USINGDIRECTIVE_ARRAY;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,43 +16,82 @@ package org.eclipse.cdt.internal.core.parser2.cpp;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionTryBlockDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
|
||||
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.ICPPASTSimpleTypeConstructorExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||
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.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
||||
|
@ -82,7 +121,8 @@ public class CPPVisitor {
|
|||
return createBinding( (IASTDeclarator) parent );
|
||||
} else if( parent instanceof ICPPASTElaboratedTypeSpecifier ){
|
||||
return createBinding( (ICPPASTElaboratedTypeSpecifier) parent );
|
||||
}
|
||||
} else if( parent instanceof IASTDeclaration )
|
||||
return createBinding( (IASTDeclaration) parent );
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -109,7 +149,23 @@ public class CPPVisitor {
|
|||
}
|
||||
return binding;
|
||||
}
|
||||
|
||||
private static IBinding createBinding( IASTDeclaration declaration ){
|
||||
if( declaration instanceof ICPPASTNamespaceDefinition ){
|
||||
ICPPASTNamespaceDefinition namespaceDef = (ICPPASTNamespaceDefinition) declaration;
|
||||
ICPPScope scope = (ICPPScope) getContainingScope( namespaceDef );
|
||||
CPPNamespace binding = (CPPNamespace) scope.getBinding( 0, namespaceDef.getName().toCharArray() );
|
||||
if( binding == null )
|
||||
binding = new CPPNamespace( namespaceDef );
|
||||
else
|
||||
binding.addDefinition( namespaceDef );
|
||||
return binding;
|
||||
} else if( declaration instanceof ICPPASTUsingDirective ){
|
||||
return resolveBinding( ((ICPPASTUsingDirective) declaration).getQualifiedName() );
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
private static IBinding createBinding( IASTDeclarator declarator ){
|
||||
IBinding binding = null;
|
||||
IASTNode parent = declarator.getParent();
|
||||
|
@ -190,6 +246,8 @@ public class CPPVisitor {
|
|||
return ((IASTForStatement)parent).getScope();
|
||||
} else if( parent instanceof IASTCompositeTypeSpecifier ){
|
||||
return ((IASTCompositeTypeSpecifier)parent).getScope();
|
||||
} else if( parent instanceof ICPPASTNamespaceDefinition ) {
|
||||
return ((ICPPASTNamespaceDefinition)parent).getScope();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -321,7 +379,7 @@ public class CPPVisitor {
|
|||
LookupData data = new LookupData( name.toCharArray() );
|
||||
IASTNode parent = name.getParent();
|
||||
if( parent instanceof ICPPASTQualifiedName ){
|
||||
data.qualified = true;
|
||||
data.qualified = ((ICPPASTQualifiedName)parent).getNames()[0] != name;
|
||||
parent = parent.getParent();
|
||||
if( parent instanceof IASTDeclarator ){
|
||||
data.forDefinition = true;
|
||||
|
@ -409,6 +467,10 @@ public class CPPVisitor {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if( declaration instanceof ICPPASTNamespaceDefinition ){
|
||||
IASTName namespaceName = ((ICPPASTNamespaceDefinition) declaration).getName();
|
||||
if( CharArrayUtils.equals( namespaceName.toCharArray(), data.name ) )
|
||||
return namespaceName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -435,7 +497,9 @@ public class CPPVisitor {
|
|||
processDirectives( data, scope, directives );
|
||||
|
||||
while( !data.usingDirectives.isEmpty() && data.usingDirectives.get( scope ) != null ){
|
||||
transitives = lookupInNominated( data, scope, null );
|
||||
if( transitives != null )
|
||||
transitives.clear();
|
||||
transitives = lookupInNominated( data, scope, transitives );
|
||||
|
||||
if( !data.qualified || data.foundItems == null ){
|
||||
processDirectives( data, scope, transitives );
|
||||
|
@ -564,10 +628,10 @@ public class CPPVisitor {
|
|||
|
||||
int size = directives.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
IASTName qualName = ((ICPPASTUsingDirective)directives.get(1)).getQualifiedName();
|
||||
IASTName qualName = ((ICPPASTUsingDirective)directives.get(i)).getQualifiedName();
|
||||
IBinding binding = qualName.resolveBinding();
|
||||
if( binding instanceof ICPPNamespaceScope ){
|
||||
temp = (IScope) binding;
|
||||
if( binding instanceof ICPPNamespace ){
|
||||
temp = ((ICPPNamespace)binding).getNamespaceScope();
|
||||
} else
|
||||
continue;
|
||||
|
||||
|
@ -577,33 +641,32 @@ public class CPPVisitor {
|
|||
|
||||
//data.usingDirectives is a map from enclosing scope to a list
|
||||
//of namespaces to consider when we reach that enclosing scope
|
||||
ICPPScope [] list = data.usingDirectives.isEmpty() ? null : (ICPPScope []) data.usingDirectives.get( enclosing );
|
||||
List list = data.usingDirectives.isEmpty() ? null : (List) data.usingDirectives.get( enclosing );
|
||||
if( list == null ){
|
||||
list = new ICPPScope [] { enclosing, null };
|
||||
list = new ArrayList();
|
||||
|
||||
if( data.usingDirectives == ObjectMap.EMPTY_MAP ){
|
||||
data.usingDirectives = new ObjectMap(2);
|
||||
}
|
||||
data.usingDirectives.put( enclosing, list );
|
||||
} else {
|
||||
int j = 0;
|
||||
for( ; j < list.length; j++ ){
|
||||
if( list[j] == null ){
|
||||
list[j] = enclosing;
|
||||
}
|
||||
}
|
||||
if( j == list.length ){
|
||||
ICPPScope [] tmpScopes = new ICPPScope[ list.length * 2 ];
|
||||
System.arraycopy( list, 0, tmpScopes, 0, list.length );
|
||||
tmpScopes[list.length] = enclosing;
|
||||
list = tmpScopes;
|
||||
}
|
||||
}
|
||||
}
|
||||
list.add( temp );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
static private ICPPScope getClosestEnclosingScope( IScope scope1, IScope scope2 ){
|
||||
return null;
|
||||
ObjectSet set = new ObjectSet( 2 );
|
||||
IScope parent = scope1;
|
||||
while( parent != null ){
|
||||
set.put( parent );
|
||||
parent = parent.getParent();
|
||||
}
|
||||
parent = scope2;
|
||||
while( parent != null && !set.containsKey( parent ) ){
|
||||
parent = parent.getParent();
|
||||
}
|
||||
return (ICPPScope) parent;
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
@ -626,6 +689,8 @@ public class CPPVisitor {
|
|||
} else if ( parent instanceof ICPPASTCompositeTypeSpecifier ){
|
||||
ICPPASTCompositeTypeSpecifier comp = (ICPPASTCompositeTypeSpecifier) parent;
|
||||
nodes = comp.getMembers();
|
||||
} else if ( parent instanceof ICPPASTNamespaceDefinition ){
|
||||
nodes = ((ICPPASTNamespaceDefinition)parent).getDeclarations();
|
||||
}
|
||||
|
||||
int idx = -1;
|
||||
|
@ -638,13 +703,13 @@ public class CPPVisitor {
|
|||
if( item instanceof ICPPASTUsingDirective && !data.ignoreUsingDirectives ) {
|
||||
if( usingDirectives != null )
|
||||
usingDirectives.add( item );
|
||||
continue;
|
||||
}
|
||||
possible = collectResult( data, item, (item == parent) );
|
||||
if( possible != null ){
|
||||
if( found == null )
|
||||
found = new ArrayList(2);
|
||||
found.add( possible );
|
||||
} else {
|
||||
possible = collectResult( data, item, (item == parent) );
|
||||
if( possible != null ){
|
||||
if( found == null )
|
||||
found = new ArrayList(2);
|
||||
found.add( possible );
|
||||
}
|
||||
}
|
||||
if( idx > -1 && ++idx < nodes.length ){
|
||||
item = nodes[idx];
|
||||
|
@ -674,7 +739,7 @@ public class CPPVisitor {
|
|||
}
|
||||
data.visited.put( temp );
|
||||
List usings = new ArrayList(2);
|
||||
List found = lookupInScope( data, scope, null, usings );
|
||||
List found = lookupInScope( data, temp, null, usings );
|
||||
if( data.foundItems == null )
|
||||
data.foundItems = found;
|
||||
else if( found != null )
|
||||
|
@ -684,10 +749,406 @@ public class CPPVisitor {
|
|||
//only consider the transitive using directives if we are an unqualified
|
||||
//lookup, or we didn't find the name in decl
|
||||
if( usings != null && usings.size() > 0 && (!data.qualified || found == null ) ){
|
||||
if( transitives == null )
|
||||
transitives = new ArrayList(2);
|
||||
transitives.addAll( usings );
|
||||
}
|
||||
}
|
||||
}
|
||||
return transitives;
|
||||
}
|
||||
|
||||
public static abstract class CPPBaseVisitorAction {
|
||||
public boolean processNames = false;
|
||||
public boolean processDeclarations = false;
|
||||
public boolean processInitializers = false;
|
||||
public boolean processParameterDeclarations = false;
|
||||
public boolean processDeclarators = false;
|
||||
public boolean processDeclSpecifiers = false;
|
||||
public boolean processExpressions = false;
|
||||
public boolean processStatements = false;
|
||||
public boolean processTypeIds = false;
|
||||
public boolean processEnumerators = false;
|
||||
public boolean processBaseSpecifiers;
|
||||
|
||||
/**
|
||||
* @return true to continue visiting, return false to stop
|
||||
*/
|
||||
public boolean processName( IASTName name ) { return true; }
|
||||
public boolean processDeclaration( IASTDeclaration declaration ){ return true; }
|
||||
public boolean processInitializer( IASTInitializer initializer ){ return true; }
|
||||
public boolean processParameterDeclaration( IASTParameterDeclaration parameterDeclaration ) { return true; }
|
||||
public boolean processDeclarator( IASTDeclarator declarator ) { return true; }
|
||||
public boolean processDeclSpecifier( IASTDeclSpecifier declSpec ){return true; }
|
||||
public boolean processExpression( IASTExpression expression ) { return true; }
|
||||
public boolean processStatement( IASTStatement statement ) { return true; }
|
||||
public boolean processTypeId( IASTTypeId typeId ) { return true; }
|
||||
public boolean processEnumerator( IASTEnumerator enumerator ) { return true; }
|
||||
public boolean processBaseSpecifier(ICPPASTBaseSpecifier specifier) { return true; }
|
||||
}
|
||||
|
||||
public static void visitTranslationUnit( IASTTranslationUnit tu, CPPBaseVisitorAction action ){
|
||||
IASTDeclaration [] decls = tu.getDeclarations();
|
||||
for( int i = 0; i < decls.length; i++ ){
|
||||
if( !visitDeclaration( decls[i], action ) ) return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param declaration
|
||||
* @param action
|
||||
* @return
|
||||
*/
|
||||
public static boolean visitDeclaration(IASTDeclaration declaration, CPPBaseVisitorAction action) {
|
||||
if( action.processDeclarations )
|
||||
if( !action.processDeclaration( declaration ) ) return false;
|
||||
|
||||
if( declaration instanceof IASTSimpleDeclaration ){
|
||||
IASTSimpleDeclaration simple = (IASTSimpleDeclaration) declaration;
|
||||
if( !visitDeclSpecifier( simple.getDeclSpecifier(), action ) ) return false;
|
||||
IASTDeclarator [] dtors = simple.getDeclarators();
|
||||
for( int i = 0; i < dtors.length; i++ ){
|
||||
if( !visitDeclarator( dtors[i], action) ) return false;
|
||||
}
|
||||
} else if( declaration instanceof IASTFunctionDefinition ){
|
||||
IASTFunctionDefinition function = (IASTFunctionDefinition) declaration;
|
||||
if( !visitDeclSpecifier( function.getDeclSpecifier(), action ) ) return false;
|
||||
if( !visitDeclarator( function.getDeclarator(), action ) ) return false;
|
||||
if( !visitStatement( function.getBody(), action ) ) return false;
|
||||
} else if( declaration instanceof ICPPASTUsingDeclaration ){
|
||||
if( !visitName( ((ICPPASTUsingDeclaration)declaration).getName(), action ) ) return false;
|
||||
} else if( declaration instanceof ICPPASTUsingDirective ){
|
||||
if( !visitName( ((ICPPASTUsingDirective)declaration).getQualifiedName(), action ) ) return false;
|
||||
} else if( declaration instanceof ICPPASTNamespaceDefinition ){
|
||||
ICPPASTNamespaceDefinition namespace = (ICPPASTNamespaceDefinition) declaration;
|
||||
if( !visitName( namespace.getName(), action ) ) return false;
|
||||
IASTDeclaration [] decls = namespace.getDeclarations();
|
||||
for( int i = 0; i < decls.length; i++ ){
|
||||
if( !visitDeclaration( decls[i], action ) ) return false;
|
||||
}
|
||||
} else if( declaration instanceof ICPPASTNamespaceAlias ){
|
||||
ICPPASTNamespaceAlias alias = (ICPPASTNamespaceAlias) declaration;
|
||||
if( !visitName( alias.getQualifiedName(), action ) ) return false;
|
||||
if( !visitName( alias.getAlias(), action ) ) return false;
|
||||
} else if( declaration instanceof ICPPASTLinkageSpecification ){
|
||||
IASTDeclaration [] decls = ((ICPPASTLinkageSpecification) declaration).getDeclarations();
|
||||
for( int i = 0; i < decls.length; i++ ){
|
||||
if( !visitDeclaration( decls[i], action ) ) return false;
|
||||
}
|
||||
} else if( declaration instanceof ICPPASTTemplateDeclaration ){
|
||||
ICPPASTTemplateDeclaration template = (ICPPASTTemplateDeclaration) declaration;
|
||||
ICPPASTTemplateParameter [] params = template.getTemplateParameters();
|
||||
for( int i = 0; i < params.length; i++ ){
|
||||
if( !visitTemplateParameter( params[i], action ) ) return false;
|
||||
}
|
||||
if( !visitDeclaration( template.getDeclaration(), action ) ) return false;
|
||||
} else if( declaration instanceof ICPPASTTemplateSpecialization ){
|
||||
if( !visitDeclaration( ((ICPPASTTemplateSpecialization) declaration).getDeclaration(), action ) ) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @param action
|
||||
* @return
|
||||
*/
|
||||
public static boolean visitName(IASTName name, CPPBaseVisitorAction action) {
|
||||
if( action.processNames )
|
||||
if( !action.processName( name ) ) return false;
|
||||
|
||||
if( name instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] names = ((ICPPASTQualifiedName)name).getNames();
|
||||
for( int i = 0; i < names.length; i++ ){
|
||||
if( !visitName( names[i], action ) ) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param declSpecifier
|
||||
* @param action
|
||||
* @return
|
||||
*/
|
||||
public static boolean visitDeclSpecifier(IASTDeclSpecifier declSpecifier, CPPBaseVisitorAction action) {
|
||||
if( action.processDeclSpecifiers )
|
||||
if( !action.processDeclSpecifier( declSpecifier ) ) return false;
|
||||
|
||||
if( declSpecifier instanceof ICPPASTCompositeTypeSpecifier ){
|
||||
ICPPASTCompositeTypeSpecifier composite = (ICPPASTCompositeTypeSpecifier) declSpecifier;
|
||||
if( !visitName( composite.getName(), action ) ) return false;
|
||||
ICPPASTBaseSpecifier [] bases = composite.getBaseSpecifiers();
|
||||
for( int i = 0; i < bases.length; i++ ) {
|
||||
if( !visitBaseSpecifier( bases[i], action ) ) return false;
|
||||
}
|
||||
IASTDeclaration [] decls = composite.getMembers();
|
||||
for( int i = 0; i < decls.length; i++ ){
|
||||
if( !visitDeclaration( decls[i], action ) ) return false;
|
||||
}
|
||||
} else if( declSpecifier instanceof ICPPASTElaboratedTypeSpecifier ){
|
||||
if( !visitName( ((ICPPASTElaboratedTypeSpecifier) declSpecifier).getName(), action ) ) return false;
|
||||
} else if( declSpecifier instanceof IASTEnumerationSpecifier ){
|
||||
IASTEnumerationSpecifier enum = (IASTEnumerationSpecifier) declSpecifier;
|
||||
if( !visitName( enum.getName(), action ) ) return false;
|
||||
IASTEnumerator [] etors = enum.getEnumerators();
|
||||
for( int i = 0; i < etors.length; i++ ){
|
||||
if( !visitEnumerator( etors[i], action ) ) return false;
|
||||
}
|
||||
} else if( declSpecifier instanceof ICPPASTNamedTypeSpecifier ){
|
||||
if( !visitName( ((ICPPASTNamedTypeSpecifier)declSpecifier).getName(), action ) ) return false;
|
||||
} else if( declSpecifier instanceof IGPPASTSimpleDeclSpecifier ) {
|
||||
IASTExpression typeOf = ((IGPPASTSimpleDeclSpecifier)declSpecifier).getTypeofExpression();
|
||||
if( typeOf != null )
|
||||
if( !visitExpression( typeOf, action ) ) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param declarator
|
||||
* @param action
|
||||
* @return
|
||||
*/
|
||||
public static boolean visitDeclarator(IASTDeclarator declarator, CPPBaseVisitorAction action) {
|
||||
if( action.processDeclarators )
|
||||
if( !action.processDeclarator( declarator ) ) return false;
|
||||
|
||||
if( !visitName( declarator.getName(), action ) ) return false;
|
||||
|
||||
if( declarator.getNestedDeclarator() != null )
|
||||
if( !visitDeclarator( declarator.getNestedDeclarator(), action ) ) return false;
|
||||
|
||||
if( declarator instanceof ICPPASTFunctionDeclarator ){
|
||||
ICPPASTFunctionDeclarator fdtor = (ICPPASTFunctionDeclarator) declarator;
|
||||
IASTParameterDeclaration [] list = fdtor.getParameters();
|
||||
for( int i = 0; i < list.length; i++ ){
|
||||
IASTParameterDeclaration param = list[i];
|
||||
if( !visitDeclSpecifier( param.getDeclSpecifier(), action ) ) return false;
|
||||
if( !visitDeclarator( param.getDeclarator(), action ) ) return false;
|
||||
}
|
||||
ICPPASTConstructorChainInitializer [] ctorChain = fdtor.getConstructorChain();
|
||||
for( int i = 0; i < list.length; i++ ){
|
||||
if( !visitName( ctorChain[i].getMemberInitializerId(), action ) ) return false;
|
||||
if( !visitExpression( ctorChain[i].getInitializerValue(), action ) ) return false;
|
||||
}
|
||||
IASTTypeId [] typeIds = fdtor.getExceptionSpecification();
|
||||
for( int i = 0; i < list.length; i++ ){
|
||||
if( !visitTypeId( typeIds[i], action ) ) return false;
|
||||
}
|
||||
|
||||
if( declarator instanceof ICPPASTFunctionTryBlockDeclarator ){
|
||||
ICPPASTCatchHandler [] catchHandlers = ((ICPPASTFunctionTryBlockDeclarator)declarator).getCatchHandlers();
|
||||
for( int i = 0; i < catchHandlers.length; i++ ){
|
||||
if( !visitStatement( catchHandlers[i], action ) ) return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( declarator.getInitializer() != null )
|
||||
if( !visitInitializer( declarator.getInitializer(), action ) ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param body
|
||||
* @param action
|
||||
* @return
|
||||
*/
|
||||
public static boolean visitStatement(IASTStatement statement, CPPBaseVisitorAction action) {
|
||||
if( action.processStatements )
|
||||
if( !action.processStatement( statement ) ) return false;
|
||||
|
||||
if( statement instanceof IASTCompoundStatement ){
|
||||
IASTStatement [] list = ((IASTCompoundStatement) statement).getStatements();
|
||||
for( int i = 0; i < list.length; i++ ){
|
||||
if( list[i] == null ) break;
|
||||
if( !visitStatement( list[i], action ) ) return false;
|
||||
}
|
||||
} else if( statement instanceof IASTDeclarationStatement ){
|
||||
if( !visitDeclaration( ((IASTDeclarationStatement)statement).getDeclaration(), action ) ) return false;
|
||||
} else if( statement instanceof IASTExpressionStatement ){
|
||||
if( !visitExpression( ((IASTExpressionStatement)statement).getExpression(), action ) ) return false;
|
||||
} else if( statement instanceof IASTCaseStatement ){
|
||||
if( !visitExpression( ((IASTCaseStatement)statement).getExpression(), action ) ) return false;
|
||||
} else if( statement instanceof IASTDoStatement ){
|
||||
if( !visitStatement( ((IASTDoStatement)statement).getBody(), action ) ) return false;
|
||||
if( !visitExpression( ((IASTDoStatement)statement).getCondition(), action ) ) return false;
|
||||
} else if( statement instanceof IASTGotoStatement ){
|
||||
if( !visitName( ((IASTGotoStatement)statement).getName(), action ) ) return false;
|
||||
} else if( statement instanceof IASTIfStatement ){
|
||||
if( !visitExpression( ((IASTIfStatement) statement ).getCondition(), action ) ) return false;
|
||||
if( !visitStatement( ((IASTIfStatement) statement ).getThenClause(), action ) ) return false;
|
||||
if( !visitStatement( ((IASTIfStatement) statement ).getElseClause(), action ) ) return false;
|
||||
} else if( statement instanceof IASTLabelStatement ){
|
||||
if( !visitName( ((IASTLabelStatement)statement).getName(), action ) ) return false;
|
||||
} else if( statement instanceof IASTReturnStatement ){
|
||||
if( !visitExpression( ((IASTReturnStatement) statement ).getReturnValue(), action ) ) return false;
|
||||
} else if( statement instanceof IASTSwitchStatement ){
|
||||
if( !visitExpression( ((IASTSwitchStatement) statement ).getController(), action ) ) return false;
|
||||
if( !visitStatement( ((IASTSwitchStatement) statement ).getBody(), action ) ) return false;
|
||||
} else if( statement instanceof IASTWhileStatement ){
|
||||
if( !visitExpression( ((IASTWhileStatement) statement ).getCondition(), action ) ) return false;
|
||||
if( !visitStatement( ((IASTWhileStatement) statement ).getBody(), action ) ) return false;
|
||||
} else if( statement instanceof IASTForStatement ){
|
||||
IASTForStatement s = (IASTForStatement) statement;
|
||||
if( s.getInitDeclaration() != null )
|
||||
if( !visitDeclaration( s.getInitDeclaration(), action ) ) return false;
|
||||
if( s.getInitExpression() != null )
|
||||
if( !visitExpression( s.getInitExpression(), action ) ) return false;
|
||||
if( !visitExpression( s.getCondition(), action ) ) return false;
|
||||
if( !visitExpression( s.getIterationExpression(), action ) ) return false;
|
||||
if( !visitStatement( s.getBody(), action ) ) return false;
|
||||
} else if( statement instanceof ICPPASTCatchHandler ){
|
||||
if( !visitDeclaration( ((ICPPASTCatchHandler) statement).getDeclaration(), action ) ) return false;
|
||||
if( !visitStatement( ((ICPPASTCatchHandler) statement).getCatchBody(), action ) ) return false;
|
||||
} else if( statement instanceof ICPPASTTryBlockStatement ){
|
||||
if( !visitStatement( ((ICPPASTTryBlockStatement)statement).getTryBody(), action ) ) return false;
|
||||
ICPPASTCatchHandler [] handlers = ((ICPPASTTryBlockStatement)statement).getCatchHandlers();
|
||||
for( int i = 0; i < handlers.length; i++ ){
|
||||
if( !visitStatement( handlers[i], action ) ) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param typeOf
|
||||
* @param action
|
||||
* @return
|
||||
*/
|
||||
public static boolean visitExpression(IASTExpression expression, CPPBaseVisitorAction action) {
|
||||
if( action.processExpressions )
|
||||
if( !action.processExpression( expression ) ) return false;
|
||||
|
||||
if( expression instanceof IASTArraySubscriptExpression ){
|
||||
if( !visitExpression( ((IASTArraySubscriptExpression)expression).getArrayExpression(), action ) ) return false;
|
||||
if( !visitExpression( ((IASTArraySubscriptExpression)expression).getSubscriptExpression(), action ) ) return false;
|
||||
} else if( expression instanceof IASTBinaryExpression ){
|
||||
if( !visitExpression( ((IASTBinaryExpression)expression).getOperand1(), action ) ) return false;
|
||||
if( !visitExpression( ((IASTBinaryExpression)expression).getOperand2(), action ) ) return false;
|
||||
} else if( expression instanceof IASTConditionalExpression){
|
||||
if( !visitExpression( ((IASTConditionalExpression)expression).getLogicalConditionExpression(), action ) ) return false;
|
||||
if( !visitExpression( ((IASTConditionalExpression)expression).getNegativeResultExpression(), action ) ) return false;
|
||||
if( !visitExpression( ((IASTConditionalExpression)expression).getPositiveResultExpression(), action ) ) return false;
|
||||
} else if( expression instanceof IASTExpressionList ){
|
||||
IASTExpression[] list = ((IASTExpressionList)expression).getExpressions();
|
||||
for( int i = 0; i < list.length; i++){
|
||||
if( list[i] == null ) break;
|
||||
if( !visitExpression( list[i], action ) ) return false;
|
||||
}
|
||||
} else if( expression instanceof IASTFieldReference ){
|
||||
if( !visitExpression( ((IASTFieldReference)expression).getFieldOwner(), action ) ) return false;
|
||||
if( !visitName( ((IASTFieldReference)expression).getFieldName(), action ) ) return false;
|
||||
} else if( expression instanceof IASTFunctionCallExpression ){
|
||||
if( !visitExpression( ((IASTFunctionCallExpression)expression).getFunctionNameExpression(), action ) ) return false;
|
||||
if( !visitExpression( ((IASTFunctionCallExpression)expression).getParameterExpression(), action ) ) return false;
|
||||
} else if( expression instanceof IASTIdExpression ){
|
||||
if( !visitName( ((IASTIdExpression)expression).getName(), action ) ) return false;
|
||||
} else if( expression instanceof IASTTypeIdExpression ){
|
||||
if( !visitTypeId( ((IASTTypeIdExpression)expression).getTypeId(), action ) ) return false;
|
||||
} else if( expression instanceof IASTCastExpression ){
|
||||
if( !visitTypeId( ((IASTCastExpression)expression).getTypeId(), action ) ) return false;
|
||||
if( !visitExpression( ((IASTCastExpression)expression).getOperand(), action ) ) return false;
|
||||
} else if( expression instanceof IASTUnaryExpression ){
|
||||
if( !visitExpression( ((IASTUnaryExpression)expression).getOperand(), action ) ) return false;
|
||||
} else if( expression instanceof IGNUASTCompoundStatementExpression ){
|
||||
if( !visitStatement( ((IGNUASTCompoundStatementExpression)expression).getCompoundStatement(), action ) ) return false;
|
||||
} else if( expression instanceof ICPPASTDeleteExpression ){
|
||||
if( !visitExpression( ((ICPPASTDeleteExpression)expression).getOperand(), action ) ) return false;
|
||||
} else if( expression instanceof ICPPASTNewExpression ) {
|
||||
ICPPASTNewExpression newExp = (ICPPASTNewExpression) expression;
|
||||
if( newExp.getNewPlacement() != null )
|
||||
if( !visitExpression( newExp.getNewPlacement(), action ) ) return false;
|
||||
if( newExp.getTypeId() != null )
|
||||
if( !visitTypeId( newExp.getTypeId(), action ) ) return false;
|
||||
IASTExpression [] exps = newExp.getNewTypeIdArrayExpressions();
|
||||
for( int i = 0; i < exps.length; i++ ){
|
||||
if( !visitExpression( exps[i], action ) ) return false;
|
||||
}
|
||||
if( newExp.getNewInitializer() != null )
|
||||
if( !visitExpression( newExp.getNewInitializer(), action ) ) return false;
|
||||
} else if( expression instanceof ICPPASTSimpleTypeConstructorExpression ){
|
||||
if( !visitExpression( ((ICPPASTSimpleTypeConstructorExpression)expression).getInitialValue(), action ) ) return false;
|
||||
} else if( expression instanceof ICPPASTTypenameExpression ){
|
||||
if( !visitName( ((ICPPASTTypenameExpression)expression).getName(), action ) ) return false;
|
||||
if( !visitExpression( ((ICPPASTTypenameExpression)expression).getInitialValue(), action ) ) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param typeId
|
||||
* @param action
|
||||
* @return
|
||||
*/
|
||||
public static boolean visitTypeId(IASTTypeId typeId, CPPBaseVisitorAction action) {
|
||||
if( action.processTypeIds )
|
||||
if( !action.processTypeId( typeId ) ) return false;
|
||||
if( !visitDeclarator( typeId.getAbstractDeclarator(), action ) ) return false;
|
||||
if( !visitDeclSpecifier( typeId.getDeclSpecifier(), action ) ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param initializer
|
||||
* @param action
|
||||
* @return
|
||||
*/
|
||||
public static boolean visitInitializer(IASTInitializer initializer, CPPBaseVisitorAction action) {
|
||||
if( action.processInitializers )
|
||||
if( !action.processInitializer( initializer ) ) return false;
|
||||
|
||||
if( initializer instanceof IASTInitializerExpression ){
|
||||
if( !visitExpression( ((IASTInitializerExpression) initializer).getExpression(), action ) ) return false;
|
||||
} else if( initializer instanceof IASTInitializerList ){
|
||||
IASTInitializer [] list = ((IASTInitializerList) initializer).getInitializers();
|
||||
for( int i = 0; i < list.length; i++ ){
|
||||
if( !visitInitializer( list[i], action ) ) return false;
|
||||
}
|
||||
} else if( initializer instanceof ICPPASTConstructorInitializer ){
|
||||
if( !visitExpression( ((ICPPASTConstructorInitializer) initializer).getExpression(), action ) ) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param enumerator
|
||||
* @param action
|
||||
* @return
|
||||
*/
|
||||
public static boolean visitEnumerator(IASTEnumerator enumerator, CPPBaseVisitorAction action) {
|
||||
if( action.processEnumerators )
|
||||
if( !action.processEnumerator( enumerator ) ) return false;
|
||||
|
||||
if( !visitName( enumerator.getName(), action ) ) return false;
|
||||
if( enumerator.getValue() != null )
|
||||
if( !visitExpression( enumerator.getValue(), action ) ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param specifier
|
||||
* @param action
|
||||
* @return
|
||||
*/
|
||||
public static boolean visitBaseSpecifier(ICPPASTBaseSpecifier specifier, CPPBaseVisitorAction action) {
|
||||
if( action.processBaseSpecifiers )
|
||||
if( !action.processBaseSpecifier( specifier ) ) return false;
|
||||
|
||||
if( !visitName( specifier.getName(), action ) ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parameter
|
||||
* @param action
|
||||
* @return
|
||||
*/
|
||||
public static boolean visitTemplateParameter(ICPPASTTemplateParameter parameter, CPPBaseVisitorAction action) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue