diff options
author | Jay Arthanareeswaran | 2018-01-03 10:47:25 +0000 |
---|---|---|
committer | Jay Arthanareeswaran | 2018-01-03 10:55:32 +0000 |
commit | bf68d315bdf3f8b63e7739d4b181734e9e689115 (patch) | |
tree | 1e7500c5b5a659648ba95624aab12f00566974ec | |
parent | 3d3255b352abe329b038fed8610941e23064d10c (diff) | |
download | eclipse.jdt.core-bf68d315bdf3f8b63e7739d4b181734e9e689115.tar.gz eclipse.jdt.core-bf68d315bdf3f8b63e7739d4b181734e9e689115.tar.xz eclipse.jdt.core-bf68d315bdf3f8b63e7739d4b181734e9e689115.zip |
Bug 529349: Java Content assist proposal results in exception
Change-Id: I1b19743874695162df20a22da0500a777b05f47b
Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
2 files changed, 32 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java index 6b87c4b030..b0fdf5a7b5 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2017 IBM Corporation and others. + * Copyright (c) 2014, 2018 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 @@ -3084,4 +3084,33 @@ public void testBug528938b() throws JavaModelException { "zzz[FIELD_REF]{zzz, LX;, Ljava.lang.String;, zzz, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}", requestor.getResults()); } +/* + * Test that completion doesn't throw NPE and produces valid completions. + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=529349 + */ +public void testBug529349a() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/p/SuperSuper.java", + "package p;\n" + + "public class SuperSuper {}\n" + + "class Super extends SuperSuper {}\n" + + "class Y {\n" + + " static class Super {}\n" + + "}\n" + + "class X extends Sup {\n" + + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "Sup"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "Y.Super[TYPE_REF]{p.Y.Super, p, Lp.Y$Super;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_CLASS ) + "}\n" + + "Super[TYPE_REF]{Super, p, Lp.Super;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_CLASS) + "}\n" + + "SuperSuper[TYPE_REF]{SuperSuper, p, Lp.SuperSuper;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_CLASS) + "}", + requestor.getResults()); +} } 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 836d38dcb5..cd9a31c65e 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 @@ -10092,7 +10092,8 @@ public final class CompletionEngine if (TypeBinding.equalsEquals(memberType, otherType)) continue next; - if (CharOperation.equals(memberType.sourceName, otherType.sourceName, true)) { + if (CharOperation.equals(memberType.sourceName, otherType.sourceName, true) + && otherType.isNestedType()) { if (memberType.enclosingType().isSuperclassOf(otherType.enclosingType())) continue next; |