Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 172307 Details for
Bug 310423
[content assist] After 'implements' annotation types should not be proposed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch with corrected typo
patch310423.txt (text/plain), 15.04 KB, created by
Ayushman Jain
on 2010-06-21 03:47:34 EDT
(
hide
)
Description:
patch with corrected typo
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2010-06-21 03:47:34 EDT
Size:
15.04 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java,v >retrieving revision 1.412 >diff -u -r1.412 CompletionEngine.java >--- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 21 Jun 2010 07:08:59 -0000 1.412 >+++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 21 Jun 2010 07:41:46 -0000 >@@ -520,6 +520,7 @@ > boolean assistNodeIsConstructor; > boolean assistNodeIsSuperType; > boolean assistNodeIsExtendedType; >+ boolean assistNodeIsInterfaceExcludingAnnotation; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310423 > int assistNodeInJavadoc = 0; > boolean assistNodeCanBeSingleMemberAnnotation = false; > >@@ -2780,6 +2781,7 @@ > this.assistNodeIsInterface = ref.isInterface(); > this.assistNodeIsSuperType = ref.isSuperType(); > this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent); >+ this.assistNodeIsInterfaceExcludingAnnotation = assistNodeIsInterfaceExcludingAnnotation(astNode, astNodeParent); > > this.completionToken = ref.completionIdentifier; > long completionPosition = ref.sourcePositions[ref.tokens.length]; >@@ -2842,6 +2844,22 @@ > return false; > } > >+ private boolean assistNodeIsInterfaceExcludingAnnotation(ASTNode astNode, ASTNode astNodeParent) { >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310423, don't propose annotations for implements. >+ if (astNodeParent == null) >+ return false; >+ if (astNodeParent instanceof TypeDeclaration) { >+ TypeDeclaration typeDeclaration = (TypeDeclaration) astNodeParent; >+ TypeReference [] superInterfaces = typeDeclaration.superInterfaces; >+ int length = superInterfaces == null ? 0 : superInterfaces.length; >+ for (int i = 0; i < length; i++) { >+ if (superInterfaces[i] == astNode) >+ return true; >+ } >+ } >+ return false; >+ } >+ > private void completionOnQualifiedAllocationExpression(ASTNode astNode, Binding qualifiedBinding, Scope scope) { > setSourceAndTokenRange(astNode.sourceStart, astNode.sourceEnd, false); > >@@ -3041,6 +3059,7 @@ > this.assistNodeIsConstructor = ref.isConstructorType; > this.assistNodeIsSuperType = ref.isSuperType(); > this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent); >+ this.assistNodeIsInterfaceExcludingAnnotation = assistNodeIsInterfaceExcludingAnnotation(astNode, astNodeParent); > > this.completionToken = ref.completionIdentifier; > long completionPosition = ref.sourcePositions[ref.tokens.length]; >@@ -3175,6 +3194,7 @@ > this.assistNodeIsConstructor = singleRef.isConstructorType; > this.assistNodeIsSuperType = singleRef.isSuperType(); > this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent); >+ this.assistNodeIsInterfaceExcludingAnnotation = assistNodeIsInterfaceExcludingAnnotation(astNode, astNodeParent); > > // can be the start of a qualified type name > if (qualifiedBinding == null) { >@@ -9291,6 +9311,7 @@ > typesFound.add(memberType); > > if (this.assistNodeIsExtendedType && memberType.isFinal()) continue next; >+ if (this.assistNodeIsInterfaceExcludingAnnotation && memberType.isAnnotationType()) continue next; > if(!this.insideQualifiedReference) { > if(this.assistNodeIsClass) { > if(!memberType.isClass()) continue next; >@@ -9779,6 +9800,7 @@ > } > > if (this.assistNodeIsExtendedType && localType.isFinal()) continue next; >+ if (this.assistNodeIsInterfaceExcludingAnnotation && localType.isAnnotationType()) continue next; > if(this.assistNodeIsClass) { > if(!localType.isClass()) continue next; > } else if(this.assistNodeIsInterface) { >@@ -10160,6 +10182,7 @@ > typesFound.add(sourceType); > > if (this.assistNodeIsExtendedType && sourceType.isFinal()) continue next; >+ if (this.assistNodeIsInterfaceExcludingAnnotation && sourceType.isAnnotationType()) continue next; > if(this.assistNodeIsClass) { > if(!sourceType.isClass()) continue next; > } else if(this.assistNodeIsInterface) { >@@ -10293,6 +10316,8 @@ > int searchFor = IJavaSearchConstants.TYPE; > if(this.assistNodeIsClass) { > searchFor = IJavaSearchConstants.CLASS; >+ } else if (this.assistNodeIsInterfaceExcludingAnnotation) { >+ searchFor = IJavaSearchConstants.INTERFACE; > } else if(this.assistNodeIsInterface) { > searchFor = IJavaSearchConstants.INTERFACE_AND_ANNOTATION; > } else if(this.assistNodeIsEnum) { >@@ -10385,6 +10410,7 @@ > continue; > > if (this.assistNodeIsExtendedType && sourceType.isFinal()) continue; >+ if (this.assistNodeIsInterfaceExcludingAnnotation && sourceType.isAnnotationType()) continue; > int accessibility = IAccessRule.K_ACCESSIBLE; > if(sourceType.hasRestrictedAccess()) { > AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(sourceType); >@@ -10472,6 +10498,8 @@ > int searchFor = IJavaSearchConstants.TYPE; > if(this.assistNodeIsClass) { > searchFor = IJavaSearchConstants.CLASS; >+ } else if (this.assistNodeIsInterfaceExcludingAnnotation) { >+ searchFor = IJavaSearchConstants.INTERFACE; > } else if(this.assistNodeIsInterface) { > searchFor = IJavaSearchConstants.INTERFACE_AND_ANNOTATION; > } else if(this.assistNodeIsEnum) { >@@ -10578,6 +10606,7 @@ > } > > if (this.assistNodeIsExtendedType && refBinding.isFinal()) continue next; >+ if (this.assistNodeIsInterfaceExcludingAnnotation && refBinding.isAnnotationType()) continue next; > if(this.assistNodeIsClass) { > if(!refBinding.isClass()) continue next; > } else if(this.assistNodeIsInterface) { >@@ -10708,6 +10737,7 @@ > typesFound.add(typeBinding); > > if (this.assistNodeIsExtendedType && typeBinding.isFinal()) continue; >+ if (this.assistNodeIsInterfaceExcludingAnnotation && typeBinding.isAnnotationType()) continue; > if(this.assistNodeIsClass) { > if(!typeBinding.isClass()) continue; > } else if(this.assistNodeIsInterface) { >@@ -10811,6 +10841,7 @@ > typesFound.add(typeBinding); > > if (this.assistNodeIsExtendedType && typeBinding.isFinal()) continue; >+ if (this.assistNodeIsInterfaceExcludingAnnotation && typeBinding.isAnnotationType()) continue; > if(this.assistNodeIsClass) { > if(!typeBinding.isClass()) continue; > } else if(this.assistNodeIsInterface) { >Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java,v >retrieving revision 1.216 >diff -u -r1.216 CompletionParser.java >--- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 20 May 2010 18:03:14 -0000 1.216 >+++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 21 Jun 2010 07:42:14 -0000 >@@ -2157,6 +2157,21 @@ > } > } > } >+protected void consumeClassHeaderImplements() { >+ super.consumeClassHeaderImplements(); >+ if (this.assistNode != null && this.assistNodeParent == null) { >+ TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr]; >+ if (typeDecl != null) { >+ TypeReference[] superInterfaces = typeDecl.superInterfaces; >+ int length = superInterfaces == null ? 0 : superInterfaces.length; >+ for (int i = 0; i < length; i++) { >+ if (superInterfaces[i] == this.assistNode) { >+ this.assistNodeParent = typeDecl; >+ } >+ } >+ } >+ } >+} > protected void consumeClassTypeElt() { > pushOnElementStack(K_NEXT_TYPEREF_IS_EXCEPTION); > super.consumeClassTypeElt(); >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java,v >retrieving revision 1.34 >diff -u -r1.34 CompletionParserTest.java >--- src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java 27 Jun 2008 16:04:46 -0000 1.34 >+++ src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java 21 Jun 2010 07:42:58 -0000 >@@ -12,7 +12,7 @@ > > import junit.framework.Test; > >-import org.eclipse.jdt.internal.codeassist.complete.*; >+import org.eclipse.jdt.internal.codeassist.complete.InvalidCursorLocation; > > public class CompletionParserTest extends AbstractCompletionTest { > public CompletionParserTest(String testName) { >@@ -8634,4 +8634,58 @@ > expectedReplacedSource, > testName); > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310423 >+// To verify that assist node parent is set to the the type declaration >+// when completion is requested after implements in a type declaration. >+public void testBug310423(){ >+ String str = >+ "import java.lang.annotation.Annotation;\n" + >+ "interface In {}\n" + >+ "interface Inn {\n" + >+ " interface Inn2 {}\n" + >+ " @interface InAnnot {}\n" + >+ "}\n" + >+ "@interface InnAnnot {}\n"+ >+ "public class Test implements In{\n" + >+ "}\n"; >+ >+ String testName = ""; >+ String completeBehind = "In"; >+ String expectedCompletionNodeToString = "<CompleteOnInterface:In>"; >+ String expectedParentNodeToString = >+ "public class Test implements <CompleteOnInterface:In> {\n" + >+ " public Test() {\n" + >+ " }\n" + >+ "}"; >+ String completionIdentifier = "In"; >+ String expectedReplacedSource = "In"; >+ int cursorLocation = str.lastIndexOf("In") + completeBehind.length() - 1; >+ String expectedUnitDisplayString = >+ "import java.lang.annotation.Annotation;\n" + >+ "interface In {\n" + >+ "}\n" + >+ "interface Inn {\n" + >+ " interface Inn2 {\n" + >+ " }\n" + >+ " @interface InAnnot {\n" + >+ " }\n" + >+ "}\n" + >+ "@interface InnAnnot {\n" + >+ "}\n" + >+ "public class Test implements <CompleteOnInterface:In> {\n" + >+ " public Test() {\n" + >+ " }\n" + >+ "}\n"; >+ >+ checkDietParse( >+ str.toCharArray(), >+ cursorLocation, >+ expectedCompletionNodeToString, >+ expectedParentNodeToString, >+ expectedUnitDisplayString, >+ completionIdentifier, >+ expectedReplacedSource, >+ testName); >+} > } >Index: src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java,v >retrieving revision 1.39 >diff -u -r1.39 GenericsCompletionParserTest.java >--- src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java 6 May 2009 08:57:01 -0000 1.39 >+++ src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java 21 Jun 2010 07:43:32 -0000 >@@ -461,7 +461,11 @@ > String completeBehind = "Y<Z>."; > int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; > String expectedCompletionNodeToString = "<CompleteOnInterface:Y<Z>.>"; >- String expectedParentNodeToString = "<NONE>"; >+ String expectedParentNodeToString = >+ "public class X implements I1, <CompleteOnInterface:Y<Z>.> {\n" + >+ " public X() {\n" + >+ " }\n" + >+ "}"; > String completionIdentifier = ""; > String expectedReplacedSource = "Y<Z>."; > String expectedUnitDisplayString = >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java,v >retrieving revision 1.120 >diff -u -r1.120 CompletionTests_1_5.java >--- src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 11 May 2010 18:58:14 -0000 1.120 >+++ src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 21 Jun 2010 07:44:50 -0000 >@@ -6602,7 +6602,6 @@ > result.context); > > assertResults( >- "ZZType.ZZAnnotation[TYPE_REF]{p.ZZType.ZZAnnotation, p, Lp.ZZType$ZZAnnotation;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_INTERFACE + R_NON_RESTRICTED) + "}\n" + > "ZZType.ZZInterface[TYPE_REF]{p.ZZType.ZZInterface, p, Lp.ZZType$ZZInterface;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_INTERFACE + R_NON_RESTRICTED) + "}", > result.proposals); > } finally { >@@ -13815,4 +13814,60 @@ > "\ud842\udf9fabc[LABEL_REF]{\ud842\udf9fabc, null, null, \ud842\udf9fabc, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", > requestor.getResults()); > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310423 >+// Annotation types are not proposed after 'implements' in a Single type ref >+public void testBug310423a() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/label/Test.java", >+ "import java.lang.annotation.Annotation;\n" + >+ "interface In {}\n" + >+ "interface Inn {\n" + >+ " interface Inn2 {}\n" + >+ " @interface IAnnot {}\n" + >+ "}\n" + >+ "@interface InnAnnot {}\n"+ >+ "public class Test implements {\n" + >+ "}\n"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "implements"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length() + 1; >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ assertResults( >+ "Inn.Inn2[TYPE_REF]{label.Inn.Inn2, label, Llabel.Inn$Inn2;, null, null, 44}\n" + >+ "In[TYPE_REF]{In, label, Llabel.In;, null, null, 47}\n" + >+ "Inn[TYPE_REF]{Inn, label, Llabel.Inn;, null, null, 47}", >+ requestor.getResults()); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310423 >+// Annotation types are not proposed after 'implements' in a Qualified type ref >+public void testBug310423b() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/label/Test.java", >+ "interface In{}\n" + >+ "interface Inn{\n" + >+ " interface Inn2{}\n" + >+ " interface Inn3{}\n" + >+ " @interface IAnnot {}\n" + >+ "}"+ >+ "public class Test implements Inn. {\n" + >+ "}\n"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "Inn."; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length() + 1; >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ assertResults( >+ "Inn.Inn2[TYPE_REF]{Inn2, label, Llabel.Inn$Inn2;, null, null, 44}\n" + >+ "Inn.Inn3[TYPE_REF]{Inn3, label, Llabel.Inn$Inn3;, null, null, 44}", >+ requestor.getResults()); >+} > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 310423
:
169489
|
170934
|
171067
|
171247
| 172307