Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2016-05-09 13:00:44 +0000
committerManoj Palat2016-05-09 16:29:28 +0000
commit5e242f081223c45e11d9b1a9a420fd587b949e50 (patch)
treee674e050f3b6068bfaf5e0db60068c5473e7b953
parenteaa3efc74b3f8005c6a75032dab14cbed1fd6832 (diff)
downloadeclipse.jdt.core-5e242f081223c45e11d9b1a9a420fd587b949e50.tar.gz
eclipse.jdt.core-5e242f081223c45e11d9b1a9a420fd587b949e50.tar.xz
eclipse.jdt.core-5e242f081223c45e11d9b1a9a420fd587b949e50.zip
Fix for bug 493222 Help is broken: HTTP 500 internal server errorI20160510-2000I20160509-2000
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InMemoryNameEnvironment.java7
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PackageBindingTest.java5
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/INameEnvironment.java28
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/INameEnvironmentExtension.java48
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java14
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEnvironment.java5
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/INameEnvironmentWithProgress.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java3
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java3
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java3
11 files changed, 67 insertions, 60 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InMemoryNameEnvironment.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InMemoryNameEnvironment.java
index 0c734d1f57..4eb0b5413c 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InMemoryNameEnvironment.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InMemoryNameEnvironment.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 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
@@ -55,11 +55,6 @@ public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
}
return new NameEnvironmentAnswer(unit, null /*no access restriction*/);
}
-@Override
-public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName, boolean searchWithSecondaryTypes) {
- return findType(typeName, packageName);
-}
-
private NameEnvironmentAnswer findTypeFromClassLibs(char[] typeName, char[][] packageName) {
for (int i = 0; i < this.classLibs.length; i++) {
NameEnvironmentAnswer answer = this.classLibs[i].findType(typeName, packageName);
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PackageBindingTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PackageBindingTest.java
index e91dffaf59..827e53d393 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PackageBindingTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PackageBindingTest.java
@@ -111,11 +111,6 @@ public class PackageBindingTest extends AbstractCompilerTest
}
@Override
- public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName, boolean searchWithSecondaryTypes) {
- return findType(typeName, packageName);
- }
-
- @Override
public boolean isPackage(char[][] parentPackageName, char[] packageName) {
this.isPackageSearchExecuted = true;
return this.isPackage;
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
index 8662107433..1c81ac4743 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -390,9 +390,6 @@ public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
false);
return null;
}
-public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName, boolean searchWithSecondaryTypes) {
- return findType(typeName, packageName);
-}
public boolean isPackage(char[][] compoundName, char[] packageName) {
String qualifiedPackageName = new String(CharOperation.concatWith(compoundName, packageName, '/'));
String qp2 = File.separatorChar == '/' ? qualifiedPackageName : qualifiedPackageName.replace('/', File.separatorChar);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/INameEnvironment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/INameEnvironment.java
index f3333a7544..9a7a2e0060 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/INameEnvironment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/INameEnvironment.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -47,30 +47,7 @@ NameEnvironmentAnswer findType(char[][] compoundTypeName);
*/
NameEnvironmentAnswer findType(char[] typeName, char[][] packageName);
-
/**
- * Find a type named <typeName> in the package <packageName>.
- * Answer the binary form of the type if it is known to be consistent.
- * Otherwise, answer the compilation unit which defines the type
- * or null if the type does not exist.
- * The default package is indicated by char[0][].
- *
- * It is known that the package containing the type exists.
- *
- * NOTE: This method can be used to find a member type using its
- * internal name A$B, but the source file for A is answered if the binary
- * file is inconsistent.
- *
- * The flag <searchWithSecondaryTypes> can be used to switch on/off the search for secondary types.
- * This is useful because the search for secondary types may by very expensive regarding the performance
- * and in many cases it isn't necessary to search for secondary types.
- *
- * @param typeName type to find
- * @param packageName package of the searched type
- * @param searchWithSecondaryTypes flag to switch on/off the search for secondary types
- * @return {@link NameEnvironmentAnswer}
- */
-NameEnvironmentAnswer findType(char[] typeName, char[][] packageName, boolean searchWithSecondaryTypes);/**
* Answer whether packageName is the name of a known subpackage inside
* the package parentPackageName. A top level package is found relative to null.
* The default package is always assumed to exist.
@@ -78,9 +55,6 @@ NameEnvironmentAnswer findType(char[] typeName, char[][] packageName, boolean se
* For example:
* isPackage({{java}, {awt}}, {event});
* isPackage(null, {java});
- *
- * TODO: When the minimum compliance moves to 1.8, add a default implementation which calls
- * findType(char[] typeName, char[][] packageName);
*/
boolean isPackage(char[][] parentPackageName, char[] packageName);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/INameEnvironmentExtension.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/INameEnvironmentExtension.java
new file mode 100644
index 0000000000..4dc4972d15
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/INameEnvironmentExtension.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.compiler.env;
+
+/**
+ * The name environment provides a callback API that the compiler
+ * can use to look up types, compilation units, and packages in the
+ * current environment. The name environment is passed to the compiler
+ * on creation.
+ *
+ * This name environment adds a method to switch on/off the search for secondary types.
+ * Refer {@link #findType(char[], char[][], boolean)}.
+ *
+ */
+public interface INameEnvironmentExtension extends INameEnvironment {
+ /**
+ * Find a type named <typeName> in the package <packageName>.
+ * Answer the binary form of the type if it is known to be consistent.
+ * Otherwise, answer the compilation unit which defines the type
+ * or null if the type does not exist.
+ * The default package is indicated by char[0][].
+ *
+ * It is known that the package containing the type exists.
+ *
+ * NOTE: This method can be used to find a member type using its
+ * internal name A$B, but the source file for A is answered if the binary
+ * file is inconsistent.
+ *
+ * The flag <searchWithSecondaryTypes> can be used to switch on/off the search for secondary types.
+ * This is useful because the search for secondary types may by very expensive regarding the performance
+ * and in many cases it isn't necessary to search for secondary types.
+ *
+ * @param typeName type to find
+ * @param packageName package of the searched type
+ * @param searchWithSecondaryTypes flag to switch on/off the search for secondary types
+ * @return {@link NameEnvironmentAnswer}
+ */
+ NameEnvironmentAnswer findType(char[] typeName, char[][] packageName, boolean searchWithSecondaryTypes);
+
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
index f50ca08f81..9496c2ff80 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
@@ -779,9 +779,17 @@ public PackageBinding createPackage(char[][] compoundName) {
// catches the case of a package statement of: package java.lang.Object;
// since the package can be added after a set of source files have already been compiled,
// we need to check whenever a package is created
- // it isn't necessary to check when creating a package, because package name can not collide with a secondary type name.
- if (this.nameEnvironment.findType(compoundName[i], parent.compoundName, false) != null) {
- return null;
+ if(this.nameEnvironment instanceof INameEnvironmentExtension) {
+ //When the nameEnvironment is an instance of INameEnvironmentWithProgress, it can get avoided to search for secondaryTypes (see flag).
+ // This is a performance optimization, because it is very expensive to search for secondary types and it isn't necessary to check when creating a package,
+ // because package name can not collide with a secondary type name.
+ if (((INameEnvironmentExtension)this.nameEnvironment).findType(compoundName[i], parent.compoundName, false) != null) {
+ return null;
+ }
+ } else {
+ if (this.nameEnvironment.findType(compoundName[i], parent.compoundName) != null) {
+ return null;
+ }
}
packageBinding = new PackageBinding(CharOperation.subarray(compoundName, 0, i + 1), parent, this);
parent.addPackage(packageBinding);
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEnvironment.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEnvironment.java
index 671506156e..24b0b5eb06 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEnvironment.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEnvironment.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2006 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
@@ -77,9 +77,6 @@ public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
}
return findType(CharOperation.arrayConcat(packageName, typeName));
}
-public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName, boolean searchWithSecondaryTypes) {
- return findType(typeName, packageName);
-}
/**
* @see INameEnvironment#isPackage(char[][], char[])
*/
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/INameEnvironmentWithProgress.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/INameEnvironmentWithProgress.java
index 583d86a11b..303275b0a8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/INameEnvironmentWithProgress.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/INameEnvironmentWithProgress.java
@@ -11,7 +11,7 @@
package org.eclipse.jdt.internal.core;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
+import org.eclipse.jdt.internal.compiler.env.INameEnvironmentExtension;
/**
* The name environment provides a callback API that the compiler
@@ -24,7 +24,8 @@ import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
*
* @since 3.6
*/
-public interface INameEnvironmentWithProgress extends INameEnvironment {
+public interface INameEnvironmentWithProgress extends INameEnvironmentExtension {
+
/**
* Set the monitor for the given name environment. In order to be able to cancel this name environment calls,
* a non-null monitor should be given.
@@ -32,4 +33,5 @@ public interface INameEnvironmentWithProgress extends INameEnvironment {
* @param monitor the given monitor
*/
void setMonitor(IProgressMonitor monitor);
+
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java
index 2004343adb..c44cba3422 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java
@@ -306,9 +306,6 @@ public class SearchableEnvironment
new String(name),
packageName == null || packageName.length == 0 ? null : CharOperation.toString(packageName));
}
- public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName, boolean searchWithSecondaryTypes) {
- return findType(typeName, packageName);
- }
/**
* Find the top-level types that are defined
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java
index ddde56d14a..c1509e1804 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java
@@ -338,9 +338,6 @@ public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
typeName);
return null;
}
-public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName, boolean searchWithSecondaryTypes) {
- return findType(typeName, packageName);
-}
public boolean isPackage(char[][] compoundName, char[] packageName) {
return isPackage(new String(CharOperation.concatWith(compoundName, packageName, '/')));
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java
index f7a4f4558a..636863b000 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java
@@ -190,9 +190,6 @@ public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
typeName);
return null;
}
-public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName, boolean searchWithSecondaryTypes) {
- return findType(typeName, packageName);
-}
public NameEnvironmentAnswer findType(char[][] compoundName) {
if (compoundName != null)

Back to the top