mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
CORE
Added OffsetLimitReachedException and restructured Parser exceptions. Continued support for code assist/selection search parser. Ensured all source in parser/ have copyright notices. TESTS Expanded ContextualParseTest::testBaseCase(). Updated tests to deal with new signatures/exceptions. UI Updated CompletionEngine to deal with new signatures/exceptions in parser.
This commit is contained in:
parent
e0485ec52b
commit
938c206289
34 changed files with 816 additions and 463 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2003-12-11 John Camelon
|
||||||
|
Expanded ContextualParseTest::testBaseCase().
|
||||||
|
Updated tests to deal with new signatures/exceptions.
|
||||||
|
|
||||||
2003-12-11 Alain Magloire
|
2003-12-11 Alain Magloire
|
||||||
|
|
||||||
New test files for the ICPathEntry in core model.
|
New test files for the ICPathEntry in core model.
|
||||||
|
|
|
@ -15,11 +15,12 @@ import java.io.StringReader;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.EndOfFile;
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
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.ParserFactory;
|
||||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
|
@ -72,7 +73,7 @@ public class BaseScannerTest extends TestCase {
|
||||||
t= scanner.nextToken();
|
t= scanner.nextToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( EndOfFile e)
|
catch ( EndOfFileException e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
catch (ScannerException se)
|
catch (ScannerException se)
|
||||||
|
@ -87,7 +88,7 @@ public class BaseScannerTest extends TestCase {
|
||||||
IToken t= scanner.nextToken();
|
IToken t= scanner.nextToken();
|
||||||
assertTrue(t.getType() == IToken.tIDENTIFIER);
|
assertTrue(t.getType() == IToken.tIDENTIFIER);
|
||||||
assertTrue(t.getImage().equals(expectedImage));
|
assertTrue(t.getImage().equals(expectedImage));
|
||||||
} catch (EndOfFile e) {
|
} catch (EndOfFileException e) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +99,7 @@ public class BaseScannerTest extends TestCase {
|
||||||
IToken t= scanner.nextToken();
|
IToken t= scanner.nextToken();
|
||||||
assertTrue(t.getType() == IToken.tINTEGER);
|
assertTrue(t.getType() == IToken.tINTEGER);
|
||||||
assertTrue(t.getImage().equals(expectedImage));
|
assertTrue(t.getImage().equals(expectedImage));
|
||||||
} catch (EndOfFile e) {
|
} catch (EndOfFileException e) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,7 +110,7 @@ public class BaseScannerTest extends TestCase {
|
||||||
IToken t= scanner.nextToken();
|
IToken t= scanner.nextToken();
|
||||||
assertTrue(t.getType() == IToken.tFLOATINGPT);
|
assertTrue(t.getType() == IToken.tFLOATINGPT);
|
||||||
assertTrue(t.getImage().equals(expectedImage));
|
assertTrue(t.getImage().equals(expectedImage));
|
||||||
} catch (EndOfFile e) {
|
} catch (EndOfFileException e) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +122,7 @@ public class BaseScannerTest extends TestCase {
|
||||||
assertTrue(t.getType() == IToken.tCHAR );
|
assertTrue(t.getType() == IToken.tCHAR );
|
||||||
Character c = new Character( expected );
|
Character c = new Character( expected );
|
||||||
assertEquals( t.getImage(), c.toString() );
|
assertEquals( t.getImage(), c.toString() );
|
||||||
} catch (EndOfFile e) {
|
} catch (EndOfFileException e) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +133,7 @@ public class BaseScannerTest extends TestCase {
|
||||||
IToken t= scanner.nextToken();
|
IToken t= scanner.nextToken();
|
||||||
assertTrue(t.getType() == IToken.tCHAR );
|
assertTrue(t.getType() == IToken.tCHAR );
|
||||||
assertEquals( t.getImage(), expected );
|
assertEquals( t.getImage(), expected );
|
||||||
} catch (EndOfFile e) {
|
} catch (EndOfFileException e) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,7 +152,7 @@ public class BaseScannerTest extends TestCase {
|
||||||
else
|
else
|
||||||
assertTrue(t.getType() == IToken.tSTRING);
|
assertTrue(t.getType() == IToken.tSTRING);
|
||||||
assertTrue(t.getImage().equals(expectedImage));
|
assertTrue(t.getImage().equals(expectedImage));
|
||||||
} catch (EndOfFile e) {
|
} catch (EndOfFileException e) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +162,9 @@ public class BaseScannerTest extends TestCase {
|
||||||
try {
|
try {
|
||||||
IToken t= scanner.nextToken();
|
IToken t= scanner.nextToken();
|
||||||
assertTrue(t.getType() == tokenType);
|
assertTrue(t.getType() == tokenType);
|
||||||
} catch (EndOfFile e) {
|
} catch (OffsetLimitReachedException e) {
|
||||||
|
assertTrue(false);
|
||||||
|
} catch (EndOfFileException e) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,7 +183,9 @@ public class BaseScannerTest extends TestCase {
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
assertNull(scanner.nextToken());
|
assertNull(scanner.nextToken());
|
||||||
} catch (EndOfFile e) {
|
}catch (OffsetLimitReachedException e) {
|
||||||
|
assertTrue(false);
|
||||||
|
} catch (EndOfFileException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +228,7 @@ public class BaseScannerTest extends TestCase {
|
||||||
IToken t= scanner.nextToken();
|
IToken t= scanner.nextToken();
|
||||||
assertTrue(t.getType() == IToken.tLCHAR );
|
assertTrue(t.getType() == IToken.tLCHAR );
|
||||||
assertEquals( t.getImage(), string );
|
assertEquals( t.getImage(), string );
|
||||||
} catch (EndOfFile e) {
|
} catch (EndOfFileException e) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,6 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupResult;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,17 +7,15 @@
|
||||||
package org.eclipse.cdt.core.parser.tests;
|
package org.eclipse.cdt.core.parser.tests;
|
||||||
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.io.StringWriter;
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
|
||||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
|
||||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserLogService;
|
import org.eclipse.cdt.internal.core.parser.ParserLogService;
|
||||||
|
|
||||||
|
@ -27,7 +25,8 @@ import org.eclipse.cdt.internal.core.parser.ParserLogService;
|
||||||
* To change the template for this generated type comment go to Window -
|
* To change the template for this generated type comment go to Window -
|
||||||
* Preferences - Java - Code Generation - Code and Comments
|
* Preferences - Java - Code Generation - Code and Comments
|
||||||
*/
|
*/
|
||||||
public class ContextualParseTest extends TestCase {
|
public class ContextualParseTest extends CompleteParseBaseTest {
|
||||||
|
|
||||||
|
|
||||||
public ContextualParseTest(String name) {
|
public ContextualParseTest(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
@ -35,9 +34,8 @@ public class ContextualParseTest extends TestCase {
|
||||||
|
|
||||||
protected IASTCompletionNode parse(String code, int offset)
|
protected IASTCompletionNode parse(String code, int offset)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
ISourceElementRequestor requestor = new NullSourceElementRequestor();
|
|
||||||
IParserLogService log = new ParserLogService();
|
IParserLogService log = new ParserLogService();
|
||||||
|
callback = new FullParseCallback();
|
||||||
IParser parser = null;
|
IParser parser = null;
|
||||||
|
|
||||||
parser =
|
parser =
|
||||||
|
@ -48,9 +46,9 @@ public class ContextualParseTest extends TestCase {
|
||||||
new ScannerInfo(),
|
new ScannerInfo(),
|
||||||
ParserMode.CONTEXTUAL_PARSE,
|
ParserMode.CONTEXTUAL_PARSE,
|
||||||
ParserLanguage.CPP,
|
ParserLanguage.CPP,
|
||||||
requestor,
|
callback,
|
||||||
log),
|
log),
|
||||||
requestor,
|
callback,
|
||||||
ParserMode.CONTEXTUAL_PARSE,
|
ParserMode.CONTEXTUAL_PARSE,
|
||||||
ParserLanguage.CPP,
|
ParserLanguage.CPP,
|
||||||
log);
|
log);
|
||||||
|
@ -61,9 +59,39 @@ public class ContextualParseTest extends TestCase {
|
||||||
|
|
||||||
public void testBaseCase() throws Exception
|
public void testBaseCase() throws Exception
|
||||||
{
|
{
|
||||||
IASTCompletionNode node = parse( "class ABC { }; AB\n\n", 17);
|
StringWriter writer = new StringWriter();
|
||||||
|
writer.write( "class ABC " );
|
||||||
|
writer.write( "{int x;}; " );
|
||||||
|
writer.write( "AB\n\n" );
|
||||||
|
|
||||||
|
IASTCompletionNode node = parse( writer.toString(), 21);
|
||||||
assertNotNull( node );
|
assertNotNull( node );
|
||||||
assertNotNull( node.getCompletionPrefix() );
|
assertNotNull( node.getCompletionPrefix() );
|
||||||
|
assertEquals( node.getCompletionScope(), ((Scope)callback.getCompilationUnit()).getScope() );
|
||||||
|
assertEquals( node.getCompletionPrefix(), "A");
|
||||||
|
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.VARIABLE_TYPE );
|
||||||
|
|
||||||
|
node = parse( writer.toString(), 12);
|
||||||
|
assertNotNull( node );
|
||||||
|
assertNotNull( node.getCompletionPrefix() );
|
||||||
|
assertTrue( node.getCompletionScope() instanceof IASTClassSpecifier );
|
||||||
|
assertEquals( node.getCompletionPrefix(), "i");
|
||||||
|
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.FIELD_TYPE );
|
||||||
|
|
||||||
|
|
||||||
|
node = parse( writer.toString(), 22);
|
||||||
|
assertNotNull( node );
|
||||||
|
assertNotNull( node.getCompletionPrefix() );
|
||||||
|
assertEquals( node.getCompletionScope(), ((Scope)callback.getCompilationUnit()).getScope() );
|
||||||
assertEquals( node.getCompletionPrefix(), "AB");
|
assertEquals( node.getCompletionPrefix(), "AB");
|
||||||
|
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.VARIABLE_TYPE );
|
||||||
|
|
||||||
|
node = parse( writer.toString(), 6);
|
||||||
|
assertNotNull( node );
|
||||||
|
assertNotNull( node.getCompletionPrefix() );
|
||||||
|
assertEquals( node.getCompletionScope(), ((Scope)callback.getCompilationUnit()).getScope() );
|
||||||
|
assertEquals( node.getCompletionPrefix(), "");
|
||||||
|
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.USER_SPECIFIED_NAME );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class ParserTestSuite extends TestCase {
|
||||||
suite.addTestSuite(QuickParseASTTests.class);
|
suite.addTestSuite(QuickParseASTTests.class);
|
||||||
suite.addTestSuite(ParserSymbolTableTest.class);
|
suite.addTestSuite(ParserSymbolTableTest.class);
|
||||||
suite.addTestSuite(CModelElementsTests.class);
|
suite.addTestSuite(CModelElementsTests.class);
|
||||||
// suite.addTestSuite(ContextualParseTest.class);
|
suite.addTestSuite(ContextualParseTest.class);
|
||||||
// suite.addTestSuite(MacroTests.class);
|
// suite.addTestSuite(MacroTests.class);
|
||||||
suite.addTestSuite( PreprocessorTest.class );
|
suite.addTestSuite( PreprocessorTest.class );
|
||||||
suite.addTestSuite( PreprocessorConditionalTest.class );
|
suite.addTestSuite( PreprocessorConditionalTest.class );
|
||||||
|
@ -40,6 +40,4 @@ public class ParserTestSuite extends TestCase {
|
||||||
suite.addTestSuite( CompleteParseASTExpressionTest.class );
|
suite.addTestSuite( CompleteParseASTExpressionTest.class );
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,11 @@ import java.io.StringReader;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.EndOfFile;
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
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.ParserFactory;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
|
@ -79,7 +80,11 @@ public class PreprocessorConditionalTest extends BaseScannerTest
|
||||||
{
|
{
|
||||||
fail( "Got #error, should not have gotten that.");
|
fail( "Got #error, should not have gotten that.");
|
||||||
}
|
}
|
||||||
catch( EndOfFile eof )
|
catch( OffsetLimitReachedException olre )
|
||||||
|
{
|
||||||
|
fail( "Should never have reached OffsetLimitReachedException");
|
||||||
|
}
|
||||||
|
catch( EndOfFileException eof )
|
||||||
{
|
{
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.io.Writer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.EndOfFile;
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||||
import org.eclipse.cdt.core.parser.IProblem;
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
@ -853,7 +853,7 @@ public class ScannerTestCase extends BaseScannerTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testQuickScan() throws EndOfFile, ParserFactoryException
|
public void testQuickScan() throws EndOfFileException, ParserFactoryException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2003-12-11 John Camelon
|
||||||
|
Added OffsetLimitReachedException and restructured Parser exceptions.
|
||||||
|
Continued support for code assist/selection search parser.
|
||||||
|
Ensured all source in parser/ have copyright notices.
|
||||||
|
|
||||||
2003-12-09 Andrew Niefer
|
2003-12-09 Andrew Niefer
|
||||||
-created TypeFilter to support support filtering of what kind of symbols to find (for prefix lookup 48306)
|
-created TypeFilter to support support filtering of what kind of symbols to find (for prefix lookup 48306)
|
||||||
-added IContainerSymbol.isVisible for bug 48294
|
-added IContainerSymbol.isVisible for bug 48294
|
||||||
|
|
|
@ -14,6 +14,6 @@ package org.eclipse.cdt.core.parser;
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Backtrack extends Exception
|
public class BacktrackException extends Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
* Created on Dec 8, 2003
|
|
||||||
*
|
|
||||||
* To change the template for this generated file go to
|
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.core.parser;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jcamelon
|
|
||||||
*
|
|
||||||
* To change the template for this generated type comment go to
|
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
|
||||||
*/
|
|
||||||
public class CompletionNode implements IASTCompletionNode {
|
|
||||||
|
|
||||||
private final String prefix;
|
|
||||||
private final IASTNode context;
|
|
||||||
private final IASTScope scope;
|
|
||||||
private final CompletionKind kind;
|
|
||||||
|
|
||||||
public CompletionNode( CompletionKind kind, IASTScope scope, IASTNode context, String prefix )
|
|
||||||
{
|
|
||||||
this.kind = kind;
|
|
||||||
this.context = context;
|
|
||||||
this.scope = scope;
|
|
||||||
this.prefix = prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTCompletionNode#getCompletionKind()
|
|
||||||
*/
|
|
||||||
public CompletionKind getCompletionKind() {
|
|
||||||
return kind;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTCompletionNode#getCompletionScope()
|
|
||||||
*/
|
|
||||||
public IASTScope getCompletionScope() {
|
|
||||||
return scope;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTCompletionNode#getCompletionContext()
|
|
||||||
*/
|
|
||||||
public IASTNode getCompletionContext() {
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTCompletionNode#getCompletionPrefix()
|
|
||||||
*/
|
|
||||||
public String getCompletionPrefix() {
|
|
||||||
return prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,28 +1,35 @@
|
||||||
/*
|
/**********************************************************************
|
||||||
* Created on Dec 8, 2003
|
* 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
|
||||||
*
|
*
|
||||||
* To change the template for this generated file go to
|
* Contributors:
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
* IBM Rational Software - Initial API and implementation
|
||||||
*/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.core.parser;
|
package org.eclipse.cdt.core.parser;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
|
||||||
* To change the template for this generated type comment go to
|
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
|
||||||
*/
|
*/
|
||||||
public class ContextualParser extends Parser implements IParser {
|
public class ContextualParser extends Parser implements IParser {
|
||||||
|
|
||||||
private CompletionKind kind;
|
protected CompletionKind kind;
|
||||||
private IASTScope scope;
|
protected IASTScope scope;
|
||||||
private IASTNode context;
|
protected IASTNode context;
|
||||||
|
protected IToken finalToken;
|
||||||
|
private Set keywordSet = new HashSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param scanner
|
* @param scanner
|
||||||
|
@ -42,14 +49,21 @@ public class ContextualParser extends Parser implements IParser {
|
||||||
public IASTCompletionNode parse(int offset) throws ParserNotImplementedException {
|
public IASTCompletionNode parse(int offset) throws ParserNotImplementedException {
|
||||||
scanner.setOffsetBoundary(offset);
|
scanner.setOffsetBoundary(offset);
|
||||||
translationUnit();
|
translationUnit();
|
||||||
return new CompletionNode( getCompletionKind(), getCompletionScope(), getCompletionContext(), getCompletionPrefix() );
|
return new ASTCompletionNode( getCompletionKind(), getCompletionScope(), getCompletionContext(), getCompletionPrefix(), getKeywordSet() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Set getKeywordSet() {
|
||||||
|
return keywordSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String getCompletionPrefix() {
|
private String getCompletionPrefix() {
|
||||||
return lastToken == null ? "" : lastToken.getImage();
|
return ( finalToken == null ? "" : finalToken.getImage() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,7 +115,7 @@ public class ContextualParser extends Parser implements IParser {
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleFunctionBody(IASTScope scope, boolean isInlineFunction) throws Backtrack, EndOfFile
|
protected void handleFunctionBody(IASTScope scope, boolean isInlineFunction) throws BacktrackException, EndOfFileException
|
||||||
{
|
{
|
||||||
if ( isInlineFunction )
|
if ( isInlineFunction )
|
||||||
skipOverCompoundStatement();
|
skipOverCompoundStatement();
|
||||||
|
@ -109,9 +123,17 @@ public class ContextualParser extends Parser implements IParser {
|
||||||
functionBody(scope);
|
functionBody(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void catchBlockCompoundStatement(IASTScope scope) throws Backtrack, EndOfFile
|
protected void catchBlockCompoundStatement(IASTScope scope) throws BacktrackException, EndOfFileException
|
||||||
{
|
{
|
||||||
compoundStatement(scope, true);
|
compoundStatement(scope, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.Parser#handleOffsetLimitException()
|
||||||
|
*/
|
||||||
|
protected void handleOffsetLimitException(OffsetLimitReachedException exception) throws EndOfFileException, OffsetLimitReachedException {
|
||||||
|
finalToken = exception.getFinalToken();
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,6 @@ package org.eclipse.cdt.core.parser;
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class EndOfFile extends Backtrack
|
public class EndOfFileException extends Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
|
@ -54,10 +54,10 @@ public interface IParser {
|
||||||
* @param expression Optional parameter representing an expression object that
|
* @param expression Optional parameter representing an expression object that
|
||||||
* your particular IParserCallback instance would appreciate
|
* your particular IParserCallback instance would appreciate
|
||||||
*
|
*
|
||||||
* @throws Backtrack thrown if the Scanner/Stream provided does not yield a valid
|
* @throws BacktrackException thrown if the Scanner/Stream provided does not yield a valid
|
||||||
* expression
|
* expression
|
||||||
*/
|
*/
|
||||||
public IASTExpression expression(IASTScope scope) throws Backtrack;
|
public IASTExpression expression(IASTScope scope) throws BacktrackException, EndOfFileException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If an error was encountered, give us the offset of the token that caused the error.
|
* If an error was encountered, give us the offset of the token that caused the error.
|
||||||
|
|
|
@ -22,13 +22,13 @@ public interface IScanner {
|
||||||
public void addIncludePath(String includePath);
|
public void addIncludePath(String includePath);
|
||||||
public void overwriteIncludePath( String [] newIncludePaths );
|
public void overwriteIncludePath( String [] newIncludePaths );
|
||||||
|
|
||||||
public IToken nextToken() throws ScannerException, EndOfFile;
|
public IToken nextToken() throws ScannerException, EndOfFileException, OffsetLimitReachedException;
|
||||||
public IToken nextToken( boolean next ) throws ScannerException, EndOfFile;
|
public IToken nextToken( boolean next ) throws ScannerException, EndOfFileException, OffsetLimitReachedException;
|
||||||
|
|
||||||
public int getCount();
|
public int getCount();
|
||||||
public int getDepth();
|
public int getDepth();
|
||||||
|
|
||||||
public IToken nextTokenForStringizing() throws ScannerException, EndOfFile;
|
public IToken nextTokenForStringizing() throws ScannerException, EndOfFileException, OffsetLimitReachedException;
|
||||||
public void setTokenizingMacroReplacementList(boolean b);
|
public void setTokenizingMacroReplacementList(boolean b);
|
||||||
public void setThrowExceptionOnBadCharacterRead( boolean throwOnBad );
|
public void setThrowExceptionOnBadCharacterRead( boolean throwOnBad );
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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 OffsetLimitReachedException extends EndOfFileException {
|
||||||
|
|
||||||
|
private final IToken finalToken;
|
||||||
|
|
||||||
|
public OffsetLimitReachedException( IToken token )
|
||||||
|
{
|
||||||
|
finalToken = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the finalToken.
|
||||||
|
*/
|
||||||
|
public IToken getFinalToken() {
|
||||||
|
return finalToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,16 +1,17 @@
|
||||||
/*
|
/**********************************************************************
|
||||||
* Created on Dec 8, 2003
|
* 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
|
||||||
*
|
*
|
||||||
* To change the template for this generated file go to
|
* Contributors:
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
* IBM Rational Software - Initial API and implementation
|
||||||
*/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.core.parser;
|
package org.eclipse.cdt.core.parser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
|
||||||
* To change the template for this generated type comment go to
|
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
|
||||||
*/
|
*/
|
||||||
public class ParserNotImplementedException extends Exception {
|
public class ParserNotImplementedException extends Exception {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,8 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.ast;
|
package org.eclipse.cdt.core.parser.ast;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.Enum;
|
import org.eclipse.cdt.core.parser.Enum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,22 +22,55 @@ public interface IASTCompletionNode {
|
||||||
|
|
||||||
public static class CompletionKind extends Enum
|
public static class CompletionKind extends Enum
|
||||||
{
|
{
|
||||||
|
// x.[ ] x->[ ]
|
||||||
public static final CompletionKind MEMBER_REFERENCE = new CompletionKind( 0 );
|
public static final CompletionKind MEMBER_REFERENCE = new CompletionKind( 0 );
|
||||||
|
// x::[ ]
|
||||||
public static final CompletionKind SCOPED_REFERENCE = new CompletionKind( 1 );
|
public static final CompletionKind SCOPED_REFERENCE = new CompletionKind( 1 );
|
||||||
|
|
||||||
|
// class member declaration type reference
|
||||||
public static final CompletionKind FIELD_TYPE = new CompletionKind( 2 );
|
public static final CompletionKind FIELD_TYPE = new CompletionKind( 2 );
|
||||||
|
|
||||||
|
// stand-alone declaration type reference
|
||||||
public static final CompletionKind VARIABLE_TYPE = new CompletionKind( 3 );
|
public static final CompletionKind VARIABLE_TYPE = new CompletionKind( 3 );
|
||||||
|
|
||||||
|
// function/method argument type reference
|
||||||
public static final CompletionKind ARGUMENT_TYPE = new CompletionKind( 4 );
|
public static final CompletionKind ARGUMENT_TYPE = new CompletionKind( 4 );
|
||||||
|
|
||||||
|
// inside code body - name reference
|
||||||
public static final CompletionKind SINGLE_NAME_REFERENCE = new CompletionKind( 5 );
|
public static final CompletionKind SINGLE_NAME_REFERENCE = new CompletionKind( 5 );
|
||||||
|
|
||||||
|
// any place one can expect a type
|
||||||
public static final CompletionKind TYPE_REFERENCE = new CompletionKind( 6 );
|
public static final CompletionKind TYPE_REFERENCE = new CompletionKind( 6 );
|
||||||
|
|
||||||
|
// any place where one can expect a class name
|
||||||
public static final CompletionKind CLASS_REFERENCE = new CompletionKind( 7 );
|
public static final CompletionKind CLASS_REFERENCE = new CompletionKind( 7 );
|
||||||
|
|
||||||
|
// any place where a namespace name is expected
|
||||||
public static final CompletionKind NAMESPACE_REFERENCE = new CompletionKind( 8 );
|
public static final CompletionKind NAMESPACE_REFERENCE = new CompletionKind( 8 );
|
||||||
|
|
||||||
|
// any place where an exception name is expected
|
||||||
public static final CompletionKind EXCEPTION_REFERENCE = new CompletionKind( 9 );
|
public static final CompletionKind EXCEPTION_REFERENCE = new CompletionKind( 9 );
|
||||||
|
|
||||||
|
// any place where exclusively a preprocessor macro name would be expected
|
||||||
public static final CompletionKind MACRO_REFERENCE = new CompletionKind( 10 );
|
public static final CompletionKind MACRO_REFERENCE = new CompletionKind( 10 );
|
||||||
|
|
||||||
|
// any place where function arguments are expected
|
||||||
public static final CompletionKind FUNCTION_REFERENCE = new CompletionKind( 11 );
|
public static final CompletionKind FUNCTION_REFERENCE = new CompletionKind( 11 );
|
||||||
|
|
||||||
|
// any place where constructor arguments are expected
|
||||||
public static final CompletionKind CONSTRUCTOR_REFERENCE = new CompletionKind( 12 );
|
public static final CompletionKind CONSTRUCTOR_REFERENCE = new CompletionKind( 12 );
|
||||||
|
|
||||||
|
// any place where exclusively a keyword is expected
|
||||||
public static final CompletionKind KEYWORD = new CompletionKind( 13 );
|
public static final CompletionKind KEYWORD = new CompletionKind( 13 );
|
||||||
|
|
||||||
//TODO MORE TO COME
|
// any place where exclusively a preprocessor directive is expected
|
||||||
|
public static final CompletionKind PREPROCESSOR_DIRECTIVE = new CompletionKind( 14 );
|
||||||
|
|
||||||
|
// any place where a type or variable name is expected to be introduced
|
||||||
|
public static final CompletionKind USER_SPECIFIED_NAME = new CompletionKind( 15 );
|
||||||
|
|
||||||
|
// error condition -- a place in the grammar where there is nothing to lookup
|
||||||
|
public static final CompletionKind NO_SUCH_KIND = new CompletionKind( 200 );
|
||||||
/**
|
/**
|
||||||
* @param enumValue
|
* @param enumValue
|
||||||
*/
|
*/
|
||||||
|
@ -68,4 +103,10 @@ public interface IASTCompletionNode {
|
||||||
* @return the prefix
|
* @return the prefix
|
||||||
*/
|
*/
|
||||||
public String getCompletionPrefix();
|
public String getCompletionPrefix();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Iterator getKeywords();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public interface IASTNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class InvalidLookupKind extends Exception
|
public static class LookupException extends Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,9 +56,8 @@ public interface IASTNode {
|
||||||
{
|
{
|
||||||
public String getPrefix();
|
public String getPrefix();
|
||||||
public Iterator getNodes();
|
public Iterator getNodes();
|
||||||
public Iterator getKeywords();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LookupResult lookup( String prefix, LookupKind kind );
|
public LookupResult lookup( String prefix, LookupKind kind ) throws LookupException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import org.eclipse.cdt.core.parser.IProblem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class BaseProblemFactory {
|
public abstract class BaseProblemFactory {
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
/*
|
/**********************************************************************
|
||||||
* Created on Dec 5, 2003
|
* 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
|
||||||
*
|
*
|
||||||
* To change the template for this generated file go to
|
* Contributors:
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
* IBM Rational Software - Initial API and implementation
|
||||||
*/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser;
|
package org.eclipse.cdt.internal.core.parser;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.Backtrack;
|
import org.eclipse.cdt.core.parser.BacktrackException;
|
||||||
import org.eclipse.cdt.core.parser.EndOfFile;
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
@ -21,9 +25,6 @@ import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
|
||||||
* To change the template for this generated type comment go to
|
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
|
||||||
*/
|
*/
|
||||||
public class CompleteParser extends Parser {
|
public class CompleteParser extends Parser {
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ public class CompleteParser extends Parser {
|
||||||
scanner.setASTFactory(astFactory);
|
scanner.setASTFactory(astFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleFunctionBody(IASTScope scope, boolean isInlineFunction) throws Backtrack, EndOfFile
|
protected void handleFunctionBody(IASTScope scope, boolean isInlineFunction) throws BacktrackException, EndOfFileException
|
||||||
{
|
{
|
||||||
if ( isInlineFunction )
|
if ( isInlineFunction )
|
||||||
skipOverCompoundStatement();
|
skipOverCompoundStatement();
|
||||||
|
@ -48,7 +49,7 @@ public class CompleteParser extends Parser {
|
||||||
functionBody(scope);
|
functionBody(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void catchBlockCompoundStatement(IASTScope scope) throws Backtrack, EndOfFile
|
protected void catchBlockCompoundStatement(IASTScope scope) throws BacktrackException, EndOfFileException
|
||||||
{
|
{
|
||||||
compoundStatement(scope, true);
|
compoundStatement(scope, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
/*
|
/**********************************************************************
|
||||||
* Created on Dec 4, 2003
|
* 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
|
||||||
*
|
*
|
||||||
* To change the template for this generated file go to
|
* Contributors:
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
* IBM Rational Software - Initial API and implementation
|
||||||
*/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser;
|
package org.eclipse.cdt.internal.core.parser;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -11,9 +15,6 @@ import java.io.Reader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
|
||||||
* To change the template for this generated type comment go to
|
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
|
||||||
*/
|
*/
|
||||||
public class LimitedScannerContext
|
public class LimitedScannerContext
|
||||||
extends ScannerContext
|
extends ScannerContext
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -12,11 +12,12 @@ package org.eclipse.cdt.internal.core.parser;
|
||||||
|
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.EndOfFile;
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IPreprocessor;
|
import org.eclipse.cdt.core.parser.IPreprocessor;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
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.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerException;
|
import org.eclipse.cdt.core.parser.ScannerException;
|
||||||
|
@ -49,7 +50,12 @@ public class Preprocessor extends Scanner implements IPreprocessor {
|
||||||
// callback IProblem here
|
// callback IProblem here
|
||||||
log.errorLog("Preprocessor Exception "+ se.getProblem().getMessage()); //$NON-NLS-1$h
|
log.errorLog("Preprocessor Exception "+ se.getProblem().getMessage()); //$NON-NLS-1$h
|
||||||
}
|
}
|
||||||
catch( EndOfFile eof )
|
catch( OffsetLimitReachedException olre )
|
||||||
|
{
|
||||||
|
// callback IProblem here
|
||||||
|
log.errorLog("Preprocessor Exception "+ olre.getMessage()); //$NON-NLS-1$h
|
||||||
|
}
|
||||||
|
catch( EndOfFileException eof )
|
||||||
{
|
{
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
/*
|
/**********************************************************************
|
||||||
* Created on Dec 5, 2003
|
* 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
|
||||||
*
|
*
|
||||||
* To change the template for this generated file go to
|
* Contributors:
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
* IBM Rational Software - Initial API and implementation
|
||||||
*/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser;
|
package org.eclipse.cdt.internal.core.parser;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.Backtrack;
|
import org.eclipse.cdt.core.parser.BacktrackException;
|
||||||
import org.eclipse.cdt.core.parser.EndOfFile;
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
@ -21,9 +25,6 @@ import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
|
||||||
* To change the template for this generated type comment go to
|
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
|
||||||
*/
|
*/
|
||||||
public class QuickParser extends Parser {
|
public class QuickParser extends Parser {
|
||||||
|
|
||||||
|
@ -40,12 +41,12 @@ public class QuickParser extends Parser {
|
||||||
scanner.setASTFactory(astFactory);
|
scanner.setASTFactory(astFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleFunctionBody(IASTScope scope, boolean isInlineFunction) throws Backtrack, EndOfFile
|
protected void handleFunctionBody(IASTScope scope, boolean isInlineFunction) throws BacktrackException, EndOfFileException
|
||||||
{
|
{
|
||||||
skipOverCompoundStatement();
|
skipOverCompoundStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void catchBlockCompoundStatement(IASTScope scope) throws Backtrack, EndOfFile
|
protected void catchBlockCompoundStatement(IASTScope scope) throws BacktrackException, EndOfFileException
|
||||||
{
|
{
|
||||||
skipOverCompoundStatement();
|
skipOverCompoundStatement();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ import java.util.Map;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.Backtrack;
|
import org.eclipse.cdt.core.parser.BacktrackException;
|
||||||
import org.eclipse.cdt.core.parser.EndOfFile;
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
import org.eclipse.cdt.core.parser.ILineOffsetReconciler;
|
import org.eclipse.cdt.core.parser.ILineOffsetReconciler;
|
||||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
@ -38,6 +38,7 @@ import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
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.ParserFactory;
|
||||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
|
@ -64,6 +65,7 @@ public class Scanner implements IScanner {
|
||||||
private boolean initialContextInitialized = false;
|
private boolean initialContextInitialized = false;
|
||||||
private final String filename;
|
private final String filename;
|
||||||
private final Reader reader;
|
private final Reader reader;
|
||||||
|
protected IToken finalToken;
|
||||||
|
|
||||||
protected void handleProblem( int problemID, String argument, int beginningOffset, boolean warning, boolean error ) throws ScannerException
|
protected void handleProblem( int problemID, String argument, int beginningOffset, boolean warning, boolean error ) throws ScannerException
|
||||||
{
|
{
|
||||||
|
@ -128,7 +130,7 @@ public class Scanner implements IScanner {
|
||||||
contextStack.push( context, requestor );
|
contextStack.push( context, requestor );
|
||||||
} catch( ContextException ce )
|
} catch( ContextException ce )
|
||||||
{
|
{
|
||||||
// should never occur
|
handleInternalError();
|
||||||
}
|
}
|
||||||
initialContextInitialized = true;
|
initialContextInitialized = true;
|
||||||
}
|
}
|
||||||
|
@ -284,6 +286,7 @@ public class Scanner implements IScanner {
|
||||||
private void setCurrentToken(IToken t) {
|
private void setCurrentToken(IToken t) {
|
||||||
if (currentToken != null)
|
if (currentToken != null)
|
||||||
currentToken.setNext(t);
|
currentToken.setNext(t);
|
||||||
|
finalToken = t;
|
||||||
currentToken = t;
|
currentToken = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,15 +694,15 @@ public class Scanner implements IScanner {
|
||||||
getChar();
|
getChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IToken nextToken() throws ScannerException, EndOfFile {
|
public IToken nextToken() throws ScannerException, EndOfFileException, OffsetLimitReachedException {
|
||||||
return nextToken( true, false );
|
return nextToken( true, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
public IToken nextToken(boolean pasting) throws ScannerException, EndOfFile {
|
public IToken nextToken(boolean pasting) throws ScannerException, EndOfFileException, OffsetLimitReachedException {
|
||||||
return nextToken( pasting, false );
|
return nextToken( pasting, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
public IToken nextToken( boolean pasting, boolean lookingForNextAlready ) throws ScannerException, EndOfFile
|
public IToken nextToken( boolean pasting, boolean lookingForNextAlready ) throws ScannerException, EndOfFileException, OffsetLimitReachedException
|
||||||
{
|
{
|
||||||
if( ! initialContextInitialized )
|
if( ! initialContextInitialized )
|
||||||
setupInitialContext();
|
setupInitialContext();
|
||||||
|
@ -793,7 +796,7 @@ public class Scanner implements IScanner {
|
||||||
IToken next = null;
|
IToken next = null;
|
||||||
try{
|
try{
|
||||||
next = nextToken( true, true );
|
next = nextToken( true, true );
|
||||||
} catch( EndOfFile e ){
|
} catch( EndOfFileException e ){
|
||||||
next = null;
|
next = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -804,7 +807,7 @@ public class Scanner implements IScanner {
|
||||||
currentToken = returnToken;
|
currentToken = returnToken;
|
||||||
try{
|
try{
|
||||||
next = nextToken( true, true );
|
next = nextToken( true, true );
|
||||||
} catch( EndOfFile e ){
|
} catch( EndOfFileException e ){
|
||||||
next = null;
|
next = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1598,11 +1601,11 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
handleProblem( IProblem.SCANNER_BAD_CHARACTER, new Character( (char)c ).toString(), getCurrentOffset(), false, true, throwExceptionOnBadCharacterRead );
|
handleProblem( IProblem.SCANNER_BAD_CHARACTER, new Character( (char)c ).toString(), getCurrentOffset(), false, true, throwExceptionOnBadCharacterRead );
|
||||||
c = ' ';
|
c = getChar();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw Parser.endOfFile;
|
throwEOF();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1613,7 +1616,8 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
// we're done
|
// we're done
|
||||||
throw Parser.endOfFile;
|
throwEOF();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1683,7 +1687,7 @@ public class Scanner implements IScanner {
|
||||||
// the static instance we always use
|
// the static instance we always use
|
||||||
protected static endOfMacroTokenException endOfMacroToken = new endOfMacroTokenException();
|
protected static endOfMacroTokenException endOfMacroToken = new endOfMacroTokenException();
|
||||||
|
|
||||||
public IToken nextTokenForStringizing() throws ScannerException, EndOfFile
|
public IToken nextTokenForStringizing() throws ScannerException, EndOfFileException, OffsetLimitReachedException
|
||||||
{
|
{
|
||||||
int beginOffset = getCurrentOffset();
|
int beginOffset = getCurrentOffset();
|
||||||
int c = getChar();
|
int c = getChar();
|
||||||
|
@ -1771,10 +1775,24 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
// we're done
|
// we're done
|
||||||
throw Parser.endOfFile;
|
throwEOF();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected void throwEOF() throws EndOfFileException, OffsetLimitReachedException {
|
||||||
|
if( offsetLimit == NO_OFFSET_LIMIT )
|
||||||
|
throw new EndOfFileException();
|
||||||
|
|
||||||
|
if( finalToken.getEndOffset() == offsetLimit )
|
||||||
|
throw new OffsetLimitReachedException(finalToken);
|
||||||
|
throw new OffsetLimitReachedException( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
cppKeywords.put("and", new Integer(IToken.t_and));
|
cppKeywords.put("and", new Integer(IToken.t_and));
|
||||||
cppKeywords.put("and_eq", new Integer(IToken.t_and_eq));
|
cppKeywords.put("and_eq", new Integer(IToken.t_and_eq));
|
||||||
|
@ -1956,20 +1974,21 @@ public class Scanner implements IScanner {
|
||||||
parser = ParserFactory.createParser(trial, nullCallback, ParserMode.QUICK_PARSE, language, log );
|
parser = ParserFactory.createParser(trial, nullCallback, ParserMode.QUICK_PARSE, language, log );
|
||||||
} catch( ParserFactoryException pfe )
|
} catch( ParserFactoryException pfe )
|
||||||
{
|
{
|
||||||
// TODO - make INTERNAL IProblem
|
handleInternalError();
|
||||||
// should never happen
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
IASTExpression exp = parser.expression(null);
|
IASTExpression exp = parser.expression(null);
|
||||||
if( exp.evaluateExpression() == 0 )
|
if( exp.evaluateExpression() == 0 )
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
} catch( Backtrack backtrack )
|
} catch( BacktrackException backtrack )
|
||||||
{
|
{
|
||||||
handleProblem( IProblem.PREPROCESSOR_CONDITIONAL_EVAL_ERROR, expression, beginningOffset, false, true, true );
|
handleProblem( IProblem.PREPROCESSOR_CONDITIONAL_EVAL_ERROR, expression, beginningOffset, false, true, true );
|
||||||
}
|
}
|
||||||
catch (ExpressionEvaluationException e) {
|
catch (ExpressionEvaluationException e) {
|
||||||
handleProblem( IProblem.PREPROCESSOR_CONDITIONAL_EVAL_ERROR, expression, beginningOffset, false, true, true );
|
handleProblem( IProblem.PREPROCESSOR_CONDITIONAL_EVAL_ERROR, expression, beginningOffset, false, true, true );
|
||||||
|
} catch (EndOfFileException e) {
|
||||||
|
handleProblem( IProblem.PREPROCESSOR_CONDITIONAL_EVAL_ERROR, expression, beginningOffset, false, true, true );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2058,7 +2077,10 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
t = helperScanner.nextToken(false);
|
t = helperScanner.nextToken(false);
|
||||||
} catch (EndOfFile eof) {
|
} 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 );
|
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#include " + includeLine, beginningOffset, false, true, true );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2091,7 +2113,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
endOffset = baseOffset + t.getEndOffset();
|
endOffset = baseOffset + t.getEndOffset();
|
||||||
|
|
||||||
} catch (EndOfFile eof) {
|
} catch (EndOfFileException eof) {
|
||||||
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#include " + includeLine, beginningOffset, false, true, true );
|
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#include " + includeLine, beginningOffset, false, true, true );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2105,7 +2127,10 @@ public class Scanner implements IScanner {
|
||||||
} else
|
} else
|
||||||
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#include " + includeLine, beginningOffset, false, true, true );
|
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#include " + includeLine, beginningOffset, false, true, true );
|
||||||
}
|
}
|
||||||
catch( EndOfFile eof )
|
catch (OffsetLimitReachedException e) {
|
||||||
|
handleInternalError();
|
||||||
|
}
|
||||||
|
catch( EndOfFileException eof )
|
||||||
{
|
{
|
||||||
// good
|
// good
|
||||||
}
|
}
|
||||||
|
@ -2172,7 +2197,7 @@ public class Scanner implements IScanner {
|
||||||
forInclusion = b;
|
forInclusion = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void poundDefine(int beginning) throws ScannerException, EndOfFile {
|
protected void poundDefine(int beginning) throws ScannerException, EndOfFileException {
|
||||||
skipOverWhitespace();
|
skipOverWhitespace();
|
||||||
// definition
|
// definition
|
||||||
String key = getNextIdentifier();
|
String key = getNextIdentifier();
|
||||||
|
@ -2245,8 +2270,12 @@ public class Scanner implements IScanner {
|
||||||
} catch (ParserFactoryException e1) {
|
} catch (ParserFactoryException e1) {
|
||||||
}
|
}
|
||||||
helperScanner.setTokenizingMacroReplacementList( true );
|
helperScanner.setTokenizingMacroReplacementList( true );
|
||||||
IToken t = helperScanner.nextToken(false);
|
IToken t = null;
|
||||||
|
try {
|
||||||
|
t = helperScanner.nextToken(false);
|
||||||
|
} catch (OffsetLimitReachedException e2) {
|
||||||
|
handleInternalError();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
//each # preprocessing token in the replacement list shall be followed
|
//each # preprocessing token in the replacement list shall be followed
|
||||||
|
@ -2268,7 +2297,11 @@ public class Scanner implements IScanner {
|
||||||
t = helperScanner.nextToken(false);
|
t = helperScanner.nextToken(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( EndOfFile eof )
|
catch( OffsetLimitReachedException olre )
|
||||||
|
{
|
||||||
|
handleInternalError();
|
||||||
|
}
|
||||||
|
catch( EndOfFileException eof )
|
||||||
{
|
{
|
||||||
// good
|
// good
|
||||||
}
|
}
|
||||||
|
@ -2363,7 +2396,6 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
else if( newDefinition instanceof String )
|
else if( newDefinition instanceof String )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( previousDefinition instanceof String )
|
if( previousDefinition instanceof String )
|
||||||
{
|
{
|
||||||
Scanner previous = new Scanner( new StringReader( (String)previousDefinition ), "redef-test", new ScannerInfo(), new NullSourceElementRequestor(),
|
Scanner previous = new Scanner( new StringReader( (String)previousDefinition ), "redef-test", new ScannerInfo(), new NullSourceElementRequestor(),
|
||||||
|
@ -2383,7 +2415,11 @@ public class Scanner implements IScanner {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch( EndOfFile eof )
|
catch( OffsetLimitReachedException olre )
|
||||||
|
{
|
||||||
|
handleInternalError();
|
||||||
|
}
|
||||||
|
catch( EndOfFileException eof )
|
||||||
{
|
{
|
||||||
if( ( p != null ) && ( c == null ) )
|
if( ( p != null ) && ( c == null ) )
|
||||||
break;
|
break;
|
||||||
|
@ -2394,7 +2430,11 @@ public class Scanner implements IScanner {
|
||||||
c = current.nextToken();
|
c = current.nextToken();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch( EndOfFile eof2 )
|
catch( OffsetLimitReachedException olre )
|
||||||
|
{
|
||||||
|
handleInternalError();
|
||||||
|
}
|
||||||
|
catch( EndOfFileException eof2 )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2408,7 +2448,15 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Vector getMacroParameters (String params, boolean forStringizing) throws ScannerException {
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected void handleInternalError() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Vector getMacroParameters (String params, boolean forStringizing) throws ScannerException {
|
||||||
|
|
||||||
Scanner tokenizer = new Scanner(new StringReader(params), TEXT, new ScannerInfo( definitions, originalConfig.getIncludePaths() ), new NullSourceElementRequestor(), mode, language, log);
|
Scanner tokenizer = new Scanner(new StringReader(params), TEXT, new ScannerInfo( definitions, originalConfig.getIncludePaths() ), new NullSourceElementRequestor(), mode, language, log);
|
||||||
tokenizer.setThrowExceptionOnBadCharacterRead(false);
|
tokenizer.setThrowExceptionOnBadCharacterRead(false);
|
||||||
|
@ -2449,11 +2497,17 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
space = true;
|
space = true;
|
||||||
}
|
}
|
||||||
} catch (EndOfFile e) {
|
}
|
||||||
|
catch( OffsetLimitReachedException olre )
|
||||||
|
{
|
||||||
|
handleInternalError();
|
||||||
|
}
|
||||||
|
catch (EndOfFileException e) {
|
||||||
// Good
|
// Good
|
||||||
parameterValues.add(str);
|
parameterValues.add(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return parameterValues;
|
return parameterValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
/*
|
/**********************************************************************
|
||||||
* Created on Dec 8, 2003
|
* 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
|
||||||
*
|
*
|
||||||
* To change the template for this generated file go to
|
* Contributors:
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
* IBM Rational Software - Initial API and implementation
|
||||||
*/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser;
|
package org.eclipse.cdt.internal.core.parser;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.Backtrack;
|
import org.eclipse.cdt.core.parser.BacktrackException;
|
||||||
import org.eclipse.cdt.core.parser.EndOfFile;
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
|
@ -22,9 +26,6 @@ import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
|
||||||
* To change the template for this generated type comment go to
|
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
|
||||||
*/
|
*/
|
||||||
public class StructuralParser extends Parser implements IParser {
|
public class StructuralParser extends Parser implements IParser {
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ public class StructuralParser extends Parser implements IParser {
|
||||||
protected void handleFunctionBody(
|
protected void handleFunctionBody(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
boolean isInlineFunction)
|
boolean isInlineFunction)
|
||||||
throws Backtrack, EndOfFile {
|
throws BacktrackException, EndOfFileException {
|
||||||
skipOverCompoundStatement();
|
skipOverCompoundStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ public class StructuralParser extends Parser implements IParser {
|
||||||
* @see org.eclipse.cdt.internal.core.parser.Parser#catchBlockCompoundStatement(org.eclipse.cdt.core.parser.ast.IASTScope)
|
* @see org.eclipse.cdt.internal.core.parser.Parser#catchBlockCompoundStatement(org.eclipse.cdt.core.parser.ast.IASTScope)
|
||||||
*/
|
*/
|
||||||
protected void catchBlockCompoundStatement(IASTScope scope)
|
protected void catchBlockCompoundStatement(IASTScope scope)
|
||||||
throws Backtrack, EndOfFile {
|
throws BacktrackException, EndOfFileException {
|
||||||
skipOverCompoundStatement();
|
skipOverCompoundStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class ASTCompletionNode implements IASTCompletionNode {
|
||||||
|
|
||||||
|
private final String prefix;
|
||||||
|
private final IASTNode context;
|
||||||
|
private final IASTScope scope;
|
||||||
|
private final CompletionKind kind;
|
||||||
|
private final Set keywordSet;
|
||||||
|
|
||||||
|
public ASTCompletionNode( CompletionKind kind, IASTScope scope, IASTNode context, String prefix, Set keywords )
|
||||||
|
{
|
||||||
|
this.kind = kind;
|
||||||
|
this.context = context;
|
||||||
|
this.scope = scope;
|
||||||
|
this.prefix = prefix;
|
||||||
|
this.keywordSet = keywords;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTCompletionNode#getCompletionKind()
|
||||||
|
*/
|
||||||
|
public CompletionKind getCompletionKind() {
|
||||||
|
return kind;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTCompletionNode#getCompletionScope()
|
||||||
|
*/
|
||||||
|
public IASTScope getCompletionScope() {
|
||||||
|
return scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTCompletionNode#getCompletionContext()
|
||||||
|
*/
|
||||||
|
public IASTNode getCompletionContext() {
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTCompletionNode#getCompletionPrefix()
|
||||||
|
*/
|
||||||
|
public String getCompletionPrefix() {
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTCompletionNode#getKeywords()
|
||||||
|
*/
|
||||||
|
public Iterator getKeywords() {
|
||||||
|
if( keywordSet == null )
|
||||||
|
return new EmptyIterator();
|
||||||
|
return keywordSet.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -32,7 +32,9 @@ public abstract class ASTSymbol extends ASTSymbolOwner implements ISymbolOwner,
|
||||||
*/
|
*/
|
||||||
public IASTScope getOwnerScope()
|
public IASTScope getOwnerScope()
|
||||||
{
|
{
|
||||||
return (IASTScope)symbol.getContainingSymbol().getASTExtension().getPrimaryDeclaration();
|
if( symbol.getContainingSymbol() != null )
|
||||||
|
return (IASTScope)symbol.getContainingSymbol().getASTExtension().getPrimaryDeclaration();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,6 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
|
|
@ -18,9 +18,6 @@ import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*
|
|
||||||
* To change the template for this generated type comment go to
|
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
|
||||||
*/
|
*/
|
||||||
public class TypeFilter {
|
public class TypeFilter {
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,14 @@ import java.io.StringReader;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.EndOfFile;
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
import org.eclipse.cdt.core.parser.IProblem;
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
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.ParserFactory;
|
||||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
|
@ -362,7 +363,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
||||||
|
|
||||||
try {
|
try {
|
||||||
token = scanner.nextToken();
|
token = scanner.nextToken();
|
||||||
} catch (EndOfFile e) {
|
} catch (EndOfFileException e) {
|
||||||
} catch (ScannerException e) {
|
} catch (ScannerException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,7 +582,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (EndOfFile e) {
|
} catch (EndOfFileException e) {
|
||||||
list.addLast( name.toCharArray() );
|
list.addLast( name.toCharArray() );
|
||||||
} catch (ScannerException e) {
|
} catch (ScannerException e) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
2003-12-11 John Camelon
|
||||||
|
Updated CompletionEngine to deal with new signatures/exceptions in parser.
|
||||||
|
|
||||||
2002-12-11 David Inglis
|
2002-12-11 David Inglis
|
||||||
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=48596
|
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=48596
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupResult;
|
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupResult;
|
||||||
import org.eclipse.cdt.internal.core.CharOperation;
|
import org.eclipse.cdt.internal.core.CharOperation;
|
||||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||||
|
@ -176,8 +177,6 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
try {
|
try {
|
||||||
result = parser.parse(completionOffset);
|
result = parser.parse(completionOffset);
|
||||||
} catch (ParserNotImplementedException e) {
|
} catch (ParserNotImplementedException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
|
@ -275,8 +274,6 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
IASTNode node = (IASTNode) nodes.next();
|
IASTNode node = (IASTNode) nodes.next();
|
||||||
addNodeToCompletions(node, result.getPrefix());
|
addNodeToCompletions(node, result.getPrefix());
|
||||||
}
|
}
|
||||||
Iterator keywords = result.getKeywords();
|
|
||||||
addKeywordsToCompletions(keywords);
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,15 +294,38 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
// Completing after a dot
|
// Completing after a dot
|
||||||
// 1. Get the search scope node
|
// 1. Get the search scope node
|
||||||
IASTNode searchNode = completionNode.getCompletionScope();
|
IASTNode searchNode = completionNode.getCompletionScope();
|
||||||
|
|
||||||
|
LookupResult result = null;
|
||||||
// 2. lookup fields & add to completion proposals
|
// 2. lookup fields & add to completion proposals
|
||||||
LookupResult result = searchNode.lookup (completionNode.getCompletionPrefix(), IASTNode.LookupKind.FIELDS);
|
try
|
||||||
addToCompletions (result);
|
{
|
||||||
// 3. looup methods & add to completion proposals
|
result = searchNode.lookup (completionNode.getCompletionPrefix(), IASTNode.LookupKind.FIELDS);
|
||||||
result = searchNode.lookup (completionNode.getCompletionPrefix(), IASTNode.LookupKind.METHODS);
|
addToCompletions (result);
|
||||||
addToCompletions (result);
|
}
|
||||||
// 4. lookup nested structures & add to completion proposals
|
catch( IASTNode.LookupException ilk )
|
||||||
result = searchNode.lookup (completionNode.getCompletionPrefix(), IASTNode.LookupKind.STRUCTURES);
|
{
|
||||||
addToCompletions (result);
|
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 3. looup methods & add to completion proposals
|
||||||
|
result = searchNode.lookup (completionNode.getCompletionPrefix(), IASTNode.LookupKind.METHODS);
|
||||||
|
addToCompletions (result);
|
||||||
|
}
|
||||||
|
catch( IASTNode.LookupException ilk )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 4. lookup nested structures & add to completion proposals
|
||||||
|
result = searchNode.lookup (completionNode.getCompletionPrefix(), IASTNode.LookupKind.STRUCTURES);
|
||||||
|
addToCompletions (result);
|
||||||
|
} catch (LookupException e) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private void completionOnTypeReference(IASTCompletionNode completionNode){
|
private void completionOnTypeReference(IASTCompletionNode completionNode){
|
||||||
// completing on a type
|
// completing on a type
|
||||||
|
@ -314,8 +334,13 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
// if the prefix is not empty
|
// if the prefix is not empty
|
||||||
if(completionNode.getCompletionPrefix().length() > 0 ) {
|
if(completionNode.getCompletionPrefix().length() > 0 ) {
|
||||||
// 2. Lookup all types that could be used here
|
// 2. Lookup all types that could be used here
|
||||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.STRUCTURES);
|
LookupResult result;
|
||||||
addToCompletions(result);
|
try {
|
||||||
|
result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.STRUCTURES);
|
||||||
|
addToCompletions(result);
|
||||||
|
} catch (LookupException e) {
|
||||||
|
}
|
||||||
|
|
||||||
// 3. Lookup keywords
|
// 3. Lookup keywords
|
||||||
// basic types should be in the keyword list
|
// basic types should be in the keyword list
|
||||||
List keywords = lookupKeyword(completionNode.getCompletionPrefix(), BASIC_TYPES_KEYWORDS);
|
List keywords = lookupKeyword(completionNode.getCompletionPrefix(), BASIC_TYPES_KEYWORDS);
|
||||||
|
@ -334,8 +359,15 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
// 3. lookup methods
|
// 3. lookup methods
|
||||||
// we are at a field declaration place, the user could be trying to override a function.
|
// we are at a field declaration place, the user could be trying to override a function.
|
||||||
// We have to lookup functions that could be overridden here.
|
// We have to lookup functions that could be overridden here.
|
||||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.METHODS);
|
LookupResult result;
|
||||||
addToCompletions(result);
|
try {
|
||||||
|
result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.METHODS);
|
||||||
|
addToCompletions(result);
|
||||||
|
} catch (LookupException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private void completionOnVariableType(IASTCompletionNode completionNode){
|
private void completionOnVariableType(IASTCompletionNode completionNode){
|
||||||
// 1. basic completion on all types
|
// 1. basic completion on all types
|
||||||
|
@ -349,13 +381,28 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
if (completionNode.getCompletionPrefix().length() > 0){
|
if (completionNode.getCompletionPrefix().length() > 0){
|
||||||
// here we have to look for anything that could be referenced within this scope
|
// here we have to look for anything that could be referenced within this scope
|
||||||
// 1. lookup local variables, global variables, functions, methods, structures, enums, macros, and namespaces
|
// 1. lookup local variables, global variables, functions, methods, structures, enums, macros, and namespaces
|
||||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.ALL);
|
try
|
||||||
addToCompletions(result);
|
{
|
||||||
|
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.ALL);
|
||||||
|
addToCompletions(result);
|
||||||
|
}
|
||||||
|
catch( LookupException ilk )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
} else // prefix is empty
|
} else // prefix is empty
|
||||||
{
|
{
|
||||||
// 1. look only for local variables
|
// 1. look only for local variables
|
||||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.LOCAL_VARIABLES);
|
try
|
||||||
addToCompletions(result);
|
{
|
||||||
|
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.LOCAL_VARIABLES);
|
||||||
|
addToCompletions(result);
|
||||||
|
}
|
||||||
|
catch( LookupException ilk )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// 2. and what can be accessed through the "this" pointer
|
// 2. and what can be accessed through the "this" pointer
|
||||||
// TODO : complete the lookup call
|
// TODO : complete the lookup call
|
||||||
}
|
}
|
||||||
|
@ -366,23 +413,42 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
IASTNode searchNode = completionNode.getCompletionScope();
|
IASTNode searchNode = completionNode.getCompletionScope();
|
||||||
// here we have to look for anything that could be referenced within this scope
|
// here we have to look for anything that could be referenced within this scope
|
||||||
// 1. lookup local variables, global variables, functions, methods, structures, enums, macros, and namespaces
|
// 1. lookup local variables, global variables, functions, methods, structures, enums, macros, and namespaces
|
||||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.ALL);
|
try
|
||||||
addToCompletions(result);
|
{
|
||||||
|
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.ALL);
|
||||||
|
addToCompletions(result);
|
||||||
|
}
|
||||||
|
catch( LookupException ilk )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void completionOnClassReference(IASTCompletionNode completionNode){
|
private void completionOnClassReference(IASTCompletionNode completionNode){
|
||||||
// 1. Get the search scope node
|
// 1. Get the search scope node
|
||||||
IASTNode searchNode = completionNode.getCompletionScope();
|
IASTNode searchNode = completionNode.getCompletionScope();
|
||||||
// only look for classes
|
// only look for classes
|
||||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.CLASSES);
|
try
|
||||||
addToCompletions(result);
|
{
|
||||||
|
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.CLASSES);
|
||||||
|
addToCompletions(result);
|
||||||
|
}
|
||||||
|
catch( LookupException ilk )
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void completionOnNamespaceReference(IASTCompletionNode completionNode){
|
private void completionOnNamespaceReference(IASTCompletionNode completionNode){
|
||||||
// 1. Get the search scope node
|
// 1. Get the search scope node
|
||||||
IASTNode searchNode = completionNode.getCompletionScope();
|
IASTNode searchNode = completionNode.getCompletionScope();
|
||||||
// only look for classes
|
// only look for classes
|
||||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.NAMESPACES);
|
try
|
||||||
addToCompletions(result);
|
{
|
||||||
|
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.NAMESPACES);
|
||||||
|
addToCompletions(result);
|
||||||
|
}
|
||||||
|
catch( LookupException ilk )
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void completionOnExceptionReference(IASTCompletionNode completionNode){
|
private void completionOnExceptionReference(IASTCompletionNode completionNode){
|
||||||
// here we have to look for all types
|
// here we have to look for all types
|
||||||
|
@ -396,8 +462,14 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
// 1. Get the search scope node
|
// 1. Get the search scope node
|
||||||
IASTNode searchNode = completionNode.getCompletionScope();
|
IASTNode searchNode = completionNode.getCompletionScope();
|
||||||
// only look for macros
|
// only look for macros
|
||||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.MACROS);
|
try
|
||||||
addToCompletions(result);
|
{
|
||||||
|
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.MACROS);
|
||||||
|
addToCompletions(result);
|
||||||
|
}
|
||||||
|
catch( LookupException ilk )
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void completionOnFunctionReference(IASTCompletionNode completionNode){
|
private void completionOnFunctionReference(IASTCompletionNode completionNode){
|
||||||
// TODO: complete the lookups
|
// TODO: complete the lookups
|
||||||
|
@ -406,7 +478,14 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
// 1. Get the search scope node
|
// 1. Get the search scope node
|
||||||
IASTNode searchNode = completionNode.getCompletionScope();
|
IASTNode searchNode = completionNode.getCompletionScope();
|
||||||
// only lookup constructors
|
// only lookup constructors
|
||||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.CONSTRUCTORS);
|
try
|
||||||
|
{
|
||||||
|
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.CONSTRUCTORS);
|
||||||
|
}
|
||||||
|
catch( LookupException ilk )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private void completionOnKeyword(IASTCompletionNode completionNode){
|
private void completionOnKeyword(IASTCompletionNode completionNode){
|
||||||
// lookup every type of keywords
|
// lookup every type of keywords
|
||||||
|
@ -485,6 +564,7 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
completionOnKeyword(completionNode);
|
completionOnKeyword(completionNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addKeywordsToCompletions( completionNode.getKeywords());
|
||||||
completionList.addAll(completions);
|
completionList.addAll(completions);
|
||||||
return completionNode;
|
return completionNode;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue