From 67e27aa5edc0d1debe3a33c02a854353b66b4c65 Mon Sep 17 00:00:00 2001 From: Brandon Donnelson Date: Fri, 13 Oct 2017 12:32:53 -0700 Subject: [PATCH] Fix Oxygen 1.a classpath exception. --- eclipse/mars/gwt-eclipse-mars.target | 4 +- eclipse/neon/gwt-eclipse-neon.target | 12 ++--- .../gdt/eclipse/core/ClasspathUtilities.java | 50 ++++++++++++------- pom.xml | 13 +++-- 4 files changed, 49 insertions(+), 30 deletions(-) diff --git a/eclipse/mars/gwt-eclipse-mars.target b/eclipse/mars/gwt-eclipse-mars.target index f3d777cb..4db79fea 100644 --- a/eclipse/mars/gwt-eclipse-mars.target +++ b/eclipse/mars/gwt-eclipse-mars.target @@ -1,7 +1,7 @@ - + @@ -43,7 +43,7 @@ - + diff --git a/eclipse/neon/gwt-eclipse-neon.target b/eclipse/neon/gwt-eclipse-neon.target index a2518f0f..3fe7bf7c 100644 --- a/eclipse/neon/gwt-eclipse-neon.target +++ b/eclipse/neon/gwt-eclipse-neon.target @@ -1,19 +1,19 @@ - + - - + + - + @@ -45,8 +45,8 @@ - - + + diff --git a/plugins/com.gwtplugins.gdt.eclipse.core/src/com/google/gdt/eclipse/core/ClasspathUtilities.java b/plugins/com.gwtplugins.gdt.eclipse.core/src/com/google/gdt/eclipse/core/ClasspathUtilities.java index 34b0f131..3c1810db 100644 --- a/plugins/com.gwtplugins.gdt.eclipse.core/src/com/google/gdt/eclipse/core/ClasspathUtilities.java +++ b/plugins/com.gwtplugins.gdt.eclipse.core/src/com/google/gdt/eclipse/core/ClasspathUtilities.java @@ -42,7 +42,7 @@ import java.util.Map; /** - * + * */ @SuppressWarnings("restriction") public final class ClasspathUtilities { @@ -77,7 +77,7 @@ public Class find(ClassLoader classLoader, String className) { /** * Finds all the classpath containers in the specified project that match the * provided container ID. - * + * * @param javaProject the project to query * @param containerId The container ID we are trying to match. * @return an array of matching classpath containers. @@ -87,6 +87,7 @@ public static IClasspathEntry[] findClasspathContainersWithContainerId( throws JavaModelException { Predicate matchPredicate = new Predicate() { + @Override public boolean apply(IClasspathEntry entry) { if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { IPath containerPath = entry.getPath(); @@ -123,7 +124,7 @@ public boolean apply(IClasspathEntry entry) { /** * Returns the {@link IClasspathEntry#CPE_CONTAINER} entry with the specified * container ID or null if one could not be found. - * + * * @param classpathEntries array of classpath entries * @param containerId container ID * @return {@link IClasspathEntry#CPE_CONTAINER} entry with the specified @@ -141,7 +142,7 @@ public static IClasspathEntry findClasspathEntryContainer( /** * Return the raw classpath entry on the project's classpath that contributes * the given type to the project. - * + * * @param javaProject The java project * @param fullyQualifiedName The fully-qualified type name * @return The raw classpath entry that contributes the type to the project, @@ -160,8 +161,20 @@ public static IClasspathEntry findRawClasspathEntryFor( IClasspathEntry[] rawClasspath = javaProject.getRawClasspath(); for (IClasspathEntry rawClasspathEntry : rawClasspath) { IClasspathEntry[] resolvedClasspath = jProject.resolveClasspath(new IClasspathEntry[] {rawClasspathEntry}); - IPackageFragmentRoot[] computePackageFragmentRoots = jProject.computePackageFragmentRoots( - resolvedClasspath, true, null); + + // was this - which is no longer, internal api refactor + //IPackageFragmentRoot[] computePackageFragmentRoots = jProject.computePackageFragmentRoots(resolvedClasspath, true, null); + + // now this - from IPackage + List fragmentRoots = new ArrayList(); + for (IClasspathEntry classPathEntry : resolvedClasspath) { + IPackageFragmentRoot[] foundRoots = javaProject.findPackageFragmentRoots(classPathEntry); + fragmentRoots.addAll(Arrays.asList(foundRoots)); + } + + IPackageFragmentRoot[] computePackageFragmentRoots = new IPackageFragmentRoot[fragmentRoots.size()]; + fragmentRoots.toArray(computePackageFragmentRoots); + if (Arrays.asList(computePackageFragmentRoots).contains( packageFragmentRoot)) { return rawClasspathEntry; @@ -177,7 +190,7 @@ public static IClasspathEntry findRawClasspathEntryFor( /** * Returns a String (in the format of the JVM classpath argument) which * contains the given classpath entries. - * + * * @param classpathEntries array of runtime classpath entries * @return flattened String of the given classpath entries in the format * suitable for passing as a JVM argument @@ -217,7 +230,7 @@ public static IClasspathEntry getNullableRawClasspathEntryForPackageFragmentRoot /** * Determines whether a ClasspathContainer exists on the provided project that * matches the provided container ID. - * + * * @param javaProject the project to query * @param containerId The container ID we are trying to match. * @return whether at least one classpath container exists that matches the @@ -235,7 +248,7 @@ public static boolean includesClasspathContainerWithContainerId( * Returns the first index of the specified * {@link IClasspathEntry#CPE_CONTAINER} entry with the specified container ID * or -1 if one could not be found. - * + * * @param classpathEntries array of classpath entries * @param containerId container ID * @return index of the specified {@link IClasspathEntry#CPE_CONTAINER} entry @@ -263,11 +276,11 @@ public static int indexOfClasspathEntryContainer( /** * Replace an {@link IClasspathEntry#CPE_CONTAINER} entry with the given * container ID, with its corresponding resolved classpath entries. - * + * * @param javaProject java project * @param containerId container ID to replace * @return true if a container was replaced - * + * * @throws JavaModelException */ public static boolean replaceContainerWithClasspathEntries( @@ -294,7 +307,7 @@ public static boolean replaceContainerWithClasspathEntries( /** * Replaces a project's classpath container entry with a new one or appends it * to the classpath if none were found. - * + * * @param javaProject The target project * @param containerId the identifier of the classpath container type * @param newContainerPath the path for the new classpath. Note: this path @@ -333,7 +346,7 @@ public static void replaceOrAppendContainer(IJavaProject javaProject, * more information: http://bugs.eclipse.org/bugs/show_bug.cgi?id=243692 - * + * *

* Note that this method is asynchronous, so the caller will regain control * immediately, and the raw classpath will be set at some future time. Right @@ -341,7 +354,7 @@ public static void replaceOrAppendContainer(IJavaProject javaProject, * If this becomes a concern in the future, a callback parameter can be * introduced. *

- * + * *

* This method does not accept an IProgressMonitor, unlike the equivalent * method in IJavaProject, because there is an implicit progress monitor @@ -349,7 +362,7 @@ public static void replaceOrAppendContainer(IJavaProject javaProject, * future, this method could be modified to accept a user-specified progress * monitor. *

- * + * * NOTE: If you are already running in a job, you probably don't want to call * this method. */ @@ -357,6 +370,7 @@ public static void setRawClasspath(final IJavaProject javaProject, final IClasspathEntry[] newClasspathEntries) { IWorkspaceRunnable runnable = new IWorkspaceRunnable() { + @Override public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException { javaProject.setRawClasspath(newClasspathEntries, monitor); @@ -376,7 +390,7 @@ public void run(IProgressMonitor monitor) throws CoreException, * more information: http://bugs.eclipse.org/bugs/show_bug.cgi?id=243692 - * + * *

* Note that this method is asynchronous, so the caller will regain control * immediately, and the raw classpath will be set at some future time. Right @@ -384,7 +398,7 @@ public void run(IProgressMonitor monitor) throws CoreException, * If this becomes a concern in the future, a callback parameter can be * introduced. *

- * + * *

* This method does not accept an IProgressMonitor, unlike the equivalent * method in IJavaProject, because there is an implicit progress monitor @@ -401,7 +415,7 @@ public static void setRawClasspath(final IJavaProject javaProject, /** * Waits indefinitely until the given classpath entries are on the given * project's raw classpath. - * + * * @throws JavaModelException * @throws InterruptedException */ diff --git a/pom.xml b/pom.xml index d3d87cbc..82fda79a 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ - 2.7.0 + 2.8.1 50000 @@ -55,13 +55,18 @@ plugins/com.gwtplugins.gdt.eclipse.suite plugins/com.gwtplugins.gdt.eclipse.suite.update plugins/com.gwtplugins.gdt.eclipse.suite.test - plugins/com.gwtplugins.gdt.eclipse.suite.test.swtbot - plugins/com.gwtplugins.gdt.eclipse.swtbot + + + + plugins/com.gwtplugins.gwt.eclipse.core plugins/com.gwtplugins.gwt.eclipse.core.test - plugins/com.gwtplugins.gwt.eclipse.core.test.swtbot + + + + plugins/com.gwtplugins.gwt.eclipse.oophm plugins/com.gwtplugins.gwt.eclipse.oophm.test plugins/com.gwtplugins.gwt.eclipse.testing