diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/UriResolver.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/UriResolver.java index bb960d83..c403e630 100644 --- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/UriResolver.java +++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/UriResolver.java @@ -24,6 +24,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.emf.common.util.URI; +import org.eclipse.jdt.core.IClasspathContainer; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragmentRoot; @@ -35,6 +36,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.function.Consumer; /** * Resolves URIs. @@ -97,27 +99,42 @@ private String resolveUriInternal(String importUri, URI declaringResourceUri, IP if (project.isOpen() && JavaProject.hasJavaNature(project)) { ArrayList paths = new ArrayList<>(); try { - IJavaProject javaProject = JavaCore.create(project); - for (IClasspathEntry classpathEntry : javaProject.getRawClasspath()) { - if (classpathEntry.getContentKind() == IPackageFragmentRoot.K_BINARY) { - if (classpathEntry.getPath().toOSString().toLowerCase().endsWith(".jar")) { - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - - if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { - IPath cpPath = classpathEntry.getPath(); - IResource res = root.findMember(cpPath); - // If res is null, the path is absolute (it's an external jar) - String path; - if (res == null) { - path = cpPath.toOSString(); - } else { - path = "${workspace_loc:" + res.getFullPath().toOSString() + "}"; - } - paths.add(DirectoryPath.parse(path, project)); - } - } - } - } + final Consumer cpeConsumer = new Consumer() { + @Override + public void accept(IClasspathEntry classpathEntry) { + if (classpathEntry.getPath().toOSString().toLowerCase().endsWith(".jar")) { + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + + if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { + IPath cpPath = classpathEntry.getPath(); + IResource res = root.findMember(cpPath); + // If res is null, the path is absolute (it's an external jar) + String path; + if (res == null) { + path = cpPath.toOSString(); + } else { + path = "${workspace_loc:" + res.getFullPath().toOSString() + "}"; + } + paths.add(DirectoryPath.parse(path, project)); + } + } + } + }; + + + IJavaProject javaProject = JavaCore.create(project); + for (IClasspathEntry classpathEntry : javaProject.getRawClasspath()) { + if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { + final IClasspathContainer container = JavaCore.getClasspathContainer(classpathEntry.getPath(), javaProject); + if(container.getKind() != IClasspathContainer.K_SYSTEM && container.getKind() != IClasspathContainer.K_DEFAULT_SYSTEM) { + for (IClasspathEntry containedClasspathEntry : container.getClasspathEntries()) { + cpeConsumer.accept(containedClasspathEntry); + } + } + } else if (classpathEntry.getContentKind() == IPackageFragmentRoot.K_BINARY) { + cpeConsumer.accept(classpathEntry); + } + } } catch(JavaModelException e) { // ignored }