mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Another partial fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=60298
This commit is contained in:
parent
2249be45a4
commit
b988081c1f
5 changed files with 24 additions and 21 deletions
|
@ -1026,4 +1026,15 @@ public class CompletionParseTest extends CompletionParseBaseTest {
|
||||||
|
|
||||||
assertEquals( result.getResultsSize(), 2 );
|
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 );
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public interface IASTCompletionNode {
|
||||||
// function/method argument type reference
|
// function/method argument type reference
|
||||||
public static final CompletionKind ARGUMENT_TYPE = new CompletionKind( 4 );
|
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 );
|
public static final CompletionKind SINGLE_NAME_REFERENCE = new CompletionKind( 5 );
|
||||||
|
|
||||||
// any place one can expect a type
|
// any place one can expect a type
|
||||||
|
@ -58,9 +58,6 @@ public interface IASTCompletionNode {
|
||||||
// any place where exclusively a preprocessor directive is expected
|
// any place where exclusively a preprocessor directive is expected
|
||||||
public static final CompletionKind PREPROCESSOR_DIRECTIVE = new CompletionKind( 13 );
|
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
|
// any place where function parameters are expected
|
||||||
public static final CompletionKind FUNCTION_REFERENCE = new CompletionKind( 15 );
|
public static final CompletionKind FUNCTION_REFERENCE = new CompletionKind( 15 );
|
||||||
|
|
||||||
|
|
|
@ -694,7 +694,15 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
nameDuple = name(d.getScope(), CompletionKind.SINGLE_NAME_REFERENCE, Key.EMPTY );
|
try
|
||||||
|
{
|
||||||
|
nameDuple = name(d.getScope(), CompletionKind.SINGLE_NAME_REFERENCE, Key.EMPTY );
|
||||||
|
}
|
||||||
|
catch( OffsetLimitReachedException olre )
|
||||||
|
{
|
||||||
|
backup( mark );
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch( BacktrackException bt )
|
catch( BacktrackException bt )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1671,9 +1671,8 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
setTypeName(sdw, typeNameBegin, typeNameEnd);
|
setTypeName(sdw, typeNameBegin, typeNameEnd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IASTCompletionNode.CompletionKind ourKind = determineDeclSpecCompletionKind(sdw, kind);
|
setCompletionValues(sdw.getScope(), kind, key );
|
||||||
setCompletionValues(sdw.getScope(), ourKind, key );
|
ITokenDuple d = name(sdw.getScope(), kind, key );
|
||||||
ITokenDuple d = name(sdw.getScope(), ourKind, key );
|
|
||||||
sdw.setTypeName(d);
|
sdw.setTypeName(d);
|
||||||
sdw.setSimpleType( IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME );
|
sdw.setSimpleType( IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME );
|
||||||
flags.setEncounteredTypename(true);
|
flags.setEncounteredTypename(true);
|
||||||
|
@ -1727,17 +1726,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
setTypeName(sdw, typeNameBegin, typeNameEnd);
|
setTypeName(sdw, typeNameBegin, typeNameEnd);
|
||||||
return;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -885,8 +885,6 @@ public class CompletionEngine implements RelevanceConstants {
|
||||||
kindStr = "NEW_TYPE_REFERENCE"; //$NON-NLS-1$
|
kindStr = "NEW_TYPE_REFERENCE"; //$NON-NLS-1$
|
||||||
else if(kind == IASTCompletionNode.CompletionKind.PREPROCESSOR_DIRECTIVE)
|
else if(kind == IASTCompletionNode.CompletionKind.PREPROCESSOR_DIRECTIVE)
|
||||||
kindStr = "PREPROCESSOR_DIRECTIVE"; //$NON-NLS-1$
|
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)
|
else if(kind == IASTCompletionNode.CompletionKind.STRUCT_REFERENCE)
|
||||||
kindStr = "STRUCT_REFERENCE"; //$NON-NLS-1$
|
kindStr = "STRUCT_REFERENCE"; //$NON-NLS-1$
|
||||||
else if(kind == IASTCompletionNode.CompletionKind.UNION_REFERENCE)
|
else if(kind == IASTCompletionNode.CompletionKind.UNION_REFERENCE)
|
||||||
|
|
Loading…
Add table
Reference in a new issue