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 169489 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]
proposed fix v1.0 + regression tests
patch310423.txt (text/plain), 19.37 KB, created by
Ayushman Jain
on 2010-05-21 07:39:36 EDT
(
hide
)
Description:
proposed fix v1.0 + regression tests
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2010-05-21 07:39:36 EDT
Size:
19.37 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.411 >diff -u -r1.411 CompletionEngine.java >--- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 22 Apr 2010 16:11:44 -0000 1.411 >+++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 21 May 2010 11:24:25 -0000 >@@ -520,6 +520,7 @@ > boolean assistNodeIsConstructor; > boolean assistNodeIsSuperType; > boolean assistNodeIsExtendedType; >+ boolean assistNodeIsInterfaceExcludingAnnotations; > int assistNodeInJavadoc = 0; > boolean assistNodeCanBeSingleMemberAnnotation = false; > >@@ -2774,7 +2775,7 @@ > CompletionOnParameterizedQualifiedTypeReference ref = (CompletionOnParameterizedQualifiedTypeReference) astNode; > > this.insideQualifiedReference = true; >- >+ this.assistNodeIsInterfaceExcludingAnnotations = ref.isInterfaceExcludingAnnotations(); > this.assistNodeIsClass = ref.isClass(); > this.assistNodeIsException = ref.isException(); > this.assistNodeIsInterface = ref.isInterface(); >@@ -3041,7 +3042,7 @@ > this.assistNodeIsConstructor = ref.isConstructorType; > this.assistNodeIsSuperType = ref.isSuperType(); > this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent); >- >+ this.assistNodeIsInterfaceExcludingAnnotations = ref.isInterfaceExcludingAnnotations(); > this.completionToken = ref.completionIdentifier; > long completionPosition = ref.sourcePositions[ref.tokens.length]; > >@@ -3175,7 +3176,7 @@ > this.assistNodeIsConstructor = singleRef.isConstructorType; > this.assistNodeIsSuperType = singleRef.isSuperType(); > this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent); >- >+ this.assistNodeIsInterfaceExcludingAnnotations = singleRef.isInterfaceExcludingAnnotations(); // can only be an annotation if preceeded by EXTENDS > // can be the start of a qualified type name > if (qualifiedBinding == null) { > if (this.completionToken.length == 0 && >@@ -4038,7 +4039,7 @@ > } > > private int computeRelevanceForInterface(){ >- if(this.assistNodeIsInterface) { >+ if(this.assistNodeIsInterface || this.assistNodeIsInterfaceExcludingAnnotations) { > return R_INTERFACE; > } > return 0; >@@ -9254,6 +9255,8 @@ > memberType.isStatic()) { > continue next; > } >+ >+ if (this.assistNodeIsInterfaceExcludingAnnotations && memberType.isAnnotationType()) continue next; > > for (int i = typesFound.size; --i >= 0;) { > ReferenceBinding otherType = (ReferenceBinding) typesFound.elementAt(i); >@@ -9284,6 +9287,8 @@ > if(!this.insideQualifiedReference) { > if(this.assistNodeIsClass) { > if(!memberType.isClass()) continue next; >+ } else if (this.assistNodeIsInterfaceExcludingAnnotations) { >+ if (!memberType.isInterface()) continue next; > } else if(this.assistNodeIsInterface) { > if(!memberType.isInterface() && !memberType.isAnnotationType()) continue next; > } else if (this.assistNodeIsAnnotation) { >@@ -9767,10 +9772,14 @@ > if (localType == otherType) > continue next; > } >+ >+ if (this.assistNodeIsInterfaceExcludingAnnotations && localType.isAnnotationType()) continue next; > > if (this.assistNodeIsExtendedType && localType.isFinal()) continue next; > if(this.assistNodeIsClass) { > if(!localType.isClass()) continue next; >+ } else if (this.assistNodeIsInterfaceExcludingAnnotations) { >+ if (!localType.isInterface()) continue next; > } else if(this.assistNodeIsInterface) { > if(!localType.isInterface() && !localType.isAnnotationType()) continue next; > } else if (this.assistNodeIsAnnotation) { >@@ -10081,6 +10090,7 @@ > > findNestedTypes(token, scope.enclosingSourceType(), scope, proposeAllMemberTypes, typesFound); > if(!this.assistNodeIsInterface && >+ !this.assistNodeIsInterfaceExcludingAnnotations && > !this.assistNodeIsConstructor && > !this.assistNodeIsAnnotation && > this.assistNodeInJavadoc == 0) { >@@ -10115,6 +10125,8 @@ > SourceTypeBinding sourceType = types[i]; > > if(isForbidden(sourceType)) continue next; >+ >+ if (this.assistNodeIsInterfaceExcludingAnnotations && sourceType.isAnnotationType()) continue next; > > if(proposeAllMemberTypes && > sourceType != outerInvocationType) { >@@ -10152,6 +10164,8 @@ > if (this.assistNodeIsExtendedType && sourceType.isFinal()) continue next; > if(this.assistNodeIsClass) { > if(!sourceType.isClass()) continue next; >+ } else if (this.assistNodeIsInterfaceExcludingAnnotations) { >+ if (!sourceType.isInterface()) continue next; > } else if(this.assistNodeIsInterface) { > if(!sourceType.isInterface() && !sourceType.isAnnotationType()) continue next; > } else if (this.assistNodeIsAnnotation) { >@@ -10283,6 +10297,8 @@ > int searchFor = IJavaSearchConstants.TYPE; > if(this.assistNodeIsClass) { > searchFor = IJavaSearchConstants.CLASS; >+ } else if(this.assistNodeIsInterfaceExcludingAnnotations) { >+ searchFor = IJavaSearchConstants.INTERFACE; > } else if(this.assistNodeIsInterface) { > searchFor = IJavaSearchConstants.INTERFACE_AND_ANNOTATION; > } else if(this.assistNodeIsEnum) { >@@ -10357,7 +10373,7 @@ > > if (isForbidden(sourceType)) continue; > if (this.assistNodeIsClass && sourceType.isInterface()) continue; >- if (this.assistNodeIsInterface && sourceType.isClass()) continue; >+ if ((this.assistNodeIsInterface || this.assistNodeIsInterfaceExcludingAnnotations) && sourceType.isClass()) continue; > > char[] qualifiedSourceTypeName = CharOperation.concatWith(sourceType.compoundName, '.'); > >@@ -10462,6 +10478,8 @@ > int searchFor = IJavaSearchConstants.TYPE; > if(this.assistNodeIsClass) { > searchFor = IJavaSearchConstants.CLASS; >+ } else if (this.assistNodeIsInterfaceExcludingAnnotations) { >+ searchFor = IJavaSearchConstants.INTERFACE; > } else if(this.assistNodeIsInterface) { > searchFor = IJavaSearchConstants.INTERFACE_AND_ANNOTATION; > } else if(this.assistNodeIsEnum) { >@@ -10570,6 +10588,8 @@ > if (this.assistNodeIsExtendedType && refBinding.isFinal()) continue next; > if(this.assistNodeIsClass) { > if(!refBinding.isClass()) continue next; >+ } else if (this.assistNodeIsInterfaceExcludingAnnotations) { >+ if (!refBinding.isInterface()) continue next; > } else if(this.assistNodeIsInterface) { > if(!refBinding.isInterface() && !refBinding.isAnnotationType()) continue next; > } else if (this.assistNodeIsAnnotation) { >@@ -10700,6 +10720,8 @@ > if (this.assistNodeIsExtendedType && typeBinding.isFinal()) continue; > if(this.assistNodeIsClass) { > if(!typeBinding.isClass()) continue; >+ } else if (this.assistNodeIsInterfaceExcludingAnnotations) { >+ if (!typeBinding.isInterface()) continue; > } else if(this.assistNodeIsInterface) { > if(!typeBinding.isInterface() && !typeBinding.isAnnotationType()) continue; > } else if (this.assistNodeIsAnnotation) { >@@ -10803,6 +10825,8 @@ > if (this.assistNodeIsExtendedType && typeBinding.isFinal()) continue; > if(this.assistNodeIsClass) { > if(!typeBinding.isClass()) continue; >+ } else if (this.assistNodeIsInterfaceExcludingAnnotations) { >+ if (!typeBinding.isInterface()) continue; > } else if(this.assistNodeIsInterface) { > if(!typeBinding.isInterface() && !typeBinding.isAnnotationType()) continue; > } else if (this.assistNodeIsAnnotation) { >Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnParameterizedQualifiedTypeReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnParameterizedQualifiedTypeReference.java,v >retrieving revision 1.12 >diff -u -r1.12 CompletionOnParameterizedQualifiedTypeReference.java >--- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnParameterizedQualifiedTypeReference.java 7 Mar 2009 00:59:00 -0000 1.12 >+++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnParameterizedQualifiedTypeReference.java 21 May 2010 11:24:25 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2009 IBM Corporation and others. >+ * Copyright (c) 2004, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -36,6 +36,8 @@ > public static final int K_CLASS = 1; > public static final int K_INTERFACE = 2; > public static final int K_EXCEPTION = 3; >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310423 >+ public static final int K_INTERFACE_EXCLUDING_ANNOTATIONS = 4; > > private int kind = K_TYPE; > public char[] completionIdentifier; >@@ -75,6 +77,10 @@ > public boolean isSuperType(){ > return this.kind == K_CLASS || this.kind == K_INTERFACE; > } >+ >+ public boolean isInterfaceExcludingAnnotations(){ >+ return this.kind == K_INTERFACE_EXCLUDING_ANNOTATIONS; >+ } > > public TypeBinding resolveType(BlockScope scope, boolean checkBounds) { > super.resolveType(scope, checkBounds); >@@ -92,6 +98,7 @@ > output.append("<CompleteOnClass:");//$NON-NLS-1$ > break; > case K_INTERFACE : >+ case K_INTERFACE_EXCLUDING_ANNOTATIONS: > output.append("<CompleteOnInterface:");//$NON-NLS-1$ > break; > case K_EXCEPTION : >@@ -132,4 +139,8 @@ > output.append('.').append(this.completionIdentifier).append('>'); > return output; > } >+ >+ public void setKind(int kind) { >+ this.kind = kind; >+ } > } >Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java,v >retrieving revision 1.29 >diff -u -r1.29 CompletionOnQualifiedTypeReference.java >--- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java 16 Jan 2009 14:29:29 -0000 1.29 >+++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java 21 May 2010 11:24:26 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -32,6 +32,8 @@ > public static final int K_CLASS = 1; > public static final int K_INTERFACE = 2; > public static final int K_EXCEPTION = 3; >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310423 >+ public static final int K_INTERFACE_EXCLUDING_ANNOTATIONS = 4; > > private int kind = K_TYPE; > public char[] completionIdentifier; >@@ -85,6 +87,10 @@ > public boolean isSuperType(){ > return this.kind == K_CLASS || this.kind == K_INTERFACE; > } >+ >+public boolean isInterfaceExcludingAnnotations(){ >+ return this.kind == K_INTERFACE_EXCLUDING_ANNOTATIONS; >+} > public void setKind(int kind) { > this.kind = kind; > } >@@ -94,6 +100,7 @@ > output.append("<CompleteOnClass:");//$NON-NLS-1$ > break; > case K_INTERFACE : >+ case K_INTERFACE_EXCLUDING_ANNOTATIONS: > output.append("<CompleteOnInterface:");//$NON-NLS-1$ > break; > case K_EXCEPTION : >Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java,v >retrieving revision 1.30 >diff -u -r1.30 CompletionOnSingleTypeReference.java >--- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java 27 Jun 2008 16:03:58 -0000 1.30 >+++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java 21 May 2010 11:24:26 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -32,6 +32,8 @@ > public static final int K_CLASS = 1; > public static final int K_INTERFACE = 2; > public static final int K_EXCEPTION = 3; >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310423 >+public static final int K_INTERFACE_EXCLUDING_ANNOTATIONS = 4; > > private int kind = K_TYPE; > public boolean isCompletionNode; >@@ -77,12 +79,16 @@ > public boolean isSuperType(){ > return this.kind == K_CLASS || this.kind == K_INTERFACE; > } >+public boolean isInterfaceExcludingAnnotations(){ >+ return this.kind == K_INTERFACE_EXCLUDING_ANNOTATIONS; >+} > public StringBuffer printExpression(int indent, StringBuffer output){ > switch (this.kind) { > case K_CLASS : > output.append("<CompleteOnClass:");//$NON-NLS-1$ > break; > case K_INTERFACE : >+ case K_INTERFACE_EXCLUDING_ANNOTATIONS: > output.append("<CompleteOnInterface:");//$NON-NLS-1$ > break; > case K_EXCEPTION : >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.214 >diff -u -r1.214 CompletionParser.java >--- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 22 Apr 2010 12:56:48 -0000 1.214 >+++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 21 May 2010 11:24:29 -0000 >@@ -2157,6 +2157,29 @@ > } > } > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310423 >+protected void consumeClassHeaderImplements() { >+ super.consumeClassHeaderImplements(); >+ // Make sure that no annotations are proposed after implements keyword >+ if (this.assistNode != null) { >+ if (this.assistNode instanceof CompletionOnSingleTypeReference) { >+ CompletionOnSingleTypeReference completionNode = (CompletionOnSingleTypeReference) this.assistNode; >+ if (completionNode.isInterface()) { >+ completionNode.setKind(CompletionOnSingleTypeReference.K_INTERFACE_EXCLUDING_ANNOTATIONS); >+ } >+ } else if (this.assistNode instanceof CompletionOnQualifiedTypeReference) { >+ CompletionOnQualifiedTypeReference completionNode = (CompletionOnQualifiedTypeReference) this.assistNode; >+ if (completionNode.isInterface()) { >+ completionNode.setKind(CompletionOnQualifiedTypeReference.K_INTERFACE_EXCLUDING_ANNOTATIONS); >+ } >+ } else if (this.assistNode instanceof CompletionOnParameterizedQualifiedTypeReference) { >+ CompletionOnParameterizedQualifiedTypeReference completionNode = (CompletionOnParameterizedQualifiedTypeReference) this.assistNode; >+ if (completionNode.isInterface()) { >+ completionNode.setKind(CompletionOnParameterizedQualifiedTypeReference.K_INTERFACE_EXCLUDING_ANNOTATIONS); >+ } >+ } >+ } >+} > protected void consumeClassTypeElt() { > pushOnElementStack(K_NEXT_TYPEREF_IS_EXCEPTION); > super.consumeClassTypeElt(); >#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 May 2010 11:24:39 -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