mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
org.eclipse.cdt.core
Removed IASTCompletionKind.SCOPED_REFERENCE as it was obsolete. Did preliminary work to support content assist within qualified names. org.eclipse.cdt.ui Updated Content Assist feature to not use IASTCompletionKind.SCOPED_REFERENCE
This commit is contained in:
parent
e4929dfcd1
commit
385ac1b870
6 changed files with 56 additions and 48 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2004-02-12 John Camelon
|
||||||
|
Removed IASTCompletionKind.SCOPED_REFERENCE as it was obsolete.
|
||||||
|
Did preliminary work to support content assist within qualified names.
|
||||||
|
|
||||||
2004-02-11 John Camelon
|
2004-02-11 John Camelon
|
||||||
Restructured Parser implementation to allow for better support of Selection Search.
|
Restructured Parser implementation to allow for better support of Selection Search.
|
||||||
Restructured Parser implementation to allow for separation between parsing expressions (Scanner) and complete C/C++ source.
|
Restructured Parser implementation to allow for separation between parsing expressions (Scanner) and complete C/C++ source.
|
||||||
|
|
|
@ -25,9 +25,6 @@ public interface IASTCompletionNode {
|
||||||
// x.[ ] x->[ ]
|
// x.[ ] x->[ ]
|
||||||
public static final CompletionKind MEMBER_REFERENCE = new CompletionKind( 0 );
|
public static final CompletionKind MEMBER_REFERENCE = new CompletionKind( 0 );
|
||||||
|
|
||||||
// x::[ ]
|
|
||||||
public static final CompletionKind SCOPED_REFERENCE = new CompletionKind( 1 );
|
|
||||||
|
|
||||||
// class member declaration type reference
|
// class member declaration type reference
|
||||||
public static final CompletionKind FIELD_TYPE = new CompletionKind( 2 );
|
public static final CompletionKind FIELD_TYPE = new CompletionKind( 2 );
|
||||||
|
|
||||||
|
|
|
@ -158,8 +158,8 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
*
|
*
|
||||||
* @throws BacktrackException request a backtrack
|
* @throws BacktrackException request a backtrack
|
||||||
*/
|
*/
|
||||||
protected IToken templateId(IASTScope scope) throws EndOfFileException, BacktrackException {
|
protected IToken templateId(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
||||||
ITokenDuple duple = name(scope);
|
ITokenDuple duple = name(scope, kind );
|
||||||
IToken last = consumeTemplateParameters(duple.getLastToken());
|
IToken last = consumeTemplateParameters(duple.getLastToken());
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
*
|
*
|
||||||
* @throws BacktrackException request a backtrack
|
* @throws BacktrackException request a backtrack
|
||||||
*/
|
*/
|
||||||
protected TokenDuple name(IASTScope scope) throws BacktrackException, EndOfFileException {
|
protected TokenDuple name(IASTScope scope, IASTCompletionNode.CompletionKind kind) throws BacktrackException, EndOfFileException {
|
||||||
IToken first = LA(1);
|
IToken first = LA(1);
|
||||||
IToken last = null;
|
IToken last = null;
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
|
@ -373,7 +373,7 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
nameDuple = name(d.getScope());
|
nameDuple = name(d.getScope(), CompletionKind.NO_SUCH_KIND );
|
||||||
}
|
}
|
||||||
catch( BacktrackException bt )
|
catch( BacktrackException bt )
|
||||||
{
|
{
|
||||||
|
@ -1125,7 +1125,7 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
name = name(scope);
|
name = name(scope, CompletionKind.TYPE_REFERENCE );
|
||||||
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1172,7 +1172,7 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
case IToken.tIDENTIFIER :
|
case IToken.tIDENTIFIER :
|
||||||
if( encounteredType ) break simpleMods;
|
if( encounteredType ) break simpleMods;
|
||||||
encounteredType = true;
|
encounteredType = true;
|
||||||
name = name(scope);
|
name = name(scope, CompletionKind.TYPE_REFERENCE);
|
||||||
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1256,7 +1256,7 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
consume();
|
consume();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
name = name(scope);
|
name = name(scope, CompletionKind.TYPE_REFERENCE );
|
||||||
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
||||||
} catch( BacktrackException b )
|
} catch( BacktrackException b )
|
||||||
{
|
{
|
||||||
|
@ -1661,7 +1661,7 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
{
|
{
|
||||||
case IToken.t_typename :
|
case IToken.t_typename :
|
||||||
consume(IToken.t_typename);
|
consume(IToken.t_typename);
|
||||||
ITokenDuple nestedName = name(scope);
|
ITokenDuple nestedName = name(scope, CompletionKind.TYPE_REFERENCE);
|
||||||
boolean templateTokenConsumed = false;
|
boolean templateTokenConsumed = false;
|
||||||
if( LT(1) == IToken.t_template )
|
if( LT(1) == IToken.t_template )
|
||||||
{
|
{
|
||||||
|
@ -1672,7 +1672,8 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
ITokenDuple templateId = null;
|
ITokenDuple templateId = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
templateId = new TokenDuple( current, templateId(scope) );
|
templateId = new TokenDuple( current, templateId(scope, CompletionKind.SINGLE_NAME_REFERENCE
|
||||||
|
) );
|
||||||
}
|
}
|
||||||
catch( BacktrackException bt )
|
catch( BacktrackException bt )
|
||||||
{
|
{
|
||||||
|
@ -2215,7 +2216,7 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
duple = name(scope);
|
duple = name(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
||||||
}
|
}
|
||||||
catch( BacktrackException bt )
|
catch( BacktrackException bt )
|
||||||
{
|
{
|
||||||
|
|
|
@ -235,7 +235,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
// optional :: and nested classes handled in name
|
// optional :: and nested classes handled in name
|
||||||
TokenDuple duple = null;
|
TokenDuple duple = null;
|
||||||
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
||||||
duple = name(scope);
|
duple = name(scope, CompletionKind.NAMESPACE_REFERENCE);
|
||||||
else
|
else
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
if (LT(1) == IToken.tSEMI)
|
if (LT(1) == IToken.tSEMI)
|
||||||
|
@ -276,7 +276,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
||||||
{
|
{
|
||||||
// optional :: and nested classes handled in name
|
// optional :: and nested classes handled in name
|
||||||
name = name(scope);
|
name = name(scope, CompletionKind.TYPE_REFERENCE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -876,7 +876,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
if( identifier == null )
|
if( identifier == null )
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
|
|
||||||
ITokenDuple duple = name(scope);
|
ITokenDuple duple = name(scope, CompletionKind.NAMESPACE_REFERENCE);
|
||||||
consume( IToken.tSEMI );
|
consume( IToken.tSEMI );
|
||||||
setCompletionValues(scope, kind, Key.DECLARATION );
|
setCompletionValues(scope, kind, Key.DECLARATION );
|
||||||
try
|
try
|
||||||
|
@ -1111,7 +1111,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
ITokenDuple duple = name(scope);
|
ITokenDuple duple = name(scope, CompletionKind.SINGLE_NAME_REFERENCE );
|
||||||
|
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
IASTExpression expressionList = null;
|
IASTExpression expressionList = null;
|
||||||
|
@ -1529,11 +1529,11 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
consume(IToken.t_typename );
|
consume(IToken.t_typename );
|
||||||
IToken first = LA(1);
|
IToken first = LA(1);
|
||||||
IToken last = null;
|
IToken last = null;
|
||||||
last = name(sdw.getScope()).getLastToken();
|
last = name(sdw.getScope(), CompletionKind.TYPE_REFERENCE).getLastToken();
|
||||||
if (LT(1) == IToken.t_template)
|
if (LT(1) == IToken.t_template)
|
||||||
{
|
{
|
||||||
consume(IToken.t_template);
|
consume(IToken.t_template);
|
||||||
last = templateId(sdw.getScope());
|
last = templateId(sdw.getScope(), CompletionKind.SINGLE_NAME_REFERENCE );
|
||||||
}
|
}
|
||||||
ITokenDuple duple = new TokenDuple(first, last);
|
ITokenDuple duple = new TokenDuple(first, last);
|
||||||
sdw.setTypeName(duple);
|
sdw.setTypeName(duple);
|
||||||
|
@ -1573,7 +1573,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ITokenDuple d = name(sdw.getScope());
|
ITokenDuple d = name(sdw.getScope(), CompletionKind.TYPE_REFERENCE );
|
||||||
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);
|
||||||
|
@ -1644,7 +1644,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ITokenDuple d = name(sdw.getScope());
|
ITokenDuple d = name(sdw.getScope(), CompletionKind.TYPE_REFERENCE);
|
||||||
IASTTypeSpecifier elaboratedTypeSpec = null;
|
IASTTypeSpecifier elaboratedTypeSpec = null;
|
||||||
final boolean isForewardDecl = ( LT(1) == IToken.tSEMI );
|
final boolean isForewardDecl = ( LT(1) == IToken.tSEMI );
|
||||||
|
|
||||||
|
@ -1691,7 +1691,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
*/
|
*/
|
||||||
protected ITokenDuple className(IASTScope scope) throws EndOfFileException, BacktrackException
|
protected ITokenDuple className(IASTScope scope) throws EndOfFileException, BacktrackException
|
||||||
{
|
{
|
||||||
ITokenDuple duple = name(scope);
|
ITokenDuple duple = name(scope, CompletionKind.USER_SPECIFIED_NAME );
|
||||||
IToken last = duple.getLastToken();
|
IToken last = duple.getLastToken();
|
||||||
if (LT(1) == IToken.tLT) {
|
if (LT(1) == IToken.tLT) {
|
||||||
last = consumeTemplateParameters(duple.getLastToken());
|
last = consumeTemplateParameters(duple.getLastToken());
|
||||||
|
@ -2007,7 +2007,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if( ! astFactory.queryIsTypeName( scope, name(scope) ) )
|
if( ! astFactory.queryIsTypeName( scope, name(scope, CompletionKind.TYPE_REFERENCE ) ) )
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -2189,7 +2189,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ITokenDuple duple = name(d.getDeclarationWrapper().getScope());
|
ITokenDuple duple = name(d.getDeclarationWrapper().getScope(), CompletionKind.SINGLE_NAME_REFERENCE );
|
||||||
d.setName(duple);
|
d.setName(duple);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2542,7 +2542,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
break;
|
break;
|
||||||
case IToken.tCOLONCOLON :
|
case IToken.tCOLONCOLON :
|
||||||
case IToken.tIDENTIFIER :
|
case IToken.tIDENTIFIER :
|
||||||
nameDuple = name(astClassSpec);
|
nameDuple = name(astClassSpec, CompletionKind.CLASS_REFERENCE );
|
||||||
break;
|
break;
|
||||||
case IToken.tCOMMA :
|
case IToken.tCOMMA :
|
||||||
try
|
try
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
2004-02-12 John Camelon
|
||||||
|
Updated Content Assist feature to not use IASTCompletionKind.SCOPED_REFERENCE
|
||||||
|
|
||||||
2004-02-11 Alain Magloire
|
2004-02-11 Alain Magloire
|
||||||
|
|
||||||
* src/org/eclipse/cdt/internal/ui/cview/CView.java
|
* src/org/eclipse/cdt/internal/ui/cview/CView.java
|
||||||
|
|
|
@ -435,22 +435,23 @@ public class CompletionEngine implements RelevanceConstants {
|
||||||
result = lookup (searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
result = lookup (searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||||
addToCompletions (result);
|
addToCompletions (result);
|
||||||
}
|
}
|
||||||
private void completionOnScopedReference(IASTCompletionNode completionNode){
|
|
||||||
// 1. Get the search scope node
|
// private void completionOnScopedReference(IASTCompletionNode completionNode){
|
||||||
// the search node is the name before the qualification
|
// // 1. Get the search scope node
|
||||||
IASTScope searchNode = completionNode.getCompletionScope();
|
// // the search node is the name before the qualification
|
||||||
// here we have to look for anything that could be referenced within this scope
|
// IASTScope searchNode = completionNode.getCompletionScope();
|
||||||
// 1. lookup local variables, global variables, functions, methods, structures, enums, and namespaces
|
// // here we have to look for anything that could be referenced within this scope
|
||||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[4];
|
// // 1. lookup local variables, global variables, functions, methods, structures, enums, and namespaces
|
||||||
kinds[0] = IASTNode.LookupKind.VARIABLES;
|
// IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[4];
|
||||||
kinds[1] = IASTNode.LookupKind.STRUCTURES;
|
// kinds[0] = IASTNode.LookupKind.VARIABLES;
|
||||||
kinds[2] = IASTNode.LookupKind.ENUMERATIONS;
|
// kinds[1] = IASTNode.LookupKind.STRUCTURES;
|
||||||
kinds[3] = IASTNode.LookupKind.NAMESPACES;
|
// kinds[2] = IASTNode.LookupKind.ENUMERATIONS;
|
||||||
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
// kinds[3] = IASTNode.LookupKind.NAMESPACES;
|
||||||
addToCompletions(result);
|
// ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||||
// TODO
|
// addToCompletions(result);
|
||||||
// lookup static members (field / methods) in type
|
// // TODO
|
||||||
}
|
// // lookup static members (field / methods) in type
|
||||||
|
// }
|
||||||
private void completionOnTypeReference(IASTCompletionNode completionNode){
|
private void completionOnTypeReference(IASTCompletionNode completionNode){
|
||||||
// completing on a type
|
// completing on a type
|
||||||
// 1. Get the search scope node
|
// 1. Get the search scope node
|
||||||
|
@ -632,10 +633,10 @@ public class CompletionEngine implements RelevanceConstants {
|
||||||
// completionOnMemberReference
|
// completionOnMemberReference
|
||||||
completionOnMemberReference(completionNode);
|
completionOnMemberReference(completionNode);
|
||||||
}
|
}
|
||||||
else if(kind == CompletionKind.SCOPED_REFERENCE){
|
// else if(kind == CompletionKind.SCOPED_REFERENCE){
|
||||||
// completionOnMemberReference
|
// // completionOnMemberReference
|
||||||
completionOnScopedReference(completionNode);
|
// completionOnScopedReference(completionNode);
|
||||||
}
|
// }
|
||||||
else if(kind == CompletionKind.FIELD_TYPE){
|
else if(kind == CompletionKind.FIELD_TYPE){
|
||||||
// CompletionOnFieldType
|
// CompletionOnFieldType
|
||||||
completionOnFieldType(completionNode);
|
completionOnFieldType(completionNode);
|
||||||
|
@ -686,7 +687,9 @@ public class CompletionEngine implements RelevanceConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
// add keywords in all cases except for member and scoped reference cases.
|
// add keywords in all cases except for member and scoped reference cases.
|
||||||
if((kind != CompletionKind.MEMBER_REFERENCE) &&(kind != CompletionKind.SCOPED_REFERENCE)){
|
if((kind != CompletionKind.MEMBER_REFERENCE)
|
||||||
|
// &&(kind != CompletionKind.SCOPED_REFERENCE)
|
||||||
|
){
|
||||||
addKeywordsToCompletions( completionNode.getKeywords());
|
addKeywordsToCompletions( completionNode.getKeywords());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,8 +704,8 @@ public class CompletionEngine implements RelevanceConstants {
|
||||||
String kindStr = "";
|
String kindStr = "";
|
||||||
if(kind == IASTCompletionNode.CompletionKind.MEMBER_REFERENCE)
|
if(kind == IASTCompletionNode.CompletionKind.MEMBER_REFERENCE)
|
||||||
kindStr = "MEMBER_REFERENCE";
|
kindStr = "MEMBER_REFERENCE";
|
||||||
else if(kind == IASTCompletionNode.CompletionKind.SCOPED_REFERENCE)
|
// else if(kind == IASTCompletionNode.CompletionKind.SCOPED_REFERENCE)
|
||||||
kindStr = "SCOPED_REFERENCE";
|
// kindStr = "SCOPED_REFERENCE";
|
||||||
else if(kind == IASTCompletionNode.CompletionKind.FIELD_TYPE)
|
else if(kind == IASTCompletionNode.CompletionKind.FIELD_TYPE)
|
||||||
kindStr = "FIELD_TYPE Class Scope";
|
kindStr = "FIELD_TYPE Class Scope";
|
||||||
else if(kind == IASTCompletionNode.CompletionKind.VARIABLE_TYPE)
|
else if(kind == IASTCompletionNode.CompletionKind.VARIABLE_TYPE)
|
||||||
|
|
Loading…
Add table
Reference in a new issue