mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
No proposals for content-assist within literals (bug 193464).
This commit is contained in:
parent
47ca7060dc
commit
0387b359a8
6 changed files with 45 additions and 21 deletions
|
@ -6,10 +6,10 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
* Mike Kucera (IBM) - bug #206952
|
* Mike Kucera (IBM) - bug #206952
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser;
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
@ -154,8 +154,13 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
|
|
||||||
// Use to create the completion node
|
// Use to create the completion node
|
||||||
protected ASTCompletionNode createCompletionNode(IToken token) {
|
protected ASTCompletionNode createCompletionNode(IToken token) {
|
||||||
|
// the preprocessor may deliver tokens for literals or header-names.
|
||||||
if (completionNode == null && token != null)
|
if (completionNode == null && token != null)
|
||||||
completionNode = new ASTCompletionNode(token, getTranslationUnit());
|
switch(token.getType()) {
|
||||||
|
case IToken.tCOMPLETION:
|
||||||
|
completionNode = new ASTCompletionNode(token, getTranslationUnit());
|
||||||
|
break;
|
||||||
|
}
|
||||||
return completionNode;
|
return completionNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,7 @@ public class CPreprocessor implements ILexerLog, IScanner {
|
||||||
private String[][] fPreIncludedFiles= null;
|
private String[][] fPreIncludedFiles= null;
|
||||||
|
|
||||||
private int fContentAssistLimit= -1;
|
private int fContentAssistLimit= -1;
|
||||||
|
private boolean fHandledCompletion= false;
|
||||||
|
|
||||||
// state information
|
// state information
|
||||||
private final CharArrayObjectMap fMacroDictionary = new CharArrayObjectMap(512);
|
private final CharArrayObjectMap fMacroDictionary = new CharArrayObjectMap(512);
|
||||||
|
@ -416,7 +417,12 @@ public class CPreprocessor implements ILexerLog, IScanner {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
t= internalFetchToken(true, false, true, fRootContext);
|
try {
|
||||||
|
t= internalFetchToken(true, false, true, fRootContext);
|
||||||
|
} catch (OffsetLimitReachedException e) {
|
||||||
|
fHandledCompletion= true;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
final int offset= fLocationMap.getSequenceNumberForOffset(t.getOffset());
|
final int offset= fLocationMap.getSequenceNumberForOffset(t.getOffset());
|
||||||
final int endOffset= fLocationMap.getSequenceNumberForOffset(t.getEndOffset());
|
final int endOffset= fLocationMap.getSequenceNumberForOffset(t.getEndOffset());
|
||||||
t.setOffset(offset, endOffset);
|
t.setOffset(offset, endOffset);
|
||||||
|
@ -440,18 +446,18 @@ public class CPreprocessor implements ILexerLog, IScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
Token t1= fetchToken();
|
Token t1= fetchToken();
|
||||||
if (t1.getType() == IToken.tEND_OF_INPUT) {
|
switch (t1.getType()) {
|
||||||
|
case IToken.tCOMPLETION:
|
||||||
|
fHandledCompletion= true;
|
||||||
|
break;
|
||||||
|
case IToken.tEND_OF_INPUT:
|
||||||
if (fContentAssistLimit >= 0) {
|
if (fContentAssistLimit >= 0) {
|
||||||
int useType= IToken.tCOMPLETION;
|
int useType= fHandledCompletion ? IToken.tEOC : IToken.tCOMPLETION;
|
||||||
if (fLastToken != null) {
|
|
||||||
final int lt= fLastToken.getType();
|
|
||||||
if (lt == IToken.tCOMPLETION || lt == IToken.tEOC) {
|
|
||||||
useType= IToken.tEOC;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int sequenceNumber= fLocationMap.getSequenceNumberForOffset(fContentAssistLimit);
|
int sequenceNumber= fLocationMap.getSequenceNumberForOffset(fContentAssistLimit);
|
||||||
t1= new Token(useType, null, sequenceNumber, sequenceNumber);
|
t1= new Token(useType, null, sequenceNumber, sequenceNumber);
|
||||||
|
fHandledCompletion= true;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (fLastToken != null) {
|
if (fLastToken != null) {
|
||||||
fLastToken.setNext(t1);
|
fLastToken.setNext(t1);
|
||||||
|
@ -474,19 +480,18 @@ public class CPreprocessor implements ILexerLog, IScanner {
|
||||||
|
|
||||||
final int tt1= t1.getType();
|
final int tt1= t1.getType();
|
||||||
switch(tt1) {
|
switch(tt1) {
|
||||||
|
case IToken.tCOMPLETION:
|
||||||
|
fHandledCompletion= true;
|
||||||
|
break;
|
||||||
|
|
||||||
case IToken.tEND_OF_INPUT:
|
case IToken.tEND_OF_INPUT:
|
||||||
if (fContentAssistLimit < 0) {
|
if (fContentAssistLimit < 0) {
|
||||||
throw new EndOfFileException();
|
throw new EndOfFileException();
|
||||||
}
|
}
|
||||||
int useType= IToken.tCOMPLETION;
|
int useType= fHandledCompletion ? IToken.tEOC : IToken.tCOMPLETION;
|
||||||
if (fLastToken != null) {
|
|
||||||
final int lt= fLastToken.getType();
|
|
||||||
if (lt == IToken.tCOMPLETION || lt == IToken.tEOC) {
|
|
||||||
useType= IToken.tEOC;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int sequenceNumber= fLocationMap.getSequenceNumberForOffset(fContentAssistLimit);
|
int sequenceNumber= fLocationMap.getSequenceNumberForOffset(fContentAssistLimit);
|
||||||
t1= new Token(useType, null, sequenceNumber, sequenceNumber);
|
t1= new Token(useType, null, sequenceNumber, sequenceNumber);
|
||||||
|
fHandledCompletion= true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IToken.tSTRING:
|
case IToken.tSTRING:
|
||||||
|
|
|
@ -174,6 +174,7 @@ final public class Lexer {
|
||||||
throw new OffsetLimitReachedException(origin, t);
|
throw new OffsetLimitReachedException(origin, t);
|
||||||
case IToken.tEND_OF_INPUT:
|
case IToken.tEND_OF_INPUT:
|
||||||
if (fSupportContentAssist) {
|
if (fSupportContentAssist) {
|
||||||
|
t.setType(IToken.tCOMPLETION);
|
||||||
throw new OffsetLimitReachedException(origin, t);
|
throw new OffsetLimitReachedException(origin, t);
|
||||||
}
|
}
|
||||||
// no break;
|
// no break;
|
||||||
|
|
|
@ -299,6 +299,7 @@ public class MacroExpander {
|
||||||
case IToken.tEND_OF_INPUT:
|
case IToken.tEND_OF_INPUT:
|
||||||
assert nesting >= 0;
|
assert nesting >= 0;
|
||||||
if (fCompletionMode) {
|
if (fCompletionMode) {
|
||||||
|
t.setType(IToken.tCOMPLETION);
|
||||||
throw new OffsetLimitReachedException(ORIGIN, null);
|
throw new OffsetLimitReachedException(ORIGIN, null);
|
||||||
}
|
}
|
||||||
break loop;
|
break loop;
|
||||||
|
|
|
@ -889,4 +889,10 @@ public class CompletionTests extends AbstractContentAssistTest {
|
||||||
final String[] expected= new String[0];
|
final String[] expected= new String[0];
|
||||||
assertCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_REP_STRINGS);
|
assertCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_REP_STRINGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void func() {float a; a= 1./*cursor*/}
|
||||||
|
public void testCompletionInFloatingPointLiteral_Bug193464() throws Exception {
|
||||||
|
final String[] expected= new String[0];
|
||||||
|
assertCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_REP_STRINGS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,4 +182,10 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest {
|
||||||
final String[] expected= new String[0];
|
final String[] expected= new String[0];
|
||||||
assertCompletionResults(expected);
|
assertCompletionResults(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void func() {float a; a= 1./*cursor*/}
|
||||||
|
public void testCompletionInFloatingPointLiteral_Bug193464() throws Exception {
|
||||||
|
final String[] expected= new String[0];
|
||||||
|
assertCompletionResults(expected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue