1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00
This commit is contained in:
John Camelon 2004-05-11 19:43:05 +00:00
parent 2249be45a4
commit b988081c1f
5 changed files with 24 additions and 21 deletions

View file

@ -1026,4 +1026,15 @@ public class CompletionParseTest extends CompletionParseBaseTest {
assertEquals( result.getResultsSize(), 2 );
}
public void testBug60298() throws Exception
{
Writer writer = new StringWriter();
writer.write( "class ABC { public: ABC(); int myInt(); };\n");
writer.write( "int ABC::" );
String code = writer.toString();
IASTCompletionNode node = parse( code, code.indexOf( "::") + 2 );
assertEquals( node.getCompletionKind(), CompletionKind.SINGLE_NAME_REFERENCE );
}
}

View file

@ -34,7 +34,7 @@ public interface IASTCompletionNode {
// function/method argument type reference
public static final CompletionKind ARGUMENT_TYPE = new CompletionKind( 4 );
// inside code body - name reference
// inside code body - name reference || int X::[ ]
public static final CompletionKind SINGLE_NAME_REFERENCE = new CompletionKind( 5 );
// any place one can expect a type
@ -58,9 +58,6 @@ public interface IASTCompletionNode {
// any place where exclusively a preprocessor directive is expected
public static final CompletionKind PREPROCESSOR_DIRECTIVE = new CompletionKind( 13 );
// any place where a type or variable name is expected to be introduced
public static final CompletionKind NESTED_NAME_REFERENCE = new CompletionKind( 14 );
// any place where function parameters are expected
public static final CompletionKind FUNCTION_REFERENCE = new CompletionKind( 15 );

View file

@ -691,11 +691,19 @@ public class ExpressionParser implements IExpressionParser, IParserData {
ITokenDuple nameDuple = null;
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
{
try
{
try
{
nameDuple = name(d.getScope(), CompletionKind.SINGLE_NAME_REFERENCE, Key.EMPTY );
}
catch( OffsetLimitReachedException olre )
{
backup( mark );
return null;
}
}
catch( BacktrackException bt )
{
backup( mark );

View file

@ -1671,9 +1671,8 @@ public abstract class Parser extends ExpressionParser implements IParser
setTypeName(sdw, typeNameBegin, typeNameEnd);
return;
}
IASTCompletionNode.CompletionKind ourKind = determineDeclSpecCompletionKind(sdw, kind);
setCompletionValues(sdw.getScope(), ourKind, key );
ITokenDuple d = name(sdw.getScope(), ourKind, key );
setCompletionValues(sdw.getScope(), kind, key );
ITokenDuple d = name(sdw.getScope(), kind, key );
sdw.setTypeName(d);
sdw.setSimpleType( IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME );
flags.setEncounteredTypename(true);
@ -1727,17 +1726,7 @@ public abstract class Parser extends ExpressionParser implements IParser
setTypeName(sdw, typeNameBegin, typeNameEnd);
return;
}
/**
* @param sdw
* @param kind
* @return
*/
protected CompletionKind determineDeclSpecCompletionKind(DeclarationWrapper sdw, CompletionKind kind) {
if( kind == CompletionKind.ARGUMENT_TYPE ) return kind;
if( sdw.getScope() instanceof IASTCompilationUnit || sdw.getScope() instanceof IASTNamespaceDefinition )
return sdw.consumedRawType() ? CompletionKind.NESTED_NAME_REFERENCE: kind;
return kind;
}
/**

View file

@ -885,8 +885,6 @@ public class CompletionEngine implements RelevanceConstants {
kindStr = "NEW_TYPE_REFERENCE"; //$NON-NLS-1$
else if(kind == IASTCompletionNode.CompletionKind.PREPROCESSOR_DIRECTIVE)
kindStr = "PREPROCESSOR_DIRECTIVE"; //$NON-NLS-1$
else if(kind == IASTCompletionNode.CompletionKind.NESTED_NAME_REFERENCE)
kindStr = "NESTED_NAME_REFERENCE"; //$NON-NLS-1$
else if(kind == IASTCompletionNode.CompletionKind.STRUCT_REFERENCE)
kindStr = "STRUCT_REFERENCE"; //$NON-NLS-1$
else if(kind == IASTCompletionNode.CompletionKind.UNION_REFERENCE)