mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
org.eclipse.cdt.core
==================== Renamed IASTNode.LookupResult IASTNode.ILookupResult. Introduced new ParseError exception for contextual parse() methods. Renamed ParserFactoryException ParserFactoryError. Replaced ParserNotImplementedException with a variant of ParseError. Updated IScanner & IParser to not reference OffsetLimitReachedException explicitly. Renamed ParserMode.CONTEXTUAL_PARSE to COMPLETION_PARSE. Cleaned up IMacroDescriptor and made Scanner definitions table consistent. Added IScanner.getDefinitions() to return the entire Map of definitions to a client. Removed most of the warnings from parser source directory. Removed the unused SyntaxErrorException. Provided partial fix for Bug 44370 IASTMacro requires more information for clients. org.eclipse.cdt.core.tests ========================== Updated references to LookupResult as it was renamed to ILookupResult. Removed some warnings from parser tests. Updated Scanner & QuickParseTests to accommodate new errors and signatures. Added QuickParseASTTests.testBug44370(). org.eclipse.cdt.ui ================== Updated references to LookupResult as it was renamed to ILookupResult. Updated references of ParserFactoryException to ParserFactoryError. Updated references of ParserNotImplementedException to ParseError. Updated references of CONTEXTUAL_PARSE to COMPLETION_PARSE.
This commit is contained in:
parent
d70a6ac41a
commit
192a8293ce
63 changed files with 752 additions and 508 deletions
|
@ -1,3 +1,9 @@
|
|||
2004-01-15 John Camelon
|
||||
Updated references to LookupResult as it was renamed to ILookupResult.
|
||||
Removed some warnings from parser tests.
|
||||
Updated Scanner & QuickParseTests to accommodate new errors and signatures.
|
||||
Added QuickParseASTTests.testBug44370().
|
||||
|
||||
2004-01-13 John Camelon
|
||||
Updated ContextualParseTest to accommodate bugfixes 48909 & 49702.
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import junit.framework.TestCase;
|
|||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
|
@ -46,7 +46,7 @@ public class BaseASTTest extends TestCase
|
|||
protected IQuickParseCallback quickParseCallback;
|
||||
protected IParser parser;
|
||||
|
||||
protected IASTCompilationUnit parse( String code, boolean quick, boolean throwExceptionOnError, ParserLanguage lang ) throws ParserException, ParserFactoryException
|
||||
protected IASTCompilationUnit parse( String code, boolean quick, boolean throwExceptionOnError, ParserLanguage lang ) throws ParserException, ParserFactoryError
|
||||
{
|
||||
ParserMode mode = quick ? ParserMode.QUICK_PARSE : ParserMode.COMPLETE_PARSE;
|
||||
quickParseCallback = ParserFactory.createQuickParseCallback();
|
||||
|
@ -57,27 +57,27 @@ public class BaseASTTest extends TestCase
|
|||
}
|
||||
|
||||
|
||||
protected IASTCompilationUnit parse( String code, boolean quick, boolean throwExceptionOnError ) throws ParserException, ParserFactoryException
|
||||
protected IASTCompilationUnit parse( String code, boolean quick, boolean throwExceptionOnError ) throws ParserException, ParserFactoryError
|
||||
{
|
||||
return parse( code, quick, throwExceptionOnError, ParserLanguage.CPP );
|
||||
}
|
||||
|
||||
protected IASTCompilationUnit parse( String code )throws ParserException, ParserFactoryException
|
||||
protected IASTCompilationUnit parse( String code )throws ParserException, ParserFactoryError
|
||||
{
|
||||
return parse( code, true, true );
|
||||
}
|
||||
|
||||
protected IASTCompilationUnit fullParse( String code ) throws ParserException, ParserFactoryException
|
||||
protected IASTCompilationUnit fullParse( String code ) throws ParserException, ParserFactoryError
|
||||
{
|
||||
return parse( code, false, true );
|
||||
}
|
||||
|
||||
protected IASTDeclaration assertSoleDeclaration( String code ) throws ParserException, ParserFactoryException
|
||||
protected IASTDeclaration assertSoleDeclaration( String code ) throws ParserException, ParserFactoryError
|
||||
{
|
||||
return assertSoleDeclaration( code, ParserLanguage.CPP );
|
||||
}
|
||||
|
||||
protected IASTDeclaration assertSoleDeclaration( String code, ParserLanguage language ) throws ParserException, ParserFactoryException
|
||||
protected IASTDeclaration assertSoleDeclaration( String code, ParserLanguage language ) throws ParserException, ParserFactoryError
|
||||
{
|
||||
Iterator declarationIter = null;
|
||||
try
|
||||
|
|
|
@ -20,9 +20,8 @@ import org.eclipse.cdt.core.parser.IScanner;
|
|||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerException;
|
||||
|
@ -41,17 +40,17 @@ public class BaseScannerTest extends TestCase {
|
|||
super(x);
|
||||
}
|
||||
|
||||
protected void initializeScanner( String input, ParserMode mode ) throws ParserFactoryException
|
||||
protected void initializeScanner( String input, ParserMode mode ) throws ParserFactoryError
|
||||
{
|
||||
initializeScanner( input, mode, new NullSourceElementRequestor( mode ));
|
||||
}
|
||||
|
||||
protected void initializeScanner( String input, ParserMode mode, ISourceElementRequestor requestor ) throws ParserFactoryException
|
||||
protected void initializeScanner( String input, ParserMode mode, ISourceElementRequestor requestor ) throws ParserFactoryError
|
||||
{
|
||||
scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", new ScannerInfo(), mode, ParserLanguage.CPP, requestor, null );
|
||||
}
|
||||
|
||||
protected void initializeScanner(String input) throws ParserFactoryException
|
||||
protected void initializeScanner(String input) throws ParserFactoryError
|
||||
{
|
||||
initializeScanner( input, ParserMode.COMPLETE_PARSE );
|
||||
}
|
||||
|
@ -162,8 +161,6 @@ public class BaseScannerTest extends TestCase {
|
|||
try {
|
||||
IToken t= scanner.nextToken();
|
||||
assertTrue(t.getType() == tokenType);
|
||||
} catch (OffsetLimitReachedException e) {
|
||||
assertTrue(false);
|
||||
} catch (EndOfFileException e) {
|
||||
assertTrue(false);
|
||||
}
|
||||
|
@ -183,8 +180,6 @@ public class BaseScannerTest extends TestCase {
|
|||
{
|
||||
try {
|
||||
assertNull(scanner.nextToken());
|
||||
}catch (OffsetLimitReachedException e) {
|
||||
assertTrue(false);
|
||||
} catch (EndOfFileException e) {
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +187,7 @@ public class BaseScannerTest extends TestCase {
|
|||
public void validateDefinition(String name, String value)
|
||||
{
|
||||
String definition= null;
|
||||
definition= (String) scanner.getDefinition(name);
|
||||
definition= scanner.getDefinition(name).getExpansionSignature();
|
||||
assertNotNull(definition);
|
||||
assertTrue(definition.trim().equals(value));
|
||||
}
|
||||
|
@ -200,9 +195,9 @@ public class BaseScannerTest extends TestCase {
|
|||
public void validateDefinition(String name, int value)
|
||||
{
|
||||
String definition= null;
|
||||
definition= (String) scanner.getDefinition(name);
|
||||
definition= scanner.getDefinition(name).getExpansionSignature();
|
||||
assertNotNull(definition);
|
||||
int intValue= (Integer.valueOf((String) definition)).intValue();
|
||||
int intValue= (Integer.valueOf(definition)).intValue();
|
||||
assertEquals(value, intValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ 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.core.parser.ast.IASTVariableReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupResult;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.ILookupResult;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
||||
|
||||
|
@ -1176,7 +1176,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
IASTClassSpecifier classB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||
IASTMethod method = (IASTMethod) i.next();
|
||||
|
||||
LookupResult result = method.lookup( "a", new IASTNode.LookupKind[] { IASTNode.LookupKind.ALL }, classB );
|
||||
ILookupResult result = method.lookup( "a", new IASTNode.LookupKind[] { IASTNode.LookupKind.ALL }, classB );
|
||||
|
||||
assertEquals( result.getResultsSize(), 1 );
|
||||
IASTField field = (IASTField) result.getNodes().next();
|
||||
|
@ -1198,7 +1198,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
IASTClassSpecifier classB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||
IASTFunction functionDef = (IASTFunction) i.next();
|
||||
|
||||
LookupResult result = functionDef.lookup( "a", new IASTNode.LookupKind[] { IASTNode.LookupKind.ALL }, classB );
|
||||
ILookupResult result = functionDef.lookup( "a", new IASTNode.LookupKind[] { IASTNode.LookupKind.ALL }, classB );
|
||||
|
||||
assertEquals( result.getResultsSize(), 1 );
|
||||
IASTField field = (IASTField) result.getNodes().next();
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.eclipse.cdt.core.parser.IProblem;
|
|||
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
|
@ -121,8 +121,7 @@ public class CompleteParseBaseTest extends TestCase
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind, org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind[] kind, IASTNode context) throws LookupException {
|
||||
// TODO Auto-generated method stub
|
||||
public ILookupResult lookup(String prefix, LookupKind[] kind, IASTNode context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -683,17 +682,17 @@ public class CompleteParseBaseTest extends TestCase
|
|||
}
|
||||
protected FullParseCallback callback;
|
||||
|
||||
protected IASTScope parse( String code ) throws ParserException, ParserFactoryException
|
||||
protected IASTScope parse( String code ) throws ParserException, ParserFactoryError
|
||||
{
|
||||
return parse( code, true, ParserLanguage.CPP );
|
||||
}
|
||||
|
||||
protected IASTScope parse( String code, boolean throwOnError ) throws ParserException, ParserFactoryException
|
||||
protected IASTScope parse( String code, boolean throwOnError ) throws ParserException, ParserFactoryError
|
||||
{
|
||||
return parse( code, throwOnError, ParserLanguage.CPP );
|
||||
}
|
||||
|
||||
protected IASTScope parse(String code, boolean throwOnError, ParserLanguage language) throws ParserException, ParserFactoryException
|
||||
protected IASTScope parse(String code, boolean throwOnError, ParserLanguage language) throws ParserException, ParserFactoryError
|
||||
{
|
||||
callback = new FullParseCallback();
|
||||
IParser parser = ParserFactory.createParser(
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.eclipse.cdt.core.parser.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupResult;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.ILookupResult;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserLogService;
|
||||
|
||||
/**
|
||||
|
@ -55,12 +55,12 @@ public class ContextualParseTest extends CompleteParseBaseTest {
|
|||
new StringReader(code),
|
||||
"completion-test",
|
||||
new ScannerInfo(),
|
||||
ParserMode.CONTEXTUAL_PARSE,
|
||||
ParserMode.COMPLETION_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,
|
||||
log),
|
||||
callback,
|
||||
ParserMode.CONTEXTUAL_PARSE,
|
||||
ParserMode.COMPLETION_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
log);
|
||||
|
||||
|
@ -144,7 +144,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
|
|||
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.ALL;
|
||||
LookupResult result = node.getCompletionScope().lookup( prefix, kinds, node.getCompletionContext() );
|
||||
ILookupResult result = node.getCompletionScope().lookup( prefix, kinds, node.getCompletionContext() );
|
||||
assertEquals( result.getPrefix(), prefix );
|
||||
|
||||
Iterator iter = result.getNodes();
|
||||
|
@ -193,7 +193,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
|
|||
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.ALL;
|
||||
LookupResult result = node.getCompletionScope().lookup( prefix, kinds, node.getCompletionContext() );
|
||||
ILookupResult result = node.getCompletionScope().lookup( prefix, kinds, node.getCompletionContext() );
|
||||
assertEquals( result.getPrefix(), prefix );
|
||||
|
||||
Iterator iter = result.getNodes();
|
||||
|
@ -309,7 +309,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
|
|||
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.METHODS;
|
||||
LookupResult result = node.getCompletionScope().lookup( prefix, kinds, node.getCompletionContext() );
|
||||
ILookupResult result = node.getCompletionScope().lookup( prefix, kinds, node.getCompletionContext() );
|
||||
assertEquals( result.getPrefix(), prefix );
|
||||
|
||||
Iterator iter = result.getNodes();
|
||||
|
@ -353,7 +353,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
|
|||
assertNotNull( node.getCompletionContext() );
|
||||
assertTrue( node.getCompletionContext() instanceof IASTClassSpecifier );
|
||||
|
||||
LookupResult result = node.getCompletionScope().lookup( prefix, new IASTNode.LookupKind [] { IASTNode.LookupKind.METHODS }, node.getCompletionContext() );
|
||||
ILookupResult result = node.getCompletionScope().lookup( prefix, new IASTNode.LookupKind [] { IASTNode.LookupKind.METHODS }, node.getCompletionContext() );
|
||||
assertEquals( result.getPrefix(), prefix );
|
||||
|
||||
Iterator iter = result.getNodes();
|
||||
|
@ -395,7 +395,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
|
|||
assertNotNull( node.getCompletionContext() );
|
||||
assertTrue( node.getCompletionContext() instanceof IASTClassSpecifier );
|
||||
|
||||
LookupResult result = node.getCompletionScope().lookup( prefix, new IASTNode.LookupKind [] { IASTNode.LookupKind.METHODS }, node.getCompletionContext() );
|
||||
ILookupResult result = node.getCompletionScope().lookup( prefix, new IASTNode.LookupKind [] { IASTNode.LookupKind.METHODS }, node.getCompletionContext() );
|
||||
assertEquals( result.getPrefix(), prefix );
|
||||
|
||||
Iterator iter = result.getNodes();
|
||||
|
@ -431,7 +431,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
|
|||
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.STATEMENT_START );
|
||||
assertNull( node.getCompletionContext() );
|
||||
|
||||
LookupResult result = node.getCompletionScope().lookup( prefix, new IASTNode.LookupKind [] { IASTNode.LookupKind.LOCAL_VARIABLES }, node.getCompletionContext() );
|
||||
ILookupResult result = node.getCompletionScope().lookup( prefix, new IASTNode.LookupKind [] { IASTNode.LookupKind.LOCAL_VARIABLES }, node.getCompletionContext() );
|
||||
assertEquals( result.getPrefix(), prefix );
|
||||
|
||||
Iterator iter = result.getNodes();
|
||||
|
@ -473,7 +473,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
|
|||
assertEquals( node.getCompletionPrefix(), "a" );
|
||||
assertTrue( node.getCompletionScope() instanceof IASTMethod );
|
||||
|
||||
LookupResult result = node.getCompletionScope().lookup( node.getCompletionPrefix(),
|
||||
ILookupResult result = node.getCompletionScope().lookup( node.getCompletionPrefix(),
|
||||
new IASTNode.LookupKind[] { IASTNode.LookupKind.THIS },
|
||||
node.getCompletionContext() );
|
||||
|
||||
|
@ -526,7 +526,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
|
|||
LookupKind[] kinds = new LookupKind[ 1 ];
|
||||
kinds[0] = LookupKind.FIELDS;
|
||||
|
||||
LookupResult result = inquestion.lookup( "a", kinds, null );
|
||||
ILookupResult result = inquestion.lookup( "a", kinds, null );
|
||||
assertEquals(result.getResultsSize(), 3 );
|
||||
}
|
||||
|
||||
|
@ -559,7 +559,7 @@ public class ContextualParseTest extends CompleteParseBaseTest {
|
|||
LookupKind[] kinds = new LookupKind[ 1 ];
|
||||
kinds[0] = LookupKind.FIELDS;
|
||||
|
||||
LookupResult result = inquestion.lookup( "a", kinds, null );
|
||||
ILookupResult result = inquestion.lookup( "a", kinds, null );
|
||||
assertEquals(result.getResultsSize(), 3 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3353,7 +3353,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
results = f.prefixLookup( new TypeFilter( LookupKind.FIELDS), "a", false );
|
||||
assertEquals( results.size(), 1 );
|
||||
assertTrue( results.contains( a3_int ) );
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* void foo( ... ){ }
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.eclipse.cdt.core.parser.EndOfFileException;
|
|||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
|
@ -80,10 +79,6 @@ public class PreprocessorConditionalTest extends BaseScannerTest
|
|||
{
|
||||
fail( "Got #error, should not have gotten that.");
|
||||
}
|
||||
catch( OffsetLimitReachedException olre )
|
||||
{
|
||||
fail( "Should never have reached OffsetLimitReachedException");
|
||||
}
|
||||
catch( EndOfFileException eof )
|
||||
{
|
||||
// expected
|
||||
|
|
|
@ -13,7 +13,10 @@ import java.io.IOException;
|
|||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||
|
@ -273,7 +276,7 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
assertEquals( elab.getName(), "A");
|
||||
assertEquals( elab.getClassKind(), ASTClassKind.STRUCT );
|
||||
assertTrue( typedef.getAbstractDeclarator().getPointerOperators().hasNext() );
|
||||
Iterator pIter = (Iterator)typedef.getAbstractDeclarator().getPointerOperators();
|
||||
Iterator pIter = typedef.getAbstractDeclarator().getPointerOperators();
|
||||
ASTPointerOperator po =(ASTPointerOperator)pIter.next();
|
||||
assertEquals( po, ASTPointerOperator.CONST_POINTER );
|
||||
assertFalse( pIter.hasNext() );
|
||||
|
@ -1311,7 +1314,7 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
assertEquals( typeSpec.getType(), IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME );
|
||||
assertEquals( typeSpec.getTypename(), "A");
|
||||
Iterator pointerOps = f.getReturnType().getPointerOperators();
|
||||
assertEquals( (ASTPointerOperator)pointerOps.next(), ASTPointerOperator.REFERENCE );
|
||||
assertEquals( pointerOps.next(), ASTPointerOperator.REFERENCE );
|
||||
assertFalse( pointerOps.hasNext() );
|
||||
assertEquals( f.getName(), "A::operator =");
|
||||
Iterator parms = f.getParameters();
|
||||
|
@ -1941,7 +1944,7 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
}
|
||||
IASTClassSpecifier structB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)assertSoleDeclaration(code.toString())).getTypeSpecifier();
|
||||
Iterator members = structB.getDeclarations();
|
||||
IASTField a = (IASTField)members.next();
|
||||
assertTrue( members.next() instanceof IASTField);
|
||||
IASTMethod b = (IASTMethod)members.next();
|
||||
assertFalse( members.hasNext() );
|
||||
assertTrue( b.hasFunctionTryBlock() );
|
||||
|
@ -1964,9 +1967,8 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
IASTTemplateDeclaration template = (IASTTemplateDeclaration)assertSoleDeclaration( writer.toString() );
|
||||
IASTClassSpecifier X = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)template.getOwnedDeclaration()).getTypeSpecifier();
|
||||
Iterator members = X.getDeclarations();
|
||||
IASTMethod defaultCons = (IASTMethod)members.next();
|
||||
IASTMethod inlinedCons = (IASTMethod)members.next();
|
||||
IASTMethod destructor = (IASTMethod)members.next();
|
||||
for( int i = 0; i < 3; ++i )
|
||||
assertTrue( members.next() instanceof IASTMethod );
|
||||
assertFalse( members.hasNext() );
|
||||
}
|
||||
|
||||
|
@ -2030,4 +2032,52 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
assertTrue( function.takesVarArgs() );
|
||||
}
|
||||
|
||||
public void testBug44370() throws Exception
|
||||
{
|
||||
parse( "#define SWAP(x,y) {x|=y;y|=x;x|=y;}\n");
|
||||
Iterator macros = quickParseCallback.getMacros();
|
||||
assertNotNull(macros);
|
||||
assertTrue( macros.hasNext());
|
||||
IASTMacro swap = (IASTMacro) macros.next();
|
||||
assertFalse( macros.hasNext() );
|
||||
assertEquals( swap.getName(), "SWAP");
|
||||
assertEquals( swap.getMacroType(), IMacroDescriptor.MacroType.FUNCTION_LIKE );
|
||||
List params = swap.getParameters();
|
||||
assertEquals( params.size(), 2 );
|
||||
assertEquals( params.get(0), "x");
|
||||
assertEquals( params.get(1), "y");
|
||||
assertEquals( swap.getCompleteSignature().trim(), "#define SWAP(x,y) {x|=y;y|=x;x|=y;}");
|
||||
assertEquals( swap.getExpansionSignature().trim(),"{x|=y;y|=x;x|=y;}");
|
||||
Iterator tokens = swap.getTokenizedExpansion().iterator();
|
||||
validateToken( (IToken)tokens.next(), IToken.tLBRACE);
|
||||
validateIdentifier( (IToken)tokens.next(), "x");
|
||||
validateToken( (IToken) tokens.next(), IToken.tBITORASSIGN );
|
||||
validateIdentifier( (IToken) tokens.next(), "y");
|
||||
validateToken( (IToken) tokens.next(), IToken.tSEMI );
|
||||
validateIdentifier( (IToken) tokens.next(), "y");
|
||||
validateToken( (IToken) tokens.next(), IToken.tBITORASSIGN );
|
||||
validateIdentifier( (IToken)tokens.next(), "x");
|
||||
validateToken( (IToken) tokens.next(), IToken.tSEMI );
|
||||
validateIdentifier( (IToken)tokens.next(), "x");
|
||||
validateToken( (IToken) tokens.next(), IToken.tBITORASSIGN );
|
||||
validateIdentifier( (IToken) tokens.next(), "y");
|
||||
validateToken( (IToken) tokens.next(), IToken.tSEMI );
|
||||
validateToken( (IToken) tokens.next(), IToken.tRBRACE );
|
||||
assertFalse( tokens.hasNext() );
|
||||
}
|
||||
/**
|
||||
* @param token
|
||||
* @param string
|
||||
*/
|
||||
private void validateIdentifier(IToken token, String identifierName ) {
|
||||
validateToken( token, IToken.tIDENTIFIER);
|
||||
assertEquals( token.getImage(), identifierName );
|
||||
}
|
||||
/**
|
||||
* @param token
|
||||
* @param i
|
||||
*/
|
||||
private void validateToken(IToken token, int signal) {
|
||||
assertEquals( token.getType(), signal );
|
||||
}
|
||||
}
|
|
@ -5,13 +5,12 @@ import java.io.Writer;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||
|
@ -720,7 +719,7 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
validateToken(IToken.tSEMI);
|
||||
|
||||
IMacroDescriptor descriptor=
|
||||
(IMacroDescriptor) scanner.getDefinition("GO");
|
||||
scanner.getDefinition("GO");
|
||||
List parms= descriptor.getParameters();
|
||||
assertNotNull(parms);
|
||||
assertTrue(parms.size() == 1);
|
||||
|
@ -769,7 +768,7 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
validateToken(IToken.tSEMI);
|
||||
validateEOF();
|
||||
|
||||
IMacroDescriptor macro= (IMacroDescriptor) scanner.getDefinition("SUM");
|
||||
IMacroDescriptor macro= scanner.getDefinition("SUM");
|
||||
List params= macro.getParameters();
|
||||
assertNotNull(params);
|
||||
assertTrue(params.size() == 7);
|
||||
|
@ -853,7 +852,7 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
}
|
||||
}
|
||||
|
||||
public void testQuickScan() throws EndOfFileException, ParserFactoryException
|
||||
public void testQuickScan() throws ParserFactoryError
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -929,7 +928,7 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
|
||||
}
|
||||
|
||||
public void testOtherPreprocessorCommands() throws ParserFactoryException
|
||||
public void testOtherPreprocessorCommands() throws ParserFactoryError
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1038,7 +1037,7 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
validateEOF();
|
||||
}
|
||||
|
||||
public void testBug35892() throws ParserFactoryException
|
||||
public void testBug35892() throws ParserFactoryError
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1069,7 +1068,7 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
validateString( "\\\"\\\\");
|
||||
}
|
||||
|
||||
public void testConditionalWithBraces() throws ParserFactoryException
|
||||
public void testConditionalWithBraces() throws ParserFactoryError
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1166,7 +1165,7 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
{
|
||||
initializeScanner( "#define X(Y)");
|
||||
validateEOF();
|
||||
IMacroDescriptor macro = (IMacroDescriptor)scanner.getDefinition( "X" );
|
||||
IMacroDescriptor macro = scanner.getDefinition( "X" );
|
||||
assertNotNull( macro );
|
||||
assertEquals( macro.getParameters().size(), 1 );
|
||||
assertEquals( (String)macro.getParameters().get(0), "Y" );
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.cdt.core.parser.ParserUtil;
|
|||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
|
@ -93,7 +93,7 @@ public class SourceIndexer extends AbstractIndexer {
|
|||
parser = ParserFactory.createParser(
|
||||
ParserFactory.createScanner( new StringReader( document.getStringContent() ), resourceFile.getLocation().toOSString(), scanInfo, ParserMode.COMPLETE_PARSE, language, requestor, ParserUtil.getParserLogService() ),
|
||||
requestor, ParserMode.COMPLETE_PARSE, language, ParserUtil.getParserLogService() );
|
||||
} catch( ParserFactoryException pfe )
|
||||
} catch( ParserFactoryError pfe )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
|||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
|
@ -131,7 +131,7 @@ public class CModelBuilder {
|
|||
language,
|
||||
ParserUtil.getParserLogService() );
|
||||
}
|
||||
catch( ParserFactoryException pfe )
|
||||
catch( ParserFactoryError pfe )
|
||||
{
|
||||
throw new ParserException( "Parser/Scanner construction failure.");
|
||||
}
|
||||
|
|
|
@ -1,9 +1,21 @@
|
|||
2004-01-15 John Camelon
|
||||
Renamed IASTNode.LookupResult IASTNode.ILookupResult.
|
||||
Introduced new ParseError exception for contextual parse() methods.
|
||||
Renamed ParserFactoryException ParserFactoryError.
|
||||
Replaced ParserNotImplementedException with a variant of ParseError.
|
||||
Updated IScanner & IParser to not reference OffsetLimitReachedException explicitly.
|
||||
Renamed ParserMode.CONTEXTUAL_PARSE to COMPLETION_PARSE.
|
||||
Cleaned up IMacroDescriptor and made Scanner definitions table consistent.
|
||||
Added IScanner.getDefinitions() to return the entire Map of definitions to a client.
|
||||
Removed most of the warnings from parser source directory.
|
||||
Removed the unused SyntaxErrorException.
|
||||
Provided partial fix for Bug 44370 IASTMacro requires more information for clients.
|
||||
|
||||
2004-01-12 John Camelon
|
||||
Fixed bug 48909 - Wrong completion node after a . or an ->
|
||||
Fixed bug 49702 - Wrong completion kind sent in const/dest and code blocks
|
||||
Added new CompletionKind - STATEMENT_START to indicate the beginning of a statement line.
|
||||
|
||||
|
||||
2004-01-08 Andrew Niefer
|
||||
fixing bug 43110 - Parser support needed for functions with ellipses
|
||||
Added IParameterizedSymbol.setHasVariableArgs() & hasVariableArgs()
|
||||
|
|
|
@ -1,19 +1,59 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2001 Rational Software Corp. 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:
|
||||
* Rational Software - initial implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
* To change this generated comment edit the template variable
|
||||
"typecomment":
|
||||
* Window>Preferences>Java>Templates.
|
||||
* To enable and disable the creation of type comments go to
|
||||
* Window>Preferences>Java>Code Generation.
|
||||
*/
|
||||
public interface IMacroDescriptor {
|
||||
void initialize(String name, List identifiers, List tokens, String sig);
|
||||
List getParameters();
|
||||
List getTokenizedExpansion();
|
||||
String getName();
|
||||
String getSignature();
|
||||
boolean compatible(IMacroDescriptor descriptor);
|
||||
|
||||
public static class MacroType extends Enum
|
||||
{
|
||||
// two kinds of macros as defined by ISO C++98
|
||||
|
||||
// object like - #define SYMBOL REPLACEMENT TOKENS
|
||||
public static final MacroType OBJECT_LIKE = new MacroType( 1 );
|
||||
|
||||
// function like - #define SYMBOL( parm1, parm2 ) TOKENS USING parms
|
||||
public static final MacroType FUNCTION_LIKE = new MacroType( 2 );
|
||||
|
||||
/**
|
||||
* @param enumValue
|
||||
*/
|
||||
protected MacroType(int enumValue) {
|
||||
super(enumValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// what kind of macro is it?
|
||||
public MacroType getMacroType();
|
||||
|
||||
// parameters for macros of type FUNCTION_LIKE
|
||||
public List getParameters();
|
||||
|
||||
// the RHS side of the macro separated into ITokens
|
||||
public List getTokenizedExpansion();
|
||||
|
||||
// the symbol name
|
||||
public String getName();
|
||||
|
||||
// the full preprocessor line of source that spawned this object
|
||||
public String getCompleteSignature();
|
||||
|
||||
// the RHS of the macro
|
||||
public String getExpansionSignature();
|
||||
|
||||
// similar to equals() but according to the C99 & C++98
|
||||
public boolean compatible(IMacroDescriptor descriptor);
|
||||
}
|
|
@ -29,15 +29,15 @@ public interface IParser {
|
|||
/**
|
||||
* Request a parse from a pre-configured parser to parse a whole translation unit or file.
|
||||
*
|
||||
* @return whether or not the parse was successful
|
||||
* @return whether or not the parse was successful
|
||||
*/
|
||||
public boolean parse();
|
||||
|
||||
/**
|
||||
* @param offset offset in the input file where code completion is being requested for
|
||||
* @return an IASTCompletionConstruct that provides a mechanism for determining C/C++ code completion contributions
|
||||
* @return an IASTCompletionConstruct that provides a mechanism for determining C/C++ code completion contributions
|
||||
*/
|
||||
public IASTCompletionNode parse( int offset )throws ParserNotImplementedException;
|
||||
public IASTCompletionNode parse( int offset ) throws ParseError;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -45,7 +45,7 @@ public interface IParser {
|
|||
* @param endingOffset
|
||||
* @return
|
||||
*/
|
||||
public IASTNode parse( int startingOffset, int endingOffset ) throws ParserNotImplementedException;
|
||||
public IASTNode parse( int startingOffset, int endingOffset ) throws ParseError;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.eclipse.cdt.core.parser;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||
|
||||
/**
|
||||
|
@ -16,25 +18,21 @@ public interface IScanner {
|
|||
public void setASTFactory( IASTFactory f );
|
||||
public void addDefinition(String key, IMacroDescriptor macroToBeAdded );
|
||||
public void addDefinition(String key, String value);
|
||||
public Object getDefinition(String key);
|
||||
public IMacroDescriptor getDefinition(String key);
|
||||
public Map getDefinitions();
|
||||
|
||||
public String[] getIncludePaths();
|
||||
public void addIncludePath(String includePath);
|
||||
public void overwriteIncludePath( String [] newIncludePaths );
|
||||
|
||||
public IToken nextToken() throws ScannerException, EndOfFileException, OffsetLimitReachedException;
|
||||
public IToken nextToken( boolean next ) throws ScannerException, EndOfFileException, OffsetLimitReachedException;
|
||||
public IToken nextToken() throws ScannerException, EndOfFileException;
|
||||
public IToken nextToken( boolean next ) throws ScannerException, EndOfFileException;
|
||||
|
||||
public int getCount();
|
||||
public int getDepth();
|
||||
|
||||
public IToken nextTokenForStringizing() throws ScannerException, EndOfFileException, OffsetLimitReachedException;
|
||||
public IToken nextTokenForStringizing() throws ScannerException, EndOfFileException;
|
||||
public void setTokenizingMacroReplacementList(boolean b);
|
||||
public void setThrowExceptionOnBadCharacterRead( boolean throwOnBad );
|
||||
|
||||
/**
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public int getLineNumberForOffset(int i);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/**********************************************************************
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class ParseError extends Error {
|
||||
|
||||
private final ParseErrorKind errorKind;
|
||||
|
||||
public static class ParseErrorKind extends Enum
|
||||
{
|
||||
// the method called is not implemented in this particular implementation
|
||||
public static final ParseErrorKind METHOD_NOT_IMPLEMENTED = new ParseErrorKind( 0 );
|
||||
|
||||
// offset specified is within a section of code #if'd out by the preprocessor
|
||||
// semantic context cannot be provided in this case
|
||||
public static final ParseErrorKind OFFSET_PREPROCESSED_OUT = new ParseErrorKind( 1 );
|
||||
|
||||
// offset range specified is not a valid identifier or qualified name
|
||||
// semantic context cannot be provided in this case
|
||||
public static final ParseErrorKind OFFSET_RANGE_NOT_NAME = new ParseErrorKind( 2 );
|
||||
|
||||
/**
|
||||
* @param enumValue
|
||||
*/
|
||||
protected ParseErrorKind(int enumValue) {
|
||||
super(enumValue);
|
||||
}
|
||||
}
|
||||
|
||||
public ParseErrorKind getErrorKind()
|
||||
{
|
||||
return errorKind;
|
||||
}
|
||||
|
||||
public ParseError( ParseErrorKind kind )
|
||||
{
|
||||
errorKind = kind;
|
||||
}
|
||||
}
|
|
@ -40,10 +40,10 @@ public class ParserFactory {
|
|||
return new CompleteParseASTFactory( language );
|
||||
}
|
||||
|
||||
public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode, ParserLanguage language, IParserLogService log ) throws ParserFactoryException
|
||||
public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode, ParserLanguage language, IParserLogService log ) throws ParserFactoryError
|
||||
{
|
||||
if( scanner == null ) throw new ParserFactoryException( ParserFactoryException.Kind.NULL_SCANNER );
|
||||
if( language == null ) throw new ParserFactoryException( ParserFactoryException.Kind.NULL_LANGUAGE );
|
||||
if( scanner == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_SCANNER );
|
||||
if( language == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_LANGUAGE );
|
||||
IParserLogService logService = ( log == null ) ? createDefaultLogService() : log;
|
||||
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
|
||||
ISourceElementRequestor ourCallback = (( callback == null) ? new NullSourceElementRequestor() : callback );
|
||||
|
@ -51,18 +51,20 @@ public class ParserFactory {
|
|||
return new CompleteParser( scanner, ourCallback, language, logService );
|
||||
else if( ourMode == ParserMode.STRUCTURAL_PARSE )
|
||||
return new StructuralParser( scanner, ourCallback, language, logService );
|
||||
else if( ourMode == ParserMode.CONTEXTUAL_PARSE )
|
||||
else if( ourMode == ParserMode.COMPLETION_PARSE )
|
||||
return new ContextualParser( scanner, ourCallback, language, logService );
|
||||
else if( ourMode == ParserMode.SELECTION_PARSE )
|
||||
return null; // TODO Implementation required
|
||||
else
|
||||
return new QuickParser( scanner, ourCallback, language, logService );
|
||||
}
|
||||
|
||||
public static IScanner createScanner( Reader input, String fileName, IScannerInfo config, ParserMode mode, ParserLanguage language, ISourceElementRequestor requestor, IParserLogService log ) throws ParserFactoryException
|
||||
public static IScanner createScanner( Reader input, String fileName, IScannerInfo config, ParserMode mode, ParserLanguage language, ISourceElementRequestor requestor, IParserLogService log ) throws ParserFactoryError
|
||||
{
|
||||
if( input == null ) throw new ParserFactoryException( ParserFactoryException.Kind.NULL_READER );
|
||||
if( fileName == null ) throw new ParserFactoryException( ParserFactoryException.Kind.NULL_FILENAME );
|
||||
if( config == null ) throw new ParserFactoryException( ParserFactoryException.Kind.NULL_CONFIG );
|
||||
if( language == null ) throw new ParserFactoryException( ParserFactoryException.Kind.NULL_LANGUAGE );
|
||||
if( input == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_READER );
|
||||
if( fileName == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_FILENAME );
|
||||
if( config == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_CONFIG );
|
||||
if( language == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_LANGUAGE );
|
||||
IParserLogService logService = ( log == null ) ? createDefaultLogService() : log;
|
||||
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
|
||||
ISourceElementRequestor ourRequestor = (( requestor == null) ? new NullSourceElementRequestor() : requestor );
|
||||
|
|
|
@ -14,7 +14,7 @@ package org.eclipse.cdt.core.parser;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ParserFactoryException extends Exception {
|
||||
public class ParserFactoryError extends Error {
|
||||
|
||||
public static class Kind extends Enum {
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class ParserFactoryException extends Exception {
|
|||
}
|
||||
}
|
||||
|
||||
public ParserFactoryException( Kind e )
|
||||
public ParserFactoryError( Kind e )
|
||||
{
|
||||
kind = e;
|
||||
}
|
|
@ -26,7 +26,12 @@ public class ParserMode extends Enum {
|
|||
public static final ParserMode QUICK_PARSE = new ParserMode( 3 );
|
||||
|
||||
// follow inclusions, parse function/method bodies, stop at particular offset
|
||||
public static final ParserMode CONTEXTUAL_PARSE = new ParserMode( 4 );
|
||||
// provide optimized lookup capability for querying symbols
|
||||
public static final ParserMode COMPLETION_PARSE = new ParserMode( 4 );
|
||||
|
||||
// follow inclusions, parse function/method bodies, stop at particular offset
|
||||
// provide specific semantic information about an offset range or selection
|
||||
public static final ParserMode SELECTION_PARSE = new ParserMode( 5 );
|
||||
|
||||
protected ParserMode( int value )
|
||||
{
|
||||
|
|
|
@ -1,18 +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.core.parser;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class ParserNotImplementedException extends Exception {
|
||||
|
||||
}
|
|
@ -1,29 +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.core.parser;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class SyntaxErrorException extends Exception {
|
||||
|
||||
private final IProblem problem;
|
||||
|
||||
public IProblem getProblem()
|
||||
{
|
||||
return problem;
|
||||
}
|
||||
|
||||
public SyntaxErrorException( IProblem problem )
|
||||
{
|
||||
this.problem = problem;
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.core.parser.ast;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
||||
|
@ -26,7 +27,7 @@ public interface IASTFactory
|
|||
String name,
|
||||
int startingOffset,
|
||||
int nameOffset,
|
||||
int nameEndOffset, int endingOffset);
|
||||
int nameEndOffset, int endingOffset, IMacroDescriptor info);
|
||||
|
||||
public IASTInclusion createInclusion(
|
||||
String name,
|
||||
|
|
|
@ -10,14 +10,14 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.ast;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTMacro extends IASTOffsetableNamedElement, ISourceElementCallbackDelegate {
|
||||
public interface IASTMacro extends IASTOffsetableNamedElement, ISourceElementCallbackDelegate, IMacroDescriptor {
|
||||
|
||||
public String getName();
|
||||
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@ public interface IASTNode {
|
|||
*/
|
||||
protected LookupKind(int enumValue) {
|
||||
super(enumValue);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +52,7 @@ public interface IASTNode {
|
|||
{
|
||||
}
|
||||
|
||||
public static interface LookupResult
|
||||
public static interface ILookupResult
|
||||
{
|
||||
public String getPrefix();
|
||||
public Iterator getNodes();
|
||||
|
@ -67,6 +66,6 @@ public interface IASTNode {
|
|||
* @return
|
||||
* @throws LookupException
|
||||
*/
|
||||
public LookupResult lookup( String prefix, LookupKind[] kind, IASTNode context) throws LookupException;
|
||||
public ILookupResult lookup( String prefix, LookupKind[] kind, IASTNode context) throws LookupException;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,10 +15,10 @@ import org.eclipse.cdt.core.parser.EndOfFileException;
|
|||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParseError;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ParserNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
|
@ -57,15 +57,15 @@ public class CompleteParser extends Parser {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParser#parse(int)
|
||||
*/
|
||||
public IASTCompletionNode parse(int offset) throws ParserNotImplementedException {
|
||||
throw new ParserNotImplementedException();
|
||||
public IASTCompletionNode parse(int offset) throws ParseError {
|
||||
throw new ParseError( ParseError.ParseErrorKind.METHOD_NOT_IMPLEMENTED );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParser#parse(int, int)
|
||||
*/
|
||||
public IASTNode parse(int startingOffset, int endingOffset) throws ParserNotImplementedException {
|
||||
throw new ParserNotImplementedException();
|
||||
public IASTNode parse(int startingOffset, int endingOffset) throws ParseError {
|
||||
throw new ParseError( ParseError.ParseErrorKind.METHOD_NOT_IMPLEMENTED );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
|||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ParserNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
|
@ -59,7 +58,7 @@ public class ContextualParser extends Parser implements IParser {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParser#parse(int)
|
||||
*/
|
||||
public IASTCompletionNode parse(int offset) throws ParserNotImplementedException {
|
||||
public IASTCompletionNode parse(int offset) {
|
||||
scanner.setOffsetBoundary(offset);
|
||||
boundaryOffset = offset;
|
||||
translationUnit();
|
||||
|
@ -123,7 +122,7 @@ public class ContextualParser extends Parser implements IParser {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParser#parse(int, int)
|
||||
*/
|
||||
public IASTNode parse(int startingOffset, int endingOffset) throws ParserNotImplementedException {
|
||||
public IASTNode parse(int startingOffset, int endingOffset) {
|
||||
scanner.setOffsetBoundary(endingOffset);
|
||||
translationUnit();
|
||||
return getCompletionContext();
|
||||
|
@ -165,7 +164,7 @@ public class ContextualParser extends Parser implements IParser {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.Parser#handleOffsetLimitException()
|
||||
*/
|
||||
protected void handleOffsetLimitException(OffsetLimitReachedException exception) throws EndOfFileException, OffsetLimitReachedException {
|
||||
protected void handleOffsetLimitException(OffsetLimitReachedException exception) throws OffsetLimitReachedException {
|
||||
setCompletionToken( exception.getFinalToken() );
|
||||
if( (finalToken!= null )&& (finalToken.getEndOffset() != boundaryOffset ))
|
||||
setCompletionToken(null);
|
||||
|
|
|
@ -16,11 +16,7 @@ import java.util.List;
|
|||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
|
||||
public class MacroDescriptor implements IMacroDescriptor {
|
||||
|
||||
public MacroDescriptor()
|
||||
{
|
||||
}
|
||||
public class FunctionMacroDescriptor implements IMacroDescriptor {
|
||||
|
||||
/**
|
||||
* Method initialize.
|
||||
|
@ -31,18 +27,20 @@ public class MacroDescriptor implements IMacroDescriptor {
|
|||
* RHS expansion in the macro definition.
|
||||
* @param sig The complete signature of the macro, as a string.
|
||||
*/
|
||||
public void initialize( String name, List identifiers, List tokens, String sig )
|
||||
public FunctionMacroDescriptor( String name, List identifiers, List tokens, String fullSignature, String expansionSignature )
|
||||
{
|
||||
this.name = name;
|
||||
identifierParameters = identifiers;
|
||||
tokenizedExpansion = tokens;
|
||||
signature = sig;
|
||||
signature = fullSignature;
|
||||
this.expansionSignature = expansionSignature;
|
||||
}
|
||||
|
||||
private String name;
|
||||
private List identifierParameters;
|
||||
private List tokenizedExpansion;
|
||||
private String signature;
|
||||
private String expansionSignature;
|
||||
/**
|
||||
* Returns the identifiers.
|
||||
* @return List
|
||||
|
@ -102,7 +100,7 @@ public class MacroDescriptor implements IMacroDescriptor {
|
|||
* Returns the signature.
|
||||
* @return String
|
||||
*/
|
||||
public final String getSignature()
|
||||
public final String getCompleteSignature()
|
||||
{
|
||||
return signature;
|
||||
}
|
||||
|
@ -114,6 +112,7 @@ public class MacroDescriptor implements IMacroDescriptor {
|
|||
if( descriptor.getName() == null ) return false;
|
||||
if( descriptor.getTokenizedExpansion() == null ) return false;
|
||||
if( descriptor.getParameters() == null ) return false;
|
||||
if( descriptor.getMacroType() != getMacroType() ) return false;
|
||||
if( ! name.equals( descriptor.getName() )) return false;
|
||||
if( descriptor.getParameters().size() != identifierParameters.size() ) return false;
|
||||
if( descriptor.getTokenizedExpansion().size() != tokenizedExpansion.size() ) return false;
|
||||
|
@ -123,4 +122,18 @@ public class MacroDescriptor implements IMacroDescriptor {
|
|||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getMacroType()
|
||||
*/
|
||||
public MacroType getMacroType() {
|
||||
return MacroType.FUNCTION_LIKE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getExpansionSignature()
|
||||
*/
|
||||
public String getExpansionSignature() {
|
||||
return expansionSignature;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
/**********************************************************************
|
||||
* 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class ObjectMacroDescriptor implements IMacroDescriptor {
|
||||
|
||||
private static final List EMPTY_LIST = new ArrayList();
|
||||
private final String fullSignature, expansionSignature;
|
||||
private final String name;
|
||||
private final List tokenizedExpansion;
|
||||
|
||||
public ObjectMacroDescriptor( String name, String signature, List tokenizedExpansion, String expansionSignature )
|
||||
{
|
||||
this.name = name;
|
||||
this.tokenizedExpansion = tokenizedExpansion;
|
||||
this.fullSignature = signature;
|
||||
this.expansionSignature = expansionSignature;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getMacroType()
|
||||
*/
|
||||
public MacroType getMacroType() {
|
||||
return MacroType.OBJECT_LIKE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getParameters()
|
||||
*/
|
||||
public List getParameters() {
|
||||
return EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getTokenizedExpansion()
|
||||
*/
|
||||
public List getTokenizedExpansion() {
|
||||
return tokenizedExpansion;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getSignature()
|
||||
*/
|
||||
public String getCompleteSignature() {
|
||||
return fullSignature;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#compatible(org.eclipse.cdt.core.parser.IMacroDescriptor)
|
||||
*/
|
||||
public boolean compatible(IMacroDescriptor descriptor) {
|
||||
if( descriptor.getName() == null ) return false;
|
||||
if( descriptor.getMacroType() != getMacroType() ) return false;
|
||||
if( descriptor.getTokenizedExpansion() == null ) return false;
|
||||
if( ! name.equals( descriptor.getName() )) return false;
|
||||
if( descriptor.getTokenizedExpansion().size() != tokenizedExpansion.size() ) return false;
|
||||
|
||||
if( ! (descriptor.getTokenizedExpansion().containsAll( tokenizedExpansion ))) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getExpansionSignature()
|
||||
*/
|
||||
public String getExpansionSignature() {
|
||||
return expansionSignature;
|
||||
}
|
||||
|
||||
}
|
|
@ -1326,7 +1326,7 @@ public abstract class Parser implements IParser
|
|||
|| (LT(3) != IToken.tLPAREN && LT(3) != IToken.tASSIGN))
|
||||
&& !LA(2).isPointer());
|
||||
}
|
||||
private void callbackSimpleDeclToken(Flags flags) throws BacktrackException, EndOfFileException
|
||||
private void callbackSimpleDeclToken(Flags flags) throws EndOfFileException
|
||||
{
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
|
@ -1624,16 +1624,16 @@ public abstract class Parser implements IParser
|
|||
ASTClassKind eck = null;
|
||||
switch (t.getType())
|
||||
{
|
||||
case Token.t_class :
|
||||
case IToken.t_class :
|
||||
eck = ASTClassKind.CLASS;
|
||||
break;
|
||||
case Token.t_struct :
|
||||
case IToken.t_struct :
|
||||
eck = ASTClassKind.STRUCT;
|
||||
break;
|
||||
case Token.t_union :
|
||||
case IToken.t_union :
|
||||
eck = ASTClassKind.UNION;
|
||||
break;
|
||||
case Token.t_enum :
|
||||
case IToken.t_enum :
|
||||
eck = ASTClassKind.ENUM;
|
||||
break;
|
||||
default :
|
||||
|
@ -1794,14 +1794,11 @@ public abstract class Parser implements IParser
|
|||
case IToken.tIDENTIFIER :
|
||||
last = consume(IToken.tIDENTIFIER);
|
||||
IToken secondMark = null;
|
||||
try
|
||||
{
|
||||
if( queryLookaheadCapability() )
|
||||
secondMark = mark();
|
||||
}
|
||||
catch( OffsetLimitReachedException olre )
|
||||
{
|
||||
else
|
||||
return new TokenDuple(last, last);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
last = consumeTemplateParameters(last);
|
||||
|
@ -2514,7 +2511,7 @@ public abstract class Parser implements IParser
|
|||
}
|
||||
if ( LT(1) == IToken.tSTAR)
|
||||
{
|
||||
result = consume(Token.tSTAR); // tokenType = "*"
|
||||
result = consume(IToken.tSTAR); // tokenType = "*"
|
||||
|
||||
d.setPointerOperatorName(nameDuple);
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.eclipse.cdt.core.parser.IParserLogService;
|
|||
import org.eclipse.cdt.core.parser.IPreprocessor;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerException;
|
||||
|
@ -50,11 +49,6 @@ public class Preprocessor extends Scanner implements IPreprocessor {
|
|||
// callback IProblem here
|
||||
log.errorLog("Preprocessor Exception "+ se.getProblem().getMessage()); //$NON-NLS-1$h
|
||||
}
|
||||
catch( OffsetLimitReachedException olre )
|
||||
{
|
||||
// callback IProblem here
|
||||
log.errorLog("Preprocessor Exception "+ olre.getMessage()); //$NON-NLS-1$h
|
||||
}
|
||||
catch( EndOfFileException eof )
|
||||
{
|
||||
// expected
|
||||
|
|
|
@ -15,10 +15,11 @@ import org.eclipse.cdt.core.parser.EndOfFileException;
|
|||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParseError;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ParserNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ParseError.ParseErrorKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
|
@ -54,15 +55,15 @@ public class QuickParser extends Parser {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParser#parse(int)
|
||||
*/
|
||||
public IASTCompletionNode parse(int offset) throws ParserNotImplementedException {
|
||||
throw new ParserNotImplementedException();
|
||||
public IASTCompletionNode parse(int offset) throws ParseError {
|
||||
throw new ParseError( ParseErrorKind.METHOD_NOT_IMPLEMENTED );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParser#parse(int, int)
|
||||
*/
|
||||
public IASTNode parse(int startingOffset, int endingOffset) throws ParserNotImplementedException {
|
||||
throw new ParserNotImplementedException();
|
||||
public IASTNode parse(int startingOffset, int endingOffset) throws ParseError {
|
||||
throw new ParseError( ParseErrorKind.METHOD_NOT_IMPLEMENTED );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,11 +41,12 @@ import org.eclipse.cdt.core.parser.Keywords;
|
|||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerException;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IMacroDescriptor.MacroType;
|
||||
import org.eclipse.cdt.core.parser.ast.ExpressionEvaluationException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||
|
@ -67,6 +68,7 @@ public class Scanner implements IScanner {
|
|||
private final String filename;
|
||||
private final Reader reader;
|
||||
protected IToken finalToken;
|
||||
private static final boolean NEW_STRATEGY = true;
|
||||
|
||||
protected void handleProblem( int problemID, String argument, int beginningOffset, boolean warning, boolean error ) throws ScannerException
|
||||
{
|
||||
|
@ -110,7 +112,25 @@ public class Scanner implements IScanner {
|
|||
|
||||
originalConfig = info;
|
||||
if( info.getDefinedSymbols() != null )
|
||||
definitions.putAll( info.getDefinedSymbols() );
|
||||
{
|
||||
if( NEW_STRATEGY )
|
||||
{
|
||||
Iterator i = info.getDefinedSymbols().keySet().iterator();
|
||||
Map m = info.getDefinedSymbols();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
String symbolName = (String) i.next();
|
||||
Object value = m.get( symbolName );
|
||||
|
||||
if( value instanceof String )
|
||||
addDefinition( symbolName, (String) value);
|
||||
else if( value instanceof IMacroDescriptor )
|
||||
addDefinition( symbolName, (IMacroDescriptor)value);
|
||||
}
|
||||
}
|
||||
else
|
||||
definitions.putAll( info.getDefinedSymbols() );
|
||||
}
|
||||
|
||||
if( info.getIncludePaths() != null )
|
||||
overwriteIncludePath( info.getIncludePaths() );
|
||||
|
@ -165,11 +185,23 @@ public class Scanner implements IScanner {
|
|||
}
|
||||
|
||||
public void addDefinition(String key, String value) {
|
||||
definitions.put(key, value);
|
||||
if( NEW_STRATEGY )
|
||||
{
|
||||
StringBuffer signatureBuffer = new StringBuffer();
|
||||
signatureBuffer.append( key );
|
||||
signatureBuffer.append( ' ');
|
||||
signatureBuffer.append( value );
|
||||
|
||||
addDefinition(key,
|
||||
new ObjectMacroDescriptor( key, signatureBuffer.toString(),
|
||||
tokenizeReplacementString( NO_OFFSET_LIMIT, key, value, null ), value ));
|
||||
}
|
||||
else
|
||||
definitions.put(key, value);
|
||||
}
|
||||
|
||||
public final Object getDefinition(String key) {
|
||||
return definitions.get(key);
|
||||
public final IMacroDescriptor getDefinition(String key) {
|
||||
return (IMacroDescriptor) definitions.get(key);
|
||||
}
|
||||
|
||||
public final String[] getIncludePaths() {
|
||||
|
@ -442,7 +474,7 @@ public class Scanner implements IScanner {
|
|||
private IScannerInfo originalConfig;
|
||||
private List includePathNames = new ArrayList();
|
||||
private List includePaths = new ArrayList();
|
||||
private Hashtable definitions = new Hashtable();
|
||||
private Map definitions = new Hashtable();
|
||||
private StringBuffer storageBuffer = null;
|
||||
|
||||
private int count = 0;
|
||||
|
@ -695,15 +727,15 @@ public class Scanner implements IScanner {
|
|||
getChar();
|
||||
}
|
||||
|
||||
public IToken nextToken() throws ScannerException, EndOfFileException, OffsetLimitReachedException {
|
||||
public IToken nextToken() throws ScannerException, EndOfFileException {
|
||||
return nextToken( true, false );
|
||||
}
|
||||
|
||||
public IToken nextToken(boolean pasting) throws ScannerException, EndOfFileException, OffsetLimitReachedException {
|
||||
public IToken nextToken(boolean pasting) throws ScannerException, EndOfFileException {
|
||||
return nextToken( pasting, false );
|
||||
}
|
||||
|
||||
public IToken nextToken( boolean pasting, boolean lookingForNextAlready ) throws ScannerException, EndOfFileException, OffsetLimitReachedException
|
||||
public IToken nextToken( boolean pasting, boolean lookingForNextAlready ) throws ScannerException, EndOfFileException
|
||||
{
|
||||
if( ! initialContextInitialized )
|
||||
setupInitialContext();
|
||||
|
@ -860,7 +892,7 @@ public class Scanner implements IScanner {
|
|||
continue;
|
||||
}
|
||||
|
||||
Object mapping = definitions.get(ident);
|
||||
IMacroDescriptor mapping = getDefinition(ident);
|
||||
|
||||
if (mapping != null) {
|
||||
if( contextStack.shouldExpandDefinition( POUND_DEFINE + ident ) ) {
|
||||
|
@ -1148,11 +1180,7 @@ public class Scanner implements IScanner {
|
|||
continue;
|
||||
}
|
||||
skipOverWhitespace();
|
||||
// definition
|
||||
String toBeUndefined = getNextIdentifier();
|
||||
|
||||
definitions.remove(toBeUndefined);
|
||||
|
||||
removeSymbol(getNextIdentifier());
|
||||
skipOverTextUntilNewline();
|
||||
c = getChar();
|
||||
continue;
|
||||
|
@ -1174,10 +1202,7 @@ public class Scanner implements IScanner {
|
|||
|
||||
case PreprocessorDirectives.IFDEF :
|
||||
skipOverWhitespace();
|
||||
String definition = getNextIdentifier();
|
||||
Object mapping = definitions.get(definition);
|
||||
|
||||
if (mapping == null) {
|
||||
if (getDefinition(getNextIdentifier()) == null) {
|
||||
// not defined
|
||||
passOnToClient = branches.poundif( false );
|
||||
skipOverTextUntilNewline();
|
||||
|
@ -1197,10 +1222,7 @@ public class Scanner implements IScanner {
|
|||
|
||||
case PreprocessorDirectives.IFNDEF :
|
||||
skipOverWhitespace();
|
||||
String def = getNextIdentifier();
|
||||
Object map = definitions.get(def);
|
||||
|
||||
if (map != null) {
|
||||
if (getDefinition(getNextIdentifier()) != null) {
|
||||
// not defined
|
||||
skipOverTextUntilNewline();
|
||||
passOnToClient = branches.poundif( false );
|
||||
|
@ -1624,6 +1646,13 @@ public class Scanner implements IScanner {
|
|||
|
||||
|
||||
/**
|
||||
* @param key
|
||||
*/
|
||||
protected void removeSymbol(String key) {
|
||||
definitions.remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected void handlePragmaOperator() throws ScannerException
|
||||
|
@ -1684,11 +1713,11 @@ public class Scanner implements IScanner {
|
|||
}
|
||||
|
||||
|
||||
protected static class endOfMacroTokenException extends Exception {};
|
||||
protected static class endOfMacroTokenException extends Exception {}
|
||||
// the static instance we always use
|
||||
protected static endOfMacroTokenException endOfMacroToken = new endOfMacroTokenException();
|
||||
|
||||
public IToken nextTokenForStringizing() throws ScannerException, EndOfFileException, OffsetLimitReachedException
|
||||
public IToken nextTokenForStringizing() throws ScannerException, EndOfFileException
|
||||
{
|
||||
int beginOffset = getCurrentOffset();
|
||||
int c = getChar();
|
||||
|
@ -1973,7 +2002,7 @@ public class Scanner implements IScanner {
|
|||
new ScannerInfo( definitions, originalConfig.getIncludePaths()),
|
||||
ParserMode.QUICK_PARSE, language, nullCallback, log );
|
||||
parser = ParserFactory.createParser(trial, nullCallback, ParserMode.QUICK_PARSE, language, log );
|
||||
} catch( ParserFactoryException pfe )
|
||||
} catch( ParserFactoryError pfe )
|
||||
{
|
||||
handleInternalError();
|
||||
}
|
||||
|
@ -2078,9 +2107,6 @@ public class Scanner implements IScanner {
|
|||
|
||||
try {
|
||||
t = helperScanner.nextToken(false);
|
||||
} catch (OffsetLimitReachedException e) {
|
||||
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#include " + includeLine, beginningOffset, false, true, true );
|
||||
return;
|
||||
} catch (EndOfFileException eof) {
|
||||
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#include " + includeLine, beginningOffset, false, true, true );
|
||||
return;
|
||||
|
@ -2128,9 +2154,6 @@ public class Scanner implements IScanner {
|
|||
} else
|
||||
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#include " + includeLine, beginningOffset, false, true, true );
|
||||
}
|
||||
catch (OffsetLimitReachedException e) {
|
||||
handleInternalError();
|
||||
}
|
||||
catch( EndOfFileException eof )
|
||||
{
|
||||
// good
|
||||
|
@ -2173,19 +2196,20 @@ public class Scanner implements IScanner {
|
|||
handleInclusion(f.trim(), useIncludePath, startOffset, beginningOffset, endOffset);
|
||||
}
|
||||
|
||||
protected static final Hashtable emptyMap = new Hashtable();
|
||||
protected Hashtable holderMap = null;
|
||||
protected static final Hashtable EMPTY_MAP = new Hashtable();
|
||||
protected static final List EMPTY_LIST = new ArrayList();
|
||||
protected Map definitionsBackupMap = null;
|
||||
|
||||
protected void temporarilyReplaceDefinitionsMap()
|
||||
{
|
||||
holderMap = definitions;
|
||||
definitions = emptyMap;
|
||||
definitionsBackupMap = definitions;
|
||||
definitions = EMPTY_MAP;
|
||||
}
|
||||
|
||||
protected void restoreDefinitionsMap()
|
||||
{
|
||||
definitions = holderMap;
|
||||
holderMap = null;
|
||||
definitions = definitionsBackupMap;
|
||||
definitionsBackupMap = null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2198,15 +2222,81 @@ public class Scanner implements IScanner {
|
|||
forInclusion = b;
|
||||
}
|
||||
|
||||
protected void poundDefine(int beginning) throws ScannerException, EndOfFileException {
|
||||
protected List tokenizeReplacementString( int beginning, String key, String replacementString, List parameterIdentifiers )
|
||||
{
|
||||
List macroReplacementTokens = new ArrayList();
|
||||
if( replacementString.trim().equals( "" ) )
|
||||
return macroReplacementTokens;
|
||||
IScanner helperScanner=null;
|
||||
try {
|
||||
helperScanner =
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(replacementString),
|
||||
SCRATCH,
|
||||
new ScannerInfo(),
|
||||
mode,
|
||||
language,
|
||||
new NullSourceElementRequestor(), log);
|
||||
} catch (ParserFactoryError e1) {
|
||||
}
|
||||
helperScanner.setTokenizingMacroReplacementList( true );
|
||||
IToken t = null;
|
||||
try {
|
||||
t = helperScanner.nextToken(false);
|
||||
} catch (ScannerException e) {
|
||||
} catch (EndOfFileException e) {
|
||||
}
|
||||
|
||||
if( t == null )
|
||||
return macroReplacementTokens;
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
//each # preprocessing token in the replacement list shall be followed
|
||||
//by a parameter as the next reprocessing token in the list
|
||||
if( t.getType() == tPOUND ){
|
||||
macroReplacementTokens.add( t );
|
||||
t = helperScanner.nextToken(false);
|
||||
if( parameterIdentifiers != null )
|
||||
{
|
||||
int index = parameterIdentifiers.indexOf(t.getImage());
|
||||
if (index == -1 ) {
|
||||
//not found
|
||||
|
||||
if( beginning != NO_OFFSET_LIMIT )
|
||||
{
|
||||
handleProblem( IProblem.PREPROCESSOR_MACRO_PASTING_ERROR, "#define " + key + " " + replacementString,
|
||||
beginning, false, true, true );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
macroReplacementTokens.add(t);
|
||||
t = helperScanner.nextToken(false);
|
||||
}
|
||||
}
|
||||
catch( EndOfFileException eof )
|
||||
{
|
||||
}
|
||||
catch( ScannerException sc )
|
||||
{
|
||||
}
|
||||
|
||||
return macroReplacementTokens;
|
||||
}
|
||||
|
||||
|
||||
protected void poundDefine(int beginning) throws ScannerException {
|
||||
skipOverWhitespace();
|
||||
// definition
|
||||
String key = getNextIdentifier();
|
||||
int offset = contextStack.getCurrentContext().getOffset() - key.length() - contextStack.getCurrentContext().undoStackSize();
|
||||
|
||||
// store the previous definition to check against later
|
||||
Object previousDefinition = definitions.get( key );
|
||||
|
||||
IMacroDescriptor previousDefinition = getDefinition( key );
|
||||
IMacroDescriptor descriptor = null;
|
||||
// get the next character
|
||||
// the C++ standard says that macros must not put
|
||||
// whitespace between the end of the definition
|
||||
|
@ -2253,67 +2343,21 @@ public class Scanner implements IScanner {
|
|||
|
||||
skipOverWhitespace();
|
||||
|
||||
ArrayList macroReplacementTokens = new ArrayList();
|
||||
List macroReplacementTokens = null;
|
||||
String replacementString = getRestOfPreprocessorLine();
|
||||
|
||||
if( ! replacementString.equals( "" ) )
|
||||
{
|
||||
IScanner helperScanner=null;
|
||||
try {
|
||||
helperScanner =
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(replacementString),
|
||||
SCRATCH,
|
||||
new ScannerInfo(),
|
||||
mode,
|
||||
language,
|
||||
new NullSourceElementRequestor(), log);
|
||||
} catch (ParserFactoryException e1) {
|
||||
}
|
||||
helperScanner.setTokenizingMacroReplacementList( true );
|
||||
IToken t = null;
|
||||
try {
|
||||
t = helperScanner.nextToken(false);
|
||||
} catch (OffsetLimitReachedException e2) {
|
||||
handleInternalError();
|
||||
}
|
||||
try {
|
||||
while (true) {
|
||||
//each # preprocessing token in the replacement list shall be followed
|
||||
//by a parameter as the next reprocessing token in the list
|
||||
if( t.getType() == tPOUND ){
|
||||
macroReplacementTokens.add( t );
|
||||
t = helperScanner.nextToken(false);
|
||||
int index = parameterIdentifiers.indexOf(t.getImage());
|
||||
if (index == -1 ) {
|
||||
//not found
|
||||
|
||||
handleProblem( IProblem.PREPROCESSOR_MACRO_PASTING_ERROR, "#define " + key + " " + replacementString,
|
||||
beginning, false, true, true );
|
||||
return;
|
||||
}
|
||||
}
|
||||
macroReplacementTokens = ( ! replacementString.equals( "" ) ) ?
|
||||
tokenizeReplacementString( beginning, key, replacementString, parameterIdentifiers ) :
|
||||
EMPTY_LIST;
|
||||
|
||||
macroReplacementTokens.add(t);
|
||||
t = helperScanner.nextToken(false);
|
||||
}
|
||||
}
|
||||
catch( OffsetLimitReachedException olre )
|
||||
{
|
||||
handleInternalError();
|
||||
}
|
||||
catch( EndOfFileException eof )
|
||||
{
|
||||
// good
|
||||
}
|
||||
}
|
||||
|
||||
IMacroDescriptor descriptor = new MacroDescriptor();
|
||||
descriptor.initialize(
|
||||
descriptor = new FunctionMacroDescriptor(
|
||||
key,
|
||||
parameterIdentifiers,
|
||||
macroReplacementTokens,
|
||||
key + "(" + parameters + ")");
|
||||
"#define " + key + "(" + parameters + ") " + replacementString,
|
||||
replacementString);
|
||||
|
||||
checkValidMacroRedefinition(key, previousDefinition, descriptor, beginning);
|
||||
addDefinition(key, descriptor);
|
||||
|
@ -2369,7 +2413,7 @@ public class Scanner implements IScanner {
|
|||
|
||||
try
|
||||
{
|
||||
astFactory.createMacro( key, beginning, offset, offset + key.length(), contextStack.getCurrentContext().getOffset() ).acceptElement( requestor );
|
||||
astFactory.createMacro( key, beginning, offset, offset + key.length(), contextStack.getCurrentContext().getOffset(), descriptor ).acceptElement( requestor );
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -2377,73 +2421,42 @@ public class Scanner implements IScanner {
|
|||
}
|
||||
}
|
||||
|
||||
protected void checkValidMacroRedefinition(
|
||||
String key,
|
||||
IMacroDescriptor previousDefinition,
|
||||
String newDefinition, int beginningOffset )
|
||||
throws ScannerException
|
||||
{
|
||||
IMacroDescriptor newMacro = new ObjectMacroDescriptor( key, key + ' ' + newDefinition,
|
||||
tokenizeReplacementString( NO_OFFSET_LIMIT, key, newDefinition, null ), newDefinition );
|
||||
checkValidMacroRedefinition( key, previousDefinition, newMacro, beginningOffset );
|
||||
}
|
||||
|
||||
|
||||
protected void checkValidMacroRedefinition(
|
||||
String key,
|
||||
String previousDefinition,
|
||||
String newDefinition, int beginningOffset )
|
||||
throws ScannerException
|
||||
{
|
||||
IMacroDescriptor prevMacro = new ObjectMacroDescriptor( key, key + ' ' + previousDefinition,
|
||||
tokenizeReplacementString( NO_OFFSET_LIMIT, key, previousDefinition, null ), previousDefinition );
|
||||
IMacroDescriptor newMacro = new ObjectMacroDescriptor( key, key + ' ' + newDefinition,
|
||||
tokenizeReplacementString( NO_OFFSET_LIMIT, key, newDefinition, null ), newDefinition );
|
||||
checkValidMacroRedefinition( key, prevMacro, newMacro, beginningOffset );
|
||||
}
|
||||
|
||||
|
||||
protected void checkValidMacroRedefinition(
|
||||
String key,
|
||||
Object previousDefinition,
|
||||
Object newDefinition, int beginningOffset )
|
||||
IMacroDescriptor previousDefinition,
|
||||
IMacroDescriptor newDefinition, int beginningOffset )
|
||||
throws ScannerException
|
||||
{
|
||||
if( mode != ParserMode.QUICK_PARSE && previousDefinition != null )
|
||||
{
|
||||
if( newDefinition instanceof IMacroDescriptor )
|
||||
{
|
||||
if( previousDefinition instanceof IMacroDescriptor )
|
||||
{
|
||||
if( ((IMacroDescriptor)previousDefinition).compatible( (IMacroDescriptor) newDefinition ) )
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if( newDefinition instanceof String )
|
||||
{
|
||||
if( previousDefinition instanceof String )
|
||||
{
|
||||
Scanner previous = new Scanner( new StringReader( (String)previousDefinition ), "redef-test", new ScannerInfo(), new NullSourceElementRequestor(),
|
||||
mode, language, log );
|
||||
Scanner current = new Scanner( new StringReader( (String)newDefinition ), "redef-test", new ScannerInfo(), new NullSourceElementRequestor(),
|
||||
mode, language, log );
|
||||
for ( ; ; )
|
||||
{
|
||||
IToken p = null;
|
||||
IToken c = null;
|
||||
try
|
||||
{
|
||||
p = previous.nextToken();
|
||||
c = current.nextToken();
|
||||
|
||||
if ( c.equals( p ) ) continue;
|
||||
break;
|
||||
|
||||
}
|
||||
catch( OffsetLimitReachedException olre )
|
||||
{
|
||||
handleInternalError();
|
||||
}
|
||||
catch( EndOfFileException eof )
|
||||
{
|
||||
if( ( p != null ) && ( c == null ) )
|
||||
break;
|
||||
if( p == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
c = current.nextToken();
|
||||
break;
|
||||
}
|
||||
catch( OffsetLimitReachedException olre )
|
||||
{
|
||||
handleInternalError();
|
||||
}
|
||||
catch( EndOfFileException eof2 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( previousDefinition.compatible( newDefinition ) )
|
||||
return;
|
||||
|
||||
handleProblem( IProblem.PREPROCESSOR_INVALID_MACRO_REDEFN, key, beginningOffset, false, true, true );
|
||||
}
|
||||
|
@ -2499,10 +2512,6 @@ public class Scanner implements IScanner {
|
|||
space = true;
|
||||
}
|
||||
}
|
||||
catch( OffsetLimitReachedException olre )
|
||||
{
|
||||
handleInternalError();
|
||||
}
|
||||
catch (EndOfFileException e) {
|
||||
// Good
|
||||
parameterValues.add(str);
|
||||
|
@ -2512,13 +2521,28 @@ public class Scanner implements IScanner {
|
|||
return parameterValues;
|
||||
}
|
||||
|
||||
protected void expandDefinition(String symbol, Object expansion, int symbolOffset)
|
||||
protected void expandDefinition(String symbol, String expansion, int symbolOffset ) throws ScannerException
|
||||
{
|
||||
StringBuffer fullSignatureBuffer = new StringBuffer();
|
||||
fullSignatureBuffer.append( symbol );
|
||||
fullSignatureBuffer.append( ' ');
|
||||
fullSignatureBuffer.append( expansion );
|
||||
List tokens = tokenizeReplacementString(NO_OFFSET_LIMIT, symbol, expansion, null );
|
||||
expandDefinition( symbol,
|
||||
new ObjectMacroDescriptor( symbol,
|
||||
fullSignatureBuffer.toString(),
|
||||
tokens,
|
||||
expansion ),
|
||||
symbolOffset);
|
||||
}
|
||||
|
||||
protected void expandDefinition(String symbol, IMacroDescriptor expansion, int symbolOffset)
|
||||
throws ScannerException
|
||||
{
|
||||
// All the tokens generated by the macro expansion
|
||||
// will have dimensions (offset and length) equal to the expanding symbol.
|
||||
if (expansion instanceof String ) {
|
||||
String replacementValue = (String) expansion;
|
||||
if ( expansion.getMacroType() == MacroType.OBJECT_LIKE ) {
|
||||
String replacementValue = expansion.getExpansionSignature();
|
||||
try
|
||||
{
|
||||
contextStack.updateContext( new StringReader(replacementValue), (POUND_DEFINE + symbol ), ScannerContext.ContextKind.MACROEXPANSION, null, requestor, symbolOffset, symbol.length());
|
||||
|
@ -2529,8 +2553,7 @@ public class Scanner implements IScanner {
|
|||
consumeUntilOutOfMacroExpansion();
|
||||
return;
|
||||
}
|
||||
} else if (expansion instanceof IMacroDescriptor ) {
|
||||
IMacroDescriptor macro = (IMacroDescriptor) expansion;
|
||||
} else if (expansion.getMacroType() == MacroType.FUNCTION_LIKE ) {
|
||||
skipOverWhitespace();
|
||||
int c = getChar();
|
||||
|
||||
|
@ -2562,8 +2585,8 @@ public class Scanner implements IScanner {
|
|||
|
||||
// create a string that represents what needs to be tokenized
|
||||
buffer = new StringBuffer();
|
||||
List tokens = macro.getTokenizedExpansion();
|
||||
List parameterNames = macro.getParameters();
|
||||
List tokens = expansion.getTokenizedExpansion();
|
||||
List parameterNames = expansion.getParameters();
|
||||
|
||||
if (parameterNames.size() != parameterValues.size())
|
||||
{
|
||||
|
@ -2595,7 +2618,7 @@ public class Scanner implements IScanner {
|
|||
t = (Token) tokens.get( ++i );
|
||||
int index = parameterNames.indexOf(t.image);
|
||||
if( index == -1 ){
|
||||
handleProblem( IProblem.PREPROCESSOR_MACRO_USAGE_ERROR, macro.getName(), getCurrentOffset(), false, true, true );
|
||||
handleProblem( IProblem.PREPROCESSOR_MACRO_USAGE_ERROR, expansion.getName(), getCurrentOffset(), false, true, true );
|
||||
return;
|
||||
} else {
|
||||
buffer.append('\"');
|
||||
|
@ -2652,7 +2675,7 @@ public class Scanner implements IScanner {
|
|||
{
|
||||
contextStack.updateContext(
|
||||
new StringReader(finalString),
|
||||
POUND_DEFINE + macro.getSignature(), ScannerContext.ContextKind.MACROEXPANSION, null, requestor, symbolOffset, endMacroOffset - symbolOffset + 1 );
|
||||
POUND_DEFINE + expansion.getCompleteSignature(), ScannerContext.ContextKind.MACROEXPANSION, null, requestor, symbolOffset, endMacroOffset - symbolOffset + 1 );
|
||||
}
|
||||
catch (ContextException e)
|
||||
{
|
||||
|
@ -2699,7 +2722,7 @@ public class Scanner implements IScanner {
|
|||
definitionIdentifier = getNextIdentifier();
|
||||
}
|
||||
|
||||
if (definitions.get(definitionIdentifier) != null)
|
||||
if (getDefinition(definitionIdentifier) != null)
|
||||
return "1";
|
||||
|
||||
return "0";
|
||||
|
@ -2746,4 +2769,12 @@ public class Scanner implements IScanner {
|
|||
public void setOffsetBoundary(int offset) {
|
||||
offsetLimit = offset;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IScanner#getDefinitions()
|
||||
*/
|
||||
public Map getDefinitions() {
|
||||
return definitions;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class StructuralParseCallback extends QuickParseCallback{
|
|||
|
||||
private void pushScope( IASTScope scope ){
|
||||
scopeStack.addFirst( currentScope );
|
||||
currentScope = (IASTScope)scope;
|
||||
currentScope = scope;
|
||||
}
|
||||
|
||||
private IASTScope popScope(){
|
||||
|
@ -73,10 +73,6 @@ public class StructuralParseCallback extends QuickParseCallback{
|
|||
return oldScope;
|
||||
}
|
||||
|
||||
private IASTScope peekAtScope(){
|
||||
return currentScope;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMacro(org.eclipse.cdt.core.parser.ast.IASTMacro)
|
||||
*/
|
||||
|
|
|
@ -16,10 +16,11 @@ import org.eclipse.cdt.core.parser.IParser;
|
|||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParseError;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ParserNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ParseError.ParseErrorKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
|
@ -62,15 +63,15 @@ public class StructuralParser extends Parser implements IParser {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParser#parse(int)
|
||||
*/
|
||||
public IASTCompletionNode parse(int offset) throws ParserNotImplementedException {
|
||||
throw new ParserNotImplementedException();
|
||||
public IASTCompletionNode parse(int offset) throws ParseError {
|
||||
throw new ParseError( ParseErrorKind.METHOD_NOT_IMPLEMENTED );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParser#parse(int, int)
|
||||
*/
|
||||
public IASTNode parse(int startingOffset, int endingOffset) throws ParserNotImplementedException {
|
||||
throw new ParserNotImplementedException();
|
||||
public IASTNode parse(int startingOffset, int endingOffset) throws ParseError {
|
||||
throw new ParseError( ParseErrorKind.METHOD_NOT_IMPLEMENTED );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.ast;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
||||
|
||||
|
@ -21,13 +24,16 @@ public class ASTMacro implements IASTMacro {
|
|||
|
||||
private int nameEndOffset = 0;
|
||||
private final String name;
|
||||
public ASTMacro( String name, int start, int end, int nameBeg, int nameEnd )
|
||||
private final IMacroDescriptor innerMacro;
|
||||
|
||||
public ASTMacro( String name, int start, int end, int nameBeg, int nameEnd, IMacroDescriptor info )
|
||||
{
|
||||
this.name =name;
|
||||
setStartingOffset(start);
|
||||
setNameOffset(nameBeg);
|
||||
setNameEndOffset(nameEnd);
|
||||
setEndingOffset(end);
|
||||
innerMacro = info;
|
||||
}
|
||||
|
||||
private int startingOffset = 0, endingOffset = 0, nameOffset = 0;
|
||||
|
@ -115,4 +121,40 @@ public class ASTMacro implements IASTMacro {
|
|||
{
|
||||
nameEndOffset = o;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getMacroType()
|
||||
*/
|
||||
public MacroType getMacroType() {
|
||||
return innerMacro.getMacroType();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getParameters()
|
||||
*/
|
||||
public List getParameters() {
|
||||
return innerMacro.getParameters();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getTokenizedExpansion()
|
||||
*/
|
||||
public List getTokenizedExpansion() {
|
||||
return innerMacro.getTokenizedExpansion();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getCompleteSignature()
|
||||
*/
|
||||
public String getCompleteSignature() {
|
||||
return innerMacro.getCompleteSignature();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getExpansionSignature()
|
||||
*/
|
||||
public String getExpansionSignature() {
|
||||
return innerMacro.getExpansionSignature();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#compatible(org.eclipse.cdt.core.parser.IMacroDescriptor)
|
||||
*/
|
||||
public boolean compatible(IMacroDescriptor descriptor) {
|
||||
return innerMacro.compatible(descriptor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.eclipse.cdt.core.parser.ast.IASTScopedElement;
|
|||
*/
|
||||
public class ASTQualifiedNamedElement implements IASTQualifiedNameElement
|
||||
{
|
||||
|
||||
/**
|
||||
* @param scope
|
||||
*/
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||
|
@ -33,8 +34,8 @@ public class BaseASTFactory {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createMacro(java.lang.String, int, int, int)
|
||||
*/
|
||||
public IASTMacro createMacro(String name, int startingOffset, int nameOffset, int nameEndOffset, int endingOffset) {
|
||||
IASTMacro m = new ASTMacro( name, startingOffset, endingOffset, nameOffset, nameEndOffset );
|
||||
public IASTMacro createMacro(String name, int startingOffset, int nameOffset, int nameEndOffset, int endingOffset, IMacroDescriptor info) {
|
||||
IASTMacro m = new ASTMacro( name, startingOffset, endingOffset, nameOffset, nameEndOffset, info );
|
||||
return m;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ 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.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||
|
@ -69,7 +68,6 @@ public class ASTBaseSpecifier implements IASTBaseSpecifier
|
|||
* @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getParentClassSpecifier()
|
||||
*/
|
||||
public IASTClassSpecifier getParentClassSpecifier()
|
||||
throws ASTNotImplementedException
|
||||
{
|
||||
return (IASTClassSpecifier)symbol.getASTExtension().getPrimaryDeclaration();
|
||||
}
|
||||
|
@ -86,7 +84,7 @@ public class ASTBaseSpecifier implements IASTBaseSpecifier
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTReferenceStore#processReferences()
|
||||
*/
|
||||
public void processReferences(ISourceElementRequestor requestor) throws ASTNotImplementedException
|
||||
public void processReferences(ISourceElementRequestor requestor)
|
||||
{
|
||||
referenceDelegate.processReferences(requestor);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.util.List;
|
|||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||
|
@ -69,7 +68,7 @@ public class ASTElaboratedTypeSpecifier extends ASTSymbol implements IASTElabora
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier#isResolved()
|
||||
*/
|
||||
public boolean isResolved() throws ASTNotImplementedException
|
||||
public boolean isResolved()
|
||||
{
|
||||
return ! getSymbol().isForwardDeclaration();
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ public class ASTFunction extends ASTScope implements IASTFunction
|
|||
private final ASTQualifiedNamedElement qualifiedName;
|
||||
private final List parameters;
|
||||
protected final ASTReferenceStore references;
|
||||
private final int nameEndOffset;
|
||||
private List declarations = new ArrayList();
|
||||
/**
|
||||
* @param symbol
|
||||
|
@ -59,7 +58,6 @@ public class ASTFunction extends ASTScope implements IASTFunction
|
|||
{
|
||||
super( symbol );
|
||||
this.parameters = parameters;
|
||||
this.nameEndOffset = nameEndOffset;
|
||||
this.returnType = returnType;
|
||||
this.exception = exception;
|
||||
setStartingOffset(startOffset);
|
||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.parser.ast.complete;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceAlias;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||
|
@ -58,7 +57,6 @@ public class ASTNamespaceAlias extends ASTSymbol implements IASTNamespaceAlias
|
|||
* @see org.eclipse.cdt.core.parser.ast.IASTNamespaceAlias#getNamespace()
|
||||
*/
|
||||
public IASTNamespaceDefinition getNamespace()
|
||||
throws ASTNotImplementedException
|
||||
{
|
||||
return namespace;
|
||||
}
|
||||
|
@ -67,7 +65,7 @@ public class ASTNamespaceAlias extends ASTSymbol implements IASTNamespaceAlias
|
|||
*/
|
||||
public void acceptElement(ISourceElementRequestor requestor)
|
||||
{
|
||||
|
||||
store.processReferences(requestor);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
|
|
|
@ -31,7 +31,7 @@ public class ASTNode implements IASTNode {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind, org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind[] kind, IASTNode context) throws LookupException {
|
||||
public ILookupResult lookup(String prefix, LookupKind[] kind, IASTNode context) throws LookupException {
|
||||
if( ! ( this instanceof ISymbolOwner ) || ( context != null && !(context instanceof ISymbolOwner) ) ){
|
||||
return null;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class ASTNode implements IASTNode {
|
|||
return new Result( prefix, iterator, lookupResults.size() );
|
||||
}
|
||||
|
||||
private class Result implements LookupResult{
|
||||
private class Result implements ILookupResult{
|
||||
private String prefix;
|
||||
private Iterator iterator;
|
||||
private int resultsNumber;
|
||||
|
|
|
@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.parser.ast.complete;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||
|
@ -127,7 +126,7 @@ public class ASTSimpleTypeSpecifier extends ASTNode implements IASTSimpleTypeSpe
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#getTypeSpecifier()
|
||||
*/
|
||||
public IASTTypeSpecifier getTypeSpecifier() throws ASTNotImplementedException
|
||||
public IASTTypeSpecifier getTypeSpecifier()
|
||||
{
|
||||
return (IASTTypeSpecifier)getSymbol().getTypeSymbol().getASTExtension().getPrimaryDeclaration();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import java.util.List;
|
|||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTArrayModifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||
|
@ -122,7 +121,7 @@ public class ASTTypeId implements IASTTypeId
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTTypeId#createTypeSymbol(org.eclipse.cdt.core.parser.ast.IASTFactory)
|
||||
*/
|
||||
public ISymbol getTypeSymbol() throws ASTNotImplementedException
|
||||
public ISymbol getTypeSymbol()
|
||||
{
|
||||
return symbol;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.parser.ast.complete;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
|
@ -123,7 +122,7 @@ public class ASTUsingDeclaration extends ASTNode implements IASTUsingDeclaration
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration#getUsingType()
|
||||
*/
|
||||
public IASTDeclaration getUsingType() throws ASTNotImplementedException
|
||||
public IASTDeclaration getUsingType()
|
||||
{
|
||||
return declaration;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.parser.ast.complete;
|
|||
import java.util.List;
|
||||
|
||||
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;
|
||||
|
@ -117,7 +116,7 @@ public class ASTUsingDirective extends ASTAnonymousDeclaration implements IASTUs
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTUsingDirective#getNamespaceDefinition()
|
||||
*/
|
||||
public IASTNamespaceDefinition getNamespaceDefinition() throws ASTNotImplementedException
|
||||
public IASTNamespaceDefinition getNamespaceDefinition()
|
||||
{
|
||||
return namespace;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
|||
*/
|
||||
public class ASTVariable extends ASTSymbol implements IASTVariable
|
||||
{
|
||||
private final boolean previouslyDeclared;
|
||||
private final IASTExpression constructorExpression;
|
||||
protected final ASTReferenceStore referenceDelegate;
|
||||
private final ASTQualifiedNamedElement qualifiedName;
|
||||
|
@ -58,7 +57,6 @@ public class ASTVariable extends ASTSymbol implements IASTVariable
|
|||
setNameEndOffset(nameEndOffset);
|
||||
referenceDelegate = new ASTReferenceStore( references );
|
||||
qualifiedName = new ASTQualifiedNamedElement( getOwnerScope(), newSymbol.getName() );
|
||||
this.previouslyDeclared =previouslyDeclared;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#isAuto()
|
||||
|
|
|
@ -338,7 +338,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
|
||||
protected IContainerSymbol getScopeToSearchUpon(
|
||||
IASTScope currentScope,
|
||||
IToken firstToken, Iterator iterator ) throws ASTSemanticException
|
||||
IToken firstToken, Iterator iterator )
|
||||
{
|
||||
if( firstToken.getType() == IToken.tCOLONCOLON )
|
||||
{
|
||||
|
@ -347,7 +347,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
else
|
||||
{
|
||||
return (IContainerSymbol)scopeToSymbol(currentScope);
|
||||
return scopeToSymbol(currentScope);
|
||||
}
|
||||
|
||||
|
||||
|
@ -627,7 +627,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
|
||||
IContainerSymbol symbol = null;
|
||||
|
||||
symbol = getScopeToSearchUpon(astClassSpec, (IToken)parentClassName.getFirstToken(), iterator );
|
||||
symbol = getScopeToSearchUpon(astClassSpec, parentClassName.getFirstToken(), iterator );
|
||||
|
||||
while( iterator.hasNext() )
|
||||
{
|
||||
|
@ -909,9 +909,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
|| (kind == IASTExpression.Kind.PM_DOTSTAR)
|
||||
|| (kind == IASTExpression.Kind.PM_ARROWSTAR)
|
||||
){
|
||||
TypeInfo lhsInfo = (TypeInfo) ((ASTExpression)lhs).getResultType().getResult();
|
||||
TypeInfo lhsInfo = ((ASTExpression)lhs).getResultType().getResult();
|
||||
if(lhsInfo != null){
|
||||
ISymbol firstContainingScope = (ISymbol) lhsInfo.getTypeSymbol();
|
||||
ISymbol firstContainingScope = lhsInfo.getTypeSymbol();
|
||||
if(firstContainingScope != null){
|
||||
ISymbol containingScope = firstContainingScope.getTypeSymbol();
|
||||
if(containingScope != null){
|
||||
|
@ -1046,7 +1046,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
throws ASTSemanticException{
|
||||
if(exp == null)
|
||||
throw new ASTSemanticException();
|
||||
TypeInfo info = (TypeInfo)((ASTExpression)exp).getResultType().getResult();
|
||||
TypeInfo info = exp.getResultType().getResult();
|
||||
info.setBit(flag, mask);
|
||||
return info;
|
||||
}
|
||||
|
@ -1186,7 +1186,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ASTExpression left =(ASTExpression)lhs;
|
||||
if(left == null)
|
||||
throw new ASTSemanticException();
|
||||
info = (TypeInfo)left.getResultType().getResult();
|
||||
info = left.getResultType().getResult();
|
||||
if ((info != null) && (info.getTypeSymbol() != null)){
|
||||
info.addOperatorExpression( TypeInfo.OperatorExpression.addressof );
|
||||
} else {
|
||||
|
@ -1201,7 +1201,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ASTExpression left =(ASTExpression)lhs;
|
||||
if(left == null)
|
||||
throw new ASTSemanticException();
|
||||
info = (TypeInfo)left.getResultType().getResult();
|
||||
info = left.getResultType().getResult();
|
||||
if ((info != null)&& (info.getTypeSymbol() != null)){
|
||||
info.addOperatorExpression( TypeInfo.OperatorExpression.indirection );
|
||||
}else {
|
||||
|
@ -1215,7 +1215,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ASTExpression left =(ASTExpression)lhs;
|
||||
if(left == null)
|
||||
throw new ASTSemanticException();
|
||||
info = (TypeInfo)left.getResultType().getResult();
|
||||
info = left.getResultType().getResult();
|
||||
if ((info != null) && (info.getTypeSymbol() != null)){
|
||||
info.addOperatorExpression( TypeInfo.OperatorExpression.subscript );
|
||||
}else {
|
||||
|
@ -1246,7 +1246,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ASTExpression right =(ASTExpression)rhs;
|
||||
if (right == null)
|
||||
throw new ASTSemanticException();
|
||||
info = (TypeInfo)right.getResultType().getResult();
|
||||
info = right.getResultType().getResult();
|
||||
if ((info != null) && (symbol != null)){
|
||||
info.addOperatorExpression( TypeInfo.OperatorExpression.indirection );
|
||||
info.setTypeSymbol(symbol);
|
||||
|
@ -1273,8 +1273,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ASTExpression right = (ASTExpression)rhs;
|
||||
ASTExpression third = (ASTExpression)thirdExpression;
|
||||
if((right != null ) && (third != null)){
|
||||
TypeInfo rightType =(TypeInfo)right.getResultType().getResult();
|
||||
TypeInfo thirdType =(TypeInfo)third.getResultType().getResult();
|
||||
TypeInfo rightType =right.getResultType().getResult();
|
||||
TypeInfo thirdType =third.getResultType().getResult();
|
||||
if((rightType != null) && (thirdType != null)){
|
||||
info = conditionalExpressionConversions(rightType, thirdType);
|
||||
} else {
|
||||
|
@ -1315,8 +1315,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ASTExpression left = (ASTExpression)lhs;
|
||||
ASTExpression right = (ASTExpression)rhs;
|
||||
if((left != null ) && (right != null)){
|
||||
TypeInfo leftType =(TypeInfo)left.getResultType().getResult();
|
||||
TypeInfo rightType =(TypeInfo)right.getResultType().getResult();
|
||||
TypeInfo leftType =left.getResultType().getResult();
|
||||
TypeInfo rightType =right.getResultType().getResult();
|
||||
info = usualArithmeticConversions(leftType, rightType);
|
||||
}
|
||||
else {
|
||||
|
@ -1352,7 +1352,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
){
|
||||
ASTExpression left = (ASTExpression)lhs;
|
||||
if(left != null){
|
||||
info =(TypeInfo)left.getResultType().getResult();
|
||||
info =left.getResultType().getResult();
|
||||
} else {
|
||||
throw new ASTSemanticException();
|
||||
}
|
||||
|
@ -1480,7 +1480,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
*/
|
||||
public IASTConstructorMemberInitializer createConstructorMemberInitializer(
|
||||
IASTScope scope,
|
||||
ITokenDuple duple, IASTExpression expressionList) throws ASTSemanticException
|
||||
ITokenDuple duple, IASTExpression expressionList)
|
||||
{
|
||||
List references = new ArrayList();
|
||||
|
||||
|
@ -2138,7 +2138,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
|
||||
IContainerSymbol parentSymbol = null;
|
||||
try {
|
||||
parentSymbol = (IContainerSymbol) parentScope.lookupNestedNameSpecifier( token );
|
||||
parentSymbol = parentScope.lookupNestedNameSpecifier( token );
|
||||
if( parentSymbol != null )
|
||||
addReference( references, createReference( parentSymbol, name, offset ));
|
||||
} catch (ParserSymbolTableException e1) {
|
||||
|
@ -2178,7 +2178,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
newSymbol.setIsForwardDeclaration(isStatic);
|
||||
boolean previouslyDeclared = false;
|
||||
if(!isStatic){
|
||||
ISymbol variableDeclaration = (ISymbol) lookupQualifiedName(ownerScope, name, new ArrayList(), false, LookupType.UNQUALIFIED);
|
||||
ISymbol variableDeclaration = lookupQualifiedName(ownerScope, name, new ArrayList(), false, LookupType.UNQUALIFIED);
|
||||
|
||||
if( variableDeclaration != null )
|
||||
{
|
||||
|
|
|
@ -19,7 +19,6 @@ import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
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;
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -28,7 +27,6 @@ import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
|||
public class ASTClassSpecifier extends ASTScopedTypeSpecifier implements IASTQClassSpecifier, IASTQScope
|
||||
{
|
||||
|
||||
private final IASTScope scope;
|
||||
public ASTClassSpecifier(
|
||||
IASTScope scope,
|
||||
String name,
|
||||
|
@ -40,8 +38,6 @@ public class ASTClassSpecifier extends ASTScopedTypeSpecifier implements IASTQCl
|
|||
ASTAccessVisibility access)
|
||||
{
|
||||
super( scope, name );
|
||||
this.scope = scope;
|
||||
qualifiedNameElement = new ASTQualifiedNamedElement( scope, name );
|
||||
classNameType = type;
|
||||
classKind = kind;
|
||||
offsets.setStartingOffset(startingOffset);
|
||||
|
@ -51,7 +47,6 @@ public class ASTClassSpecifier extends ASTScopedTypeSpecifier implements IASTQCl
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
private final ASTQualifiedNamedElement qualifiedNameElement;
|
||||
private final String name;
|
||||
private List declarations = new ArrayList();
|
||||
private List baseClauses = new ArrayList();
|
||||
|
|
|
@ -19,11 +19,10 @@ public class ASTNode implements IASTNode {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind[], org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
public LookupResult lookup(
|
||||
public ILookupResult lookup(
|
||||
String prefix,
|
||||
LookupKind[] kind,
|
||||
IASTNode context)
|
||||
throws LookupException {
|
||||
IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -38,11 +38,10 @@ public class ASTScopedTypeSpecifier extends ASTQualifiedNamedElement implements
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind[], org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
public LookupResult lookup(
|
||||
public ILookupResult lookup(
|
||||
String prefix,
|
||||
LookupKind[] kind,
|
||||
IASTNode context)
|
||||
throws LookupException {
|
||||
IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.eclipse.cdt.core.parser.ITokenDuple;
|
|||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||
|
@ -69,7 +68,7 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createUsingDirective(org.eclipse.cdt.internal.core.parser.ast.IASTScope, org.eclipse.cdt.internal.core.parser.TokenDuple)
|
||||
*/
|
||||
public IASTUsingDirective createUsingDirective(IASTScope scope, ITokenDuple duple, int startingOffset, int endingOffset) throws ASTSemanticException {
|
||||
public IASTUsingDirective createUsingDirective(IASTScope scope, ITokenDuple duple, int startingOffset, int endingOffset) {
|
||||
return new ASTUsingDirective( scope, duple.toString(), startingOffset, endingOffset );
|
||||
}
|
||||
|
||||
|
@ -115,7 +114,7 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
|||
/* (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)
|
||||
*/
|
||||
public IASTClassSpecifier createClassSpecifier(IASTScope scope, ITokenDuple name, ASTClassKind kind, ClassNameType type, ASTAccessVisibility access, int startingOffset, int nameOffset, int nameEndOffset ) throws ASTSemanticException {
|
||||
public IASTClassSpecifier createClassSpecifier(IASTScope scope, ITokenDuple name, ASTClassKind kind, ClassNameType type, ASTAccessVisibility access, int startingOffset, int nameOffset, int nameEndOffset ) {
|
||||
return new ASTClassSpecifier( scope, name == null ? "" : name.toString() , kind, type, startingOffset, nameOffset, nameEndOffset, access );
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
|
||||
obj.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template );
|
||||
|
||||
Command command = new AddSymbolCommand( (ISymbol) obj, containing );
|
||||
Command command = new AddSymbolCommand( obj, containing );
|
||||
getSymbolTable().pushCommand( command );
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
data.foundItems = ParserSymbolTable.lookupInContained( data, inSymbol );
|
||||
|
||||
if( data.foundItems != null ){
|
||||
foundSymbol = (ISymbol) ParserSymbolTable.resolveAmbiguities( data );//, data.foundItems );
|
||||
foundSymbol = ParserSymbolTable.resolveAmbiguities( data );//, data.foundItems );
|
||||
}
|
||||
|
||||
if( foundSymbol == null && inSymbol.getContainingSymbol() != null ){
|
||||
|
@ -541,7 +541,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
//no parameter information at all, so make an empty list.
|
||||
data.parameters = ( parameters == null ) ? new LinkedList() : parameters;
|
||||
|
||||
ParserSymbolTable.lookup( data, (IContainerSymbol) this );
|
||||
ParserSymbolTable.lookup( data, this );
|
||||
return (IParameterizedSymbol) ParserSymbolTable.resolveAmbiguities( data );
|
||||
}
|
||||
|
||||
|
@ -555,7 +555,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
//no parameter information at all, so make an empty list.
|
||||
data.parameters = ( parameters == null ) ? new LinkedList() : parameters;
|
||||
|
||||
ParserSymbolTable.lookup( data, (IContainerSymbol)this );
|
||||
ParserSymbolTable.lookup( data, this );
|
||||
|
||||
return (IParameterizedSymbol) ParserSymbolTable.resolveAmbiguities( data );
|
||||
}
|
||||
|
@ -568,7 +568,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
LookupData data = new LookupData( name, TypeInfo.t_any, getTemplateInstance() );
|
||||
data.parameters = arguments;
|
||||
|
||||
ParserSymbolTable.lookup( data, (IContainerSymbol) this );
|
||||
ParserSymbolTable.lookup( data, this );
|
||||
ISymbol found = ParserSymbolTable.resolveAmbiguities( data );
|
||||
if( found.isType( TypeInfo.t_template ) ){
|
||||
return ((IParameterizedSymbol) found).instantiate( arguments );
|
||||
|
|
|
@ -92,7 +92,7 @@ public class NamespaceSymbolExtension extends AbstractSymbolExtension
|
|||
/* (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
|
||||
public void addDefinition(ASTSymbol definition)
|
||||
{
|
||||
otherDefinitions.add( definition );
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
param.setContainingSymbol( this );
|
||||
param.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template );
|
||||
|
||||
Command command = new AddParameterCommand( this, (BasicSymbol)param );
|
||||
Command command = new AddParameterCommand( this, param );
|
||||
getSymbolTable().pushCommand( command );
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
|
||||
arg.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template );
|
||||
|
||||
Command command = new AddArgumentCommand( this, (BasicSymbol) arg );
|
||||
Command command = new AddArgumentCommand( this, arg );
|
||||
getSymbolTable().pushCommand( command );
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,6 @@ public class ParserSymbolTable {
|
|||
}
|
||||
}
|
||||
|
||||
ISymbol symbol = null; //the return value
|
||||
LinkedList transitives = new LinkedList(); //list of transitive using directives
|
||||
|
||||
//if this name define in this scope?
|
||||
|
@ -159,7 +158,7 @@ public class ParserSymbolTable {
|
|||
if( !data.usingDirectivesOnly && inSymbol instanceof IDerivableContainerSymbol ){
|
||||
//if we still havn't found it, check any parents we have
|
||||
data.visited.clear(); //each virtual base class is searched at most once
|
||||
map = lookupInParents( data, (IDerivableContainerSymbol)inSymbol );
|
||||
map = lookupInParents( data, inSymbol );
|
||||
|
||||
if( data.foundItems == null || data.foundItems.isEmpty() ){
|
||||
data.foundItems = map;
|
||||
|
@ -293,8 +292,6 @@ public class ParserSymbolTable {
|
|||
protected static Map lookupInContained( LookupData data, IContainerSymbol lookIn ) throws ParserSymbolTableException{
|
||||
Map found = new LinkedHashMap();
|
||||
|
||||
boolean foundSomething = false;
|
||||
ISymbol temp = null;
|
||||
Object obj = null;
|
||||
|
||||
if( data.associated != null ){
|
||||
|
@ -617,7 +614,7 @@ public class ParserSymbolTable {
|
|||
return symbol;
|
||||
}
|
||||
|
||||
private static boolean checkAmbiguity( Object obj1, Object obj2 ) throws ParserSymbolTableException{
|
||||
private static boolean checkAmbiguity( Object obj1, Object obj2 ){
|
||||
//it is not ambiguous if they are the same thing and it is static or an enumerator
|
||||
if( obj1 == obj2 ){
|
||||
|
||||
|
@ -646,7 +643,7 @@ public class ParserSymbolTable {
|
|||
* @param map
|
||||
* @throws ParserSymbolTableException
|
||||
*/
|
||||
private static void mergeInheritedResults( Map resultMap, Map map ) throws ParserSymbolTableException{
|
||||
private static void mergeInheritedResults( Map resultMap, Map map ){
|
||||
if( resultMap == null || map == null || map.isEmpty() ){
|
||||
return;
|
||||
}
|
||||
|
@ -784,17 +781,10 @@ public class ParserSymbolTable {
|
|||
* provided in data.parameters.
|
||||
*/
|
||||
static protected ISymbol resolveAmbiguities( LookupData data ) throws ParserSymbolTableException{
|
||||
ISymbol decl = null;
|
||||
ISymbol obj = null;
|
||||
IContainerSymbol cls = null;
|
||||
|
||||
if( data.foundItems == null || data.foundItems.isEmpty() || data.mode == LookupMode.PREFIX ){
|
||||
return null;
|
||||
}
|
||||
|
||||
int size = data.foundItems.size();
|
||||
//Iterator iter = data.foundItems.iterator();
|
||||
|
||||
Object object = data.foundItems.get( data.name );
|
||||
|
||||
LinkedList functionList = new LinkedList();
|
||||
|
@ -865,7 +855,6 @@ public class ParserSymbolTable {
|
|||
Iterator sourceParams = null;
|
||||
Iterator targetParams = null;
|
||||
|
||||
int numTargetParams = 0;
|
||||
int comparison;
|
||||
Cost cost = null;
|
||||
Cost temp = null;
|
||||
|
@ -914,8 +903,6 @@ public class ParserSymbolTable {
|
|||
}
|
||||
|
||||
targetParams = parameterList.iterator();
|
||||
numTargetParams = parameterList.size();
|
||||
|
||||
if( currFnCost == null ){
|
||||
currFnCost = new Cost [ numSourceParams ];
|
||||
}
|
||||
|
@ -1290,20 +1277,20 @@ public class ParserSymbolTable {
|
|||
try{
|
||||
//a member of a base class
|
||||
if( obj.getContainingSymbol().getType() == context.getType() ){
|
||||
okToAdd = ( hasBaseClass( (IDerivableContainerSymbol) context, (IDerivableContainerSymbol) container ) > 0 );
|
||||
okToAdd = ( hasBaseClass( context, container ) > 0 );
|
||||
}
|
||||
else if ( obj.getContainingSymbol().getType() == TypeInfo.t_union ) {
|
||||
// TODO : must be an _anonymous_ union
|
||||
container = container.getContainingSymbol();
|
||||
okToAdd = ( container instanceof IDerivableContainerSymbol )
|
||||
? ( hasBaseClass( (IDerivableContainerSymbol)context, (IDerivableContainerSymbol) container ) > 0 )
|
||||
? ( hasBaseClass( context, container ) > 0 )
|
||||
: false;
|
||||
}
|
||||
//an enumerator for an enumeration
|
||||
else if ( obj.getType() == TypeInfo.t_enumerator ){
|
||||
container = container.getContainingSymbol();
|
||||
okToAdd = ( container instanceof IDerivableContainerSymbol )
|
||||
? ( hasBaseClass( (IDerivableContainerSymbol)context, (IDerivableContainerSymbol) container ) > 0 )
|
||||
? ( hasBaseClass( context, container ) > 0 )
|
||||
: false;
|
||||
}
|
||||
} catch ( ParserSymbolTableException e ) {
|
||||
|
@ -1551,7 +1538,7 @@ public class ParserSymbolTable {
|
|||
// to an rvalue of type "pointer to cv B", where B is a base class of D.
|
||||
if( (srcDecl instanceof IDerivableContainerSymbol) && trgDecl.isType( srcDecl.getType() ) ){
|
||||
try {
|
||||
temp = hasBaseClass( (IDerivableContainerSymbol) srcDecl, (IDerivableContainerSymbol) trgDecl );
|
||||
temp = hasBaseClass( srcDecl, trgDecl );
|
||||
} catch (ParserSymbolTableException e) {
|
||||
//not going to happen since we didn't ask for the visibility exception
|
||||
}
|
||||
|
@ -1571,7 +1558,7 @@ public class ParserSymbolTable {
|
|||
TypeInfo.PtrOp srcPtr = trg.hasPtrOperators() ? (TypeInfo.PtrOp)trg.getPtrOperators().iterator().next() : null;
|
||||
if( trgDecl.isType( srcDecl.getType() ) && srcPtr != null && srcPtr.getType() == TypeInfo.PtrOp.t_memberPointer ){
|
||||
try {
|
||||
temp = hasBaseClass( (IDerivableContainerSymbol)ptr.getMemberOf(), (IDerivableContainerSymbol)srcPtr.getMemberOf() );
|
||||
temp = hasBaseClass( ptr.getMemberOf(), srcPtr.getMemberOf() );
|
||||
} catch (ParserSymbolTableException e) {
|
||||
//not going to happen since we didn't ask for the visibility exception
|
||||
}
|
||||
|
@ -1609,7 +1596,7 @@ public class ParserSymbolTable {
|
|||
return;
|
||||
}
|
||||
|
||||
int temp = hasBaseClass( (IDerivableContainerSymbol) srcDecl, (IDerivableContainerSymbol) trgDecl, true );
|
||||
int temp = hasBaseClass( srcDecl, trgDecl, true );
|
||||
|
||||
if( temp > -1 ){
|
||||
cost.rank = Cost.DERIVED_TO_BASE_CONVERSION;
|
||||
|
@ -1723,10 +1710,10 @@ public class ParserSymbolTable {
|
|||
}
|
||||
|
||||
if( constructor != null ){
|
||||
constructorCost = checkStandardConversionSequence( (TypeInfo) new TypeInfo( TypeInfo.t_type, 0, constructor.getContainingSymbol() ), target );
|
||||
constructorCost = checkStandardConversionSequence( new TypeInfo( TypeInfo.t_type, 0, constructor.getContainingSymbol() ), target );
|
||||
}
|
||||
if( conversion != null ){
|
||||
conversionCost = checkStandardConversionSequence( (TypeInfo) new TypeInfo( target.getType(), 0, target.getTypeSymbol() ), target );
|
||||
conversionCost = checkStandardConversionSequence( new TypeInfo( target.getType(), 0, target.getTypeSymbol() ), target );
|
||||
}
|
||||
|
||||
//if both are valid, then the conversion is ambiguous
|
||||
|
@ -1819,7 +1806,7 @@ public class ParserSymbolTable {
|
|||
TypeInfo info = null;
|
||||
|
||||
if( topInfo.getType() == TypeInfo.t_type && topInfo.getTypeSymbol() != null ){
|
||||
returnInfo = (TypeInfo)new TypeInfo();
|
||||
returnInfo = new TypeInfo();
|
||||
|
||||
ISymbol typeSymbol = topInfo.getTypeSymbol();
|
||||
|
||||
|
@ -1866,6 +1853,7 @@ public class ParserSymbolTable {
|
|||
return returnInfo;
|
||||
}
|
||||
|
||||
//TODO Andrew - This code is dead, I didn't cut it out as I assume you plan to make it live soon. Be forewarned.
|
||||
static private IParameterizedSymbol matchTemplatePartialSpecialization( IParameterizedSymbol template, List args ){
|
||||
if( template == null ){
|
||||
return null;
|
||||
|
@ -2047,7 +2035,7 @@ public class ParserSymbolTable {
|
|||
List aPtrs = aSymbol.getPtrOperators();
|
||||
|
||||
if( pPtrs != null ){
|
||||
TypeInfo.PtrOp pOp = (TypeInfo.PtrOp) pPtrs.iterator().next();;
|
||||
TypeInfo.PtrOp pOp = (TypeInfo.PtrOp) pPtrs.iterator().next();
|
||||
TypeInfo.PtrOp aOp = ( aPtrs != null ) ? (TypeInfo.PtrOp)pPtrs.iterator().next() : null;
|
||||
|
||||
if( pOp != null && aOp != null && pOp.getType() == aOp.getType() ){
|
||||
|
@ -2096,7 +2084,7 @@ public class ParserSymbolTable {
|
|||
}
|
||||
if( pSymbol.getPtrOperators() != null ){
|
||||
List ptrs = pSymbol.getPtrOperators();
|
||||
TypeInfo.PtrOp op = (TypeInfo.PtrOp) ptrs.iterator().next();;
|
||||
TypeInfo.PtrOp op = (TypeInfo.PtrOp) ptrs.iterator().next();
|
||||
if( op.getType() == TypeInfo.PtrOp.t_memberPointer ){
|
||||
if( !deduceTemplateArgument( map, op.getMemberOf(), pFunction.getContainingSymbol(), argumentMap ) ){
|
||||
return false;
|
||||
|
@ -2252,7 +2240,7 @@ public class ParserSymbolTable {
|
|||
}
|
||||
|
||||
static public class Mark extends Command{
|
||||
public void undoIt(){ };
|
||||
public void undoIt(){ }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,11 +19,12 @@ import java.util.Map;
|
|||
|
||||
public class TemplateInstance extends BasicSymbol
|
||||
{
|
||||
private final ParserSymbolTable _table;
|
||||
//TODO ANDREW - this field is not read, is this a work in progress?
|
||||
//private final ParserSymbolTable _table;
|
||||
|
||||
protected TemplateInstance( ParserSymbolTable table, ISymbol symbol, Map argMap ){
|
||||
super(table, ParserSymbolTable.EMPTY_NAME );
|
||||
this._table = table;
|
||||
//this._table = table;
|
||||
_instantiatedSymbol = symbol;
|
||||
symbol.setTemplateInstance( this );
|
||||
_argumentMap = argMap;
|
||||
|
|
|
@ -25,9 +25,8 @@ import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
|||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
|
@ -185,7 +184,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
ParserLanguage.CPP,
|
||||
callback,
|
||||
ParserUtil.getParserLogService());
|
||||
} catch (ParserFactoryException e) {
|
||||
} catch (ParserFactoryError e) {
|
||||
|
||||
}
|
||||
LinkedList list = scanForNames( scanner, null );
|
||||
|
@ -255,7 +254,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,ParserUtil.getParserLogService());
|
||||
} catch (ParserFactoryException e) {
|
||||
} catch (ParserFactoryError e) {
|
||||
|
||||
}
|
||||
LinkedList list = scanForNames( scanner, null );
|
||||
|
@ -297,7 +296,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,ParserUtil.getParserLogService());
|
||||
} catch (ParserFactoryException e) {
|
||||
} catch (ParserFactoryError e) {
|
||||
}
|
||||
|
||||
LinkedList names = scanForNames( scanner, null );
|
||||
|
@ -355,7 +354,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,ParserUtil.getParserLogService());
|
||||
} catch (ParserFactoryException e1) {
|
||||
} catch (ParserFactoryError e1) {
|
||||
}
|
||||
|
||||
IToken token = null;
|
||||
|
@ -419,7 +418,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,ParserUtil.getParserLogService());
|
||||
} catch (ParserFactoryException e1) {
|
||||
} catch (ParserFactoryError e1) {
|
||||
}
|
||||
IQuickParseCallback callback = ParserFactory.createQuickParseCallback();
|
||||
IParser parser=null;
|
||||
|
@ -430,7 +429,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
callback,
|
||||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP, ParserUtil.getParserLogService());
|
||||
} catch (ParserFactoryException e2) {
|
||||
} catch (ParserFactoryError e2) {
|
||||
}
|
||||
|
||||
if( parser.parse() ){
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
|||
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
|
@ -443,7 +443,7 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
|||
IScanner scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETE_PARSE, language, this, ParserUtil.getParserLogService() );
|
||||
parser = ParserFactory.createParser( scanner, this, ParserMode.COMPLETE_PARSE, language, ParserUtil.getParserLogService() );
|
||||
}
|
||||
catch( ParserFactoryException pfe )
|
||||
catch( ParserFactoryError pfe )
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2004-01-15 John Camelon
|
||||
Updated references to LookupResult as it was renamed to ILookupResult.
|
||||
Updated references of ParserFactoryException to ParserFactoryError.
|
||||
Updated references of ParserNotImplementedException to ParseError.
|
||||
Updated references of CONTEXTUAL_PARSE to COMPLETION_PARSE.
|
||||
|
||||
2004-01-13 John Camelon
|
||||
Updated CompletionEngine to handle IASTCompletionKind.CompletionKind.STATEMENT_START
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ public class CStructureCreator implements IStructureCreator {
|
|||
// The CParseTreeBuilder will throw CParseTreeBuilder.ParseError
|
||||
// for acceptProblem.
|
||||
|
||||
//TODO : New : ParserFactoryException gets thrown by ParserFactory primitives
|
||||
//TODO : New : ParserFactoryError gets thrown by ParserFactory primitives
|
||||
}
|
||||
|
||||
return root;
|
||||
|
|
|
@ -23,11 +23,11 @@ import org.eclipse.cdt.core.parser.IParser;
|
|||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.core.parser.ParseError;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ParserNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||
|
@ -48,7 +48,7 @@ import org.eclipse.cdt.core.parser.ast.IASTScope;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupResult;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.ILookupResult;
|
||||
import org.eclipse.cdt.internal.core.CharOperation;
|
||||
import org.eclipse.cdt.internal.core.model.IDebugLogConstants;
|
||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||
|
@ -184,10 +184,10 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
IParser parser = null;
|
||||
try
|
||||
{
|
||||
IScanner scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.CONTEXTUAL_PARSE, language, requestor, ParserUtil.getParserLogService() );
|
||||
parser = ParserFactory.createParser( scanner, requestor, ParserMode.CONTEXTUAL_PARSE, language, ParserUtil.getParserLogService() );
|
||||
IScanner scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETION_PARSE, language, requestor, ParserUtil.getParserLogService() );
|
||||
parser = ParserFactory.createParser( scanner, requestor, ParserMode.COMPLETION_PARSE, language, ParserUtil.getParserLogService() );
|
||||
}
|
||||
catch( ParserFactoryException pfe )
|
||||
catch( ParserFactoryError pfe )
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -195,7 +195,8 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
IASTCompletionNode result = null;
|
||||
try {
|
||||
result = parser.parse(completionOffset);
|
||||
} catch (ParserNotImplementedException e) {
|
||||
} catch (ParseError e ) {
|
||||
//TODO - this can be more than just a Not Implemented exception
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
|
@ -358,7 +359,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
numNamespaces = 0;
|
||||
numMacros = 0;
|
||||
}
|
||||
private void addToCompletions (LookupResult result){
|
||||
private void addToCompletions (ILookupResult result){
|
||||
if(result == null)
|
||||
return;
|
||||
Iterator nodes = result.getNodes();
|
||||
|
@ -385,10 +386,10 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
return result;
|
||||
}
|
||||
|
||||
private LookupResult lookup(IASTScope searchNode, String prefix, LookupKind[] kinds, IASTNode context){
|
||||
private ILookupResult lookup(IASTScope searchNode, String prefix, LookupKind[] kinds, IASTNode context){
|
||||
try {
|
||||
logLookups (kinds);
|
||||
LookupResult result = searchNode.lookup (prefix, kinds, context);
|
||||
ILookupResult result = searchNode.lookup (prefix, kinds, context);
|
||||
return result ;
|
||||
} catch (IASTNode.LookupException ilk ){
|
||||
// do we want to do something here?
|
||||
|
@ -401,7 +402,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
// 1. Get the search scope node
|
||||
IASTScope searchNode = completionNode.getCompletionScope();
|
||||
|
||||
LookupResult result = null;
|
||||
ILookupResult result = null;
|
||||
// lookup fields and methods with the right visibility
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[2];
|
||||
kinds[0] = IASTNode.LookupKind.FIELDS;
|
||||
|
@ -415,7 +416,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
{
|
||||
IASTScope searchNode = completionNode.getCompletionScope();
|
||||
|
||||
LookupResult result = null;
|
||||
ILookupResult result = null;
|
||||
// lookup fields and methods with the right visibility
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[7];
|
||||
kinds[0] = IASTNode.LookupKind.FIELDS;
|
||||
|
@ -439,7 +440,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
kinds[1] = IASTNode.LookupKind.STRUCTURES;
|
||||
kinds[2] = IASTNode.LookupKind.ENUMERATIONS;
|
||||
kinds[3] = IASTNode.LookupKind.NAMESPACES;
|
||||
LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
// TODO
|
||||
// lookup static members (field / methods) in type
|
||||
|
@ -451,7 +452,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
// if the prefix is not empty
|
||||
if(completionNode.getCompletionPrefix().length() > 0 ) {
|
||||
// 2. Lookup all types that could be used here
|
||||
LookupResult result;
|
||||
ILookupResult result;
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[2];
|
||||
kinds[0] = IASTNode.LookupKind.STRUCTURES;
|
||||
kinds[1] = IASTNode.LookupKind.ENUMERATIONS;
|
||||
|
@ -500,7 +501,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
kinds[4] = IASTNode.LookupKind.ENUMERATIONS;
|
||||
kinds[5] = IASTNode.LookupKind.METHODS;
|
||||
kinds[6] = IASTNode.LookupKind.FUNCTIONS;
|
||||
LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
} else // prefix is empty
|
||||
{
|
||||
|
@ -510,7 +511,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
kinds[0] = IASTNode.LookupKind.LOCAL_VARIABLES;
|
||||
kinds[1] = IASTNode.LookupKind.FIELDS;
|
||||
kinds[2] = IASTNode.LookupKind.METHODS;
|
||||
LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
}
|
||||
}
|
||||
|
@ -521,7 +522,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
// only look for classes
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.CLASSES;
|
||||
LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
}
|
||||
private void completionOnNamespaceReference(IASTCompletionNode completionNode){
|
||||
|
@ -530,7 +531,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
// only look for namespaces
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.NAMESPACES;
|
||||
LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
}
|
||||
private void completionOnExceptionReference(IASTCompletionNode completionNode){
|
||||
|
@ -547,7 +548,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
// only look for macros
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.MACROS;
|
||||
LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
}
|
||||
private void completionOnFunctionReference(IASTCompletionNode completionNode){
|
||||
|
@ -559,7 +560,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
// only lookup constructors
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.CONSTRUCTORS;
|
||||
LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
}
|
||||
private void completionOnKeyword(IASTCompletionNode completionNode){
|
||||
|
|
Loading…
Add table
Reference in a new issue