diff options
| author | ssankaran | 2013-12-01 13:57:56 +0000 |
|---|---|---|
| committer | ssankaran | 2013-12-01 13:57:56 +0000 |
| commit | 87d442c9d1ef66a35b04453c972faa6e201fed9c (patch) | |
| tree | 393bd2aa8109bd9fc79d9dd1d6fba015bc9d584f | |
| parent | 0c0e9f808d4509f3cefc470c2105f7ba1290fdb7 (diff) | |
| download | eclipse.jdt.core-87d442c9d1ef66a35b04453c972faa6e201fed9c.tar.gz eclipse.jdt.core-87d442c9d1ef66a35b04453c972faa6e201fed9c.tar.xz eclipse.jdt.core-87d442c9d1ef66a35b04453c972faa6e201fed9c.zip | |
Fixed Bug 421902 - [1.8][reconciler] Deleting an interface declaration
shows no errors on uses of the interface
| -rw-r--r-- | org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java | 37 | ||||
| -rw-r--r-- | org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java | 25 |
2 files changed, 61 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java index 74297dda7d..1b7c53069a 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java @@ -5452,4 +5452,41 @@ public void testBug374176b() throws CoreException, IOException, InterruptedExcep deleteProject(project15); } } +public void testSecondaryTypeDeletion() throws CoreException, IOException { + + // Set working copy content with no error + setUpWorkingCopy("/Reconciler/src/X.java", + "interface I {\n" + + " void foo();\n" + + "}\n" + + "public class X {\n" + + " static void goo(I i) {\n" + + " }\n" + + "}\n" + ); + assertProblems( + "Unexpected problems", + "----------\n" + + "----------\n" + ); + + String contents = + "public class X {\n" + + " static void goo(I i) {\n" + + " }\n" + + "}\n"; + + setWorkingCopyContents(contents); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, true, null, null); + assertProblems( + "Wrong expected problems", + "----------\n" + + "1. ERROR in /Reconciler/src/X.java (at line 2)\n" + + " static void goo(I i) {\n" + + " ^\n" + + "I cannot be resolved to a type\n" + + "----------\n" + ); + } +}
\ No newline at end of file diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java index ebfb67b19c..130d7b96fd 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java @@ -1,9 +1,13 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2013 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 * http://www.eclipse.org/legal/epl-v10.html + * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. * * Contributors: * IBM Corporation - initial API and implementation @@ -702,6 +706,25 @@ public class NameLookup implements SuffixConstants { } } } + if (type != null) { + ICompilationUnit unit = type.getCompilationUnit(); + if (unit != null && unit.isWorkingCopy()) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=421902 + IType[] types = null; + try { + types = unit.getTypes(); + } catch (JavaModelException e) { + return null; + } + boolean typeFound = false; + for (int i = 0, typesLength = types == null ? 0 : types.length; i < typesLength; i++) { + if (types[i].getElementName().equals(typeName)) { + typeFound = true; + break; + } + } + if (!typeFound) type = null; + } + } return type == null ? null : new Answer(type, null); } |
