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 96989 Details for
Bug 209643
keyword completion proposals for @interface and enum
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
bug209643_003.txt (text/plain), 14.30 KB, created by
David Audel
on 2008-04-22 05:10:34 EDT
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
David Audel
Created:
2008-04-22 05:10:34 EDT
Size:
14.30 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >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.190 >diff -u -r1.190 CompletionParser.java >--- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 16 Apr 2008 09:39:09 -0000 1.190 >+++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 22 Apr 2008 09:09:30 -0000 >@@ -298,6 +298,7 @@ > FAKE_TYPE_NAME, > this.compilationUnit.compilationResult(), > (Annotation)orphan); >+ fakeType.isParameter = true; > currentElement.parent.add(fakeType, 0); > this.pendingAnnotation = fakeType; > return; >@@ -1338,6 +1339,9 @@ > } > > keywords[count++] = Keywords.CLASS; >+ if (this.options.complianceLevel >= ClassFileConstants.JDK1_5) { >+ keywords[count++] = Keywords.ENUM; >+ } > > if((lastModifiers & ClassFileConstants.AccFinal) == 0) { > keywords[count++] = Keywords.INTERFACE; >Index: codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java,v >retrieving revision 1.7 >diff -u -r1.7 Keywords.java >--- codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java 10 May 2006 18:03:52 -0000 1.7 >+++ codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java 22 Apr 2008 09:09:30 -0000 >@@ -23,6 +23,7 @@ > char[] DEFAULT = "default".toCharArray(); //$NON-NLS-1$ > char[] DO = "do".toCharArray(); //$NON-NLS-1$ > char[] ELSE = "else".toCharArray(); //$NON-NLS-1$ >+ char[] ENUM = "enum".toCharArray(); //$NON-NLS-1$ > char[] EXTENDS = "extends".toCharArray(); //$NON-NLS-1$ > char[] FINAL = "final".toCharArray(); //$NON-NLS-1$ > char[] FINALLY = "finally".toCharArray(); //$NON-NLS-1$ >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.365 >diff -u -r1.365 CompletionEngine.java >--- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 16 Apr 2008 11:19:30 -0000 1.365 >+++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 22 Apr 2008 09:09:26 -0000 >@@ -1708,6 +1708,36 @@ > this.completionToken = type.token; > setSourceAndTokenRange(type.sourceStart, type.sourceEnd); > >+ if (scope.parent.parent != null && >+ !(scope.parent.parent instanceof MethodScope) && >+ !fakeType.isParameter) { >+ >+ if (this.completionToken.length <= Keywords.INTERFACE.length >+ && CharOperation.prefixEquals(this.completionToken, Keywords.INTERFACE, false /* ignore case */ >+ )){ >+ int relevance = computeBaseRelevance(); >+ relevance += computeRelevanceForResolution(); >+ relevance += computeRelevanceForInterestingProposal(); >+ relevance += computeRelevanceForCaseMatching(this.completionToken, Keywords.INTERFACE); >+ relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for keywords >+ relevance += R_ANNOTATION; // this proposal is most relevant than annotation proposals >+ >+ this.noProposal = false; >+ if(!this.requestor.isIgnored(CompletionProposal.KEYWORD)) { >+ CompletionProposal proposal = this.createProposal(CompletionProposal.KEYWORD, this.actualCompletionPosition); >+ proposal.setName(Keywords.INTERFACE); >+ proposal.setCompletion(Keywords.INTERFACE); >+ proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); >+ proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); >+ proposal.setRelevance(relevance); >+ this.requestor.accept(proposal); >+ if(DEBUG) { >+ this.printDebug(proposal); >+ } >+ } >+ } >+ } >+ > findTypesAndPackages(this.completionToken, scope, false, false, new ObjectVector()); > } else if (annot.type instanceof CompletionOnQualifiedTypeReference) { > this.insideQualifiedReference = true; >@@ -4989,7 +5019,7 @@ > relevance += computeRelevanceForResolution(); > relevance += computeRelevanceForInterestingProposal(); > relevance += computeRelevanceForCaseMatching(keyword, choices[i]); >- relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for keywors >+ relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for keywords > if (staticFieldsAndMethodOnly && this.insideQualifiedReference) relevance += R_NON_INHERITED; > > if(CharOperation.equals(choices[i], Keywords.TRUE) || CharOperation.equals(choices[i], Keywords.FALSE)) { >@@ -5125,6 +5155,10 @@ > if(canBeType) { > keywords[count++] = Keywords.CLASS; > keywords[count++] = Keywords.INTERFACE; >+ >+ if((modifiers & ClassFileConstants.AccFinal) == 0) { >+ keywords[count++] = Keywords.ENUM; >+ } > } > } else { > // class >#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.102 >diff -u -r1.102 CompletionTests_1_5.java >--- src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 21 Apr 2008 17:40:45 -0000 1.102 >+++ src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 22 Apr 2008 09:09:35 -0000 >@@ -2423,6 +2423,7 @@ > requestor.getResults()); > } else { > assertResults( >+ "interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" + > "Deprecated[TYPE_REF]{Deprecated, java.lang, Ljava.lang.Deprecated;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_TARGET + R_NON_RESTRICTED + R_UNQUALIFIED) + "}\n" + > "TestAnnotation[TYPE_REF]{TestAnnotation, test0087, Ltest0087.TestAnnotation;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_TARGET + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", > requestor.getResults()); >@@ -9016,6 +9017,7 @@ > this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); > > assertResults( >+ "interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" + > "QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_TARGET + R_NON_RESTRICTED) + "}\n" + > "Deprecated[TYPE_REF]{Deprecated, java.lang, Ljava.lang.Deprecated;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_TARGET + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", > requestor.getResults()); >@@ -11788,6 +11790,161 @@ > "MyEnumVar[LOCAL_VARIABLE_REF]{MyEnumVar, null, Ltest.p.MyEnum;, MyEnumVar, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ENUM + R_ENUM_CONSTANT + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", > requestor.getResults()); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=209643 >+public void test0367() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test.java", >+ "package test;\n"+ >+ "public enu\n"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "enu"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ assertResults( >+ "enum[KEYWORD]{enum, null, null, enum, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", >+ requestor.getResults()); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=209643 >+public void test0368() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[2]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test.java", >+ "package test;\n"+ >+ "public class Test {\n" + >+ " enu\n"+ >+ "\n"); >+ >+ this.workingCopies[1] = getWorkingCopy( >+ "/Completion/src/test/enumFoo.java", >+ "package test;\n"+ >+ "public class enumFoo {\n" + >+ "\n"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "enu"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ assertResults( >+ "enu[POTENTIAL_METHOD_DECLARATION]{enu, Ltest.Test;, ()V, enu, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + >+ "Enum[TYPE_REF]{Enum, java.lang, Ljava.lang.Enum;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + >+ "enum[KEYWORD]{enum, null, null, enum, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + >+ "enumFoo[TYPE_REF]{enumFoo, test, Ltest.enumFoo;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", >+ requestor.getResults()); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=209643 >+public void test0369() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test.java", >+ "package test;\n"+ >+ "public @int\n"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "@int"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ assertResults( >+ "interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}", >+ requestor.getResults()); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=209643 >+public void test0370() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test.java", >+ "package test;\n"+ >+ "public class Test {\n"+ >+ " public @int\n" + >+ "}\n"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "@int"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ assertResults( >+ "interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}", >+ requestor.getResults()); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=209643 >+public void test0371() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test.java", >+ "package test;\n"+ >+ "public class Test {\n"+ >+ " public void foo() {\n"+ >+ " @int\n" + >+ " }\n"+ >+ "}\n"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "@int"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ assertResults( >+ "", >+ requestor.getResults()); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=209643 >+public void test0372() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test.java", >+ "package test;\n"+ >+ "public class Test {\n"+ >+ " public void foo() {\n"+ >+ " int var0;\n" + >+ " if (true) {\n" + >+ " int var1;\n" + >+ " @int\n" + >+ " }\n" + >+ " }\n"+ >+ "}\n"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "@int"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ assertResults( >+ "", >+ requestor.getResults()); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=209643 >+public void test0373() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test.java", >+ "package test;\n"+ >+ "public class Test {\n"+ >+ " public void foo(@int float var) {\n"+ >+ " \n" + >+ " }\n"+ >+ "}\n"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "@int"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ assertResults( >+ "", >+ requestor.getResults()); >+} > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=153130 > public void testEC001() throws JavaModelException { > this.workingCopies = new ICompilationUnit[1]; >@@ -13165,7 +13322,7 @@ > requestor.getResults()); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=222326 >-public void test0367() throws JavaModelException { >+public void test0367_0() throws JavaModelException { > this.workingCopies = new ICompilationUnit[7]; > this.workingCopies[0] = getWorkingCopy( > "/Completion/src/X.java",
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 209643
: 96989