Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNitin Dahyabhai2020-05-02 03:46:54 +0000
committerNitin Dahyabhai2020-05-02 03:46:54 +0000
commit041325716197a16321f4031164bce13ecedce7a8 (patch)
tree24cb61762ac0cc43fb45ab6755ca559e4e85d2cd
parent04b55496af6dff15c0f3d0994d38cfef7bb3e434 (diff)
downloadwebtools.sourceediting-041325716197a16321f4031164bce13ecedce7a8.tar.gz
webtools.sourceediting-041325716197a16321f4031164bce13ecedce7a8.tar.xz
webtools.sourceediting-041325716197a16321f4031164bce13ecedce7a8.zip
[562631] Remove an indirect reference to JSDT, update script template
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/StructuredTextViewerConfigurationHTML.java4
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ContentTypeSpecs.java41
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/resources/ScriptWebResourcesCompletionProposalComputer.java26
-rw-r--r--web/bundles/org.eclipse.wst.html.ui/templates/htmldefault-templates.properties6
4 files changed, 50 insertions, 27 deletions
diff --git a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/StructuredTextViewerConfigurationHTML.java b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/StructuredTextViewerConfigurationHTML.java
index 0f0b207e1a..5f4d456fd0 100644
--- a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/StructuredTextViewerConfigurationHTML.java
+++ b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/StructuredTextViewerConfigurationHTML.java
@@ -39,6 +39,7 @@ import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeIdF
import org.eclipse.wst.html.core.internal.text.StructuredTextPartitionerForHTML;
import org.eclipse.wst.html.core.text.IHTMLPartitions;
import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
+import org.eclipse.wst.html.ui.internal.Logger;
import org.eclipse.wst.html.ui.internal.autoedit.AutoEditStrategyForTabs;
import org.eclipse.wst.html.ui.internal.contentassist.HTMLStructuredContentAssistProcessor;
import org.eclipse.wst.html.ui.internal.preferences.HTMLUIPreferenceNames;
@@ -233,6 +234,9 @@ public class StructuredTextViewerConfigurationHTML extends StructuredTextViewerC
else if (partitionType == ICSSPartitions.STYLE || partitionType == ICSSPartitions.COMMENT) {
providers = new LineStyleProvider[]{getLineStyleProviderForEmbeddedCSS()};
}
+ else {
+ Logger.log(Logger.INFO, "No line style provider for " + partitionType);
+ }
return providers;
}
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 1b8d0f575b..d103cf1d74 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2019 IBM Corporation and others.
+ * Copyright (c) 2004, 2020 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
@@ -28,29 +28,40 @@ import org.eclipse.core.runtime.content.IContentType;
*/
public class ContentTypeSpecs {
public static ContentTypeSpecs createFor(String contentTypeId) {
+ return createFor(new String[]{contentTypeId});
+ }
+
+ public static ContentTypeSpecs createFor(String[] contentTypeIds) {
// long startTime = System.currentTimeMillis();
- IContentType baseContentType = Platform.getContentTypeManager().getContentType(contentTypeId);
- String[] baseExtensions = baseContentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
- Arrays.sort(baseExtensions);
Set<String> filenameExtensions = new HashSet<>();
Set<String> filenames = new HashSet<>();
- IContentType[] contentTypes = Platform.getContentTypeManager().getAllContentTypes();
- for (int i = 0, length = contentTypes.length; i < length; i++) {
- if (contentTypes[i].isKindOf(baseContentType)) {
- String[] fileExtension = contentTypes[i].getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
- for (int j = 0; j < fileExtension.length; j++) {
- filenameExtensions.add(fileExtension[j]);
- }
- String[] names = contentTypes[i].getFileSpecs(IContentType.FILE_NAME_SPEC);
- for (int j = 0; j < names.length; j++) {
- filenames.add(names[j]);
+ Set<String> combinedBaseExtensions = new HashSet<>();
+ for (String contentTypeId: contentTypeIds) {
+ IContentType baseContentType = Platform.getContentTypeManager().getContentType(contentTypeId);
+ String[] baseExtensions = baseContentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
+ for (int i = 0; i < baseExtensions.length; i++) {
+ combinedBaseExtensions.add(baseExtensions[i]);
+ }
+ Arrays.sort(baseExtensions);
+ IContentType[] contentTypes = Platform.getContentTypeManager().getAllContentTypes();
+ for (int i = 0, length = contentTypes.length; i < length; i++) {
+ if (contentTypes[i].isKindOf(baseContentType)) {
+ String[] fileExtension = contentTypes[i].getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
+ for (int j = 0; j < fileExtension.length; j++) {
+ filenameExtensions.add(fileExtension[j]);
+ }
+ String[] names = contentTypes[i].getFileSpecs(IContentType.FILE_NAME_SPEC);
+ for (int j = 0; j < names.length; j++) {
+ filenames.add(names[j]);
+ }
}
}
}
+ String[] baseTypeFilenameExtensions = combinedBaseExtensions.toArray(new String[combinedBaseExtensions.size()]);
// move the extensions of the base type to the start to match quicker
String[] stringExtensions = filenameExtensions.toArray(new String[filenameExtensions.size()]);
for (int i = stringExtensions.length - 1; i > 0; i--) {
- if (Arrays.binarySearch(baseExtensions, stringExtensions[i]) >= 0) {
+ if (Arrays.binarySearch(baseTypeFilenameExtensions, stringExtensions[i]) >= 0) {
stringExtensions[i] = stringExtensions[i - 1];
}
}
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 fdf7d8bb50..3a5822334d 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
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2013, 2019 Angelo ZERR and others
+ * Copyright (c) 2013, 2020 Angelo ZERR 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
@@ -11,17 +11,27 @@
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
* Mickael Istria (Red Hat Inc.) - Extracted, refactored and moved to org.eclipse
* Nitin Dahyabhai (IBM Corporation) - improve performance finding matching resources
- */
+ */
package org.eclipse.wst.html.ui.internal.contentassist.resources;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.w3c.dom.Node;
-public class ScriptWebResourcesCompletionProposalComputer extends
- AbstractWebResourcesCompletionProposalComputer {
+public class ScriptWebResourcesCompletionProposalComputer extends AbstractWebResourcesCompletionProposalComputer {
+
+ ContentTypeSpecs fileMatcher = null;
+
+ public ScriptWebResourcesCompletionProposalComputer() {
+ IContentType[] types = Platform.getContentTypeManager().findContentTypesFor("file.js");
+ String[] typeNames = new String[types.length];
+ for (int i = 0; i < typeNames.length; i++) {
+ typeNames[i] = types[i].getId();
+ }
+ fileMatcher = ContentTypeSpecs.createFor(typeNames);
+ }
- ContentTypeSpecs fileMatcher = ContentTypeSpecs.createFor("org.eclipse.wst.jsdt.core.jsSource");
-
@Override
ContentTypeSpecs createFilenameMatcher() {
return fileMatcher;
@@ -30,9 +40,7 @@ public class ScriptWebResourcesCompletionProposalComputer extends
@Override
boolean matchRequest(ContentAssistRequest contentAssistRequest) {
Node node = contentAssistRequest.getNode();
- return
- "script".equals(node.getLocalName()) &&
- "src".equals(getCurrentAttributeName(contentAssistRequest));
+ return "script".equals(node.getLocalName()) && "src".equals(getCurrentAttributeName(contentAssistRequest));
}
}
diff --git a/web/bundles/org.eclipse.wst.html.ui/templates/htmldefault-templates.properties b/web/bundles/org.eclipse.wst.html.ui/templates/htmldefault-templates.properties
index 334422e1c1..a8fb6b5f01 100644
--- a/web/bundles/org.eclipse.wst.html.ui/templates/htmldefault-templates.properties
+++ b/web/bundles/org.eclipse.wst.html.ui/templates/htmldefault-templates.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2004, 2016 IBM Corporation and others.
+# Copyright (c) 2004, 2020 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
@@ -46,10 +46,10 @@ Templates.xhtmlstrict.desc=xhtml 1.0 strict
Templates.xhtmlstrict.content=<?xml version="1.0" encoding="${encoding}" ?>\n<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml">\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=${encoding}" />\n<title>Insert title here</title>\n</head>\n<body>\n${cursor}\n</body>\n</html>
Templates.script.name=script
Templates.script.desc=script (commented)
-Templates.script.content=<script type=\"${cursor}text/javascript\">\n<!--\n\n//-->\n</script>
+Templates.script.content=<script type=\"text/javascript\">\n${cursor}\n</script>
Templates.style.name=style
Templates.style.desc=style (commented)
-Templates.style.content=<style>\n<!--\n${cursor}\n-->\n</style>
+Templates.style.content=<style>\n${cursor}\n</style>
Templates.css.name=css
Templates.css.desc=link to external style sheet
Templates.css.content=<link rel="stylesheet" type="text/css" href="${cursor}">

Back to the top