diff options
author | Stephan Herrmann | 2019-07-02 20:26:33 +0000 |
---|---|---|
committer | Stephan Herrmann | 2019-07-04 11:52:50 +0000 |
commit | 50ecbd5c524eb4fbbb539a28ce70a3d0ec8c30cb (patch) | |
tree | afb66501931ca03bb97c1e2025850642cb152e57 | |
parent | 235d033c53538724b68f25cfb45c9c57c97cba3a (diff) | |
download | eclipse.jdt.core-50ecbd5c524eb4fbbb539a28ce70a3d0ec8c30cb.tar.gz eclipse.jdt.core-50ecbd5c524eb4fbbb539a28ce70a3d0ec8c30cb.tar.xz eclipse.jdt.core-50ecbd5c524eb4fbbb539a28ce70a3d0ec8c30cb.zip |
Bug 548888 - Type completion inside module-info's javadoc raises NPE
Change-Id: Ia0fdf399b4310db66cdbf91cb7a24c72cff3fc59
2 files changed, 29 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests9.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests9.java index 0fc84e4d81..3dbfe28d00 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests9.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests9.java @@ -1596,4 +1596,32 @@ public void testBug530911() throws Exception { deleteProject(project1); } } +public void testBug548888() throws Exception { + IJavaProject project1 = createJavaProject("Completion9_1", new String[] {"src"}, new String[] {"JCL19_LIB", "org.eclipse.jdt.core.tests.model.TEST_CONTAINER"}, "bin", "9"); + try { + project1.open(null); + + String content = + "/**\n" + + " * @see List\n" + + " */\n" + + "module firstmod {\n" + + "}\n"; + String filePath = "/Completion9_1/src/module-info.java"; + String completeBehind="List"; + createFile(filePath, content); + int cursorLocation = content.lastIndexOf(completeBehind) + completeBehind.length(); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); + + waitUntilIndexesReady(); + + ICompilationUnit unit = getCompilationUnit(filePath); + unit.codeComplete(cursorLocation, requestor); + + String expected = "List[TYPE_REF]{java.util.List, java.util, Ljava.util.List;, null, 53}"; + assertResults(expected, requestor.getResults()); + } finally { + deleteProject(project1); + } +} }
\ No newline at end of file diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java index 4b72d13521..26ecdd31b2 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java @@ -2337,6 +2337,7 @@ public final class CompletionEngine throw new CompletionNodeFound(this.parser.assistNode, null, parsedUnit.scope); } catch (CompletionNodeFound e) { + this.unitScope = parsedUnit.scope; if (e.astNode != null) { // if null then we found a problem in the completion node if(DEBUG) { |