diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java index b8e74f01806a..69844cdef078 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java @@ -198,7 +198,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx assert !myDisposed; Application application = ApplicationManager.getApplication(); application.assertIsDispatchThread(); - assert !application.isWriteAccessAllowed(); + assert !application.isWriteAccessAllowed() : "Write access is required"; // pump first so that queued event do not interfere UIUtil.dispatchAllInvocationEvents(); diff --git a/xml/impl/resources/standardSchemas/catalog.xsd b/xml/impl/resources/standardSchemas/catalog.xsd new file mode 100644 index 000000000000..5b932b47f213 --- /dev/null +++ b/xml/impl/resources/standardSchemas/catalog.xsd @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerEx.java b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerEx.java index d327ac4beb7c..00e93a44d273 100644 --- a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerEx.java +++ b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerEx.java @@ -60,7 +60,7 @@ public abstract class ExternalResourceManagerEx extends ExternalResourceManager public abstract void setDefaultHtmlDoctype(@NotNull String defaultHtmlDoctype, @NotNull Project project); public abstract String getCatalogPropertiesFile(); - public abstract void setCatalogPropertiesFile(String filePath); + public abstract void setCatalogPropertiesFile(@Nullable String filePath); public abstract long getModificationCount(@NotNull Project project); } diff --git a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java index e3fe4ba5cf8f..ed3aa301d460 100644 --- a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java +++ b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java @@ -145,7 +145,10 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple if (result == null) { result = getStdResource(url, version); } -// getCatalogManager().getCatalog().resolveURI() + XMLCatalogManager manager = getCatalogManager(); + if (manager != null) { + result = manager.resolve(url); + } if (result == null) { result = url; } @@ -446,6 +449,7 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple public void setCatalogPropertiesFile(String filePath) { myCatalogManager = null; myCatalogPropertiesFile = filePath; + myModificationCount++; } @Nullable diff --git a/xml/impl/src/com/intellij/javaee/InternalResourceProvider.java b/xml/impl/src/com/intellij/javaee/InternalResourceProvider.java index 8706f9f0b8a2..d9755ad98847 100644 --- a/xml/impl/src/com/intellij/javaee/InternalResourceProvider.java +++ b/xml/impl/src/com/intellij/javaee/InternalResourceProvider.java @@ -46,6 +46,8 @@ public class InternalResourceProvider implements StandardResourceProvider{ impl.addInternalResource("http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd","xhtml1-frameset.dtd"); impl.addInternalResource("http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd","xhtml11/xhtml11.dtd"); + impl.addInternalResource("urn:oasis:names:tc:entity:xmlns:xml:catalog", "catalog.xsd"); + // Plugins DTDs // stathik impl.addInternalResource("http://plugins.intellij.net/plugin.dtd", "plugin.dtd"); impl.addInternalResource("http://plugins.intellij.net/plugin-repository.dtd", "plugin-repository.dtd"); diff --git a/xml/impl/src/com/intellij/javaee/XMLCatalogConfigurable.java b/xml/impl/src/com/intellij/javaee/XMLCatalogConfigurable.java index 099fec7f15e2..739d0d3880df 100644 --- a/xml/impl/src/com/intellij/javaee/XMLCatalogConfigurable.java +++ b/xml/impl/src/com/intellij/javaee/XMLCatalogConfigurable.java @@ -20,6 +20,7 @@ import com.intellij.openapi.options.BaseConfigurable; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.ui.TextFieldWithBrowseButton; +import com.intellij.openapi.util.Comparing; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; @@ -70,6 +71,11 @@ public class XMLCatalogConfigurable extends BaseConfigurable implements Searchab myPropertyFile.setText(ExternalResourceManagerEx.getInstanceEx().getCatalogPropertiesFile()); } + @Override + public boolean isModified() { + return !Comparing.equal(ExternalResourceManagerEx.getInstanceEx().getCatalogPropertiesFile(), myPropertyFile.getText()); + } + @Override public void disposeUIResources() { diff --git a/xml/tests/src/com/intellij/xml/XMLCatalogManagerTest.java b/xml/tests/src/com/intellij/xml/XMLCatalogManagerTest.java index 630642fb3620..2905c3081b0c 100644 --- a/xml/tests/src/com/intellij/xml/XMLCatalogManagerTest.java +++ b/xml/tests/src/com/intellij/xml/XMLCatalogManagerTest.java @@ -15,6 +15,8 @@ */ package com.intellij.xml; +import com.intellij.codeInsight.daemon.impl.HighlightInfo; +import com.intellij.javaee.ExternalResourceManagerEx; import com.intellij.javaee.XMLCatalogManager; import com.intellij.testFramework.IdeaTestCase; import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; @@ -23,6 +25,7 @@ import org.apache.xml.resolver.CatalogManager; import java.io.File; import java.io.IOException; import java.net.URI; +import java.util.List; import java.util.Vector; /** @@ -54,10 +57,33 @@ public class XMLCatalogManagerTest extends LightPlatformCodeInsightFixtureTestCa assertTrue(resolve, resolve.endsWith("/catalog/xhtml1-strict.dtd")); } + public void testHighlighting() { + myFixture.configureByFile("policy.xml"); + List infos = myFixture.doHighlighting(); + assertEquals("urn:oasis:names:tc:xacml:1.0:policy", infos.get(0).text); + } + + public void testFixedHighlighting() throws Exception { + myFixture.configureByFile("policy.xml"); + try { + ExternalResourceManagerEx.getInstanceEx().setCatalogPropertiesFile(getTestDataPath() + "catalog.properties"); + List infos = myFixture.doHighlighting(); + assertEquals(infos.toString(), 0, infos.size()); + } + finally { + ExternalResourceManagerEx.getInstanceEx().setCatalogPropertiesFile(null); + } + } + private XMLCatalogManager getManager() throws IOException { return new XMLCatalogManager(getTestDataPath() + "catalog.properties"); } + @Override + protected boolean isWriteActionRequired() { + return false; + } + @Override protected String getBasePath() { return "/xml/tests/testData/catalog/"; diff --git a/xml/tests/testData/catalog/catalog.xml b/xml/tests/testData/catalog/catalog.xml index 2618424db905..1e97c2c0decd 100644 --- a/xml/tests/testData/catalog/catalog.xml +++ b/xml/tests/testData/catalog/catalog.xml @@ -6,4 +6,6 @@ uri="xhtml1-strict.dtd"/> + \ No newline at end of file diff --git a/xml/tests/testData/catalog/catalog/cs-xacml-schema-policy-01.xsd b/xml/tests/testData/catalog/catalog/cs-xacml-schema-policy-01.xsd new file mode 100644 index 000000000000..3ce43dabb218 --- /dev/null +++ b/xml/tests/testData/catalog/catalog/cs-xacml-schema-policy-01.xsd @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml/tests/testData/catalog/policy.xml b/xml/tests/testData/catalog/policy.xml new file mode 100644 index 000000000000..9ea5785ce8f0 --- /dev/null +++ b/xml/tests/testData/catalog/policy.xml @@ -0,0 +1,18 @@ + + xxx + + + + + + + + + + + + + \ No newline at end of file