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 96818 Details for
Bug 227761
NPE from CompletionContext.getVisibleElements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
bug227761_001.txt (text/plain), 3.95 KB, created by
David Audel
on 2008-04-21 06:24:33 EDT
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
David Audel
Created:
2008-04-21 06:24:33 EDT
Size:
3.95 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.2 >diff -u -r1.2 InternalExtendedCompletionContext.java >--- codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java 14 Apr 2008 10:55:46 -0000 1.2 >+++ codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java 21 Apr 2008 10:23:55 -0000 >@@ -31,6 +31,7 @@ > import org.eclipse.jdt.internal.compiler.ast.Initializer; > import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; > import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; >+import org.eclipse.jdt.internal.compiler.ast.TypeParameter; > import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; > import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding; > import org.eclipse.jdt.internal.compiler.lookup.Binding; >@@ -274,7 +275,21 @@ > ReferenceContext referenceContext = scope.referenceContext(); > if (referenceContext instanceof AbstractMethodDeclaration) { > AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) referenceContext; >- typeVariables = methodDeclaration.binding.typeVariables; >+ TypeParameter[] typeParameters = methodDeclaration.typeParameters(); >+ if (typeParameters != null && typeParameters.length > 0) { >+ int length = typeParameters.length; >+ int count = 0; >+ typeVariables = new TypeVariableBinding[length]; >+ for (int i = 0; i < length; i++) { >+ if (typeParameters[i].binding != null) { >+ typeVariables[count++] = typeParameters[i].binding; >+ } >+ } >+ >+ if (count != length) { >+ System.arraycopy(typeVariables, 0, typeVariables = new TypeVariableBinding[count], 0, count); >+ } >+ } > } > > CompilationUnitDeclaration previousUnitBeingCompleted = lookupEnvironment.unitBeingCompleted; >#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.8 >diff -u -r1.8 CompletionContextTests_1_5.java >--- src/org/eclipse/jdt/core/tests/model/CompletionContextTests_1_5.java 14 Apr 2008 10:55:44 -0000 1.8 >+++ src/org/eclipse/jdt/core/tests/model/CompletionContextTests_1_5.java 21 Apr 2008 10:23:56 -0000 >@@ -1267,4 +1267,37 @@ > "}", > result.context); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=227761 >+public void test0040() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src3/test/X.java", >+ "package test;\n" + >+ "public class X {\n" + >+ " public X foo() {return null;}\n" + >+ " public A() {\n" + >+ " zzzz\n" + >+ " }\n" + >+ "}"); >+ >+ String str = this.workingCopies[0].getSource(); >+ int tokenStart = str.lastIndexOf("zzzz"); >+ int tokenEnd = tokenStart + "zzzz".length() - 1; >+ int cursorLocation = str.lastIndexOf("zzzz") + "zzzz".length(); >+ >+ CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation, false, true, "Ltest.X;"); >+ >+ assertResults( >+ "completion offset="+(cursorLocation)+"\n" + >+ "completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" + >+ "completion token=\"zzzz\"\n" + >+ "completion token kind=TOKEN_KIND_NAME\n" + >+ "expectedTypesSignatures=null\n" + >+ "expectedTypesKeys=null\n" + >+ "completion token location={STATEMENT_START}\n" + >+ "visibleElements={\n" + >+ " foo() {key=Ltest/X;.foo()Ltest/X;} [in X [in [Working copy] X.java [in test [in src3 [in Completion]]]]],\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 227761
: 96818