From 93c7225abf11aa26e23f83c9fb9725f15c5f26c1 Mon Sep 17 00:00:00 2001 From: John Camelon Date: Tue, 20 Apr 2004 20:07:17 +0000 Subject: [PATCH] org.eclipse.cdt.core

nbsp;Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=59134
nbsp;Partially fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=58858
nbsp;Added in additional CompletionKind's for STRUCT_REFERENCE, UNION_REFERENCE and ENUM_REFERENCE.

org.eclipse.cdt.core.tests
nbsp;Updated CompletionParseTest for CompletionKind updates. --- core/org.eclipse.cdt.core.tests/ChangeLog | 3 ++ .../parser/tests/CompletionParseTest.java | 2 +- .../parser/ChangeLog-parser | 5 +++ .../core/parser/ast/IASTCompletionNode.java | 9 +++++ .../cdt/internal/core/parser/Parser.java | 38 ++++++++----------- .../core/parser/token/KeywordSets.java | 1 + 6 files changed, 34 insertions(+), 24 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index ccd632051d0..56d151a67cd 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -1,3 +1,6 @@ +2004-04-20 John Camelon + Updated CompletionParseTest for CompletionKind updates. + 2004-04-20 John Camelon Moved testBug39684() & testBug39695() from ASTFailedTests to QuickParseASTTests. Updated CompleteParseASTTest::testBug39697(). diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompletionParseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompletionParseTest.java index 2e03648358b..4377d947698 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompletionParseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompletionParseTest.java @@ -141,7 +141,7 @@ public class CompletionParseTest extends CompleteParseBaseTest { assertNotNull( node.getCompletionPrefix() ); assertEquals( node.getCompletionScope(), ((Scope)callback.getCompilationUnit()).getScope() ); assertEquals( node.getCompletionPrefix(), ""); - assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.USER_SPECIFIED_NAME ); + assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.CLASS_REFERENCE ); keywords = node.getKeywords(); assertFalse( keywords.hasNext() ); } diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog-parser b/core/org.eclipse.cdt.core/parser/ChangeLog-parser index 2caf34bfcd9..9f39d66de62 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog-parser +++ b/core/org.eclipse.cdt.core/parser/ChangeLog-parser @@ -1,3 +1,8 @@ +2004-04-20 John Camelon + Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=59134 + Partially fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=58858 + Added in additional CompletionKind's for STRUCT_REFERENCE, UNION_REFERENCE and ENUM_REFERENCE. + 2004-04-20 John Camelon Restructuring of the parser extension packages. Introduce IParserExtension and IASTFactory mechanisms w/partial implementation for GCC. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTCompletionNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTCompletionNode.java index d285d605002..6a75015d123 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTCompletionNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTCompletionNode.java @@ -70,6 +70,15 @@ public interface IASTCompletionNode { // inside something that does not reach the parser - (#ifdefed out/comment) public static final CompletionKind UNREACHABLE_CODE = new CompletionKind( 17 ); + // structs only + public static final CompletionKind STRUCT_REFERENCE = new CompletionKind( 18 ); + + // unions only + public static final CompletionKind UNION_REFERENCE = new CompletionKind( 19 ); + + // enums only + public static final CompletionKind ENUM_REFERENCE = new CompletionKind( 20 ); + // error condition -- a place in the grammar where there is nothing to lookup public static final CompletionKind NO_SUCH_KIND = new CompletionKind( 200 ); /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java index 5b35f5a811b..dc5612c9c91 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java @@ -1691,26 +1691,32 @@ public abstract class Parser extends ExpressionParser implements IParser // this is an elaborated class specifier IToken t = consume(); ASTClassKind eck = null; + CompletionKind completionKind = null; + switch (t.getType()) { case IToken.t_class : eck = ASTClassKind.CLASS; + completionKind = CompletionKind.CLASS_REFERENCE; break; case IToken.t_struct : eck = ASTClassKind.STRUCT; + completionKind = CompletionKind.STRUCT_REFERENCE; break; case IToken.t_union : eck = ASTClassKind.UNION; + completionKind = CompletionKind.UNION_REFERENCE; break; case IToken.t_enum : eck = ASTClassKind.ENUM; + completionKind = CompletionKind.ENUM_REFERENCE; break; default : backup( t ); throw backtrack; } - ITokenDuple d = name(sdw.getScope(), CompletionKind.TYPE_REFERENCE); + ITokenDuple d = name(sdw.getScope(), completionKind); IASTTypeSpecifier elaboratedTypeSpec = null; final boolean isForewardDecl = ( LT(1) == IToken.tSEMI ); @@ -1749,26 +1755,6 @@ public abstract class Parser extends ExpressionParser implements IParser IToken first = consume(IToken.tIDENTIFIER); // throws backtrack if its not that return first; } - /** - * Parses a className. - * - * class-name: identifier | template-id - * - * @throws BacktrackException - */ - protected ITokenDuple className(IASTScope scope) throws EndOfFileException, BacktrackException - { -// ITokenDuple duple = name(scope, CompletionKind.USER_SPECIFIED_NAME ); -// IToken last = duple.getLastToken(); -// if (LT(1) == IToken.tLT) { -// last = consumeTemplateParameters(duple.getLastToken()); -// //last = templateArgumentList( scope, duple.getLastToken() ); -// } -// -// return new TokenDuple(duple.getFirstToken(), last); - return name( scope, CompletionKind.USER_SPECIFIED_NAME ); - } - /** * Parses the initDeclarator construct of the ANSI C++ spec. * @@ -2341,9 +2327,11 @@ public abstract class Parser extends ExpressionParser implements IParser IToken mark = mark(); IToken identifier = null; consume( IToken.t_enum ); + setCompletionValues( sdw.getScope(), CompletionKind.ENUM_REFERENCE ); if (LT(1) == IToken.tIDENTIFIER) { identifier = identifier(); + setCompletionValues( sdw.getScope(), CompletionKind.ENUM_REFERENCE ); } if (LT(1) == IToken.tLBRACE) { @@ -2463,6 +2451,7 @@ public abstract class Parser extends ExpressionParser implements IParser { ClassNameType nameType = ClassNameType.IDENTIFIER; ASTClassKind classKind = null; + CompletionKind completionKind = null; ASTAccessVisibility access = ASTAccessVisibility.PUBLIC; IToken classKey = null; IToken mark = mark(); @@ -2474,14 +2463,17 @@ public abstract class Parser extends ExpressionParser implements IParser classKey = consume(); classKind = ASTClassKind.CLASS; access = ASTAccessVisibility.PRIVATE; + completionKind = CompletionKind.CLASS_REFERENCE; break; case IToken.t_struct : classKey = consume(); classKind = ASTClassKind.STRUCT; + completionKind = CompletionKind.STRUCT_REFERENCE; break; case IToken.t_union : classKey = consume(); classKind = ASTClassKind.UNION; + completionKind = CompletionKind.UNION_REFERENCE; break; default : throw backtrack; @@ -2490,10 +2482,10 @@ public abstract class Parser extends ExpressionParser implements IParser ITokenDuple duple = null; - setCompletionValues(sdw.getScope(), CompletionKind.USER_SPECIFIED_NAME, Key.EMPTY ); + setCompletionValues(sdw.getScope(), completionKind, Key.EMPTY ); // class name if (LT(1) == IToken.tIDENTIFIER) - duple = className(sdw.getScope()); + duple = name( sdw.getScope(), completionKind ); if (duple != null && !duple.isIdentifier()) nameType = ClassNameType.TEMPLATE; if (LT(1) != IToken.tCOLON && LT(1) != IToken.tLBRACE) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java index 3dfe0a328c2..5b5ab801750 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java @@ -275,6 +275,7 @@ public class KeywordSets { EXPRESSION_C.add( Keywords.UNSIGNED); EXPRESSION_C.add( Keywords.FLOAT); EXPRESSION_C.add( Keywords.DOUBLE); + EXPRESSION_C.add( Keywords.SIZEOF ); }