Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNitin Dahyabhai2019-05-30 12:51:47 -0400
committerNitin Dahyabhai2019-05-30 12:52:05 -0400
commit12232675002034e762f9182b4e5f6852b344004a (patch)
tree9fabb361c1a783a336c5a4a66d0121768b7f889b
parent8304fd9e33c99e19fde79a33ed9833ccfbdee000 (diff)
downloadwebtools.sourceediting-12232675002034e762f9182b4e5f6852b344004a.tar.gz
webtools.sourceediting-12232675002034e762f9182b4e5f6852b344004a.tar.xz
webtools.sourceediting-12232675002034e762f9182b4e5f6852b344004a.zip
[495132] Tweaks and last minute fixes to resource path proposals.R3_14
Offer proposals when editing a file outside of the deployable roots, have proposals replace to textLength instead of full length, and show absolute path of proposed resources as the additional info for non-images.
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/AbstractWebResourcesCompletionProposalComputer.java55
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/CSSWebResourcesCompletionProposalComputer.java36
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ContentTypeSpecs.java35
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/HrefWebResourcesCompletionProposalComputer.java38
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ImageWebResourcesCompletionProposalComputer.java40
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ScriptWebResourcesCompletionProposalComputer.java38
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/FacetModuleCoreSupportDelegate.java8
-rw-r--r--web/tests/org.eclipse.wst.html.ui.tests/src/org/eclipse/wst/html/ui/tests/contentassist/TestHTMLContentAssistComputers.java25
8 files changed, 112 insertions, 163 deletions
diff --git a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/AbstractWebResourcesCompletionProposalComputer.java b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/AbstractWebResourcesCompletionProposalComputer.java
index bc2ec328e..72190dfa3 100644
--- a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/AbstractWebResourcesCompletionProposalComputer.java
+++ b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/AbstractWebResourcesCompletionProposalComputer.java
@@ -14,20 +14,30 @@
*/
package org.eclipse.wst.html.ui.internal.contentassist.resources;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IFile;
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.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.html.core.internal.validate.ModuleCoreSupport;
+import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
import org.eclipse.wst.html.ui.internal.Logger;
+import org.eclipse.wst.html.ui.internal.wizard.FacetModuleCoreSupport;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
import org.eclipse.wst.sse.core.utils.StringUtils;
import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext;
@@ -97,15 +107,54 @@ public abstract class AbstractWebResourcesCompletionProposalComputer extends Def
if (image != null) {
this.images.add(image);
}
- final int replacementLength = request.getRegion().getLength();
+ final int replacementLength = request.getRegion().getTextLength();
final int replacementOffset = request.getStartOffset();
- return new CustomCompletionProposal(replacementString, replacementOffset, replacementLength, cursorPosition, image, relativeProposal, null, null, 0);
+ return new CustomCompletionProposal(replacementString, replacementOffset, replacementLength, cursorPosition, image, relativeProposal, null, proposalPath.toString(), 0);
+ }
+
+ protected IPath[] findMatchingPaths(IResource referenceResource) {
+ ContentTypeSpecs fileMatcher = createFilenameMatcher();
+ final List<IPath> res = new ArrayList<>();
+ IWorkspaceRoot root = referenceResource.getWorkspace().getRoot();
+ IPath referencePath = referenceResource.getFullPath();
+ IPath[] roots = FacetModuleCoreSupport.getAcceptableRootPaths(referenceResource.getProject());
+ /*
+ * If editing a file not within one of the roots, offer everything
+ * project-wide. The deployment information is either wrong or the
+ * user is intentionally editing something that won't be deployed, and
+ * they know better than us.
+ */
+ boolean referencePathWithinValidRoot = false;
+ for (int i = 0; i < roots.length; i++) {
+ referencePathWithinValidRoot |= roots[i].isPrefixOf(referencePath);
+ }
+ if (!referencePathWithinValidRoot) {
+ roots = new IPath[]{referenceResource.getProject().getFullPath()};
+ }
+ 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();
+ }
+ }, 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()]);
}
- abstract protected IPath[] findMatchingPaths(IResource referenceResource);
abstract boolean matchRequest(ContentAssistRequest contentAssistRequest);
+ abstract ContentTypeSpecs createFilenameMatcher();
+
@Override
public void sessionEnded() {
if (this.completionComputerJob != null) {
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 789b4b27c..bde000f0b 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
@@ -14,20 +14,7 @@
*/
package org.eclipse.wst.html.ui.internal.contentassist.resources;
-import java.util.ArrayList;
-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,27 +23,8 @@ public class CSSWebResourcesCompletionProposalComputer extends
ContentTypeSpecs fileMatcher = ContentTypeSpecs.createFor(ContentTypeIdForCSS.ContentTypeID_CSS);
@Override
- protected IPath[] findMatchingPaths(IResource referenceResource) {
- final List<IPath> res = new ArrayList<>();
- 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();
- }
- }, 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()]);
+ ContentTypeSpecs createFilenameMatcher() {
+ return fileMatcher;
}
@Override
diff --git a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ContentTypeSpecs.java b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ContentTypeSpecs.java
index 9c3647277..1b8d0f575 100644
--- a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ContentTypeSpecs.java
+++ b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ContentTypeSpecs.java
@@ -13,8 +13,10 @@
*******************************************************************************/
package org.eclipse.wst.html.ui.internal.contentassist.resources;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.Platform;
@@ -57,12 +59,12 @@ public class ContentTypeSpecs {
}
String[] fFilenames = new String[0];
- String[] fFilenameExtensions = new String[0];
+ String[] fExtensions = new String[0];
private ContentTypeSpecs(String[] fileNames, String[] extensions) {
super();
fFilenames = fileNames;
- fFilenameExtensions = extensions;
+ fExtensions = extensions;
Arrays.sort(fileNames);
}
@@ -70,13 +72,34 @@ public class ContentTypeSpecs {
if (Arrays.binarySearch(fFilenames, filename) >= 0) {
return true;
}
- for (int i = 0; i < fFilenameExtensions.length; i++) {
- if (filename.length() > fFilenameExtensions[i].length() + 1
- && filename.charAt(filename.length() - fFilenameExtensions[i].length() - 1) == '.'
- && filename.endsWith(fFilenameExtensions[i])) {
+ for (int i = 0; i < fExtensions.length; i++) {
+ if (filename.length() > fExtensions[i].length() + 1
+ && filename.charAt(filename.length() - fExtensions[i].length() - 1) == '.'
+ && filename.endsWith(fExtensions[i])) {
return true;
}
}
return false;
}
+
+ public void addFilename(String filename) {
+ List<String> combinedList = new ArrayList<String>(fFilenames.length + 1);
+ for (int i = 0; i < fFilenames.length; i++) {
+ combinedList.add(fFilenames[i]);
+ }
+ combinedList.add(filename);
+ String[] combinedArray = combinedList.toArray(new String[combinedList.size()]);
+ Arrays.sort(combinedArray);
+ fFilenames = combinedArray;
+ }
+
+ public void addFilenameExtension(String extension) {
+ List<String> combinedList = new ArrayList<String>(fExtensions.length + 1);
+ for (int i = 0; i < fExtensions.length; i++) {
+ combinedList.add(fExtensions[i]);
+ }
+ combinedList.add(extension);
+ String[] combinedArray = combinedList.toArray(new String[combinedList.size()]);
+ fExtensions = combinedArray;
+ }
}
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 3a21e1686..2390bc7df 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
@@ -14,50 +14,22 @@
*/
package org.eclipse.wst.html.ui.internal.contentassist.resources;
-import java.util.ArrayList;
-import java.util.List;
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;
public class HrefWebResourcesCompletionProposalComputer extends AbstractWebResourcesCompletionProposalComputer {
ContentTypeSpecs fileMatcher = ContentTypeSpecs.createFor(IContentTypeManager.CT_TEXT);
+ {
+ fileMatcher.addFilenameExtension("txt");
+ }
@Override
- protected IPath[] findMatchingPaths(IResource referenceResource) {
- final List<IPath> res = new ArrayList<>();
- 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();
- }
- }, 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()]);
+ ContentTypeSpecs createFilenameMatcher() {
+ return fileMatcher;
}
@Override
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 ec85b6cb9..400ee5c75 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
@@ -15,24 +15,13 @@
package org.eclipse.wst.html.ui.internal.contentassist.resources;
import java.net.URL;
-import java.util.ArrayList;
-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.jface.text.contentassist.ICompletionProposal;
import org.eclipse.osgi.util.NLS;
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;
@@ -50,12 +39,12 @@ public class ImageWebResourcesCompletionProposalComputer extends
if (image != null) {
super.images.add(image);
}
- final int replacementLength = request.getRegion().getLength();
+ final int replacementLength = request.getRegion().getTextLength();
final int replacementOffset = request.getStartOffset();
URL previewURL = null;
String previewErrorInfo = null;
try {
- previewURL = new URL("platform://resource/" + proposalPath);
+ previewURL = new URL("platform://resource" + proposalPath);
} catch (Exception ex) {
previewErrorInfo = NLS.bind(HTMLUIMessages.cannotGenerateImagePreview, ex.getMessage());
}
@@ -66,29 +55,10 @@ public class ImageWebResourcesCompletionProposalComputer extends
return new CustomCompletionProposal(replacementString, replacementOffset, replacementLength, cursorPosition, image, relativeProposal, null, previewErrorInfo, 0);
}
}
-
+
@Override
- protected IPath[] findMatchingPaths(IResource referenceResource) {
- final List<IPath> res = new ArrayList<>();
- 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();
- }
- }, 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()]);
+ ContentTypeSpecs createFilenameMatcher() {
+ return fileMatcher;
}
@Override
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 3b7173f91..fdf7d8bb5 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
@@ -14,19 +14,6 @@
*/
package org.eclipse.wst.html.ui.internal.contentassist.resources;
-import java.util.ArrayList;
-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;
@@ -34,29 +21,10 @@ public class ScriptWebResourcesCompletionProposalComputer extends
AbstractWebResourcesCompletionProposalComputer {
ContentTypeSpecs fileMatcher = ContentTypeSpecs.createFor("org.eclipse.wst.jsdt.core.jsSource");
-
+
@Override
- protected IPath[] findMatchingPaths(IResource referenceResource) {
- final List<IPath> res = new ArrayList<>();
- 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();
- }
- }, 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()]);
+ ContentTypeSpecs createFilenameMatcher() {
+ return fileMatcher;
}
@Override
diff --git a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/FacetModuleCoreSupportDelegate.java b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/FacetModuleCoreSupportDelegate.java
index 436377a1f..0c1f2ca93 100644
--- a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/FacetModuleCoreSupportDelegate.java
+++ b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/FacetModuleCoreSupportDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2016 IBM Corporation and others.
+ * Copyright (c) 2007, 2019 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -104,7 +104,7 @@ final class FacetModuleCoreSupportDelegate {
return new IPath[]{project.getFullPath()};
}
- List paths = new ArrayList();
+ List<IPath> paths = new ArrayList<>();
IVirtualFolder componentFolder = ComponentCore.createFolder(project, Path.ROOT);
if (componentFolder != null && componentFolder.exists()) {
IContainer[] workspaceFolders = componentFolder.getUnderlyingFolders();
@@ -143,10 +143,10 @@ final class FacetModuleCoreSupportDelegate {
}
}
- else {
+ if (paths.isEmpty()) {
paths.add(project.getFullPath());
}
- return (IPath[]) paths.toArray(new IPath[paths.size()]);
+ return paths.toArray(new IPath[paths.size()]);
}
static IPath getDefaultRoot(IProject project) {
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 4f0125e33..e0beb1b5e 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
@@ -35,6 +35,7 @@ import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.wst.html.core.text.IHTMLPartitions;
import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML;
+import org.eclipse.wst.html.ui.internal.contentassist.resources.AbstractWebResourcesCompletionProposalComputer;
import org.eclipse.wst.html.ui.internal.contentassist.resources.CSSWebResourcesCompletionProposalComputer;
import org.eclipse.wst.html.ui.internal.contentassist.resources.HrefWebResourcesCompletionProposalComputer;
import org.eclipse.wst.html.ui.internal.contentassist.resources.ImageWebResourcesCompletionProposalComputer;
@@ -45,7 +46,6 @@ import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import junit.extensions.TestSetup;
-import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -61,13 +61,13 @@ public class TestHTMLContentAssistComputers extends TestCase {
private static final String PROJECT_FILES = "/testresources/contentassist";
/** The project that all of the tests use */
- private static IProject fProject;
+ static IProject fProject;
/**
* Used to keep track of the already open editors so that the tests don't go through
* the trouble of opening the same editors over and over again
*/
- private static Map<IFile, StructuredTextEditor> fFileToEditorMap = new HashMap<>();
+ static Map<IFile, StructuredTextEditor> fFileToEditorMap = new HashMap<>();
/**
* <p>Default constructor<p>
@@ -180,7 +180,7 @@ public class TestHTMLContentAssistComputers extends TestCase {
public void testResourceProposalsForAHref() throws Exception {
IFile referencePoint = fProject.getFile("testResources.html");
HrefWebResourcesCompletionProposalComputer proposalComputer = new HrefWebResourcesCompletionProposalComputer();
- Method findMatchingPaths = HrefWebResourcesCompletionProposalComputer.class.getDeclaredMethod("findMatchingPaths", IResource.class);
+ Method findMatchingPaths = AbstractWebResourcesCompletionProposalComputer.class.getDeclaredMethod("findMatchingPaths", IResource.class);
assertNotNull("findMatchingPaths", findMatchingPaths);
findMatchingPaths.setAccessible(true);
IPath[] paths = (IPath[]) findMatchingPaths.invoke(proposalComputer, referencePoint);
@@ -201,7 +201,7 @@ public class TestHTMLContentAssistComputers extends TestCase {
public void testResourceProposalsForImgSrc() throws Exception {
IFile referencePoint = fProject.getFile("testResources.html");
ImageWebResourcesCompletionProposalComputer proposalComputer = new ImageWebResourcesCompletionProposalComputer();
- Method findMatchingPaths = ImageWebResourcesCompletionProposalComputer.class.getDeclaredMethod("findMatchingPaths", IResource.class);
+ Method findMatchingPaths = AbstractWebResourcesCompletionProposalComputer.class.getDeclaredMethod("findMatchingPaths", IResource.class);
assertNotNull("findMatchingPaths", findMatchingPaths);
findMatchingPaths.setAccessible(true);
IPath[] paths = (IPath[]) findMatchingPaths.invoke(proposalComputer, referencePoint);
@@ -219,7 +219,7 @@ public class TestHTMLContentAssistComputers extends TestCase {
public void testResourceProposalsForLinkHref() throws Exception {
IFile referencePoint = fProject.getFile("testResources.html");
CSSWebResourcesCompletionProposalComputer proposalComputer = new CSSWebResourcesCompletionProposalComputer();
- Method findMatchingPaths = CSSWebResourcesCompletionProposalComputer.class.getDeclaredMethod("findMatchingPaths", IResource.class);
+ Method findMatchingPaths = AbstractWebResourcesCompletionProposalComputer.class.getDeclaredMethod("findMatchingPaths", IResource.class);
assertNotNull("findMatchingPaths", findMatchingPaths);
findMatchingPaths.setAccessible(true);
IPath[] paths = (IPath[]) findMatchingPaths.invoke(proposalComputer, referencePoint);
@@ -236,7 +236,7 @@ public class TestHTMLContentAssistComputers extends TestCase {
public void testResourceProposalsForScriptSrc() throws Exception {
IFile referencePoint = fProject.getFile("testResources.html");
ScriptWebResourcesCompletionProposalComputer proposalComputer = new ScriptWebResourcesCompletionProposalComputer();
- Method findMatchingPaths = ScriptWebResourcesCompletionProposalComputer.class.getDeclaredMethod("findMatchingPaths", IResource.class);
+ Method findMatchingPaths = AbstractWebResourcesCompletionProposalComputer.class.getDeclaredMethod("findMatchingPaths", IResource.class);
assertNotNull("findMatchingPaths", findMatchingPaths);
findMatchingPaths.setAccessible(true);
IPath[] paths = (IPath[]) findMatchingPaths.invoke(proposalComputer, referencePoint);
@@ -313,10 +313,9 @@ public class TestHTMLContentAssistComputers extends TestCase {
}
//fire content assist session ending
- Method privateFireSessionEndEventMethod = ContentAssistant.class.
- getDeclaredMethod("fireSessionEndEvent", null);
+ Method privateFireSessionEndEventMethod = ContentAssistant.class.getDeclaredMethod("fireSessionEndEvent", new Class[0]);
privateFireSessionEndEventMethod.setAccessible(true);
- privateFireSessionEndEventMethod.invoke(contentAssistant, null);
+ privateFireSessionEndEventMethod.invoke(contentAssistant, new Object[0]);
return pages;
}
@@ -339,7 +338,7 @@ public class TestHTMLContentAssistComputers extends TestCase {
//if errors report them
if(error.length() > 0) {
- Assert.fail(error.toString());
+ fail(error.toString());
}
}
@@ -461,9 +460,9 @@ public class TestHTMLContentAssistComputers extends TestCase {
*/
public void tearDown() throws Exception {
//close out the editors
- Iterator iter = fFileToEditorMap.values().iterator();
+ Iterator<StructuredTextEditor> iter = fFileToEditorMap.values().iterator();
while(iter.hasNext()) {
- StructuredTextEditor editor = (StructuredTextEditor)iter.next();
+ StructuredTextEditor editor = iter.next();
editor.doSave(null);
editor.close(false);
}

Back to the top