mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Updated Scanner to allow for more robust completion in #if directives.
This commit is contained in:
parent
df79974b26
commit
de5b46412d
2 changed files with 42 additions and 23 deletions
|
@ -1,3 +1,6 @@
|
|||
2004-01-30 John Camelon
|
||||
Updated Scanner to allow for more robust completion in #if directives.
|
||||
|
||||
2004-01-30 John Camelon
|
||||
Fixed Bug 50487 - Wrong completion kind and prefix after "#ifdef"
|
||||
|
||||
|
|
|
@ -1827,7 +1827,7 @@ public class Scanner implements IScanner {
|
|||
*/
|
||||
private void handleCompletionOnDefinition(String definition) throws EndOfFileException {
|
||||
IASTCompletionNode node = new ASTCompletionNode( IASTCompletionNode.CompletionKind.MACRO_REFERENCE,
|
||||
null, null, definition, KeywordSets.getKeywords(KeywordSets.Key.MACRO, language) );
|
||||
null, null, definition, KeywordSets.getKeywords(KeywordSets.Key.EMPTY, language) );
|
||||
|
||||
throwEOF( node );
|
||||
}
|
||||
|
@ -1836,9 +1836,17 @@ public class Scanner implements IScanner {
|
|||
* @param expression2
|
||||
*/
|
||||
private void handleCompletionOnExpression(String expression) throws EndOfFileException {
|
||||
int completionPoint = expression.length();
|
||||
int completionPoint = expression.length() + 2;
|
||||
IASTCompletionNode.CompletionKind kind = IASTCompletionNode.CompletionKind.MACRO_REFERENCE;
|
||||
|
||||
String prefix = "";
|
||||
|
||||
if( ! expression.trim().equals(""))
|
||||
{
|
||||
IScanner subScanner = ParserFactory.createScanner( new StringReader(expression), SCRATCH, EMPTY_INFO, ParserMode.QUICK_PARSE, language, new NullSourceElementRequestor(), new NullLogService());
|
||||
IToken lastToken = null;
|
||||
while( true )
|
||||
{
|
||||
try
|
||||
{
|
||||
lastToken = subScanner.nextToken();
|
||||
|
@ -1846,22 +1854,30 @@ public class Scanner implements IScanner {
|
|||
catch( EndOfFileException eof )
|
||||
{
|
||||
// ok
|
||||
break;
|
||||
} catch (ScannerException e) {
|
||||
handleInternalError();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String prefix = "";
|
||||
|
||||
if( ( lastToken != null ))
|
||||
{
|
||||
if( ( lastToken.getType() == IToken.tIDENTIFIER )
|
||||
&& ( lastToken.getEndOffset() == completionPoint ) )
|
||||
{
|
||||
prefix = lastToken.getImage();
|
||||
else if( ( lastToken.getEndOffset() == completionPoint ) &&
|
||||
( lastToken.getType() != IToken.tIDENTIFIER ) )
|
||||
kind = IASTCompletionNode.CompletionKind.NO_SUCH_KIND;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
IASTCompletionNode node = new ASTCompletionNode( IASTCompletionNode.CompletionKind.MACRO_REFERENCE,
|
||||
null, null, prefix, KeywordSets.getKeywords(KeywordSets.Key.MACRO, language) );
|
||||
IASTCompletionNode node = new ASTCompletionNode( kind,
|
||||
null, null, prefix,
|
||||
KeywordSets.getKeywords(((kind == IASTCompletionNode.CompletionKind.NO_SUCH_KIND )? KeywordSets.Key.EMPTY : KeywordSets.Key.MACRO), language) );
|
||||
|
||||
throwEOF( node );
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue