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 180425 Details for
Bug 311022
NPE in InternalExtendedCompletionContext.getVisibleElement
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed fix v1.0 (small correction) + regression tests
patch311022.txt (text/plain), 6.00 KB, created by
Ayushman Jain
on 2010-10-07 10:03:28 EDT
(
hide
)
Description:
proposed fix v1.0 (small correction) + regression tests
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2010-10-07 10:03:28 EDT
Size:
6.00 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java,v >retrieving revision 1.20 >diff -u -r1.20 InternalExtendedCompletionContext.java >--- codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java 25 Sep 2010 06:52:42 -0000 1.20 >+++ codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java 7 Oct 2010 14:00:12 -0000 >@@ -386,7 +386,7 @@ > next : for (int i = 0; i < size; i++) { > try { > LocalVariableBinding binding = (LocalVariableBinding) this.visibleLocalVariables.elementAt(i); >- if (assignableTypeBinding != null && !binding.type.isCompatibleWith(assignableTypeBinding)) continue next; >+ if (binding.type == null || (assignableTypeBinding != null && !binding.type.isCompatibleWith(assignableTypeBinding))) continue next; > JavaElement localVariable = getJavaElement(binding); > if (localVariable != null) result[elementCount++] = localVariable; > } catch(AbortCompilation e) { >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/CompletionContextTests_1_5.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionContextTests_1_5.java,v >retrieving revision 1.14 >diff -u -r1.14 CompletionContextTests_1_5.java >--- src/org/eclipse/jdt/core/tests/model/CompletionContextTests_1_5.java 14 May 2009 23:08:08 -0000 1.14 >+++ src/org/eclipse/jdt/core/tests/model/CompletionContextTests_1_5.java 7 Oct 2010 14:00:13 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2009 IBM Corporation and others. >+ * Copyright (c) 2005, 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 >@@ -1370,4 +1370,80 @@ > "completion token location=UNKNOWN", > result.context); > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=311022 >+public void testBug311022a() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[3]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src3/test/X.java", >+ "package test;\n" + >+ "public class X {\n" + >+ " void foo(Object o) {}\n" + >+ " <T> void bar() {\n" + >+ " T<T> loc = 12;\n" + >+ " foo\n" + >+ " }\n" + >+ "}"); >+ >+ String str = this.workingCopies[0].getSource(); >+ int tokenStart = str.lastIndexOf("foo"); >+ int tokenEnd = tokenStart + "foo".length() - 1; >+ int cursorLocation = str.lastIndexOf("foo") + "foo".length(); >+ >+ CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation, true, true, "Ljava.lang.Object;"); >+ String jclPath = getExternalJCLPathString("1.5"); >+ assertResults( >+ "completion offset="+(cursorLocation)+"\n" + >+ "completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" + >+ "completion token=\"foo\"\n" + >+ "completion token kind=TOKEN_KIND_NAME\n" + >+ "expectedTypesSignatures=null\n" + >+ "expectedTypesKeys=null\n" + >+ "completion token location={STATEMENT_START}\n" + >+ "enclosingElement=bar() {key=Ltest/X;.bar<T:Ljava/lang/Object;>()V} [in X [in [Working copy] X.java [in test [in src3 [in Completion]]]]]\n" + >+ "visibleElements={\n" + >+ " toString() {key=Ljava/lang/Object;.toString()Ljava/lang/String;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" + >+ " getClass() {key=Ljava/lang/Object;.getClass()Ljava/lang/Class<+Ljava/lang/Object;>;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" + >+ " clone() {key=Ljava/lang/Object;.clone()Ljava/lang/Object;|Ljava/lang/CloneNotSupportedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" + >+ "}", >+ result.context); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=311022 >+public void testBug311022b() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[3]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src3/test/X.java", >+ "package test;\n" + >+ "public class X<A1,A2> {\n" + >+ " void foo(Object 0) {}\n" + >+ " <T> void bar() {\n" + >+ " X<String, String, String> x;\n" + >+ " foo\n" + >+ " }\n" + >+ "}"); >+ >+ String str = this.workingCopies[0].getSource(); >+ int tokenStart = str.lastIndexOf("foo"); >+ int tokenEnd = tokenStart + "foo".length() - 1; >+ int cursorLocation = str.lastIndexOf("foo") + "foo".length(); >+ >+ CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation, true, true, "Ljava.lang.Object;"); >+ String jclPath = getExternalJCLPathString("1.5"); >+ assertResults( >+ "completion offset="+(cursorLocation)+"\n" + >+ "completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" + >+ "completion token=\"foo\"\n" + >+ "completion token kind=TOKEN_KIND_NAME\n" + >+ "expectedTypesSignatures=null\n" + >+ "expectedTypesKeys=null\n" + >+ "completion token location={STATEMENT_START}\n" + >+ "enclosingElement=bar() {key=Ltest/X;.bar<T:Ljava/lang/Object;>()V} [in X [in [Working copy] X.java [in test [in src3 [in Completion]]]]]\n" + >+ "visibleElements={\n" + >+ " toString() {key=Ljava/lang/Object;.toString()Ljava/lang/String;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" + >+ " getClass() {key=Ljava/lang/Object;.getClass()Ljava/lang/Class<+Ljava/lang/Object;>;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" + >+ " clone() {key=Ljava/lang/Object;.clone()Ljava/lang/Object;|Ljava/lang/CloneNotSupportedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" + >+ "}", >+ result.context); >+} > }
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 311022
:
180424
| 180425