1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Updated Scanner for content assist in preprocessor directives.

This commit is contained in:
John Camelon 2004-01-23 21:04:23 +00:00
parent f26c374088
commit 7c3ab2617b
3 changed files with 32 additions and 3 deletions

View file

@ -1,3 +1,6 @@
2004-01-23 John Camelon
Added support for content assist in the scanner..
2004-01-22 John Camelon 2004-01-22 John Camelon
Added token, scanner and problem subpackages to org.eclipse.cdt.internal.core.parser. Added token, scanner and problem subpackages to org.eclipse.cdt.internal.core.parser.

View file

@ -10,16 +10,26 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.core.parser; package org.eclipse.cdt.core.parser;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
/** /**
* @author jcamelon * @author jcamelon
*/ */
public class OffsetLimitReachedException extends EndOfFileException { public class OffsetLimitReachedException extends EndOfFileException {
private final IASTCompletionNode node;
private final IToken finalToken; private final IToken finalToken;
public OffsetLimitReachedException( IASTCompletionNode node )
{
this.node = node;
finalToken = null;
}
public OffsetLimitReachedException( IToken token ) public OffsetLimitReachedException( IToken token )
{ {
finalToken = token; finalToken = token;
node = null;
} }
/** /**
@ -28,5 +38,17 @@ public class OffsetLimitReachedException extends EndOfFileException {
public IToken getFinalToken() { public IToken getFinalToken() {
return finalToken; return finalToken;
} }
/**
* @return returns the IASTCompletionNode
*/
public IASTCompletionNode getCompletionNode()
{
return node;
}
/**
* @author jcamelon
*/
} }

View file

@ -1194,6 +1194,7 @@ public class Scanner implements IScanner {
c = getChar(); c = getChar();
continue; continue;
case PreprocessorDirectives.IF : case PreprocessorDirectives.IF :
//TODO add in content assist stuff here
// get the rest of the line // get the rest of the line
int currentOffset = getCurrentOffset(); int currentOffset = getCurrentOffset();
String expression = getRestOfPreprocessorLine(); String expression = getRestOfPreprocessorLine();
@ -1210,6 +1211,7 @@ public class Scanner implements IScanner {
case PreprocessorDirectives.IFDEF : case PreprocessorDirectives.IFDEF :
//TODO add in content assist stuff here
skipOverWhitespace(); skipOverWhitespace();
if (getDefinition(getNextIdentifier()) == null) { if (getDefinition(getNextIdentifier()) == null) {
// not defined // not defined
@ -1234,6 +1236,7 @@ public class Scanner implements IScanner {
continue; continue;
case PreprocessorDirectives.IFNDEF : case PreprocessorDirectives.IFNDEF :
//TODO add in content assist stuff here
skipOverWhitespace(); skipOverWhitespace();
if (getDefinition(getNextIdentifier()) != null) { if (getDefinition(getNextIdentifier()) != null) {
// not defined // not defined
@ -1247,6 +1250,7 @@ public class Scanner implements IScanner {
continue; continue;
case PreprocessorDirectives.ELSE : case PreprocessorDirectives.ELSE :
//TODO add in content assist stuff here
try try
{ {
passOnToClient = branches.poundelse(); passOnToClient = branches.poundelse();
@ -1264,6 +1268,7 @@ public class Scanner implements IScanner {
continue; continue;
case PreprocessorDirectives.ELIF : case PreprocessorDirectives.ELIF :
//TODO add in content assist stuff here
int co = getCurrentOffset(); int co = getCurrentOffset();
String elsifExpression = getRestOfPreprocessorLine().trim(); String elsifExpression = getRestOfPreprocessorLine().trim();
@ -1291,7 +1296,6 @@ public class Scanner implements IScanner {
continue; continue;
case PreprocessorDirectives.LINE : case PreprocessorDirectives.LINE :
//TO DO
skipOverTextUntilNewline(); skipOverTextUntilNewline();
c = getChar(); c = getChar();
continue; continue;
@ -1839,7 +1843,7 @@ public class Scanner implements IScanner {
if( finalToken.getEndOffset() == offsetLimit ) if( finalToken.getEndOffset() == offsetLimit )
throw new OffsetLimitReachedException(finalToken); throw new OffsetLimitReachedException(finalToken);
throw new OffsetLimitReachedException( null ); throw new OffsetLimitReachedException( (IToken)null );
} }