Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNitin Dahyabhai2019-05-29 10:10:53 -0400
committerNitin Dahyabhai2019-05-29 10:10:53 -0400
commit48386877fcc82d991bd15980cce8f1eb1a638bf5 (patch)
tree100afac14ada122c7a57c48880e54fd907fe3a1a
parent4e03166cc66fbb3a97629a127a1f0d9db8435db8 (diff)
downloadwebtools.sourceediting-48386877fcc82d991bd15980cce8f1eb1a638bf5.tar.gz
webtools.sourceediting-48386877fcc82d991bd15980cce8f1eb1a638bf5.tar.xz
webtools.sourceediting-48386877fcc82d991bd15980cce8f1eb1a638bf5.zip
[495132] respect multiple root projects
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/CSSWebResourcesCompletionProposalComputer.java29
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/HrefWebResourcesCompletionProposalComputer.java30
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ImageWebResourcesCompletionProposalComputer.java29
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ScriptWebResourcesCompletionProposalComputer.java29
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/FacetModuleCoreSupport.java4
-rw-r--r--web/tests/org.eclipse.wst.html.ui.tests/src/org/eclipse/wst/html/ui/tests/contentassist/TestHTMLContentAssistComputers.java12
6 files changed, 81 insertions, 52 deletions
diff --git a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/CSSWebResourcesCompletionProposalComputer.java b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/CSSWebResourcesCompletionProposalComputer.java
index 9c9e634f4..789b4b27c 100644
--- a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/CSSWebResourcesCompletionProposalComputer.java
+++ b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/CSSWebResourcesCompletionProposalComputer.java
@@ -20,12 +20,14 @@ import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.wst.css.core.internal.provisional.contenttype.ContentTypeIdForCSS;
import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
+import org.eclipse.wst.html.ui.internal.wizard.FacetModuleCoreSupport;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.w3c.dom.Node;
@@ -36,18 +38,23 @@ public class CSSWebResourcesCompletionProposalComputer extends
@Override
protected IPath[] findMatchingPaths(IResource referenceResource) {
final List<IPath> res = new ArrayList<>();
- try {
- referenceResource.getProject().accept(new IResourceProxyVisitor() {
- @Override
- public boolean visit(IResourceProxy proxy) throws CoreException {
- if (proxy.getType() == IResource.FILE && fileMatcher.matches(proxy.getName())) {
- res.add(proxy.requestFullPath());
+ IWorkspaceRoot root = referenceResource.getWorkspace().getRoot();
+ IPath[] roots = FacetModuleCoreSupport.getAcceptableRootPaths(referenceResource.getProject());
+ for (int i = 0; i < roots.length; i++) {
+ try {
+ root.findMember(roots[i]).accept(new IResourceProxyVisitor() {
+ @Override
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ if (proxy.getType() == IResource.FILE && fileMatcher.matches(proxy.getName())) {
+ res.add(proxy.requestFullPath());
+ }
+ return !proxy.isDerived();
}
- return !proxy.isDerived();
- }
- }, IResource.NONE);
- } catch (CoreException ex) {
- HTMLUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, HTMLUIPlugin.ID, ex.getMessage(), ex));
+ }, IResource.NONE);
+ }
+ catch (CoreException ex) {
+ HTMLUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, HTMLUIPlugin.ID, ex.getMessage(), ex));
+ }
}
return res.toArray(new IPath[res.size()]);
}
diff --git a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/HrefWebResourcesCompletionProposalComputer.java b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/HrefWebResourcesCompletionProposalComputer.java
index 1e6ffc9bd..3a21e1686 100644
--- a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/HrefWebResourcesCompletionProposalComputer.java
+++ b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/HrefWebResourcesCompletionProposalComputer.java
@@ -21,12 +21,14 @@ import java.util.Locale;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
+import org.eclipse.wst.html.ui.internal.wizard.FacetModuleCoreSupport;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.w3c.dom.Node;
@@ -37,19 +39,23 @@ public class HrefWebResourcesCompletionProposalComputer extends AbstractWebResou
@Override
protected IPath[] findMatchingPaths(IResource referenceResource) {
final List<IPath> res = new ArrayList<>();
- try {
- referenceResource.getProject().accept(new IResourceProxyVisitor() {
- @Override
- public boolean visit(IResourceProxy proxy) throws CoreException {
- if (proxy.getType() == IResource.FILE && (proxy.getName().endsWith(".txt") || fileMatcher.matches(proxy.getName()))) {
- res.add(proxy.requestFullPath());
+ IWorkspaceRoot root = referenceResource.getWorkspace().getRoot();
+ IPath[] roots = FacetModuleCoreSupport.getAcceptableRootPaths(referenceResource.getProject());
+ for (int i = 0; i < roots.length; i++) {
+ try {
+ root.findMember(roots[i]).accept(new IResourceProxyVisitor() {
+ @Override
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ if (proxy.getType() == IResource.FILE && (proxy.getName().toLowerCase().endsWith(".txt") || fileMatcher.matches(proxy.getName()))) {
+ res.add(proxy.requestFullPath());
+ }
+ return !proxy.isDerived();
}
- return !proxy.isDerived();
- }
- }, IResource.NONE);
- }
- catch (CoreException ex) {
- HTMLUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, HTMLUIPlugin.ID, ex.getMessage(), ex));
+ }, IResource.NONE);
+ }
+ catch (CoreException ex) {
+ HTMLUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, HTMLUIPlugin.ID, ex.getMessage(), ex));
+ }
}
return res.toArray(new IPath[res.size()]);
}
diff --git a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ImageWebResourcesCompletionProposalComputer.java b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ImageWebResourcesCompletionProposalComputer.java
index 238656962..ec85b6cb9 100644
--- a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ImageWebResourcesCompletionProposalComputer.java
+++ b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ImageWebResourcesCompletionProposalComputer.java
@@ -21,6 +21,7 @@ import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
@@ -31,6 +32,7 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
+import org.eclipse.wst.html.ui.internal.wizard.FacetModuleCoreSupport;
import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.w3c.dom.Node;
@@ -68,18 +70,23 @@ public class ImageWebResourcesCompletionProposalComputer extends
@Override
protected IPath[] findMatchingPaths(IResource referenceResource) {
final List<IPath> res = new ArrayList<>();
- try {
- referenceResource.getProject().accept(new IResourceProxyVisitor() {
- @Override
- public boolean visit(IResourceProxy proxy) throws CoreException {
- if (proxy.getType() == IResource.FILE && fileMatcher.matches(proxy.getName())) {
- res.add(proxy.requestFullPath());
+ IWorkspaceRoot root = referenceResource.getWorkspace().getRoot();
+ IPath[] roots = FacetModuleCoreSupport.getAcceptableRootPaths(referenceResource.getProject());
+ for (int i = 0; i < roots.length; i++) {
+ try {
+ root.findMember(roots[i]).accept(new IResourceProxyVisitor() {
+ @Override
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ if (proxy.getType() == IResource.FILE && fileMatcher.matches(proxy.getName())) {
+ res.add(proxy.requestFullPath());
+ }
+ return !proxy.isDerived();
}
- return !proxy.isDerived();
- }
- }, IResource.NONE);
- } catch (CoreException ex) {
- HTMLUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, HTMLUIPlugin.ID, ex.getMessage(), ex));
+ }, IResource.NONE);
+ }
+ catch (CoreException ex) {
+ HTMLUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, HTMLUIPlugin.ID, ex.getMessage(), ex));
+ }
}
return res.toArray(new IPath[res.size()]);
}
diff --git a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ScriptWebResourcesCompletionProposalComputer.java b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ScriptWebResourcesCompletionProposalComputer.java
index 6f45a3fa2..3b7173f91 100644
--- a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ScriptWebResourcesCompletionProposalComputer.java
+++ b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ScriptWebResourcesCompletionProposalComputer.java
@@ -20,11 +20,13 @@ import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
+import org.eclipse.wst.html.ui.internal.wizard.FacetModuleCoreSupport;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.w3c.dom.Node;
@@ -36,18 +38,23 @@ public class ScriptWebResourcesCompletionProposalComputer extends
@Override
protected IPath[] findMatchingPaths(IResource referenceResource) {
final List<IPath> res = new ArrayList<>();
- try {
- referenceResource.getProject().accept(new IResourceProxyVisitor() {
- @Override
- public boolean visit(IResourceProxy proxy) throws CoreException {
- if (proxy.getType() == IResource.FILE && fileMatcher.matches(proxy.getName())) {
- res.add(proxy.requestFullPath());
+ IWorkspaceRoot root = referenceResource.getWorkspace().getRoot();
+ IPath[] roots = FacetModuleCoreSupport.getAcceptableRootPaths(referenceResource.getProject());
+ for (int i = 0; i < roots.length; i++) {
+ try {
+ root.findMember(roots[i]).accept(new IResourceProxyVisitor() {
+ @Override
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ if (proxy.getType() == IResource.FILE && fileMatcher.matches(proxy.getName())) {
+ res.add(proxy.requestFullPath());
+ }
+ return !proxy.isDerived();
}
- return !proxy.isDerived();
- }
- }, IResource.NONE);
- } catch (CoreException ex) {
- HTMLUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, HTMLUIPlugin.ID, ex.getMessage(), ex));
+ }, IResource.NONE);
+ }
+ catch (CoreException ex) {
+ HTMLUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, HTMLUIPlugin.ID, ex.getMessage(), ex));
+ }
}
return res.toArray(new IPath[res.size()]);
}
diff --git a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/FacetModuleCoreSupport.java b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/FacetModuleCoreSupport.java
index cd0681f8f..9c9cda708 100644
--- a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/FacetModuleCoreSupport.java
+++ b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/FacetModuleCoreSupport.java
@@ -24,8 +24,10 @@ import org.eclipse.core.runtime.Path;
* Because ModuleCore API calls can result in locks needing to be acquired,
* none of these methods should be called while other thread locks have
* already been acquired.
+ *
+ * <b>For internal use only.</b>
*/
-final class FacetModuleCoreSupport {
+public final class FacetModuleCoreSupport {
static final boolean _dump_NCDFE = false;
static final String META_INF_RESOURCES = "META-INF/resources/"; //$NON-NLS-1$
static final IPath META_INF_RESOURCES_PATH = new Path(META_INF_RESOURCES);
diff --git a/web/tests/org.eclipse.wst.html.ui.tests/src/org/eclipse/wst/html/ui/tests/contentassist/TestHTMLContentAssistComputers.java b/web/tests/org.eclipse.wst.html.ui.tests/src/org/eclipse/wst/html/ui/tests/contentassist/TestHTMLContentAssistComputers.java
index f382e4ab1..4f0125e33 100644
--- a/web/tests/org.eclipse.wst.html.ui.tests/src/org/eclipse/wst/html/ui/tests/contentassist/TestHTMLContentAssistComputers.java
+++ b/web/tests/org.eclipse.wst.html.ui.tests/src/org/eclipse/wst/html/ui/tests/contentassist/TestHTMLContentAssistComputers.java
@@ -190,12 +190,12 @@ public class TestHTMLContentAssistComputers extends TestCase {
strings[i] = paths[i].toString();
}
assertTrue(String.valueOf(paths.length).concat(StringUtils.pack(strings)), paths.length >= 6);
- assertTrue(Arrays.asList(paths).stream().map((p)->p.toString()).anyMatch((s)->s.endsWith("/alsoempty.css")));
- assertTrue(Arrays.asList(paths).stream().map((p)->p.toString()).anyMatch((s)->s.endsWith("/alsoempty.js")));
- assertTrue(Arrays.asList(paths).stream().map((p)->p.toString()).anyMatch((s)->s.endsWith("/alsoempty.txt")));
- assertTrue(Arrays.asList(paths).stream().map((p)->p.toString()).anyMatch((s)->s.endsWith("/empty.css")));
- assertTrue(Arrays.asList(paths).stream().map((p)->p.toString()).anyMatch((s)->s.endsWith("/empty.js")));
- assertTrue(Arrays.asList(paths).stream().map((p)->p.toString()).anyMatch((s)->s.endsWith("/empty.txt")));
+ assertTrue(StringUtils.pack(strings), Arrays.asList(paths).stream().map((p)->p.toString()).anyMatch((s)->s.endsWith("/alsoempty.css")));
+ assertTrue(StringUtils.pack(strings), Arrays.asList(paths).stream().map((p)->p.toString()).anyMatch((s)->s.endsWith("/alsoempty.js")));
+ assertTrue(StringUtils.pack(strings), Arrays.asList(paths).stream().map((p)->p.toString()).anyMatch((s)->s.endsWith("/alsoempty.txt")));
+ assertTrue(StringUtils.pack(strings), Arrays.asList(paths).stream().map((p)->p.toString()).anyMatch((s)->s.endsWith("/empty.css")));
+ assertTrue(StringUtils.pack(strings), Arrays.asList(paths).stream().map((p)->p.toString()).anyMatch((s)->s.endsWith("/empty.js")));
+ assertTrue(StringUtils.pack(strings), Arrays.asList(paths).stream().map((p)->p.toString()).anyMatch((s)->s.endsWith("/empty.txt")));
}
public void testResourceProposalsForImgSrc() throws Exception {

Back to the top