mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
revert "IDEA-89266 fix storing of default html doctype"
This commit is contained in:
@@ -106,7 +106,6 @@
|
||||
|
||||
<applicationService serviceInterface="com.intellij.javaee.ExternalResourceManager"
|
||||
serviceImplementation="com.intellij.javaee.ExternalResourceManagerImpl"/>
|
||||
<project.converterProvider implementation="com.intellij.javaee.DefaultHtmlDoctypeConverter"/>
|
||||
|
||||
<standardResourceProvider implementation="com.intellij.javaee.InternalResourceProvider"/>
|
||||
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
package com.intellij.javaee;
|
||||
|
||||
import com.intellij.conversion.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author Eugene.Kudelevsky
|
||||
*/
|
||||
public class DefaultHtmlDoctypeConverter extends ConverterProvider {
|
||||
protected DefaultHtmlDoctypeConverter() {
|
||||
super("default-html-language-level");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getConversionDescription() {
|
||||
return "Default HTML language level setting will be updated";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectConverter createConverter(@NotNull ConversionContext context) {
|
||||
return new MyConverter(context);
|
||||
}
|
||||
|
||||
private static class MyConverter extends ProjectConverter {
|
||||
private final ConversionContext myContext;
|
||||
|
||||
private MyConverter(@NotNull ConversionContext context) {
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConversionNeeded() {
|
||||
return getElementToUpdate() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preProcessingFinished() throws CannotConvertException {
|
||||
final Element defaultHtmlDoctype = getElementToUpdate();
|
||||
|
||||
if (defaultHtmlDoctype != null) {
|
||||
defaultHtmlDoctype.setText(ExternalResourceManagerImpl.HTML5_DOCTYPE_ELEMENT);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Element getElementToUpdate() {
|
||||
final ComponentManagerSettings settings = myContext.getProjectRootManagerSettings();
|
||||
if (settings == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Element root = settings.getComponentElement("ProjectResources");
|
||||
if (root == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Element defaultHtmlDoctype = root.getChild("default-html-language-level");
|
||||
if (defaultHtmlDoctype == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String value = defaultHtmlDoctype.getTextTrim();
|
||||
value = value != null ? myContext.expandPath(value) : null;
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!FileUtil.toSystemIndependentName(value).endsWith("idea.jar!/resources/html5-schema/html5.rnc")) {
|
||||
return null;
|
||||
}
|
||||
return defaultHtmlDoctype;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<File> getAdditionalAffectedFiles() {
|
||||
final ComponentManagerSettings settings = myContext.getProjectRootManagerSettings();
|
||||
final File file = settings != null ? settings.getFile() : null;
|
||||
return file != null
|
||||
? Collections.singletonList(file)
|
||||
: Collections.<File>emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,12 +101,10 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple
|
||||
@NonNls private static final String URL_ATTR = "url";
|
||||
@NonNls private static final String LOCATION_ATTR = "location";
|
||||
@NonNls private static final String IGNORED_RESOURCE_ELEMENT = "ignored-resource";
|
||||
@NonNls private static final String HTML_DEFAULT_DOCTYPE_ELEMENT = "default-html-language-level";
|
||||
@NonNls private static final String HTML_DEFAULT_DOCTYPE_ELEMENT = "default-html-doctype";
|
||||
private static final String DEFAULT_VERSION = null;
|
||||
@NonNls public static final String STANDARD_SCHEMAS = "/standardSchemas/";
|
||||
|
||||
public static String HTML5_DOCTYPE_ELEMENT = "HTML5";
|
||||
|
||||
public ExternalResourceManagerImpl(PathMacrosImpl pathMacros) {
|
||||
myPathMacros = pathMacros;
|
||||
}
|
||||
@@ -363,14 +361,7 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple
|
||||
|
||||
Element child = element.getChild(HTML_DEFAULT_DOCTYPE_ELEMENT);
|
||||
if (child != null) {
|
||||
final String text = child.getText();
|
||||
|
||||
if (HTML5_DOCTYPE_ELEMENT.equals(text)) {
|
||||
myDefaultHtmlDoctype = Html5SchemaProvider.HTML5_SCHEMA_LOCATION;
|
||||
}
|
||||
else {
|
||||
myDefaultHtmlDoctype = text;
|
||||
}
|
||||
myDefaultHtmlDoctype = child.getText();
|
||||
}
|
||||
Element catalogElement = element.getChild(CATALOG_PROPERTIES_ELEMENT);
|
||||
if (catalogElement != null) {
|
||||
@@ -401,14 +392,7 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple
|
||||
|
||||
if (myDefaultHtmlDoctype != null) {
|
||||
final Element e = new Element(HTML_DEFAULT_DOCTYPE_ELEMENT);
|
||||
|
||||
if (Html5SchemaProvider.HTML5_SCHEMA_LOCATION.equals(myDefaultHtmlDoctype)) {
|
||||
// do not store the path to html5 schema in project settings
|
||||
e.setText(HTML5_DOCTYPE_ELEMENT);
|
||||
}
|
||||
else {
|
||||
e.setText(myDefaultHtmlDoctype);
|
||||
}
|
||||
e.setText(myDefaultHtmlDoctype);
|
||||
element.addContent(e);
|
||||
}
|
||||
if (myCatalogPropertiesFile != null) {
|
||||
|
||||
@@ -3,9 +3,8 @@ package com.intellij.xml;
|
||||
import com.intellij.javaee.ExternalResourceManagerImpl;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.util.io.URLUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.URL;
|
||||
@@ -47,12 +46,12 @@ public abstract class Html5SchemaProvider {
|
||||
xhtmlSchemaLocationURL = htmlSchemaLocationURL;
|
||||
}
|
||||
|
||||
HTML5_SCHEMA_LOCATION = VfsUtilCore.urlToPath(VfsUtil.fixURLforIDEA(
|
||||
URLUtil.unescapePercentSequences(htmlSchemaLocationURL.toExternalForm())));
|
||||
HTML5_SCHEMA_LOCATION =
|
||||
VfsUtil.urlToPath(VfsUtil.fixURLforIDEA(FileUtil.unquote(htmlSchemaLocationURL.toExternalForm())));
|
||||
LOG.info("HTML5_SCHEMA_LOCATION = " + HTML5_SCHEMA_LOCATION);
|
||||
|
||||
XHTML5_SCHEMA_LOCATION = VfsUtilCore.urlToPath(VfsUtil.fixURLforIDEA(
|
||||
URLUtil.unescapePercentSequences(xhtmlSchemaLocationURL.toExternalForm())));
|
||||
XHTML5_SCHEMA_LOCATION =
|
||||
VfsUtil.urlToPath(VfsUtil.fixURLforIDEA(FileUtil.unquote(xhtmlSchemaLocationURL.toExternalForm())));
|
||||
LOG.info("XHTML5_SCHEMA_LOCATION = " + XHTML5_SCHEMA_LOCATION);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user