mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-14 07:29:51 +00:00
8175886: JShell: crash on tab-complete with NPE
Reviewed-by: jlahoda
This commit is contained in:
parent
e94e5d35bf
commit
54adf4b246
@ -381,7 +381,18 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis {
|
||||
}
|
||||
ImportTree it = findImport(tp);
|
||||
if (it != null) {
|
||||
addElements(membersOf(at, at.getElements().getPackageElement("").asType(), false), it.isStatic() ? STATIC_ONLY.and(accessibility) : accessibility, smartFilter, result);
|
||||
// the context of the identifier is an import, look for
|
||||
// package names that start with the identifier.
|
||||
// If and when Java allows imports from the default
|
||||
// package to the the default package which would allow
|
||||
// JShell to change to use the default package, and that
|
||||
// change is done, then this should use some variation
|
||||
// of membersOf(at, at.getElements().getPackageElement("").asType(), false)
|
||||
addElements(listPackages(at, ""),
|
||||
it.isStatic()
|
||||
? STATIC_ONLY.and(accessibility)
|
||||
: accessibility,
|
||||
smartFilter, result);
|
||||
}
|
||||
break;
|
||||
case CLASS: {
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8131025 8141092 8153761 8145263 8131019
|
||||
* @bug 8131025 8141092 8153761 8145263 8131019 8175886
|
||||
* @summary Test Completion and Documentation
|
||||
* @library /tools/lib
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
@ -295,6 +295,11 @@ public class CompletionSuggestionTest extends KullaTesting {
|
||||
new HashSet<>(Arrays.asList("class")));
|
||||
}
|
||||
|
||||
public void testImportStart() {
|
||||
assertCompletion("import ja|", "java", "javax");
|
||||
assertCompletion("import o|", "org");
|
||||
}
|
||||
|
||||
public void testBrokenClassFile() throws Exception {
|
||||
Compiler compiler = new Compiler();
|
||||
Path testOutDir = Paths.get("CompletionTestBrokenClassFile");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user