diff --git a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java index 3fea6249054e..0238f601e11b 100644 --- a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java @@ -18,6 +18,8 @@ package com.intellij.codeInsight; import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; import com.intellij.ide.DataManager; import com.intellij.injected.editor.EditorWindow; +import com.intellij.javaee.ExternalResourceManager; +import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.Result; @@ -40,6 +42,7 @@ import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.roots.ContentEntry; import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; @@ -704,4 +707,22 @@ public abstract class CodeInsightTestCase extends PsiTestCase { assertNotNull("Package " + name + " not found", aPackage); return aPackage; } + protected void registerResourceTemporarily(final String url, final String location) { + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + ExternalResourceManager.getInstance().addResource(url, location); + } + }); + + Disposer.register(getTestRootDisposable(), new Disposable() { + @Override + public void dispose() { + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + ExternalResourceManager.getInstance().removeResource(url); + } + }); + } + }); + } } diff --git a/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesFileTest.java b/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesFileTest.java index 2f9db59d653e..ecf65cdb9861 100644 --- a/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesFileTest.java +++ b/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesFileTest.java @@ -43,8 +43,13 @@ public class PropertiesFileTest extends LightPlatformTestCase { } public void testAddPropertyAfterComment() throws Exception { - PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "#xxxxx"); - propertiesFile.addProperty(myPropertyToAdd); + final PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "#xxxxx"); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + propertiesFile.addProperty(myPropertyToAdd); + } + }); + List properties = propertiesFile.getProperties(); Property added = properties.get(0); @@ -57,8 +62,13 @@ public class PropertiesFileTest extends LightPlatformTestCase { } public void testAddPropertyAfterProperty() throws Exception { - PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "xxx=yyy"); - propertiesFile.addProperty(myPropertyToAdd); + final PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "xxx=yyy"); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + propertiesFile.addProperty(myPropertyToAdd); + } + }); + List properties = propertiesFile.getProperties(); assertEquals(2, properties.size()); @@ -112,9 +122,14 @@ public class PropertiesFileTest extends LightPlatformTestCase { } public void testAddToEnd() throws IncorrectOperationException { - PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "a=b\\nccc"); + final PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "a=b\\nccc"); assertEquals(1,propertiesFile.getProperties().size()); - propertiesFile.addProperty(myPropertyToAdd); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + propertiesFile.addProperty(myPropertyToAdd); + } + }); + assertEquals("a=b\\nccc\nkkk=vvv", propertiesFile.getText()); } @@ -129,20 +144,35 @@ public class PropertiesFileTest extends LightPlatformTestCase { } public void testAddPropertyAfter() throws IncorrectOperationException { - PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "a=b\nc=d\ne=f"); - Property c = propertiesFile.findPropertyByKey("c"); - propertiesFile.addPropertyAfter(myPropertyToAdd, c); + final PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "a=b\nc=d\ne=f"); + final Property c = propertiesFile.findPropertyByKey("c"); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + propertiesFile.addPropertyAfter(myPropertyToAdd, c); + } + }); + assertEquals("a=b\nc=d\nkkk=vvv\ne=f", propertiesFile.getText()); } public void testAddPropertyAfterLast() throws IncorrectOperationException { - PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "a=b\nc=d\ne=f"); - Property p = propertiesFile.findPropertyByKey("e"); - propertiesFile.addPropertyAfter(myPropertyToAdd, p); + final PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "a=b\nc=d\ne=f"); + final Property p = propertiesFile.findPropertyByKey("e"); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + propertiesFile.addPropertyAfter(myPropertyToAdd, p); + } + }); + assertEquals("a=b\nc=d\ne=f\nkkk=vvv", propertiesFile.getText()); } public void testAddPropertyAfterInBeginning() throws IncorrectOperationException { - PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "a=b\nc=d\ne=f"); - propertiesFile.addPropertyAfter(myPropertyToAdd, null); + final PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "a=b\nc=d\ne=f"); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + propertiesFile.addPropertyAfter(myPropertyToAdd, null); + } + }); + assertEquals("kkk=vvv\na=b\nc=d\ne=f", propertiesFile.getText()); } public void testUnescapedKey() throws IncorrectOperationException { diff --git a/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java b/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java index 2b6108f13645..7c7c2dcf3d01 100644 --- a/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java +++ b/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java @@ -24,6 +24,7 @@ import com.intellij.codeInspection.InspectionToolProvider; import com.intellij.codeInspection.htmlInspections.RequiredAttributesInspection; import com.intellij.javaee.ExternalResourceManagerEx; import com.intellij.mock.MockProgressIndicator; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PluginPathManager; import com.intellij.openapi.application.Result; import com.intellij.openapi.application.WriteAction; @@ -158,7 +159,11 @@ public abstract class HighlightingTestBase extends UsefulTestCase implements Ide public abstract String getTestDataPath(); protected void init() { - ExternalResourceManagerEx.getInstanceEx().addIgnoredResource("urn:test:undefined"); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + ExternalResourceManagerEx.getInstanceEx().addIgnoredResource("urn:test:undefined"); + } + }); } protected void tearDown() throws Exception { diff --git a/plugins/relaxng/test/org/intellij/plugins/relaxNG/RngHtml5CompletionTest.java b/plugins/relaxng/test/org/intellij/plugins/relaxNG/RngHtml5CompletionTest.java index f1c813eeeab6..7fe2b870dce3 100644 --- a/plugins/relaxng/test/org/intellij/plugins/relaxNG/RngHtml5CompletionTest.java +++ b/plugins/relaxng/test/org/intellij/plugins/relaxNG/RngHtml5CompletionTest.java @@ -16,6 +16,7 @@ package org.intellij.plugins.relaxNG; import com.intellij.javaee.ExternalResourceManagerEx; +import com.intellij.openapi.application.ApplicationManager; /** * @author Eugene.Kudelevsky @@ -32,8 +33,12 @@ public class RngHtml5CompletionTest extends HighlightingTestBase { protected void init() { super.init(); - final ExternalResourceManagerEx m = ExternalResourceManagerEx.getInstanceEx(); - m.addResource("http://www.w3.org/1999/xhtml/html5", toAbsolutePath("/highlighting/html5/html5.rnc")); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + final ExternalResourceManagerEx m = ExternalResourceManagerEx.getInstanceEx(); + m.addResource("http://www.w3.org/1999/xhtml/html5", toAbsolutePath("/highlighting/html5/html5.rnc")); + } + }); } public void testHtml5_1() throws Throwable { diff --git a/plugins/relaxng/test/org/intellij/plugins/relaxNG/RngXmlHighlightingTest.java b/plugins/relaxng/test/org/intellij/plugins/relaxNG/RngXmlHighlightingTest.java index 57f6a875f0c2..b21f37c0ee78 100644 --- a/plugins/relaxng/test/org/intellij/plugins/relaxNG/RngXmlHighlightingTest.java +++ b/plugins/relaxng/test/org/intellij/plugins/relaxNG/RngXmlHighlightingTest.java @@ -17,6 +17,7 @@ package org.intellij.plugins.relaxNG; import com.intellij.javaee.ExternalResourceManagerEx; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.fileTypes.StdFileTypes; import org.intellij.plugins.testUtil.CopyFile; @@ -36,26 +37,30 @@ public class RngXmlHighlightingTest extends HighlightingTestBase { super.init(); FileTypeManager.getInstance().registerFileType(StdFileTypes.XML, "fo"); - final ExternalResourceManagerEx m = ExternalResourceManagerEx.getInstanceEx(); - m.addResource("urn:test:simple.rng", toAbsolutePath("highlighting/simple.rng")); - m.addResource("urn:test:addressBook", toAbsolutePath("highlighting/rnc/addressbook.rnc")); - m.addResource("http://www.w3.org/1999/XSL/Transform", toAbsolutePath("highlighting/relaxng.rng")); - m.addResource("http://www.w3.org/1999/XSL/Format", toAbsolutePath("highlighting/rnc/fo/main.rnc")); - m.addResource("http://docbook.org/ns/docbook", toAbsolutePath("highlighting/docbook.rng")); - m.addResource("urn:intelliForm:AttachmentFilter", toAbsolutePath("highlighting/attachment-filter.rng")); - m.addResource("http://www.w3.org/1999/xhtml/html5", toAbsolutePath("highlighting/html5/xhtml5.rnc")); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + final ExternalResourceManagerEx m = ExternalResourceManagerEx.getInstanceEx(); + m.addResource("urn:test:simple.rng", toAbsolutePath("highlighting/simple.rng")); + m.addResource("urn:test:addressBook", toAbsolutePath("highlighting/rnc/addressbook.rnc")); + m.addResource("http://www.w3.org/1999/XSL/Transform", toAbsolutePath("highlighting/relaxng.rng")); + m.addResource("http://www.w3.org/1999/XSL/Format", toAbsolutePath("highlighting/rnc/fo/main.rnc")); + m.addResource("http://docbook.org/ns/docbook", toAbsolutePath("highlighting/docbook.rng")); + m.addResource("urn:intelliForm:AttachmentFilter", toAbsolutePath("highlighting/attachment-filter.rng")); + m.addResource("http://www.w3.org/1999/xhtml/html5", toAbsolutePath("highlighting/html5/xhtml5.rnc")); - m.addIgnoredResource("urn:intelliForm:Spaces"); - m.addIgnoredResource("http://www.w3.org/1999/xlink"); - m.addIgnoredResource("http://www.w3.org/2000/svg"); - m.addIgnoredResource("http://www.ascc.net/xml/schematron"); - m.addIgnoredResource("http://www.w3.org/2000/svg"); - m.addIgnoredResource("http://www.w3.org/1998/Math/MathML"); - m.addIgnoredResource("http://nwalsh.com/xmlns/schema-control/"); - m.addIgnoredResource("http://xml.apache.org/fop/extensions"); - m.addIgnoredResource("http://www.antennahouse.com/names/XSL/Extensions"); - m.addIgnoredResource("http://www.renderx.com/XSL/Extensions"); - m.addIgnoredResource("http://relaxng.org/ns/compatibility/annotations/1.0"); + m.addIgnoredResource("urn:intelliForm:Spaces"); + m.addIgnoredResource("http://www.w3.org/1999/xlink"); + m.addIgnoredResource("http://www.w3.org/2000/svg"); + m.addIgnoredResource("http://www.ascc.net/xml/schematron"); + m.addIgnoredResource("http://www.w3.org/2000/svg"); + m.addIgnoredResource("http://www.w3.org/1998/Math/MathML"); + m.addIgnoredResource("http://nwalsh.com/xmlns/schema-control/"); + m.addIgnoredResource("http://xml.apache.org/fop/extensions"); + m.addIgnoredResource("http://www.antennahouse.com/names/XSL/Extensions"); + m.addIgnoredResource("http://www.renderx.com/XSL/Extensions"); + m.addIgnoredResource("http://relaxng.org/ns/compatibility/annotations/1.0"); + } + }); } public void testSimpleElement() throws Throwable { diff --git a/plugins/relaxng/test/org/intellij/plugins/relaxNG/RngXmlValidationTest.java b/plugins/relaxng/test/org/intellij/plugins/relaxNG/RngXmlValidationTest.java index 3aa5c11d84ed..d870ea18fe06 100644 --- a/plugins/relaxng/test/org/intellij/plugins/relaxNG/RngXmlValidationTest.java +++ b/plugins/relaxng/test/org/intellij/plugins/relaxNG/RngXmlValidationTest.java @@ -17,6 +17,7 @@ package org.intellij.plugins.relaxNG; import com.intellij.javaee.ExternalResourceManager; +import com.intellij.openapi.application.ApplicationManager; import org.intellij.plugins.testUtil.CopyFile; /** @@ -84,10 +85,14 @@ public class RngXmlValidationTest extends HighlightingTestBase { protected void init() { super.init(); - final ExternalResourceManager mgr = ExternalResourceManager.getInstance(); - mgr.addResource("urn:test:simple.rng", toAbsolutePath("validation/simple.rng")); - mgr.addResource("urn:test:simple.rnc", toAbsolutePath("validation/simple.rnc")); - mgr.addResource("http://www.w3.org/1999/XSL/Transform", toAbsolutePath("validation/relaxng.rng")); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + final ExternalResourceManager mgr = ExternalResourceManager.getInstance(); + mgr.addResource("urn:test:simple.rng", toAbsolutePath("validation/simple.rng")); + mgr.addResource("urn:test:simple.rnc", toAbsolutePath("validation/simple.rnc")); + mgr.addResource("http://www.w3.org/1999/XSL/Transform", toAbsolutePath("validation/relaxng.rng")); + } + }); } public String getTestDataPath() { diff --git a/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/xslt/Xslt2HighlightingTest.java b/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/xslt/Xslt2HighlightingTest.java index 96e576dea89a..41987db3c862 100644 --- a/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/xslt/Xslt2HighlightingTest.java +++ b/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/xslt/Xslt2HighlightingTest.java @@ -16,6 +16,7 @@ package org.intellij.lang.xpath.xslt; import com.intellij.javaee.ExternalResourceManagerEx; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.util.ArrayUtil; import org.intellij.lang.xpath.TestBase; import org.intellij.lang.xpath.xslt.impl.XsltStuffProvider; @@ -30,8 +31,12 @@ public class Xslt2HighlightingTest extends TestBase { protected void setUp() throws Exception { super.setUp(); myFixture.enableInspections(XsltStuffProvider.INSPECTION_CLASSES); - ExternalResourceManagerEx.getInstanceEx().addIgnoredResource("urn:my"); - ExternalResourceManagerEx.getInstanceEx().addIgnoredResource("nsx"); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + ExternalResourceManagerEx.getInstanceEx().addIgnoredResource("urn:my"); + ExternalResourceManagerEx.getInstanceEx().addIgnoredResource("nsx"); + } + }); } public void testCurrentMode() throws Throwable { diff --git a/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/xslt/XsltHighlightingTest.java b/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/xslt/XsltHighlightingTest.java index 9a7f4c1e6841..0797b78d4811 100644 --- a/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/xslt/XsltHighlightingTest.java +++ b/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/xslt/XsltHighlightingTest.java @@ -36,7 +36,11 @@ public class XsltHighlightingTest extends TestBase { protected void setUp() throws Exception { super.setUp(); myFixture.enableInspections(XsltStuffProvider.INSPECTION_CLASSES); - ExternalResourceManagerEx.getInstanceEx().addIgnoredResource("urn:my"); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + ExternalResourceManagerEx.getInstanceEx().addIgnoredResource("urn:my"); + } + }); } public void xtestBackwardIncludedVariable() throws Throwable { diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/IgnoreExtResourceAction.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/IgnoreExtResourceAction.java index 2a1c2299d93d..54d922bcb14c 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/IgnoreExtResourceAction.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/IgnoreExtResourceAction.java @@ -16,9 +16,11 @@ package com.intellij.codeInsight.daemon.impl.quickfix; import com.intellij.javaee.ExternalResourceManagerEx; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.psi.PsiFile; import com.intellij.openapi.editor.Editor; import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; /** * @author mike @@ -28,7 +30,11 @@ public class IgnoreExtResourceAction extends BaseExtResourceAction { return "ignore.external.resource.text"; } - protected void doInvoke(final PsiFile file, final int offset, final String uri, final Editor editor) throws IncorrectOperationException { - ExternalResourceManagerEx.getInstanceEx().addIgnoredResource(uri); + protected void doInvoke(@NotNull final PsiFile file, final int offset, @NotNull final String uri, final Editor editor) throws IncorrectOperationException { + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + ExternalResourceManagerEx.getInstanceEx().addIgnoredResource(uri); + } + }); } } diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ManuallySetupExtResourceAction.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ManuallySetupExtResourceAction.java index e2ff6e831beb..6558a45e209f 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ManuallySetupExtResourceAction.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ManuallySetupExtResourceAction.java @@ -17,6 +17,7 @@ package com.intellij.codeInsight.daemon.impl.quickfix; import com.intellij.javaee.ExternalResourceConfigurable; import com.intellij.javaee.ExternalResourceManager; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.options.ShowSettingsUtil; import com.intellij.openapi.project.Project; @@ -34,7 +35,12 @@ public class ManuallySetupExtResourceAction extends BaseExtResourceAction { } protected void doInvoke(@NotNull final PsiFile file, final int offset, @NotNull final String uri, final Editor editor) throws IncorrectOperationException { - ExternalResourceManager.getInstance().addResource(uri,""); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + ExternalResourceManager.getInstance().addResource(uri, ""); + } + }); + final Project project = file.getProject(); final ExternalResourceConfigurable component = new ExternalResourceConfigurable(project); ShowSettingsUtil.getInstance().editConfigurable(project, component, new Runnable() { diff --git a/xml/impl/src/com/intellij/javaee/ExternalResourceConfigurable.java b/xml/impl/src/com/intellij/javaee/ExternalResourceConfigurable.java index 6a4b80ca2f99..9fd80b66ea6d 100644 --- a/xml/impl/src/com/intellij/javaee/ExternalResourceConfigurable.java +++ b/xml/impl/src/com/intellij/javaee/ExternalResourceConfigurable.java @@ -15,6 +15,7 @@ */ package com.intellij.javaee; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.options.BaseConfigurable; import com.intellij.openapi.options.OptionalConfigurable; import com.intellij.openapi.options.SearchableConfigurable; @@ -139,24 +140,30 @@ public class ExternalResourceConfigurable extends BaseConfigurable implements Se } public void apply() { - ExternalResourceManagerEx manager = ExternalResourceManagerEx.getInstanceEx(); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + ExternalResourceManagerEx manager = ExternalResourceManagerEx.getInstanceEx(); - manager.clearAllResources(myProject); - for (Object myPair : myPairs) { - EditLocationDialog.NameLocationPair pair = (EditLocationDialog.NameLocationPair)myPair; - String s = pair.myLocation.replace('\\', '/'); - if (pair.myShared) { - manager.addResource(pair.myName, s); - } else { - manager.addResource(pair.myName, s, myProject); + manager.clearAllResources(myProject); + for (Object myPair : myPairs) { + EditLocationDialog.NameLocationPair pair = (EditLocationDialog.NameLocationPair)myPair; + String s = pair.myLocation.replace('\\', '/'); + if (pair.myShared) { + manager.addResource(pair.myName, s); + } + else { + manager.addResource(pair.myName, s, myProject); + } + } + + for (Object myIgnoredUrl : myIgnoredUrls) { + String url = (String)myIgnoredUrl; + manager.addIgnoredResource(url); + } + manager.setDefaultHtmlDoctype(myHtmlLanguageLevelForm.getDoctype(), myProject); } - } + }); - for (Object myIgnoredUrl : myIgnoredUrls) { - String url = (String)myIgnoredUrl; - manager.addIgnoredResource(url); - } - manager.setDefaultHtmlDoctype(myHtmlLanguageLevelForm.getDoctype(), myProject); setModified(false); } diff --git a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java index 68f06ea53f3d..2eb908a0607a 100644 --- a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java +++ b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java @@ -215,6 +215,7 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple } public void addResource(@NonNls String url, @NonNls String version, @NonNls String location) { + ApplicationManager.getApplication().assertWriteAccessAllowed(); addSilently(url, version, location); fireExternalResourceChanged(); } @@ -232,6 +233,7 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple } public void removeResource(String url, String version) { + ApplicationManager.getApplication().assertWriteAccessAllowed(); Map map = getMap(myResources, version, false); if (map != null) { String location = map.remove(url); @@ -272,6 +274,7 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple } public void clearAllResources(Project project) { + ApplicationManager.getApplication().assertWriteAccessAllowed(); clearAllResources(); getProjectResources(project).clearAllResources(); myModificationCount++; @@ -279,6 +282,7 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple } public void addIgnoredResource(String url) { + ApplicationManager.getApplication().assertWriteAccessAllowed(); addIgnoredSilently(url); fireExternalResourceChanged(); } @@ -289,6 +293,7 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple } public void removeIgnoredResource(String url) { + ApplicationManager.getApplication().assertWriteAccessAllowed(); if (myIgnoredResources.remove(url)) { myModificationCount++; fireExternalResourceChanged(); @@ -395,7 +400,7 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple } - private final static NotNullLazyKey INSTANCE_CACHE = ServiceManager.createLazyKey(ProjectResources.class); + private static final NotNullLazyKey INSTANCE_CACHE = ServiceManager.createLazyKey(ProjectResources.class); private static ExternalResourceManagerImpl getProjectResources(Project project) { return INSTANCE_CACHE.getValue(project);