mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Scanner2 + entire UI AutomatedSuite now pass.
This commit is contained in:
parent
b6a1800bd0
commit
df2be63243
1 changed files with 50 additions and 7 deletions
|
@ -823,6 +823,12 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
private final boolean isLimitReached() {
|
private final boolean isLimitReached() {
|
||||||
if( offsetBoundary == -1 ) return false;
|
if( offsetBoundary == -1 ) return false;
|
||||||
if( bufferPos[bufferStackPos] == offsetBoundary - 1 ) return true;
|
if( bufferPos[bufferStackPos] == offsetBoundary - 1 ) return true;
|
||||||
|
if( bufferPos[bufferStackPos] == offsetBoundary )
|
||||||
|
{
|
||||||
|
int c = bufferStack[bufferStackPos][bufferPos[bufferStackPos]];
|
||||||
|
if( c == '\n' || c == ' ' || c == '\t' || c == '\r')
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1098,6 +1104,8 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
int limit = bufferLimit[bufferStackPos];
|
int limit = bufferLimit[bufferStackPos];
|
||||||
int startingLineNumber = bufferLineNums[ bufferStackPos ];
|
int startingLineNumber = bufferLineNums[ bufferStackPos ];
|
||||||
skipOverWhiteSpace();
|
skipOverWhiteSpace();
|
||||||
|
if( isLimitReached() )
|
||||||
|
handleCompletionOnPreprocessorDirective( "#" ); //$NON-NLS-1$
|
||||||
|
|
||||||
// find the directive
|
// find the directive
|
||||||
int start = ++bufferPos[bufferStackPos];
|
int start = ++bufferPos[bufferStackPos];
|
||||||
|
@ -1144,9 +1152,13 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
start = bufferPos[bufferStackPos];
|
start = bufferPos[bufferStackPos];
|
||||||
skipToNewLine();
|
skipToNewLine();
|
||||||
len = bufferPos[bufferStackPos] - start;
|
len = bufferPos[bufferStackPos] - start;
|
||||||
|
if( isLimitReached() )
|
||||||
|
handleCompletionOnExpression( CharArrayUtils.extract( buffer, start, len ) );
|
||||||
if (expressionEvaluator.evaluate(buffer, start, len, definitions) == 0) {
|
if (expressionEvaluator.evaluate(buffer, start, len, definitions) == 0) {
|
||||||
if (dlog != null) dlog.println("#if <FALSE> " + new String(buffer,start+1,len-1)); //$NON-NLS-1$
|
if (dlog != null) dlog.println("#if <FALSE> " + new String(buffer,start+1,len-1)); //$NON-NLS-1$
|
||||||
skipOverConditionalCode(true);
|
skipOverConditionalCode(true);
|
||||||
|
if( isLimitReached() )
|
||||||
|
handleInvalidCompletion();
|
||||||
} else
|
} else
|
||||||
if (dlog != null) dlog.println("#if <TRUE> " + new String(buffer,start+1,len-1)); //$NON-NLS-1$
|
if (dlog != null) dlog.println("#if <TRUE> " + new String(buffer,start+1,len-1)); //$NON-NLS-1$
|
||||||
return;
|
return;
|
||||||
|
@ -1155,6 +1167,8 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
// Condition must have been true, skip over the rest
|
// Condition must have been true, skip over the rest
|
||||||
skipToNewLine();
|
skipToNewLine();
|
||||||
skipOverConditionalCode(false);
|
skipOverConditionalCode(false);
|
||||||
|
if( isLimitReached() )
|
||||||
|
handleInvalidCompletion();
|
||||||
return;
|
return;
|
||||||
case ppError:
|
case ppError:
|
||||||
throw new ScannerException(null);
|
throw new ScannerException(null);
|
||||||
|
@ -1513,7 +1527,7 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
return CharArrayUtils.trim( result );
|
return CharArrayUtils.trim( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePPUndef() {
|
private void handlePPUndef() throws EndOfFileException {
|
||||||
char[] buffer = bufferStack[bufferStackPos];
|
char[] buffer = bufferStack[bufferStackPos];
|
||||||
int limit = bufferLimit[bufferStackPos];
|
int limit = bufferLimit[bufferStackPos];
|
||||||
|
|
||||||
|
@ -1543,18 +1557,27 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
}
|
}
|
||||||
--bufferPos[bufferStackPos];
|
--bufferPos[bufferStackPos];
|
||||||
|
|
||||||
|
if( isLimitReached() )
|
||||||
|
handleCompletionOnDefinition( new String( buffer, idstart, idlen ));
|
||||||
|
|
||||||
skipToNewLine();
|
skipToNewLine();
|
||||||
|
|
||||||
definitions.remove(buffer, idstart, idlen);
|
definitions.remove(buffer, idstart, idlen);
|
||||||
if (dlog != null) dlog.println("#undef " + new String(buffer, idstart, idlen)); //$NON-NLS-1$
|
if (dlog != null) dlog.println("#undef " + new String(buffer, idstart, idlen)); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePPIfdef(boolean positive) {
|
private void handlePPIfdef(boolean positive) throws EndOfFileException {
|
||||||
char[] buffer = bufferStack[bufferStackPos];
|
char[] buffer = bufferStack[bufferStackPos];
|
||||||
int limit = bufferLimit[bufferStackPos];
|
int limit = bufferLimit[bufferStackPos];
|
||||||
|
|
||||||
|
if( isLimitReached() )
|
||||||
|
handleCompletionOnDefinition( EMPTY_STRING );
|
||||||
|
|
||||||
skipOverWhiteSpace();
|
skipOverWhiteSpace();
|
||||||
|
|
||||||
|
if( isLimitReached() )
|
||||||
|
handleCompletionOnDefinition( EMPTY_STRING );
|
||||||
|
|
||||||
// get the Identifier
|
// get the Identifier
|
||||||
int idstart = ++bufferPos[bufferStackPos];
|
int idstart = ++bufferPos[bufferStackPos];
|
||||||
if (idstart >= limit)
|
if (idstart >= limit)
|
||||||
|
@ -1579,6 +1602,9 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
}
|
}
|
||||||
--bufferPos[bufferStackPos];
|
--bufferPos[bufferStackPos];
|
||||||
|
|
||||||
|
if( isLimitReached() )
|
||||||
|
handleCompletionOnDefinition( new String( buffer, idstart, idlen ));
|
||||||
|
|
||||||
skipToNewLine();
|
skipToNewLine();
|
||||||
|
|
||||||
if ((definitions.get(buffer, idstart, idlen) != null) == positive) {
|
if ((definitions.get(buffer, idstart, idlen) != null) == positive) {
|
||||||
|
@ -1592,6 +1618,8 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
+ " <FALSE> " + new String(buffer, idstart, idlen)); //$NON-NLS-1$
|
+ " <FALSE> " + new String(buffer, idstart, idlen)); //$NON-NLS-1$
|
||||||
// skip over this group
|
// skip over this group
|
||||||
skipOverConditionalCode(true);
|
skipOverConditionalCode(true);
|
||||||
|
if( isLimitReached() )
|
||||||
|
handleInvalidCompletion();
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkelse - if potential for more, otherwise skip to endif
|
// checkelse - if potential for more, otherwise skip to endif
|
||||||
|
@ -2757,6 +2785,9 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
private static final int ppError = 9;
|
private static final int ppError = 9;
|
||||||
private static final int ppInclude_next = 10;
|
private static final int ppInclude_next = 10;
|
||||||
|
|
||||||
|
private static final char[] TAB = { '\t' };
|
||||||
|
private static final char[] SPACE = { ' ' };
|
||||||
|
|
||||||
static {
|
static {
|
||||||
keywords = new CharArrayIntMap(IToken.tLAST, -1);
|
keywords = new CharArrayIntMap(IToken.tLAST, -1);
|
||||||
|
|
||||||
|
@ -2874,12 +2905,24 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
/**
|
/**
|
||||||
* @param expression2
|
* @param expression2
|
||||||
*/
|
*/
|
||||||
protected void handleCompletionOnExpression(String expression) throws EndOfFileException {
|
protected void handleCompletionOnExpression(char [] buffer ) throws EndOfFileException {
|
||||||
|
|
||||||
|
|
||||||
IASTCompletionNode.CompletionKind kind = IASTCompletionNode.CompletionKind.MACRO_REFERENCE;
|
IASTCompletionNode.CompletionKind kind = IASTCompletionNode.CompletionKind.MACRO_REFERENCE;
|
||||||
|
int lastSpace = CharArrayUtils.lastIndexOf( SPACE, buffer );
|
||||||
|
int lastTab = CharArrayUtils.lastIndexOf( TAB, buffer );
|
||||||
|
int max = lastSpace > lastTab ? lastSpace : lastTab;
|
||||||
|
|
||||||
|
char [] prefix = CharArrayUtils.trim( CharArrayUtils.extract( buffer, max, buffer.length - max ) );
|
||||||
|
for( int i = 0; i < prefix.length; ++i )
|
||||||
|
{
|
||||||
|
char c = prefix[i];
|
||||||
|
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
|
||||||
|
|| c == '_' || (c >= '0' && c <= '9'))
|
||||||
|
continue;
|
||||||
|
handleInvalidCompletion();
|
||||||
|
}
|
||||||
IASTCompletionNode node = new ASTCompletionNode( kind,
|
IASTCompletionNode node = new ASTCompletionNode( kind,
|
||||||
null, null, EMPTY_STRING,
|
null, null, new String( prefix ),
|
||||||
KeywordSets.getKeywords(((kind == IASTCompletionNode.CompletionKind.NO_SUCH_KIND )? KeywordSetKey.EMPTY : KeywordSetKey.MACRO), language), EMPTY_STRING, null );
|
KeywordSets.getKeywords(((kind == IASTCompletionNode.CompletionKind.NO_SUCH_KIND )? KeywordSetKey.EMPTY : KeywordSetKey.MACRO), language), EMPTY_STRING, null );
|
||||||
|
|
||||||
throw new OffsetLimitReachedException( node );
|
throw new OffsetLimitReachedException( node );
|
||||||
|
|
Loading…
Add table
Reference in a new issue