1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-01 21:35:40 +02:00

Fixed 69439 - [Content Assist] confusion when completing after "123."

This commit is contained in:
John Camelon 2004-09-23 00:43:45 +00:00
parent ea59725106
commit 08f62553a6
3 changed files with 18 additions and 7 deletions

View file

@ -1251,4 +1251,13 @@ public class CompletionParseTest extends CompletionParseBaseTest {
assertEquals( result.getResultsSize(), 2 ); assertEquals( result.getResultsSize(), 2 );
} }
public void testBug69439() throws Exception
{
String code = "float f = 123."; //$NON-NLS-1$
IASTCompletionNode node = parse( code, code.indexOf( ".") + 1 ); //$NON-NLS-1$
assertNotNull( node );
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.NO_SUCH_KIND );
}
} }

View file

@ -752,14 +752,9 @@ public class Parser implements IParserData, IParser
ITokenDuple nameDuple = null; ITokenDuple nameDuple = null;
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON) { if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON) {
try { try {
try { nameDuple = name(d.getScope(),
nameDuple = name(d.getScope(),
CompletionKind.SINGLE_NAME_REFERENCE, CompletionKind.SINGLE_NAME_REFERENCE,
KeywordSetKey.EMPTY); KeywordSetKey.EMPTY);
} catch (OffsetLimitReachedException olre) {
backup(mark);
return null;
}
} catch (BacktrackException bt) { } catch (BacktrackException bt) {
backup(mark); backup(mark);
return null; return null;

View file

@ -1124,7 +1124,7 @@ public class Scanner2 implements IScanner, IScannerData {
return lineNum; return lineNum;
} }
private IToken scanNumber() { private IToken scanNumber() throws EndOfFileException {
char[] buffer = bufferStack[bufferStackPos]; char[] buffer = bufferStack[bufferStackPos];
int start = bufferPos[bufferStackPos]; int start = bufferPos[bufferStackPos];
int limit = bufferLimit[bufferStackPos]; int limit = bufferLimit[bufferStackPos];
@ -1158,6 +1158,9 @@ public class Scanner2 implements IScanner, IScannerData {
continue; continue;
case '.': case '.':
if( isLimitReached() )
handleNoSuchCompletion();
if (isFloat){ if (isFloat){
// second dot // second dot
handleProblem( IProblem.SCANNER_BAD_FLOATING_POINT, start, null ); handleProblem( IProblem.SCANNER_BAD_FLOATING_POINT, start, null );
@ -3080,6 +3083,10 @@ public class Scanner2 implements IScanner, IScannerData {
throw new OffsetLimitReachedException( node ); throw new OffsetLimitReachedException( node );
} }
protected void handleNoSuchCompletion() throws EndOfFileException
{
throw new OffsetLimitReachedException( new ASTCompletionNode( IASTCompletionNode.CompletionKind.NO_SUCH_KIND, null, null, EMPTY_STRING, KeywordSets.getKeywords(KeywordSetKey.EMPTY, language ) , EMPTY_STRING, null));
}
protected void handleInvalidCompletion() throws EndOfFileException protected void handleInvalidCompletion() throws EndOfFileException
{ {