mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
CORE
Fleshed out basic declarations for FullParse AST. Fixed Bug 40554 - Fields coming back as Vars Fixed Bug 40555 - Methods come back as Functions TESTS Created CompleteParseASTTest and added it to ParserTestSuite.
This commit is contained in:
parent
e5b1373aa6
commit
f25e4d8bd0
67 changed files with 2158 additions and 316 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2003-07-21 John Camelon
|
||||||
|
Created CompleteParseASTTest and added it to ParserTestSuite.
|
||||||
|
|
||||||
2003-07-18 John Camelon
|
2003-07-18 John Camelon
|
||||||
Updated ParserSymbolTableTests to remove dependencies on parser.ast.full classes.
|
Updated ParserSymbolTableTests to remove dependencies on parser.ast.full classes.
|
||||||
Updated Parser test suites for updates to ParserFactory.
|
Updated Parser test suites for updates to ParserFactory.
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.core.parser.IParser;
|
||||||
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
||||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
|
@ -58,7 +59,23 @@ public class BaseASTTest extends TestCase
|
||||||
|
|
||||||
protected IASTDeclaration assertSoleDeclaration( String code ) throws ParserException
|
protected IASTDeclaration assertSoleDeclaration( String code ) throws ParserException
|
||||||
{
|
{
|
||||||
Iterator declarationIter = parse( code ).getDeclarations();
|
Iterator declarationIter = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
declarationIter = parse(code).getDeclarations();
|
||||||
|
}
|
||||||
|
catch (ASTNotImplementedException e1)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ParserException e)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
}
|
||||||
|
assertNotNull( declarationIter );
|
||||||
assertTrue( declarationIter.hasNext() );
|
assertTrue( declarationIter.hasNext() );
|
||||||
IASTDeclaration returnValue = (IASTDeclaration)declarationIter.next();
|
IASTDeclaration returnValue = (IASTDeclaration)declarationIter.next();
|
||||||
assertFalse( declarationIter.hasNext() );
|
assertFalse( declarationIter.hasNext() );
|
||||||
|
|
|
@ -0,0 +1,458 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors: -
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.core.parser.tests;
|
||||||
|
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CompleteParseASTTest extends TestCase
|
||||||
|
{
|
||||||
|
public class Scope implements IASTScope
|
||||||
|
{
|
||||||
|
private List decls = new ArrayList();
|
||||||
|
private final IASTScope scope;
|
||||||
|
public Scope( IASTScope scope )
|
||||||
|
{
|
||||||
|
this.scope = scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDeclaration( IASTDeclaration d )
|
||||||
|
{
|
||||||
|
decls.add(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterator getDeclarations()
|
||||||
|
{
|
||||||
|
return decls.iterator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FullParseCallback extends NullSourceElementRequestor implements ISourceElementRequestor
|
||||||
|
{
|
||||||
|
|
||||||
|
private Stack inclusions = new Stack();
|
||||||
|
private Scope compilationUnit;
|
||||||
|
|
||||||
|
public IASTScope getCompilationUnit()
|
||||||
|
{
|
||||||
|
return compilationUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptVariable(org.eclipse.cdt.core.parser.ast.IASTVariable)
|
||||||
|
*/
|
||||||
|
public void acceptVariable(IASTVariable variable)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFunctionDeclaration(org.eclipse.cdt.core.parser.ast.IASTFunction)
|
||||||
|
*/
|
||||||
|
public void acceptFunctionDeclaration(IASTFunction function)
|
||||||
|
{
|
||||||
|
getCurrentScope().addDeclaration(function);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsingDirective(org.eclipse.cdt.core.parser.ast.IASTUsingDirective)
|
||||||
|
*/
|
||||||
|
public void acceptUsingDirective(IASTUsingDirective usageDirective)
|
||||||
|
{
|
||||||
|
getCurrentScope().addDeclaration(usageDirective);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration)
|
||||||
|
*/
|
||||||
|
public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration)
|
||||||
|
{
|
||||||
|
getCurrentScope().addDeclaration(usageDeclaration);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptASMDefinition(org.eclipse.cdt.core.parser.ast.IASTASMDefinition)
|
||||||
|
*/
|
||||||
|
public void acceptASMDefinition(IASTASMDefinition asmDefinition)
|
||||||
|
{
|
||||||
|
getCurrentScope().addDeclaration(asmDefinition);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedefDeclaration(org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration)
|
||||||
|
*/
|
||||||
|
public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef)
|
||||||
|
{
|
||||||
|
getCurrentScope().addDeclaration(typedef);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerationSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier)
|
||||||
|
*/
|
||||||
|
public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptAbstractTypeSpecDeclaration(org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration)
|
||||||
|
*/
|
||||||
|
public void acceptAbstractTypeSpecDeclaration(IASTAbstractTypeSpecifierDeclaration abstractDeclaration)
|
||||||
|
{
|
||||||
|
getCurrentScope().addDeclaration( abstractDeclaration );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
|
||||||
|
*/
|
||||||
|
public void enterFunctionBody(IASTFunction function)
|
||||||
|
{
|
||||||
|
pushScope( function );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
|
||||||
|
*/
|
||||||
|
public void exitFunctionBody(IASTFunction function)
|
||||||
|
{
|
||||||
|
popScope();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
|
||||||
|
*/
|
||||||
|
public void enterCompilationUnit(IASTCompilationUnit compilationUnit)
|
||||||
|
{
|
||||||
|
pushScope( compilationUnit );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
|
||||||
|
*/
|
||||||
|
public void enterInclusion(IASTInclusion inclusion)
|
||||||
|
{
|
||||||
|
pushInclusion( inclusion );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param inclusion
|
||||||
|
*/
|
||||||
|
private void pushInclusion(IASTInclusion inclusion)
|
||||||
|
{
|
||||||
|
inclusions.push( inclusion );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
|
||||||
|
*/
|
||||||
|
public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition)
|
||||||
|
{
|
||||||
|
pushScope( namespaceDefinition );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#entesrClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
|
||||||
|
*/
|
||||||
|
public void enterClassSpecifier(IASTClassSpecifier classSpecification)
|
||||||
|
{
|
||||||
|
pushScope( classSpecification );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
|
||||||
|
*/
|
||||||
|
public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec)
|
||||||
|
{
|
||||||
|
pushScope( linkageSpec );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
|
||||||
|
*/
|
||||||
|
public void enterTemplateDeclaration(IASTTemplateDeclaration declaration)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
|
||||||
|
*/
|
||||||
|
public void enterTemplateSpecialization(IASTTemplateSpecialization specialization)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
|
||||||
|
*/
|
||||||
|
public void enterTemplateInstantiation(IASTTemplateInstantiation instantiation)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMethodDeclaration(org.eclipse.cdt.core.parser.ast.IASTMethod)
|
||||||
|
*/
|
||||||
|
public void acceptMethodDeclaration(IASTMethod method)
|
||||||
|
{
|
||||||
|
getCurrentScope().addDeclaration( method );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
|
||||||
|
*/
|
||||||
|
public void enterMethodBody(IASTMethod method)
|
||||||
|
{
|
||||||
|
pushScope(method);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
|
||||||
|
*/
|
||||||
|
public void exitMethodBody(IASTMethod method)
|
||||||
|
{
|
||||||
|
popScope();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptField(org.eclipse.cdt.core.parser.ast.IASTField)
|
||||||
|
*/
|
||||||
|
public void acceptField(IASTField field)
|
||||||
|
{
|
||||||
|
getCurrentScope().addDeclaration(field);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
|
||||||
|
*/
|
||||||
|
public void exitTemplateDeclaration(IASTTemplateDeclaration declaration)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
|
||||||
|
*/
|
||||||
|
public void exitTemplateSpecialization(IASTTemplateSpecialization specialization)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateExplicitInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
|
||||||
|
*/
|
||||||
|
public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
|
||||||
|
*/
|
||||||
|
public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec)
|
||||||
|
{
|
||||||
|
popScope();
|
||||||
|
getCurrentScope().addDeclaration(linkageSpec);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
|
||||||
|
*/
|
||||||
|
public void exitClassSpecifier(IASTClassSpecifier classSpecification)
|
||||||
|
{
|
||||||
|
popScope();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
|
||||||
|
*/
|
||||||
|
public void exitNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition)
|
||||||
|
{
|
||||||
|
popScope();
|
||||||
|
getCurrentScope().addDeclaration(namespaceDefinition);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
|
||||||
|
*/
|
||||||
|
public void exitInclusion(IASTInclusion inclusion)
|
||||||
|
{
|
||||||
|
popInclusion();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void popInclusion()
|
||||||
|
{
|
||||||
|
inclusions.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
|
||||||
|
*/
|
||||||
|
public void exitCompilationUnit(IASTCompilationUnit compilationUnit)
|
||||||
|
{
|
||||||
|
this.compilationUnit = popScope();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptPointerToFunction(org.eclipse.cdt.core.parser.ast.IASTPointerToFunction)
|
||||||
|
*/
|
||||||
|
public void acceptPointerToFunction(IASTPointerToFunction function)
|
||||||
|
{
|
||||||
|
getCurrentScope().addDeclaration(function);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptPointerToMethod(org.eclipse.cdt.core.parser.ast.IASTPointerToMethod)
|
||||||
|
*/
|
||||||
|
public void acceptPointerToMethod(IASTPointerToMethod method)
|
||||||
|
{
|
||||||
|
getCurrentScope().addDeclaration(method); }
|
||||||
|
|
||||||
|
|
||||||
|
private Stack scopes = new Stack();
|
||||||
|
protected Scope getCurrentScope()
|
||||||
|
{
|
||||||
|
return (Scope)scopes.peek();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Scope popScope()
|
||||||
|
{
|
||||||
|
return (Scope)scopes.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void pushScope( IASTScope scope )
|
||||||
|
{
|
||||||
|
scopes.push( new Scope( scope ));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected FullParseCallback callback;
|
||||||
|
|
||||||
|
protected IASTScope parse( String code )throws ParserException
|
||||||
|
{
|
||||||
|
callback = new FullParseCallback();
|
||||||
|
IParser parser = ParserFactory.createParser(
|
||||||
|
ParserFactory.createScanner( new StringReader( code ), "test-code", new ScannerInfo(),
|
||||||
|
ParserMode.COMPLETE_PARSE, callback ), callback, ParserMode.COMPLETE_PARSE
|
||||||
|
);
|
||||||
|
parser.parse();
|
||||||
|
return callback.getCompilationUnit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param a
|
||||||
|
*/
|
||||||
|
public CompleteParseASTTest(String a)
|
||||||
|
{
|
||||||
|
super(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testEmptyCompilationUnit() throws Exception
|
||||||
|
{
|
||||||
|
IASTScope compilationUnit = parse( "// no real code ");
|
||||||
|
assertNotNull( compilationUnit );
|
||||||
|
assertFalse( compilationUnit.getDeclarations().hasNext() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSimpleNamespace() throws Exception
|
||||||
|
{
|
||||||
|
Iterator declarations = parse( "namespace A { }").getDeclarations();
|
||||||
|
IASTNamespaceDefinition namespaceDefinition = (IASTNamespaceDefinition)declarations.next();
|
||||||
|
assertEquals( namespaceDefinition.getName(), "A" );
|
||||||
|
assertFalse( namespaceDefinition.getDeclarations().hasNext() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMultipleNamespaceDefinitions() throws Exception
|
||||||
|
{
|
||||||
|
Iterator declarations = parse( "namespace A { } namespace A { }").getDeclarations();
|
||||||
|
IASTNamespaceDefinition namespaceDefinition = (IASTNamespaceDefinition)declarations.next();
|
||||||
|
assertEquals( namespaceDefinition.getName(), "A" );
|
||||||
|
namespaceDefinition = (IASTNamespaceDefinition)declarations.next();
|
||||||
|
assertEquals( namespaceDefinition.getName(), "A" );
|
||||||
|
assertFalse( namespaceDefinition.getDeclarations().hasNext() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNestedNamespaceDefinitions() throws Exception
|
||||||
|
{
|
||||||
|
Iterator declarations = parse( "namespace A { namespace B { } }").getDeclarations();
|
||||||
|
IASTNamespaceDefinition namespaceDefinition = (IASTNamespaceDefinition)declarations.next();
|
||||||
|
assertEquals( namespaceDefinition.getName(), "A" );
|
||||||
|
assertFalse( declarations.hasNext() );
|
||||||
|
Iterator subDeclarations = namespaceDefinition.getDeclarations();
|
||||||
|
IASTNamespaceDefinition subDeclaration = (IASTNamespaceDefinition)subDeclarations.next();
|
||||||
|
assertEquals( subDeclaration.getName(), "B" );
|
||||||
|
assertFalse( subDeclarations.hasNext() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// public void testEmptyClassDeclaration() throws Exception
|
||||||
|
// {
|
||||||
|
// Iterator declarations = parse( "class A { };").getDeclarations();
|
||||||
|
// IASTClassSpecifier classSpec = (IASTClassSpecifier)declarations.next();
|
||||||
|
// assertEquals( classSpec.getName(), "A");
|
||||||
|
// assertFalse( classSpec.getDeclarations().hasNext() );
|
||||||
|
// assertFalse( declarations.hasNext() );
|
||||||
|
// }
|
||||||
|
}
|
|
@ -18,12 +18,12 @@ import java.util.Map;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.complete.SymbolExtension;
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException;
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Mark;
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Mark;
|
||||||
|
@ -102,20 +102,60 @@ public class ParserSymbolTableTest extends TestCase {
|
||||||
assertEquals( look, null );
|
assertEquals( look, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected class NullSymbolExtension implements ISymbolASTExtension
|
||||||
|
{
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension#getPrimaryDeclaration()
|
||||||
|
*/
|
||||||
|
public ASTSymbol getPrimaryDeclaration()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension#getAllDefinitions()
|
||||||
|
*/
|
||||||
|
public Iterator getAllDefinitions()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension#addDefinition(org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol)
|
||||||
|
*/
|
||||||
|
public void addDefinition(ASTSymbol definition) throws ExtensionException
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner#getSymbol()
|
||||||
|
*/
|
||||||
|
public ISymbol getSymbol()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testSimpleSetGetObject() throws Exception{
|
public void testSimpleSetGetObject() throws Exception{
|
||||||
newTable();
|
newTable();
|
||||||
|
|
||||||
IContainerSymbol x = table.new Declaration("x");
|
IContainerSymbol x = table.new Declaration("x");
|
||||||
|
|
||||||
ISymbolASTExtension extension = new SymbolExtension( null, null ); // cheating!
|
ISymbolASTExtension extension = new NullSymbolExtension ();
|
||||||
|
|
||||||
x.setASTNode( extension );
|
x.setASTExtension( extension );
|
||||||
|
|
||||||
table.getCompilationUnit().addSymbol( x );
|
table.getCompilationUnit().addSymbol( x );
|
||||||
|
|
||||||
ISymbol look = table.getCompilationUnit().Lookup( "x" );
|
ISymbol look = table.getCompilationUnit().Lookup( "x" );
|
||||||
|
|
||||||
assertEquals( look.getASTNode(), extension );
|
assertEquals( look.getASTExtension(), extension );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class ParserTestSuite extends TestCase {
|
||||||
suite.addTestSuite( PreprocessorTest.class );
|
suite.addTestSuite( PreprocessorTest.class );
|
||||||
suite.addTestSuite( PreprocessorConditionalTest.class );
|
suite.addTestSuite( PreprocessorConditionalTest.class );
|
||||||
suite.addTestSuite( QuickParseASTQualifiedNameTest.class);
|
suite.addTestSuite( QuickParseASTQualifiedNameTest.class);
|
||||||
|
suite.addTestSuite( CompleteParseASTTest.class );
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1156,16 +1156,16 @@ public class QuickParseASTTests extends BaseASTTest
|
||||||
assertFalse( inclusions.hasNext());
|
assertFalse( inclusions.hasNext());
|
||||||
|
|
||||||
assertEquals( i.getName(), "stdio.h");
|
assertEquals( i.getName(), "stdio.h");
|
||||||
assertEquals( i.getElementStartingOffset(), 0 );
|
assertEquals( i.getStartingOffset(), 0 );
|
||||||
assertEquals( i.getElementNameOffset(), 10 );
|
assertEquals( i.getNameOffset(), 10 );
|
||||||
assertEquals( i.getElementEndingOffset(), 18 );
|
assertEquals( i.getEndingOffset(), 18 );
|
||||||
|
|
||||||
|
|
||||||
IASTMacro m = (IASTMacro)macros.next();
|
IASTMacro m = (IASTMacro)macros.next();
|
||||||
assertEquals( m.getName(), "DEF" );
|
assertEquals( m.getName(), "DEF" );
|
||||||
assertEquals( m.getElementStartingOffset(), 19 );
|
assertEquals( m.getStartingOffset(), 19 );
|
||||||
assertEquals( m.getElementNameOffset(), 27 );
|
assertEquals( m.getNameOffset(), 27 );
|
||||||
assertEquals( m.getElementEndingOffset(), 18 + 19);
|
assertEquals( m.getEndingOffset(), 18 + 19);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTemplateDeclarationOfFunction() throws Exception
|
public void testTemplateDeclarationOfFunction() throws Exception
|
||||||
|
|
|
@ -466,10 +466,10 @@ public class DOMBuilder implements ISourceElementRequestor
|
||||||
Macro m =
|
Macro m =
|
||||||
new Macro(
|
new Macro(
|
||||||
macro.getName(),
|
macro.getName(),
|
||||||
macro.getElementNameOffset(),
|
macro.getNameOffset(),
|
||||||
macro.getElementStartingOffset(),
|
macro.getStartingOffset(),
|
||||||
macro.getElementEndingOffset()
|
macro.getEndingOffset()
|
||||||
- macro.getElementStartingOffset());
|
- macro.getStartingOffset());
|
||||||
translationUnit.addMacro(m);
|
translationUnit.addMacro(m);
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -488,11 +488,11 @@ public class DOMBuilder implements ISourceElementRequestor
|
||||||
SimpleDeclaration declaration =
|
SimpleDeclaration declaration =
|
||||||
getTypeSpecOwner(
|
getTypeSpecOwner(
|
||||||
getCurrentDOMScope(),
|
getCurrentDOMScope(),
|
||||||
variable.getElementStartingOffset());
|
variable.getStartingOffset());
|
||||||
if (declaration == null)
|
if (declaration == null)
|
||||||
{
|
{
|
||||||
declaration =
|
declaration =
|
||||||
startSimpleDeclaration(variable.getElementStartingOffset());
|
startSimpleDeclaration(variable.getStartingOffset());
|
||||||
declaration.getDeclSpecifier().setConst(
|
declaration.getDeclSpecifier().setConst(
|
||||||
variable.getAbstractDeclaration().isConst());
|
variable.getAbstractDeclaration().isConst());
|
||||||
declaration.getDeclSpecifier().setExtern(variable.isExtern());
|
declaration.getDeclSpecifier().setExtern(variable.isExtern());
|
||||||
|
@ -579,7 +579,7 @@ public class DOMBuilder implements ISourceElementRequestor
|
||||||
SimpleDeclaration simpleDeclaration =
|
SimpleDeclaration simpleDeclaration =
|
||||||
getTypeSpecOwner(
|
getTypeSpecOwner(
|
||||||
getCurrentDOMScope(),
|
getCurrentDOMScope(),
|
||||||
function.getElementStartingOffset());
|
function.getStartingOffset());
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsageDirective(org.eclipse.cdt.core.parser.ast.IASTUsageDirective)
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsageDirective(org.eclipse.cdt.core.parser.ast.IASTUsageDirective)
|
||||||
|
@ -647,9 +647,9 @@ public class DOMBuilder implements ISourceElementRequestor
|
||||||
Inclusion i =
|
Inclusion i =
|
||||||
new Inclusion(
|
new Inclusion(
|
||||||
inclusion.getName(),
|
inclusion.getName(),
|
||||||
inclusion.getElementNameOffset(),
|
inclusion.getNameOffset(),
|
||||||
inclusion.getElementStartingOffset(),
|
inclusion.getStartingOffset(),
|
||||||
inclusion.getElementEndingOffset(),
|
inclusion.getEndingOffset(),
|
||||||
inclusion.isLocal());
|
inclusion.isLocal());
|
||||||
translationUnit.addInclusion(i);
|
translationUnit.addInclusion(i);
|
||||||
}
|
}
|
||||||
|
@ -662,10 +662,10 @@ public class DOMBuilder implements ISourceElementRequestor
|
||||||
new NamespaceDefinition(getCurrentDOMScope());
|
new NamespaceDefinition(getCurrentDOMScope());
|
||||||
namespaceDef.setName(namespaceDefinition.getName());
|
namespaceDef.setName(namespaceDefinition.getName());
|
||||||
((IOffsetable)namespaceDef).setStartingOffset(
|
((IOffsetable)namespaceDef).setStartingOffset(
|
||||||
namespaceDefinition.getElementStartingOffset());
|
namespaceDefinition.getStartingOffset());
|
||||||
if (!namespaceDefinition.getName().equals(""))
|
if (!namespaceDefinition.getName().equals(""))
|
||||||
namespaceDef.setNameOffset(
|
namespaceDef.setNameOffset(
|
||||||
namespaceDefinition.getElementNameOffset());
|
namespaceDefinition.getNameOffset());
|
||||||
this.domScopes.push(namespaceDef);
|
this.domScopes.push(namespaceDef);
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -675,7 +675,7 @@ public class DOMBuilder implements ISourceElementRequestor
|
||||||
{
|
{
|
||||||
SimpleDeclaration decl =
|
SimpleDeclaration decl =
|
||||||
startSimpleDeclaration(
|
startSimpleDeclaration(
|
||||||
classSpecification.getElementStartingOffset());
|
classSpecification.getStartingOffset());
|
||||||
int kind = ClassKey.t_struct;
|
int kind = ClassKey.t_struct;
|
||||||
int visibility = AccessSpecifier.v_public;
|
int visibility = AccessSpecifier.v_public;
|
||||||
if (classSpecification.getClassKind() == ASTClassKind.CLASS)
|
if (classSpecification.getClassKind() == ASTClassKind.CLASS)
|
||||||
|
@ -694,10 +694,10 @@ public class DOMBuilder implements ISourceElementRequestor
|
||||||
ClassSpecifier classSpecifier = new ClassSpecifier(kind, decl);
|
ClassSpecifier classSpecifier = new ClassSpecifier(kind, decl);
|
||||||
classSpecifier.setVisibility(visibility);
|
classSpecifier.setVisibility(visibility);
|
||||||
classSpecifier.setStartingOffset(
|
classSpecifier.setStartingOffset(
|
||||||
classSpecification.getElementStartingOffset());
|
classSpecification.getStartingOffset());
|
||||||
decl.setTypeSpecifier(classSpecifier);
|
decl.setTypeSpecifier(classSpecifier);
|
||||||
classSpecifier.setName(classSpecification.getName());
|
classSpecifier.setName(classSpecification.getName());
|
||||||
classSpecifier.setNameOffset(classSpecification.getElementNameOffset());
|
classSpecifier.setNameOffset(classSpecification.getNameOffset());
|
||||||
domScopes.push(classSpecifier);
|
domScopes.push(classSpecifier);
|
||||||
}
|
}
|
||||||
protected SimpleDeclaration startSimpleDeclaration(int startingOffset)
|
protected SimpleDeclaration startSimpleDeclaration(int startingOffset)
|
||||||
|
@ -810,9 +810,9 @@ public class DOMBuilder implements ISourceElementRequestor
|
||||||
{
|
{
|
||||||
ClassSpecifier c = (ClassSpecifier)getCurrentDOMScope();
|
ClassSpecifier c = (ClassSpecifier)getCurrentDOMScope();
|
||||||
c.setTotalLength(
|
c.setTotalLength(
|
||||||
classSpecification.getElementEndingOffset()
|
classSpecification.getEndingOffset()
|
||||||
+ 1
|
+ 1
|
||||||
- classSpecification.getElementStartingOffset());
|
- classSpecification.getStartingOffset());
|
||||||
domScopes.pop();
|
domScopes.pop();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -822,8 +822,8 @@ public class DOMBuilder implements ISourceElementRequestor
|
||||||
{
|
{
|
||||||
NamespaceDefinition definition = (NamespaceDefinition)domScopes.pop();
|
NamespaceDefinition definition = (NamespaceDefinition)domScopes.pop();
|
||||||
definition.setTotalLength(
|
definition.setTotalLength(
|
||||||
namespaceDefinition.getElementEndingOffset()
|
namespaceDefinition.getEndingOffset()
|
||||||
- namespaceDefinition.getElementStartingOffset());
|
- namespaceDefinition.getStartingOffset());
|
||||||
getCurrentDOMScope().addDeclaration(definition);
|
getCurrentDOMScope().addDeclaration(definition);
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -851,16 +851,16 @@ public class DOMBuilder implements ISourceElementRequestor
|
||||||
public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration)
|
public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration)
|
||||||
{
|
{
|
||||||
SimpleDeclaration decl =
|
SimpleDeclaration decl =
|
||||||
startSimpleDeclaration(enumeration.getElementStartingOffset());
|
startSimpleDeclaration(enumeration.getStartingOffset());
|
||||||
EnumerationSpecifier es = new EnumerationSpecifier(decl);
|
EnumerationSpecifier es = new EnumerationSpecifier(decl);
|
||||||
es.setStartingOffset(enumeration.getElementStartingOffset());
|
es.setStartingOffset(enumeration.getStartingOffset());
|
||||||
es.setStartImage("enum");
|
es.setStartImage("enum");
|
||||||
decl.setTypeSpecifier(es);
|
decl.setTypeSpecifier(es);
|
||||||
es.setName(enumeration.getName());
|
es.setName(enumeration.getName());
|
||||||
es.setTotalLength(
|
es.setTotalLength(
|
||||||
enumeration.getElementEndingOffset()
|
enumeration.getEndingOffset()
|
||||||
+ 1
|
+ 1
|
||||||
- enumeration.getElementStartingOffset());
|
- enumeration.getStartingOffset());
|
||||||
Iterator i = enumeration.getEnumerators();
|
Iterator i = enumeration.getEnumerators();
|
||||||
while (i.hasNext())
|
while (i.hasNext())
|
||||||
{
|
{
|
||||||
|
@ -869,11 +869,11 @@ public class DOMBuilder implements ISourceElementRequestor
|
||||||
es.addEnumeratorDefinition(definition);
|
es.addEnumeratorDefinition(definition);
|
||||||
definition.setName(enumerator.getName());
|
definition.setName(enumerator.getName());
|
||||||
((IOffsetable)definition).setStartingOffset(
|
((IOffsetable)definition).setStartingOffset(
|
||||||
enumerator.getElementNameOffset());
|
enumerator.getNameOffset());
|
||||||
definition.setTotalLength(
|
definition.setTotalLength(
|
||||||
enumerator.getElementEndingOffset()
|
enumerator.getEndingOffset()
|
||||||
+ 1
|
+ 1
|
||||||
- enumerator.getElementStartingOffset());
|
- enumerator.getStartingOffset());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2003-07-21 John Camelon
|
||||||
|
Fleshed out basic declarations for FullParse AST.
|
||||||
|
Fixed Bug 40554 - Fields coming back as Vars
|
||||||
|
Fixed Bug 40555 - Methods come back as Functions
|
||||||
|
|
||||||
2003-07-18 John Camelon
|
2003-07-18 John Camelon
|
||||||
Added ISourceElementCallbackDelegate interface for AST constructs to allow the Parser to delegate callback's to the nodes themselves.
|
Added ISourceElementCallbackDelegate interface for AST constructs to allow the Parser to delegate callback's to the nodes themselves.
|
||||||
Got rid of ParserMode.STRUCTURAL_PARSE for the time being.
|
Got rid of ParserMode.STRUCTURAL_PARSE for the time being.
|
||||||
|
|
|
@ -20,6 +20,12 @@ public class ASTSemanticException extends Exception
|
||||||
{
|
{
|
||||||
private final IProblem theProblem;
|
private final IProblem theProblem;
|
||||||
|
|
||||||
|
public ASTSemanticException()
|
||||||
|
{
|
||||||
|
theProblem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -33,7 +39,7 @@ public class ASTSemanticException extends Exception
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IProblem getTheProblem()
|
public IProblem getProblem()
|
||||||
{
|
{
|
||||||
return theProblem;
|
return theProblem;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.IASTArrayModifier;
|
import org.eclipse.cdt.internal.core.parser.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension;
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
|
@ -51,7 +50,7 @@ public interface IASTFactory
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
String identifier,
|
String identifier,
|
||||||
int startingOffset,
|
int startingOffset,
|
||||||
int nameOffset);
|
int nameOffset) throws ASTSemanticException;
|
||||||
public IASTCompilationUnit createCompilationUnit();
|
public IASTCompilationUnit createCompilationUnit();
|
||||||
public IASTLinkageSpecification createLinkageSpecification(
|
public IASTLinkageSpecification createLinkageSpecification(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
|
@ -62,9 +61,8 @@ public interface IASTFactory
|
||||||
ASTClassKind kind,
|
ASTClassKind kind,
|
||||||
ClassNameType type,
|
ClassNameType type,
|
||||||
ASTAccessVisibility access,
|
ASTAccessVisibility access,
|
||||||
IASTTemplate ownerTemplateDeclaration,
|
|
||||||
int startingOffset,
|
int startingOffset,
|
||||||
int nameOffset);
|
int nameOffset) throws ASTSemanticException;
|
||||||
/**
|
/**
|
||||||
* @param astClassSpec
|
* @param astClassSpec
|
||||||
* @param isVirtual
|
* @param isVirtual
|
||||||
|
@ -216,5 +214,4 @@ public interface IASTFactory
|
||||||
boolean isPureVirtual,
|
boolean isPureVirtual,
|
||||||
ASTAccessVisibility visibility, ASTPointerOperator pointerOperator);
|
ASTAccessVisibility visibility, ASTPointerOperator pointerOperator);
|
||||||
|
|
||||||
public ISymbolASTExtension createSymbolTableDeclarationExtension( IASTDeclaration declaration, IASTDeclaration definition ) throws ASTNotImplementedException;
|
|
||||||
}
|
}
|
|
@ -19,8 +19,7 @@ public interface IASTOffsetableElement {
|
||||||
public void setStartingOffset( int o );
|
public void setStartingOffset( int o );
|
||||||
public void setEndingOffset( int o );
|
public void setEndingOffset( int o );
|
||||||
|
|
||||||
public int getElementStartingOffset();
|
public int getStartingOffset();
|
||||||
public int getElementEndingOffset();
|
public int getEndingOffset();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,6 @@ package org.eclipse.cdt.core.parser.ast;
|
||||||
public interface IASTOffsetableNamedElement extends IASTOffsetableElement {
|
public interface IASTOffsetableNamedElement extends IASTOffsetableElement {
|
||||||
|
|
||||||
public String getName();
|
public String getName();
|
||||||
public int getElementNameOffset();
|
public int getNameOffset();
|
||||||
public void setElementNameOffset( int o );
|
public void setNameOffset( int o );
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,5 +18,5 @@ import java.util.Iterator;
|
||||||
*/
|
*/
|
||||||
public interface IASTScope {
|
public interface IASTScope {
|
||||||
|
|
||||||
public Iterator getDeclarations();
|
public Iterator getDeclarations() throws ASTNotImplementedException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,5 +16,5 @@ package org.eclipse.cdt.core.parser.ast;
|
||||||
*/
|
*/
|
||||||
public interface IASTScopedElement
|
public interface IASTScopedElement
|
||||||
{
|
{
|
||||||
IASTScope getOwnerScope();
|
IASTScope getOwnerScope();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,4 +17,5 @@ package org.eclipse.cdt.core.parser.ast;
|
||||||
public interface IASTUsingDirective extends IASTDeclaration, IASTOffsetableElement {
|
public interface IASTUsingDirective extends IASTDeclaration, IASTOffsetableElement {
|
||||||
|
|
||||||
public String getNamespaceName();
|
public String getNamespaceName();
|
||||||
|
public IASTNamespaceDefinition getNamespaceDefinition() throws ASTNotImplementedException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,9 @@ public class ContextStack {
|
||||||
}
|
}
|
||||||
|
|
||||||
undoStack.clear();
|
undoStack.clear();
|
||||||
push( new ScannerContext().initialize(reader, filename, type, null, macroOffset, macroLength, startLine ), requestor );
|
IScannerContext context = new ScannerContext().initialize(reader, filename, type, null, macroOffset, macroLength, startLine );
|
||||||
|
context.setExtension(inclusion);
|
||||||
|
push( context, requestor );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void push( IScannerContext context, ISourceElementRequestor requestor ) throws ScannerException
|
protected void push( IScannerContext context, ISourceElementRequestor requestor ) throws ScannerException
|
||||||
|
|
|
@ -312,7 +312,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
*/
|
*/
|
||||||
private IASTDeclaration createASTNode(Declarator declarator)
|
private IASTDeclaration createASTNode(Declarator declarator)
|
||||||
{
|
{
|
||||||
boolean isWithinClass = (getScope() instanceof IASTClassSpecifier);
|
boolean isWithinClass = (getScope() instanceof IASTClassSpecifier); //TODO fix this for COMPLETE_PARSE
|
||||||
boolean isFunction = declarator.isFunction();
|
boolean isFunction = declarator.isFunction();
|
||||||
boolean hasInnerDeclarator = ( declarator.getOwnedDeclarator() != null );
|
boolean hasInnerDeclarator = ( declarator.getOwnedDeclarator() != null );
|
||||||
|
|
||||||
|
|
|
@ -684,12 +684,21 @@ public class Parser implements IParser
|
||||||
if (LT(1) == IToken.tLBRACE)
|
if (LT(1) == IToken.tLBRACE)
|
||||||
{
|
{
|
||||||
consume();
|
consume();
|
||||||
IASTNamespaceDefinition namespaceDefinition =
|
IASTNamespaceDefinition namespaceDefinition = null;
|
||||||
astFactory.createNamespaceDefinition(
|
try
|
||||||
scope,
|
{
|
||||||
(identifier == null ? "" : identifier.getImage()),
|
namespaceDefinition =
|
||||||
first.getOffset(),
|
astFactory.createNamespaceDefinition(
|
||||||
(identifier == null ? 0 : identifier.getOffset()));
|
scope,
|
||||||
|
(identifier == null ? "" : identifier.getImage()),
|
||||||
|
first.getOffset(),
|
||||||
|
(identifier == null ? 0 : identifier.getOffset()));
|
||||||
|
}
|
||||||
|
catch (ASTSemanticException e)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
|
||||||
|
}
|
||||||
namespaceDefinition.enterScope( requestor );
|
namespaceDefinition.enterScope( requestor );
|
||||||
namepsaceDeclarationLoop : while (LT(1) != IToken.tRBRACE)
|
namepsaceDeclarationLoop : while (LT(1) != IToken.tRBRACE)
|
||||||
{
|
{
|
||||||
|
@ -2215,17 +2224,25 @@ public class Parser implements IParser
|
||||||
backup(mark);
|
backup(mark);
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
IASTClassSpecifier astClassSpecifier =
|
IASTClassSpecifier astClassSpecifier = null;
|
||||||
astFactory
|
|
||||||
.createClassSpecifier(
|
try
|
||||||
sdw.getScope(),
|
{
|
||||||
duple == null ? "" : duple.toString(),
|
astClassSpecifier =
|
||||||
classKind,
|
astFactory
|
||||||
nameType,
|
.createClassSpecifier(
|
||||||
access,
|
sdw.getScope(),
|
||||||
null, //TODO add TemplateDeclaration here
|
duple == null ? "" : duple.toString(),
|
||||||
classKey.getOffset(),
|
classKind,
|
||||||
duple == null ? 0 : duple.getFirstToken().getOffset());
|
nameType,
|
||||||
|
access,
|
||||||
|
classKey.getOffset(),
|
||||||
|
duple == null ? 0 : duple.getFirstToken().getOffset());
|
||||||
|
}
|
||||||
|
catch (ASTSemanticException e)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated catch block`
|
||||||
|
}
|
||||||
sdw.setTypeSpecifier(astClassSpecifier);
|
sdw.setTypeSpecifier(astClassSpecifier);
|
||||||
// base clause
|
// base clause
|
||||||
if (LT(1) == IToken.tCOLON)
|
if (LT(1) == IToken.tCOLON)
|
||||||
|
|
|
@ -16,6 +16,7 @@ import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
||||||
|
@ -63,7 +64,7 @@ public class QuickParseCallback extends NullSourceElementRequestor implements IQ
|
||||||
|
|
||||||
public class OffsetableIterator implements Iterator
|
public class OffsetableIterator implements Iterator
|
||||||
{
|
{
|
||||||
private final Iterator declarationIter;
|
private Iterator declarationIter;
|
||||||
private final Iterator inclusionIter;
|
private final Iterator inclusionIter;
|
||||||
private final Iterator macroIter;
|
private final Iterator macroIter;
|
||||||
|
|
||||||
|
@ -71,7 +72,14 @@ public class QuickParseCallback extends NullSourceElementRequestor implements IQ
|
||||||
|
|
||||||
public OffsetableIterator()
|
public OffsetableIterator()
|
||||||
{
|
{
|
||||||
declarationIter = compilationUnit.getDeclarations();
|
try
|
||||||
|
{
|
||||||
|
declarationIter = compilationUnit.getDeclarations();
|
||||||
|
}
|
||||||
|
catch (ASTNotImplementedException ne )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
inclusionIter = inclusions.iterator();
|
inclusionIter = inclusions.iterator();
|
||||||
macroIter = macros.iterator();
|
macroIter = macros.iterator();
|
||||||
updateInclusionIterator();
|
updateInclusionIterator();
|
||||||
|
@ -125,30 +133,30 @@ public class QuickParseCallback extends NullSourceElementRequestor implements IQ
|
||||||
|
|
||||||
// case 3: 1 is null
|
// case 3: 1 is null
|
||||||
if( currentMacro == null )
|
if( currentMacro == null )
|
||||||
if( currentDeclaration.getElementStartingOffset() < currentInclusion.getElementStartingOffset() )
|
if( currentDeclaration.getStartingOffset() < currentInclusion.getStartingOffset() )
|
||||||
return updateDeclarationIterator();
|
return updateDeclarationIterator();
|
||||||
else
|
else
|
||||||
return updateInclusionIterator();
|
return updateInclusionIterator();
|
||||||
|
|
||||||
if( currentInclusion == null )
|
if( currentInclusion == null )
|
||||||
if( currentDeclaration.getElementStartingOffset() < currentMacro.getElementStartingOffset() )
|
if( currentDeclaration.getStartingOffset() < currentMacro.getStartingOffset() )
|
||||||
return updateDeclarationIterator();
|
return updateDeclarationIterator();
|
||||||
else
|
else
|
||||||
return updateMacroIterator();
|
return updateMacroIterator();
|
||||||
|
|
||||||
if( currentDeclaration == null )
|
if( currentDeclaration == null )
|
||||||
if( currentInclusion.getElementStartingOffset() < currentMacro.getElementStartingOffset() )
|
if( currentInclusion.getStartingOffset() < currentMacro.getStartingOffset() )
|
||||||
return updateInclusionIterator();
|
return updateInclusionIterator();
|
||||||
else
|
else
|
||||||
return updateMacroIterator();
|
return updateMacroIterator();
|
||||||
|
|
||||||
// case 4: none are null
|
// case 4: none are null
|
||||||
if( currentInclusion.getElementStartingOffset() < currentMacro.getElementStartingOffset() &&
|
if( currentInclusion.getStartingOffset() < currentMacro.getStartingOffset() &&
|
||||||
currentInclusion.getElementStartingOffset() < currentDeclaration.getElementStartingOffset() )
|
currentInclusion.getStartingOffset() < currentDeclaration.getStartingOffset() )
|
||||||
return updateInclusionIterator();
|
return updateInclusionIterator();
|
||||||
|
|
||||||
if( currentMacro.getElementStartingOffset() < currentInclusion.getElementStartingOffset() &&
|
if( currentMacro.getStartingOffset() < currentInclusion.getStartingOffset() &&
|
||||||
currentMacro.getElementStartingOffset() < currentDeclaration.getElementStartingOffset() )
|
currentMacro.getStartingOffset() < currentDeclaration.getStartingOffset() )
|
||||||
return updateMacroIterator();
|
return updateMacroIterator();
|
||||||
// only remaining case
|
// only remaining case
|
||||||
return updateDeclarationIterator();
|
return updateDeclarationIterator();
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.internal.core.parser;
|
package org.eclipse.cdt.internal.core.parser;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
|
@ -61,6 +62,8 @@ public class TokenDuple implements ITokenDuple {
|
||||||
* @see java.util.Iterator#next()
|
* @see java.util.Iterator#next()
|
||||||
*/
|
*/
|
||||||
public Object next() {
|
public Object next() {
|
||||||
|
if( ! hasNext() )
|
||||||
|
throw new NoSuchElementException();
|
||||||
IToken temp = iter;
|
IToken temp = iter;
|
||||||
iter = iter.getNext();
|
iter = iter.getNext();
|
||||||
return temp;
|
return temp;
|
||||||
|
|
|
@ -55,21 +55,21 @@ public class ASTInclusion implements IASTInclusion {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset() {
|
public int getStartingOffset() {
|
||||||
return startingOffset;
|
return startingOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset() {
|
public int getEndingOffset() {
|
||||||
return endingOffset;
|
return endingOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementNameOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementNameOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementNameOffset() {
|
public int getNameOffset() {
|
||||||
return nameOffset;
|
return nameOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class ASTInclusion implements IASTInclusion {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.ast.IOffsetableElementRW#setNameOffset(int)
|
* @see org.eclipse.cdt.internal.core.parser.ast.IOffsetableElementRW#setNameOffset(int)
|
||||||
*/
|
*/
|
||||||
public void setElementNameOffset(int o) {
|
public void setNameOffset(int o) {
|
||||||
nameOffset = o;
|
nameOffset = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,25 +48,25 @@ public class ASTMacro implements IASTMacro {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IOffsetableElementRW#setNameOffset(int)
|
* @see org.eclipse.cdt.core.parser.ast.IOffsetableElementRW#setNameOffset(int)
|
||||||
*/
|
*/
|
||||||
public void setElementNameOffset(int o) {
|
public void setNameOffset(int o) {
|
||||||
nameOffset = o;
|
nameOffset = o;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset() {
|
public int getStartingOffset() {
|
||||||
return startingOffset;
|
return startingOffset;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset() {
|
public int getEndingOffset() {
|
||||||
return endingOffset;
|
return endingOffset;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementNameOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementNameOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementNameOffset() {
|
public int getNameOffset() {
|
||||||
return nameOffset;
|
return nameOffset;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
package org.eclipse.cdt.internal.core.parser.ast;
|
||||||
|
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class BaseASTFactory {
|
||||||
IASTMacro m = new ASTMacro( name );
|
IASTMacro m = new ASTMacro( name );
|
||||||
m.setStartingOffset( startingOffset );
|
m.setStartingOffset( startingOffset );
|
||||||
m.setEndingOffset( endingOffset );
|
m.setEndingOffset( endingOffset );
|
||||||
m.setElementNameOffset( nameOffset );
|
m.setNameOffset( nameOffset );
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class BaseASTFactory {
|
||||||
IASTInclusion inclusion = new ASTInclusion( name, fileName, local );
|
IASTInclusion inclusion = new ASTInclusion( name, fileName, local );
|
||||||
inclusion.setStartingOffset( startingOffset );
|
inclusion.setStartingOffset( startingOffset );
|
||||||
inclusion.setEndingOffset( endingOffset );
|
inclusion.setEndingOffset( endingOffset );
|
||||||
inclusion.setElementNameOffset( nameOffset );
|
inclusion.setNameOffset( nameOffset );
|
||||||
return inclusion;
|
return inclusion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class NamedOffsets extends Offsets {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementNameOffset() {
|
public int getNameOffset() {
|
||||||
return nameOffset;
|
return nameOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,11 @@ public class Offsets {
|
||||||
endingOffset = o;
|
endingOffset = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getElementStartingOffset() {
|
public int getStartingOffset() {
|
||||||
return startingOffset;
|
return startingOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getElementEndingOffset() {
|
public int getEndingOffset() {
|
||||||
return endingOffset;
|
return endingOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.Offsets;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ASTAbstractTypeSpecifierDeclaration
|
||||||
|
extends ASTAnonymousDeclaration
|
||||||
|
implements IASTAbstractTypeSpecifierDeclaration
|
||||||
|
{
|
||||||
|
private final IASTTypeSpecifier typeSpec;
|
||||||
|
private final IASTTemplate ownerTemplate;
|
||||||
|
private Offsets offsets = new Offsets();
|
||||||
|
/**
|
||||||
|
* @param ownerScope
|
||||||
|
*/
|
||||||
|
public ASTAbstractTypeSpecifierDeclaration(IContainerSymbol ownerScope, IASTTypeSpecifier typeSpecifier, IASTTemplate ownerTemplate, int startingOffset, int endingOffset )
|
||||||
|
{
|
||||||
|
super(ownerScope);
|
||||||
|
this.typeSpec = typeSpecifier;
|
||||||
|
this.ownerTemplate = ownerTemplate;
|
||||||
|
setStartingOffset(startingOffset);
|
||||||
|
setEndingOffset(endingOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void acceptElement(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
requestor.acceptAbstractTypeSpecDeclaration(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void enterScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void exitScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTTypeSpecifierOwner#getTypeSpecifier()
|
||||||
|
*/
|
||||||
|
public IASTTypeSpecifier getTypeSpecifier()
|
||||||
|
{
|
||||||
|
return typeSpec;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTTemplatedDeclaration#getOwnerTemplateDeclaration()
|
||||||
|
*/
|
||||||
|
public IASTTemplate getOwnerTemplateDeclaration()
|
||||||
|
{
|
||||||
|
return ownerTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
|
||||||
|
*/
|
||||||
|
public void setStartingOffset(int o)
|
||||||
|
{
|
||||||
|
offsets.setStartingOffset(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
|
||||||
|
*/
|
||||||
|
public void setEndingOffset(int o)
|
||||||
|
{
|
||||||
|
offsets.setEndingOffset(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getStartingOffset()
|
||||||
|
*/
|
||||||
|
public int getStartingOffset()
|
||||||
|
{
|
||||||
|
return offsets.getStartingOffset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getEndingOffset()
|
||||||
|
*/
|
||||||
|
public int getEndingOffset()
|
||||||
|
{
|
||||||
|
return offsets.getEndingOffset();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class ASTAnonymousDeclaration implements IASTDeclaration
|
||||||
|
{
|
||||||
|
private final IContainerSymbol ownerScope;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public ASTAnonymousDeclaration( IContainerSymbol ownerScope )
|
||||||
|
{
|
||||||
|
this.ownerScope = ownerScope;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTScopedElement#getOwnerScope()
|
||||||
|
*/
|
||||||
|
public IASTScope getOwnerScope()
|
||||||
|
{
|
||||||
|
return (IASTScope)ownerScope.getASTExtension().getPrimaryDeclaration();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,171 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier
|
||||||
|
{
|
||||||
|
private NamedOffsets offsets = new NamedOffsets();
|
||||||
|
private final ClassNameType classNameType;
|
||||||
|
private final ASTClassKind classKind;
|
||||||
|
private ASTAccessVisibility currentVisibility;
|
||||||
|
private final ASTQualifiedNamedElement qualifiedName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param symbol
|
||||||
|
*/
|
||||||
|
public ASTClassSpecifier(ISymbol symbol, ASTClassKind kind, ClassNameType type, ASTAccessVisibility access, int startingOffset, int nameOffset )
|
||||||
|
{
|
||||||
|
super(symbol);
|
||||||
|
classKind = kind;
|
||||||
|
classNameType = type;
|
||||||
|
currentVisibility = access;
|
||||||
|
setStartingOffset(startingOffset);
|
||||||
|
setNameOffset(nameOffset);
|
||||||
|
qualifiedName = new ASTQualifiedNamedElement( getOwnerScope(), symbol.getName() );
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getClassNameType()
|
||||||
|
*/
|
||||||
|
public ClassNameType getClassNameType()
|
||||||
|
{
|
||||||
|
return classNameType;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getClassKind()
|
||||||
|
*/
|
||||||
|
public ASTClassKind getClassKind()
|
||||||
|
{
|
||||||
|
return classKind;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getBaseClauses()
|
||||||
|
*/
|
||||||
|
public Iterator getBaseClauses()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getCurrentVisibilityMode()
|
||||||
|
*/
|
||||||
|
public ASTAccessVisibility getCurrentVisibilityMode()
|
||||||
|
{
|
||||||
|
return currentVisibility;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#setCurrentVisibility(org.eclipse.cdt.core.parser.ast.ASTAccessVisibility)
|
||||||
|
*/
|
||||||
|
public void setCurrentVisibility(ASTAccessVisibility visibility)
|
||||||
|
{
|
||||||
|
currentVisibility = visibility;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getName()
|
||||||
|
*/
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return symbol.getName();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getNameOffset()
|
||||||
|
*/
|
||||||
|
public int getNameOffset()
|
||||||
|
{
|
||||||
|
return offsets.getNameOffset();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||||
|
*/
|
||||||
|
public void setNameOffset(int o)
|
||||||
|
{
|
||||||
|
offsets.setNameOffset(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void acceptElement(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void enterScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
//TODO Iterate baseClauses and callback on their references
|
||||||
|
requestor.enterClassSpecifier(this);
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void exitScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
requestor.exitClassSpecifier(this);
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
|
||||||
|
*/
|
||||||
|
public void setStartingOffset(int o)
|
||||||
|
{
|
||||||
|
offsets.setStartingOffset(o);
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
|
||||||
|
*/
|
||||||
|
public void setEndingOffset(int o)
|
||||||
|
{
|
||||||
|
offsets.setEndingOffset(o);
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getStartingOffset()
|
||||||
|
*/
|
||||||
|
public int getStartingOffset()
|
||||||
|
{
|
||||||
|
return offsets.getStartingOffset();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getEndingOffset()
|
||||||
|
*/
|
||||||
|
public int getEndingOffset()
|
||||||
|
{
|
||||||
|
return offsets.getEndingOffset();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName()
|
||||||
|
*/
|
||||||
|
public String[] getFullyQualifiedName()
|
||||||
|
{
|
||||||
|
return qualifiedName.getFullyQualifiedName();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTScopedElement#getOwnerScope()
|
||||||
|
*/
|
||||||
|
public IASTScope getOwnerScope()
|
||||||
|
{
|
||||||
|
return (IASTScope)symbol.getContainingSymbol().getASTExtension().getPrimaryDeclaration();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ASTCompilationUnit
|
||||||
|
extends ASTScope
|
||||||
|
implements IASTCompilationUnit
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param symbol
|
||||||
|
*/
|
||||||
|
public ASTCompilationUnit(ISymbol symbol)
|
||||||
|
{
|
||||||
|
super(symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void acceptElement(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void enterScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
requestor.enterCompilationUnit( this );
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void exitScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
requestor.exitCompilationUnit( this );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,131 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ASTNamespaceDefinition
|
||||||
|
extends ASTScope
|
||||||
|
implements IASTNamespaceDefinition
|
||||||
|
{
|
||||||
|
|
||||||
|
private NamedOffsets namedOffsets = new NamedOffsets();
|
||||||
|
private final ASTQualifiedNamedElement qualifiedName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param namespaceSymbol
|
||||||
|
* @param startingOffset
|
||||||
|
* @param nameOffset
|
||||||
|
*/
|
||||||
|
public ASTNamespaceDefinition(ISymbol namespaceSymbol, int startingOffset, int nameOffset)
|
||||||
|
{
|
||||||
|
super( namespaceSymbol );
|
||||||
|
setStartingOffset( startingOffset );
|
||||||
|
setNameOffset( nameOffset );
|
||||||
|
qualifiedName = new ASTQualifiedNamedElement( getOwnerScope(), namespaceSymbol.getName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getName()
|
||||||
|
*/
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return symbol.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getNameOffset()
|
||||||
|
*/
|
||||||
|
public int getNameOffset()
|
||||||
|
{
|
||||||
|
return namedOffsets.getNameOffset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||||
|
*/
|
||||||
|
public void setNameOffset(int o)
|
||||||
|
{
|
||||||
|
namedOffsets.setNameOffset( o );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
|
||||||
|
*/
|
||||||
|
public void setStartingOffset(int o)
|
||||||
|
{
|
||||||
|
namedOffsets.setStartingOffset(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
|
||||||
|
*/
|
||||||
|
public void setEndingOffset(int o)
|
||||||
|
{
|
||||||
|
namedOffsets.setEndingOffset(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getStartingOffset()
|
||||||
|
*/
|
||||||
|
public int getStartingOffset()
|
||||||
|
{
|
||||||
|
return namedOffsets.getStartingOffset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getEndingOffset()
|
||||||
|
*/
|
||||||
|
public int getEndingOffset()
|
||||||
|
{
|
||||||
|
return namedOffsets.getEndingOffset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void acceptElement(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void enterScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
requestor.enterNamespaceDefinition( this );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void exitScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
requestor.exitNamespaceDefinition( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName()
|
||||||
|
*/
|
||||||
|
public String[] getFullyQualifiedName()
|
||||||
|
{
|
||||||
|
return qualifiedName.getFullyQualifiedName();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class ASTScope extends ASTSymbol implements IASTScope
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param symbol
|
||||||
|
*/
|
||||||
|
public ASTScope(ISymbol symbol)
|
||||||
|
{
|
||||||
|
super(symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IContainerSymbol getContainerSymbol()
|
||||||
|
{
|
||||||
|
return (IContainerSymbol)symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
|
||||||
|
*/
|
||||||
|
public Iterator getDeclarations()
|
||||||
|
{
|
||||||
|
return new ScopeIterator( getContainerSymbol().getContainedSymbols() );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class ASTSymbol extends ASTSymbolOwner implements ISymbolOwner, IASTDeclaration
|
||||||
|
{
|
||||||
|
|
||||||
|
public ASTSymbol( ISymbol symbol )
|
||||||
|
{
|
||||||
|
super(symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTScopedElement#getOwnerScope()
|
||||||
|
*/
|
||||||
|
public IASTScope getOwnerScope()
|
||||||
|
{
|
||||||
|
return (IASTScope)symbol.getContainingSymbol().getASTExtension().getPrimaryDeclaration();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ASTSymbolOwner implements ISymbolOwner
|
||||||
|
{
|
||||||
|
protected final ISymbol symbol;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public ASTSymbolOwner( ISymbol symbol )
|
||||||
|
{
|
||||||
|
this.symbol = symbol;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner#getSymbol()
|
||||||
|
*/
|
||||||
|
public ISymbol getSymbol()
|
||||||
|
{
|
||||||
|
return symbol;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,114 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.Offsets;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ASTUsingDirective extends ASTAnonymousDeclaration implements IASTUsingDirective
|
||||||
|
{
|
||||||
|
private final IASTNamespaceDefinition namespace;
|
||||||
|
private Offsets offsets = new Offsets();
|
||||||
|
/**
|
||||||
|
* @param namespaceDefinition
|
||||||
|
* @param startingOffset
|
||||||
|
* @param endingOffset
|
||||||
|
*/
|
||||||
|
public ASTUsingDirective(IContainerSymbol ownerSymbol, IASTNamespaceDefinition namespaceDefinition, int startingOffset, int endingOffset)
|
||||||
|
{
|
||||||
|
super( ownerSymbol );
|
||||||
|
namespace = namespaceDefinition;
|
||||||
|
setStartingOffset(startingOffset);
|
||||||
|
setEndingOffset(endingOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTUsingDirective#getNamespaceName()
|
||||||
|
*/
|
||||||
|
public String getNamespaceName()
|
||||||
|
{
|
||||||
|
String [] fqn = namespace.getFullyQualifiedName();
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
for( int i = 0; i < fqn.length; ++i )
|
||||||
|
{
|
||||||
|
buffer.append( fqn[ i ] );
|
||||||
|
if( i + 1 != fqn.length )
|
||||||
|
buffer.append( "::");
|
||||||
|
}
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
|
||||||
|
*/
|
||||||
|
public void setStartingOffset(int o)
|
||||||
|
{
|
||||||
|
offsets.setStartingOffset(o);
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
|
||||||
|
*/
|
||||||
|
public void setEndingOffset(int o)
|
||||||
|
{
|
||||||
|
offsets.setEndingOffset( o );
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
|
*/
|
||||||
|
public int getStartingOffset()
|
||||||
|
{
|
||||||
|
return offsets.getStartingOffset();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
|
*/
|
||||||
|
public int getEndingOffset()
|
||||||
|
{
|
||||||
|
return offsets.getEndingOffset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void acceptElement(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void enterScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void exitScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTUsingDirective#getNamespaceDefinition()
|
||||||
|
*/
|
||||||
|
public IASTNamespaceDefinition getNamespaceDefinition() throws ASTNotImplementedException
|
||||||
|
{
|
||||||
|
return namespace;
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,12 +10,13 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||||
|
@ -24,7 +25,6 @@ import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
|
import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification;
|
import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification;
|
||||||
|
@ -58,7 +58,16 @@ import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.IASTArrayModifier;
|
import org.eclipse.cdt.internal.core.parser.ast.IASTArrayModifier;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ForewardDeclaredSymbolExtension;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension;
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.NamespaceSymbolExtension;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.StandardSymbolExtension;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension.ExtensionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -84,8 +93,62 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
int endingOffset)
|
int endingOffset)
|
||||||
throws ASTSemanticException
|
throws ASTSemanticException
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
Iterator iter = duple.iterator();
|
||||||
return null;
|
if( ! iter.hasNext() )
|
||||||
|
throw new ASTSemanticException();
|
||||||
|
|
||||||
|
IToken t1 = (IToken)iter.next();
|
||||||
|
IContainerSymbol symbol = null;
|
||||||
|
|
||||||
|
symbol = getScopeToSearchUpon(scope, t1 );
|
||||||
|
|
||||||
|
while( iter.hasNext() )
|
||||||
|
{
|
||||||
|
IToken t = (IToken)iter.next();
|
||||||
|
if( t.getType() == IToken.tCOLONCOLON ) continue;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
symbol = symbol.LookupNestedNameSpecifier( t.getImage() );
|
||||||
|
}
|
||||||
|
catch( ParserSymbolTableException pste )
|
||||||
|
{
|
||||||
|
throw new ASTSemanticException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
((ASTScope)scope).getContainerSymbol().addUsingDirective( symbol );
|
||||||
|
} catch (ParserSymbolTableException pste) {
|
||||||
|
}
|
||||||
|
|
||||||
|
IASTUsingDirective astUD = new ASTUsingDirective( scopeToSymbol(scope), ((IASTNamespaceDefinition)symbol.getASTExtension().getPrimaryDeclaration()), startingOffset, endingOffset );
|
||||||
|
return astUD;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected IContainerSymbol getScopeToSearchUpon(
|
||||||
|
IASTScope currentScope,
|
||||||
|
IToken firstToken )
|
||||||
|
{
|
||||||
|
IContainerSymbol symbol = null;
|
||||||
|
if( firstToken.getType() == IToken.tCOLONCOLON )
|
||||||
|
symbol = pst.getCompilationUnit();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
symbol = (IContainerSymbol)scopeToSymbol(currentScope).Lookup( firstToken.getImage() );
|
||||||
|
}
|
||||||
|
catch( ParserSymbolTableException pste )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return symbol;
|
||||||
|
}
|
||||||
|
protected IContainerSymbol scopeToSymbol(IASTScope currentScope)
|
||||||
|
{
|
||||||
|
return ((ASTScope)currentScope).getContainerSymbol();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, boolean, org.eclipse.cdt.core.parser.ITokenDuple, int, int)
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, boolean, org.eclipse.cdt.core.parser.ITokenDuple, int, int)
|
||||||
|
@ -119,19 +182,99 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
String identifier,
|
String identifier,
|
||||||
int startingOffset,
|
int startingOffset,
|
||||||
int nameOffset)
|
int nameOffset) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
// first we look up the symbol in the PST see if it already exists
|
||||||
return null;
|
// if not we create it
|
||||||
|
// TODO : handle the anonymous case
|
||||||
|
|
||||||
|
IContainerSymbol pstScope = scopeToSymbol(scope);
|
||||||
|
ISymbol namespaceSymbol = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
namespaceSymbol = pstScope.Lookup( identifier );
|
||||||
|
}
|
||||||
|
catch (ParserSymbolTableException e)
|
||||||
|
{
|
||||||
|
throw new ASTSemanticException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( namespaceSymbol != null )
|
||||||
|
{
|
||||||
|
if( namespaceSymbol.getType() != ParserSymbolTable.TypeInfo.t_namespace )
|
||||||
|
throw new ASTSemanticException();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
namespaceSymbol = pst.newContainerSymbol( identifier, ParserSymbolTable.TypeInfo.t_namespace );
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstScope.addSymbol( namespaceSymbol );
|
||||||
|
}
|
||||||
|
catch (ParserSymbolTableException e1)
|
||||||
|
{
|
||||||
|
// not overloading, should never happen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ASTNamespaceDefinition namespaceDef = new ASTNamespaceDefinition( namespaceSymbol, startingOffset, nameOffset );
|
||||||
|
try
|
||||||
|
{
|
||||||
|
attachSymbolExtension( namespaceSymbol, namespaceDef );
|
||||||
|
}
|
||||||
|
catch (ExtensionException e1)
|
||||||
|
{
|
||||||
|
// will not happen with namespaces
|
||||||
|
}
|
||||||
|
return namespaceDef;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createCompilationUnit()
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createCompilationUnit()
|
||||||
*/
|
*/
|
||||||
public IASTCompilationUnit createCompilationUnit()
|
public IASTCompilationUnit createCompilationUnit()
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
ISymbol symbol = pst.getCompilationUnit();
|
||||||
return null;
|
ASTCompilationUnit compilationUnit = new ASTCompilationUnit( symbol );
|
||||||
|
try
|
||||||
|
{
|
||||||
|
attachSymbolExtension(symbol, compilationUnit );
|
||||||
|
}
|
||||||
|
catch (ExtensionException e)
|
||||||
|
{
|
||||||
|
//should not happen with CompilationUnit
|
||||||
|
}
|
||||||
|
return compilationUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void attachSymbolExtension(
|
||||||
|
ISymbol symbol,
|
||||||
|
ASTSymbol astSymbol ) throws ExtensionException
|
||||||
|
{
|
||||||
|
ISymbolASTExtension extension = symbol.getASTExtension();
|
||||||
|
if( extension == null )
|
||||||
|
{
|
||||||
|
if( astSymbol instanceof IASTNamespaceDefinition )
|
||||||
|
extension = new NamespaceSymbolExtension( symbol, astSymbol );
|
||||||
|
else if( astSymbol instanceof IASTFunction ) // TODO : other foreward declare cases
|
||||||
|
{
|
||||||
|
extension = new ForewardDeclaredSymbolExtension( symbol, astSymbol );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
extension = new StandardSymbolExtension( symbol, astSymbol );
|
||||||
|
}
|
||||||
|
symbol.setASTExtension( extension );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
extension.addDefinition( astSymbol );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, int)
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, int)
|
||||||
*/
|
*/
|
||||||
|
@ -152,12 +295,41 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
ASTClassKind kind,
|
ASTClassKind kind,
|
||||||
ClassNameType type,
|
ClassNameType type,
|
||||||
ASTAccessVisibility access,
|
ASTAccessVisibility access,
|
||||||
IASTTemplate ownerTemplateDeclaration,
|
|
||||||
int startingOffset,
|
int startingOffset,
|
||||||
int nameOffset)
|
int nameOffset) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
IContainerSymbol containerSymbol = scopeToSymbol(scope);
|
||||||
return null;
|
ParserSymbolTable.TypeInfo.eType pstType = null;
|
||||||
|
|
||||||
|
if( kind == ASTClassKind.CLASS )
|
||||||
|
pstType = ParserSymbolTable.TypeInfo.t_class;
|
||||||
|
else if( kind == ASTClassKind.STRUCT )
|
||||||
|
pstType = ParserSymbolTable.TypeInfo.t_struct;
|
||||||
|
else if( kind == ASTClassKind.UNION )
|
||||||
|
pstType = ParserSymbolTable.TypeInfo.t_union;
|
||||||
|
else
|
||||||
|
throw new ASTSemanticException();
|
||||||
|
|
||||||
|
IDerivableContainerSymbol classSymbol = pst.newDerivableContainerSymbol( name, pstType );
|
||||||
|
try
|
||||||
|
{
|
||||||
|
containerSymbol.addSymbol( classSymbol );
|
||||||
|
}
|
||||||
|
catch (ParserSymbolTableException e)
|
||||||
|
{
|
||||||
|
throw new ASTSemanticException();
|
||||||
|
}
|
||||||
|
|
||||||
|
ASTClassSpecifier classSpecifier = new ASTClassSpecifier( classSymbol, kind, type, access, startingOffset, nameOffset );
|
||||||
|
try
|
||||||
|
{
|
||||||
|
attachSymbolExtension(classSymbol, classSpecifier );
|
||||||
|
}
|
||||||
|
catch (ExtensionException e1)
|
||||||
|
{
|
||||||
|
throw new ASTSemanticException();
|
||||||
|
}
|
||||||
|
return classSpecifier;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#addBaseSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, java.lang.String)
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#addBaseSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, java.lang.String)
|
||||||
|
@ -463,8 +635,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
int startingOffset,
|
int startingOffset,
|
||||||
int endingOffset)
|
int endingOffset)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
return new ASTAbstractTypeSpecifierDeclaration( scopeToSymbol(scope), typeSpecifier, template, startingOffset, endingOffset);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createPointerToFunction(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplate, org.eclipse.cdt.core.parser.ast.ASTPointerOperator)
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createPointerToFunction(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplate, org.eclipse.cdt.core.parser.ast.ASTPointerOperator)
|
||||||
|
@ -514,11 +685,6 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createSymbolTableDeclarationExtension(org.eclipse.cdt.core.parser.ast.IASTDeclaration, org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
protected ParserSymbolTable pst = new ParserSymbolTable();
|
||||||
*/
|
|
||||||
public ISymbolASTExtension createSymbolTableDeclarationExtension(IASTDeclaration declaration, IASTDeclaration definition) throws ASTNotImplementedException
|
|
||||||
{
|
|
||||||
return new SymbolExtension( declaration, definition );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ScopeIterator implements Iterator
|
||||||
|
{
|
||||||
|
private final Map sourceMap;
|
||||||
|
private final Iterator keyIter;
|
||||||
|
private Iterator subIterator = null;
|
||||||
|
|
||||||
|
public ScopeIterator( Map in )
|
||||||
|
{
|
||||||
|
sourceMap = in;
|
||||||
|
if( sourceMap != null )
|
||||||
|
keyIter = in.keySet().iterator();
|
||||||
|
else
|
||||||
|
keyIter = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#hasNext()
|
||||||
|
*/
|
||||||
|
public boolean hasNext() {
|
||||||
|
if( keyIter == null )
|
||||||
|
return false;
|
||||||
|
if( subIterator != null && subIterator.hasNext() )
|
||||||
|
return true;
|
||||||
|
subIterator = null;
|
||||||
|
return keyIter.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#next()
|
||||||
|
*/
|
||||||
|
public Object next() {
|
||||||
|
if( ! hasNext() )
|
||||||
|
throw new NoSuchElementException();
|
||||||
|
|
||||||
|
if( subIterator != null )
|
||||||
|
return subIterator.next();
|
||||||
|
|
||||||
|
|
||||||
|
ISymbolASTExtension symbol = ((ISymbol)sourceMap.get( keyIter.next() )).getASTExtension();
|
||||||
|
subIterator = symbol.getAllDefinitions();
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#remove()
|
||||||
|
*/
|
||||||
|
public void remove() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,82 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v0.5
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v05.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Rational Software - Initial API and implementation
|
|
||||||
***********************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jcamelon
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class SymbolExtension implements ISymbolASTExtension
|
|
||||||
{
|
|
||||||
private ISymbol symbol;
|
|
||||||
private final IASTDeclaration declaration;
|
|
||||||
private IASTDeclaration definition;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public SymbolExtension( IASTDeclaration declaration, IASTDeclaration definition )
|
|
||||||
{
|
|
||||||
this.declaration = declaration;
|
|
||||||
this.definition = definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDeclarationExtension#getDeclaration()
|
|
||||||
*/
|
|
||||||
public IASTDeclaration getDeclaration()
|
|
||||||
{
|
|
||||||
return declaration;
|
|
||||||
}
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDeclarationExtension#getDefinition()
|
|
||||||
*/
|
|
||||||
public IASTDeclaration getDefinition()
|
|
||||||
{
|
|
||||||
return definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDeclarationExtension#setDefinition(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
|
||||||
*/
|
|
||||||
public void setDefinition(IASTDeclaration definition)
|
|
||||||
{
|
|
||||||
this.definition = definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDeclarationExtension#hasBeenDefined()
|
|
||||||
*/
|
|
||||||
public boolean hasBeenDefined()
|
|
||||||
{
|
|
||||||
return ( definition != null );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDeclarationExtension#getSymbol()
|
|
||||||
*/
|
|
||||||
public ISymbol getSymbol()
|
|
||||||
{
|
|
||||||
return symbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDeclarationExtension#setSymbol(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
|
||||||
*/
|
|
||||||
public void setSymbol(ISymbol s)
|
|
||||||
{
|
|
||||||
symbol = s;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -57,15 +57,15 @@ public class ASTASMDefinition
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset() {
|
public int getStartingOffset() {
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset() {
|
public int getEndingOffset() {
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -74,16 +74,16 @@ public class ASTAbstractTypeSpecifierDeclaration
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset()
|
public int getStartingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset()
|
public int getEndingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
private Offsets offsets = new Offsets();
|
private Offsets offsets = new Offsets();
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
|
import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -34,8 +34,7 @@ public class ASTClassSpecifier extends ASTScopedTypeSpecifier implements IASTQCl
|
||||||
String name,
|
String name,
|
||||||
ASTClassKind kind,
|
ASTClassKind kind,
|
||||||
ClassNameType type,
|
ClassNameType type,
|
||||||
ASTAccessVisibility access,
|
ASTAccessVisibility access)
|
||||||
IASTTemplate ownerTemplate)
|
|
||||||
{
|
{
|
||||||
super( scope, name );
|
super( scope, name );
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
|
@ -99,14 +98,14 @@ public class ASTClassSpecifier extends ASTScopedTypeSpecifier implements IASTQCl
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementNameOffset()
|
public int getNameOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementNameOffset();
|
return offsets.getNameOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||||
*/
|
*/
|
||||||
public void setElementNameOffset(int o)
|
public void setNameOffset(int o)
|
||||||
{
|
{
|
||||||
offsets.setNameOffset(o);
|
offsets.setNameOffset(o);
|
||||||
}
|
}
|
||||||
|
@ -128,16 +127,16 @@ public class ASTClassSpecifier extends ASTScopedTypeSpecifier implements IASTQCl
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset()
|
public int getStartingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset()
|
public int getEndingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.ast.quick.IASTQScope#addDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
* @see org.eclipse.cdt.internal.core.parser.ast.quick.IASTQScope#addDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
||||||
|
|
|
@ -69,15 +69,15 @@ public class ASTElaboratedTypeSpecifier implements IASTElaboratedTypeSpecifier
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset()
|
public int getStartingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset()
|
public int getEndingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,14 +53,14 @@ public class ASTEnumerationSpecifier extends ASTScopedTypeSpecifier
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementNameOffset()
|
public int getNameOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementNameOffset();
|
return offsets.getNameOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||||
*/
|
*/
|
||||||
public void setElementNameOffset(int o)
|
public void setNameOffset(int o)
|
||||||
{
|
{
|
||||||
offsets.setNameOffset(o);
|
offsets.setNameOffset(o);
|
||||||
}
|
}
|
||||||
|
@ -81,16 +81,16 @@ public class ASTEnumerationSpecifier extends ASTScopedTypeSpecifier
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset()
|
public int getStartingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset()
|
public int getEndingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List enumerators = new ArrayList();
|
private List enumerators = new ArrayList();
|
||||||
|
|
|
@ -54,14 +54,14 @@ public class ASTEnumerator
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementNameOffset()
|
public int getNameOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementNameOffset();
|
return offsets.getNameOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||||
*/
|
*/
|
||||||
public void setElementNameOffset(int o)
|
public void setNameOffset(int o)
|
||||||
{
|
{
|
||||||
offsets.setNameOffset(o);
|
offsets.setNameOffset(o);
|
||||||
}
|
}
|
||||||
|
@ -82,16 +82,16 @@ public class ASTEnumerator
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset()
|
public int getStartingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset()
|
public int getEndingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTEnumerator#getOwnerEnumerationSpecifier()
|
* @see org.eclipse.cdt.core.parser.ast.IASTEnumerator#getOwnerEnumerationSpecifier()
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
@ -60,4 +61,18 @@ public class ASTField extends ASTVariable implements IASTField
|
||||||
{
|
{
|
||||||
return visibility;
|
return visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void acceptElement( ISourceElementRequestor requestor )
|
||||||
|
{
|
||||||
|
requestor.acceptField( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enterScope( ISourceElementRequestor requestor )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exitScope( ISourceElementRequestor requestor )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
|
import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.*;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,14 +115,14 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementNameOffset()
|
public int getNameOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementNameOffset();
|
return offsets.getNameOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||||
*/
|
*/
|
||||||
public void setElementNameOffset(int o)
|
public void setNameOffset(int o)
|
||||||
{
|
{
|
||||||
offsets.setNameOffset( o );
|
offsets.setNameOffset( o );
|
||||||
}
|
}
|
||||||
|
@ -149,16 +150,16 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset()
|
public int getStartingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset()
|
public int getEndingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
|
* @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
|
||||||
|
|
|
@ -76,16 +76,16 @@ public class ASTLinkageSpecification
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset()
|
public int getStartingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset()
|
public int getEndingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
private Offsets offsets = new Offsets();
|
private Offsets offsets = new Offsets();
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification;
|
import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification;
|
||||||
|
@ -18,6 +19,7 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
|
import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
|
@ -155,4 +157,20 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTMember#getOwnerClassSpecifier()
|
* @see org.eclipse.cdt.core.parser.ast.IASTMember#getOwnerClassSpecifier()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public void acceptElement( ISourceElementRequestor requestor )
|
||||||
|
{
|
||||||
|
requestor.acceptMethodDeclaration( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enterScope( ISourceElementRequestor requestor )
|
||||||
|
{
|
||||||
|
requestor.enterMethodBody(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exitScope( ISourceElementRequestor requestor )
|
||||||
|
{
|
||||||
|
requestor.exitMethodBody(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.*;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,14 +47,14 @@ public class ASTNamespaceDefinition extends ASTDeclaration implements IASTNamesp
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementNameOffset() {
|
public int getNameOffset() {
|
||||||
return offsets.getElementNameOffset();
|
return offsets.getNameOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||||
*/
|
*/
|
||||||
public void setElementNameOffset(int o) {
|
public void setNameOffset(int o) {
|
||||||
offsets.setNameOffset( o );
|
offsets.setNameOffset( o );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,15 +76,15 @@ public class ASTNamespaceDefinition extends ASTDeclaration implements IASTNamesp
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset() {
|
public int getStartingOffset() {
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset() {
|
public int getEndingOffset() {
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List declarations = new ArrayList();
|
private List declarations = new ArrayList();
|
||||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScopedTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTScopedTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
|
|
@ -72,16 +72,16 @@ public class ASTTemplateDeclaration extends ASTDeclaration implements IASTTempla
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset()
|
public int getStartingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset()
|
public int getEndingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -69,17 +69,17 @@ public class ASTTemplateInstantiation extends ASTDeclaration implements IASTTemp
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset()
|
public int getStartingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset()
|
public int getEndingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -57,16 +57,16 @@ public class ASTTemplateSpecialization extends ASTDeclaration implements IASTTem
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset()
|
public int getStartingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset()
|
public int getEndingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.*;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +38,7 @@ public class ASTTypedefDeclaration extends ASTDeclaration implements IASTTypedef
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.mapping = mapping;
|
this.mapping = mapping;
|
||||||
setStartingOffset(startingOffset);
|
setStartingOffset(startingOffset);
|
||||||
setElementNameOffset(nameOffset);
|
setNameOffset(nameOffset);
|
||||||
qualifiedName = new ASTQualifiedNamedElement( scope, name );
|
qualifiedName = new ASTQualifiedNamedElement( scope, name );
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -57,14 +58,14 @@ public class ASTTypedefDeclaration extends ASTDeclaration implements IASTTypedef
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementNameOffset()
|
public int getNameOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementNameOffset();
|
return offsets.getNameOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||||
*/
|
*/
|
||||||
public void setElementNameOffset(int o)
|
public void setNameOffset(int o)
|
||||||
{
|
{
|
||||||
offsets.setNameOffset(o);
|
offsets.setNameOffset(o);
|
||||||
}
|
}
|
||||||
|
@ -86,16 +87,16 @@ public class ASTTypedefDeclaration extends ASTDeclaration implements IASTTypedef
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset()
|
public int getStartingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset()
|
public int getEndingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName()
|
* @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName()
|
||||||
|
|
|
@ -65,16 +65,16 @@ public class ASTUsingDeclaration
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset()
|
public int getStartingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset()
|
public int getEndingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
private Offsets offsets = new Offsets();
|
private Offsets offsets = new Offsets();
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.Offsets;
|
import org.eclipse.cdt.internal.core.parser.ast.Offsets;
|
||||||
|
@ -57,16 +59,16 @@ public class ASTUsingDirective
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset()
|
public int getStartingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset()
|
public int getEndingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
private Offsets offsets = new Offsets();
|
private Offsets offsets = new Offsets();
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -88,4 +90,11 @@ public class ASTUsingDirective
|
||||||
public void exitScope(ISourceElementRequestor requestor)
|
public void exitScope(ISourceElementRequestor requestor)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTUsingDirective#getNamespaceDefinition()
|
||||||
|
*/
|
||||||
|
public IASTNamespaceDefinition getNamespaceDefinition() throws ASTNotImplementedException
|
||||||
|
{
|
||||||
|
throw new ASTNotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.*;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,28 +142,28 @@ public class ASTVariable extends ASTDeclaration implements IASTVariable
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementStartingOffset()
|
public int getStartingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementStartingOffset();
|
return offsets.getStartingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementEndingOffset()
|
public int getEndingOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementEndingOffset();
|
return offsets.getEndingOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
|
||||||
*/
|
*/
|
||||||
public int getElementNameOffset()
|
public int getNameOffset()
|
||||||
{
|
{
|
||||||
return offsets.getElementNameOffset();
|
return offsets.getNameOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||||
*/
|
*/
|
||||||
public void setElementNameOffset(int o)
|
public void setNameOffset(int o)
|
||||||
{
|
{
|
||||||
offsets.setNameOffset(o);
|
offsets.setNameOffset(o);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||||
|
@ -25,7 +24,6 @@ import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
|
import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||||
|
@ -59,7 +57,6 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.IASTArrayModifier;
|
import org.eclipse.cdt.internal.core.parser.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -90,7 +87,7 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
||||||
public IASTNamespaceDefinition createNamespaceDefinition(IASTScope scope, String identifier, int first, int nameOffset) {
|
public IASTNamespaceDefinition createNamespaceDefinition(IASTScope scope, String identifier, int first, int nameOffset) {
|
||||||
IASTNamespaceDefinition definition = new ASTNamespaceDefinition( scope, identifier );
|
IASTNamespaceDefinition definition = new ASTNamespaceDefinition( scope, identifier );
|
||||||
definition.setStartingOffset( first );
|
definition.setStartingOffset( first );
|
||||||
definition.setElementNameOffset( nameOffset );
|
definition.setNameOffset( nameOffset );
|
||||||
return definition;
|
return definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,10 +115,10 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, org.eclipse.cdt.core.parser.ast.ClassKind, org.eclipse.cdt.core.parser.ast.ClassNameType, org.eclipse.cdt.core.parser.ast.AccessVisibility, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, org.eclipse.cdt.core.parser.ast.ClassKind, org.eclipse.cdt.core.parser.ast.ClassNameType, org.eclipse.cdt.core.parser.ast.AccessVisibility, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
|
||||||
*/
|
*/
|
||||||
public IASTClassSpecifier createClassSpecifier(IASTScope scope, String name, ASTClassKind kind, ClassNameType type, ASTAccessVisibility access, IASTTemplate ownerTemplateDeclaration, int startingOffset, int nameOffset) {
|
public IASTClassSpecifier createClassSpecifier(IASTScope scope, String name, ASTClassKind kind, ClassNameType type, ASTAccessVisibility access, int startingOffset, int nameOffset) throws ASTSemanticException {
|
||||||
IASTClassSpecifier spec = new ASTClassSpecifier( scope, name, kind, type, access, ownerTemplateDeclaration );
|
IASTClassSpecifier spec = new ASTClassSpecifier( scope, name, kind, type, access );
|
||||||
spec.setStartingOffset( startingOffset );
|
spec.setStartingOffset( startingOffset );
|
||||||
spec.setElementNameOffset( nameOffset );
|
spec.setNameOffset( nameOffset );
|
||||||
return spec;
|
return spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,14 +318,4 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
||||||
{
|
{
|
||||||
return new ASTPointerToMethod(scope, name, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate, isConst, isVolatile, isConstructor, isDestructor, isVirtual, isExplicit, isPureVirtual, visibility, pointerOperator);
|
return new ASTPointerToMethod(scope, name, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate, isConst, isVolatile, isConstructor, isDestructor, isVirtual, isExplicit, isPureVirtual, visibility, pointerOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createSymbolTableDeclarationExtension(org.eclipse.cdt.core.parser.ast.IASTDeclaration, org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
|
||||||
*/
|
|
||||||
public ISymbolASTExtension createSymbolTableDeclarationExtension(IASTDeclaration declaration, IASTDeclaration definition) throws ASTNotImplementedException
|
|
||||||
{
|
|
||||||
throw new ASTNotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.pst;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class AbstractSymbolExtension implements ISymbolASTExtension
|
||||||
|
{
|
||||||
|
protected final ISymbol symbol;
|
||||||
|
protected final ASTSymbol primaryDeclaration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public AbstractSymbolExtension( ISymbol symbol, ASTSymbol primaryDeclaration )
|
||||||
|
{
|
||||||
|
this.symbol = symbol;
|
||||||
|
this.primaryDeclaration = primaryDeclaration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner#getSymbol()
|
||||||
|
*/
|
||||||
|
public ISymbol getSymbol()
|
||||||
|
{
|
||||||
|
return symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ASTSymbol getPrimaryDeclaration()
|
||||||
|
{
|
||||||
|
return primaryDeclaration;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,109 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.pst;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ForewardDeclaredSymbolExtension extends AbstractSymbolExtension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private class DualIterator implements Iterator
|
||||||
|
{
|
||||||
|
private int state = 0;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public DualIterator()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#hasNext()
|
||||||
|
*/
|
||||||
|
public boolean hasNext()
|
||||||
|
{
|
||||||
|
if( state == 0 ) return true;
|
||||||
|
if( state == 1 && definitionSymbol != null ) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#next()
|
||||||
|
*/
|
||||||
|
public Object next()
|
||||||
|
{
|
||||||
|
switch( state )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
state = 1;
|
||||||
|
return primaryDeclaration;
|
||||||
|
case 1:
|
||||||
|
if( definitionSymbol != null )
|
||||||
|
{
|
||||||
|
state = 2;
|
||||||
|
return definitionSymbol;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
throw new NoSuchElementException();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#remove()
|
||||||
|
*/
|
||||||
|
public void remove()
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ASTSymbol definitionSymbol = null;
|
||||||
|
/**
|
||||||
|
* @param symbol
|
||||||
|
* @param primaryDeclaration
|
||||||
|
*/
|
||||||
|
public ForewardDeclaredSymbolExtension(
|
||||||
|
ISymbol symbol,
|
||||||
|
ASTSymbol primaryDeclaration)
|
||||||
|
{
|
||||||
|
super(symbol, primaryDeclaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension#getAllDefinitions()
|
||||||
|
*/
|
||||||
|
public Iterator getAllDefinitions()
|
||||||
|
{
|
||||||
|
return new DualIterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension#addDefinition(org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol)
|
||||||
|
*/
|
||||||
|
public void addDefinition(ASTSymbol definition) throws ExtensionException
|
||||||
|
{
|
||||||
|
if( definitionSymbol != null )
|
||||||
|
throw new ExtensionException();
|
||||||
|
definitionSymbol = definition;
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,8 +25,8 @@ public interface ISymbol {
|
||||||
|
|
||||||
public Object clone();
|
public Object clone();
|
||||||
|
|
||||||
public ISymbolASTExtension getASTNode();
|
public ISymbolASTExtension getASTExtension();
|
||||||
public void setASTNode( ISymbolASTExtension obj );
|
public void setASTExtension( ISymbolASTExtension obj );
|
||||||
|
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.pst;
|
package org.eclipse.cdt.internal.core.parser.pst;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -18,8 +20,13 @@ import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||||
*/
|
*/
|
||||||
public interface ISymbolASTExtension extends ISymbolOwner
|
public interface ISymbolASTExtension extends ISymbolOwner
|
||||||
{
|
{
|
||||||
public IASTDeclaration getDeclaration();
|
public class ExtensionException extends Exception
|
||||||
public IASTDeclaration getDefinition();
|
{
|
||||||
public void setDefinition( IASTDeclaration definition );
|
}
|
||||||
public boolean hasBeenDefined();
|
|
||||||
|
|
||||||
|
public ASTSymbol getPrimaryDeclaration();
|
||||||
|
public Iterator getAllDefinitions();
|
||||||
|
public void addDefinition( ASTSymbol definition ) throws ExtensionException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,4 @@ package org.eclipse.cdt.internal.core.parser.pst;
|
||||||
public interface ISymbolOwner
|
public interface ISymbolOwner
|
||||||
{
|
{
|
||||||
public ISymbol getSymbol();
|
public ISymbol getSymbol();
|
||||||
public void setSymbol( ISymbol s );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.pst;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class NamespaceSymbolExtension extends AbstractSymbolExtension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private class LocalIterator implements Iterator
|
||||||
|
{
|
||||||
|
private boolean donePrimary = false;
|
||||||
|
private Iterator secondaries = otherDefinitions.iterator();
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public LocalIterator()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#hasNext()
|
||||||
|
*/
|
||||||
|
public boolean hasNext()
|
||||||
|
{
|
||||||
|
if( ! donePrimary ) return true;
|
||||||
|
return secondaries.hasNext();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#next()
|
||||||
|
*/
|
||||||
|
public Object next()
|
||||||
|
{
|
||||||
|
if( ! hasNext() )
|
||||||
|
throw new NoSuchElementException();
|
||||||
|
|
||||||
|
if( ! donePrimary )
|
||||||
|
{
|
||||||
|
donePrimary = true;
|
||||||
|
return primaryDeclaration;
|
||||||
|
}
|
||||||
|
|
||||||
|
return secondaries.next();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#remove()
|
||||||
|
*/
|
||||||
|
public void remove()
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected List otherDefinitions = new ArrayList();
|
||||||
|
/**
|
||||||
|
* @param symbol
|
||||||
|
* @param primaryDeclaration
|
||||||
|
*/
|
||||||
|
public NamespaceSymbolExtension(
|
||||||
|
ISymbol symbol,
|
||||||
|
ASTSymbol primaryDeclaration)
|
||||||
|
{
|
||||||
|
super(symbol, primaryDeclaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension#getAllDefinitions()
|
||||||
|
*/
|
||||||
|
public Iterator getAllDefinitions()
|
||||||
|
{
|
||||||
|
return new LocalIterator();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension#addDefinition(org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol)
|
||||||
|
*/
|
||||||
|
public void addDefinition(ASTSymbol definition) throws ExtensionException
|
||||||
|
{
|
||||||
|
otherDefinitions.add( definition );
|
||||||
|
}
|
||||||
|
}
|
|
@ -2067,8 +2067,8 @@ public class ParserSymbolTable {
|
||||||
public String getName() { return _name; }
|
public String getName() { return _name; }
|
||||||
public void setName(String name) { _name = name; }
|
public void setName(String name) { _name = name; }
|
||||||
|
|
||||||
public ISymbolASTExtension getASTNode() { return _object; }
|
public ISymbolASTExtension getASTExtension() { return _object; }
|
||||||
public void setASTNode( ISymbolASTExtension obj ) { _object = obj; }
|
public void setASTExtension( ISymbolASTExtension obj ) { _object = obj; }
|
||||||
|
|
||||||
public IContainerSymbol getContainingSymbol() { return _containingScope; }
|
public IContainerSymbol getContainingSymbol() { return _containingScope; }
|
||||||
public void setContainingSymbol( IContainerSymbol scope ){
|
public void setContainingSymbol( IContainerSymbol scope ){
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.pst;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class StandardSymbolExtension extends AbstractSymbolExtension
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private class SimpleIterator implements Iterator
|
||||||
|
{
|
||||||
|
boolean hasNext = true;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public SimpleIterator()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#hasNext()
|
||||||
|
*/
|
||||||
|
public boolean hasNext()
|
||||||
|
{
|
||||||
|
return hasNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#next()
|
||||||
|
*/
|
||||||
|
public Object next()
|
||||||
|
{
|
||||||
|
if( hasNext )
|
||||||
|
{
|
||||||
|
hasNext = false;
|
||||||
|
return primaryDeclaration;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NoSuchElementException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#remove()
|
||||||
|
*/
|
||||||
|
public void remove()
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param symbol
|
||||||
|
* @param primaryDeclaration
|
||||||
|
*/
|
||||||
|
public StandardSymbolExtension(ISymbol symbol, ASTSymbol primaryDeclaration)
|
||||||
|
{
|
||||||
|
super(symbol, primaryDeclaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension#getAllDefinitions()
|
||||||
|
*/
|
||||||
|
public Iterator getAllDefinitions()
|
||||||
|
{
|
||||||
|
return this.new SimpleIterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension#addDefinition(org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol)
|
||||||
|
*/
|
||||||
|
public void addDefinition(ASTSymbol definition) throws ExtensionException
|
||||||
|
{
|
||||||
|
throw new ExtensionException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -328,9 +328,9 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int offset = node.getElementNameOffset();
|
int offset = node.getNameOffset();
|
||||||
if( offset == 0 )
|
if( offset == 0 )
|
||||||
offset = node.getElementStartingOffset();
|
offset = node.getStartingOffset();
|
||||||
|
|
||||||
if( currentResource != null ){
|
if( currentResource != null ){
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue