diff options
author | Tor Norbye <tnorbye@google.com> | 2013-05-31 07:45:51 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2013-05-31 07:45:51 -0700 |
commit | ec3fb1e06285c0467a7a20360ca80453bc7635d4 (patch) | |
tree | 2402cdec34611f34b8385ff45387d6734bf6f994 /xml | |
parent | a6eac331b3d9f0d4168b12356ea256c83f4e9c05 (diff) | |
download | idea-ec3fb1e06285c0467a7a20360ca80453bc7635d4.tar.gz |
Snapshot 568f05589922685b8c8f9a2f2f465043b8128542 from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: I47fe8cb5d8a3c9876cd4c313dca1a8cc531288ec
Diffstat (limited to 'xml')
184 files changed, 1244 insertions, 820 deletions
diff --git a/xml/dom-impl/src/META-INF/DomPlugin.xml b/xml/dom-impl/src/META-INF/DomPlugin.xml index 3cdb2f68dc92..ae1e1b0ce0ef 100644 --- a/xml/dom-impl/src/META-INF/DomPlugin.xml +++ b/xml/dom-impl/src/META-INF/DomPlugin.xml @@ -63,7 +63,7 @@ <semContributor implementation="com.intellij.util.xml.impl.DomSemContributor"/> <annotator language="XML" implementationClass="com.intellij.util.xml.impl.DefaultDomAnnotator"/> - <lang.documentationProvider language="XML" implementationClass="com.intellij.util.xml.DomDocumentationProvider"/> + <lang.documentationProvider language="XML" implementationClass="com.intellij.util.xml.DomDocumentationProvider" id="dom"/> <usageTypeProvider implementation="com.intellij.util.xml.DomUsageTypeProvider"/> diff --git a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomHighlightingHelperImpl.java b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomHighlightingHelperImpl.java index 310f095bd492..3330f90c5c77 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomHighlightingHelperImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomHighlightingHelperImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -119,7 +119,7 @@ public class DomHighlightingHelperImpl extends DomHighlightingHelper { GenericDomValueReference domReference = ContainerUtil.findInstance(psiReferences, GenericDomValueReference.class); final Converter converter = WrappingConverter.getDeepestConverter(element.getConverter(), element); boolean hasBadResolve = false; - if (!(domReference != null && isDomResolveOK(element, domReference, converter))) { + if (domReference == null || !isDomResolveOK(element, domReference, converter)) { for (final PsiReference reference : psiReferences) { if (reference != domReference && hasBadResolve(reference)) { hasBadResolve = true; @@ -132,7 +132,8 @@ public class DomHighlightingHelperImpl extends DomHighlightingHelper { hasBadResolve(domReference = new GenericDomValueReference(element)))) { hasBadResolve = true; final String errorMessage = converter - .getErrorMessage(element.getStringValue(), ConvertContextFactory.createConvertContext(DomManagerImpl.getDomInvocationHandler(element))); + .getErrorMessage(element.getStringValue(), ConvertContextFactory.createConvertContext( + DomManagerImpl.getDomInvocationHandler(element))); if (errorMessage != null && XmlHighlightVisitor.getErrorDescription(domReference) != null) { list.add(holder.createResolveProblem(element, domReference)); } @@ -151,8 +152,8 @@ public class DomHighlightingHelperImpl extends DomHighlightingHelper { } private static boolean isDomResolveOK(GenericDomValue element, GenericDomValueReference domReference, Converter converter) { - return !hasBadResolve(domReference) - || converter instanceof ResolvingConverter && ((ResolvingConverter)converter).getAdditionalVariants(domReference.getConvertContext()).contains(element.getStringValue()); + return !hasBadResolve(domReference) || + converter instanceof ResolvingConverter && ((ResolvingConverter)converter).getAdditionalVariants(domReference.getConvertContext()).contains(element.getStringValue()); } @NotNull diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomDescriptorProvider.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomDescriptorProvider.java index 18ed303637f8..9fe2273d9a83 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomDescriptorProvider.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomDescriptorProvider.java @@ -45,7 +45,7 @@ public class DomDescriptorProvider implements XmlElementDescriptorProvider { if (parent instanceof XmlTag) { final XmlElementDescriptor descriptor = ((XmlTag)parent).getDescriptor(); - if (descriptor != null && descriptor instanceof DomElementXmlDescriptor) { + if (descriptor instanceof DomElementXmlDescriptor) { return descriptor.getElementDescriptor(tag, (XmlTag)parent); } } diff --git a/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilder.java b/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilder.java index d637974baf1a..8c62add6171c 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilder.java +++ b/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilder.java @@ -26,6 +26,7 @@ import com.intellij.psi.PsiManager; import com.intellij.psi.stubs.BinaryFileStubBuilder; import com.intellij.psi.stubs.Stub; import com.intellij.psi.xml.XmlFile; +import com.intellij.util.indexing.FileContent; import com.intellij.util.xml.*; import com.intellij.util.xml.stubs.FileStub; import com.intellij.xml.util.XmlUtil; @@ -44,8 +45,9 @@ public class DomStubBuilder implements BinaryFileStubBuilder { } @Override - public Stub buildStubTree(VirtualFile file, byte[] content, Project project) { - + public Stub buildStubTree(FileContent fileContent) { + VirtualFile file = fileContent.getFile(); + Project project = fileContent.getProject(); PsiFile psiFile = PsiManager.getInstance(project).findFile(file); if (!(psiFile instanceof XmlFile)) return null; diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboControl.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboControl.java index 3984d19fba47..4966c85f1b17 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboControl.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboControl.java @@ -95,11 +95,12 @@ public class ComboControl extends BaseModifiableControl<JComboBox, String> { }; final ResolvingConverter resolvingConverter = (ResolvingConverter)converter; final Collection<Object> variants = resolvingConverter.getVariants(context); - final List<Pair<String, Icon>> all = ContainerUtil.map(variants, new Function<Object, Pair<String, Icon>>() { - public Pair<String, Icon> fun(final Object s) { - return Pair.create(ElementPresentationManager.getElementName(s), ElementPresentationManager.getIcon(s)); - } - }); + final List<Pair<String, Icon>> all = + new ArrayList<Pair<String, Icon>>(ContainerUtil.map(variants, new Function<Object, Pair<String, Icon>>() { + public Pair<String, Icon> fun(final Object s) { + return Pair.create(ElementPresentationManager.getElementName(s), ElementPresentationManager.getIcon(s)); + } + })); all.addAll(ContainerUtil.map(resolvingConverter.getAdditionalVariants(context), new Function() { public Object fun(final Object s) { return new Pair(s, null); diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java index dc21e4d94167..2486c87e1b9b 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java @@ -13,6 +13,7 @@ import com.intellij.ide.ui.search.SearchableOptionsRegistrar; import com.intellij.lang.annotation.Annotation; import com.intellij.mock.MockInspectionProfile; import com.intellij.profile.codeInspection.InspectionProfileManager; +import com.intellij.profile.codeInspection.InspectionProfileManagerImpl; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiType; import com.intellij.psi.xml.XmlElement; @@ -41,7 +42,7 @@ public class DomHighlightingLiteTest extends DomTestCase { final InspectionToolRegistrar registrar = new InspectionToolRegistrar(SearchableOptionsRegistrar.getInstance()); registrar.registerTools(new InspectionToolProvider[0]); - final InspectionProfileManager inspectionProfileManager = new InspectionProfileManager(registrar, new MockSchemesManagerFactory()); + final InspectionProfileManager inspectionProfileManager = new InspectionProfileManagerImpl(registrar, new MockSchemesManagerFactory()); myInspectionProfile = new MockInspectionProfile(); myAnnotationsManager = new DomElementAnnotationsManagerImpl(getProject()) { diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomIncludesTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomIncludesTest.java index 16d2b6f11835..3de62d6660d5 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomIncludesTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomIncludesTest.java @@ -15,7 +15,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.xml.XmlFile; import com.intellij.testFramework.Timings; -import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase; import com.intellij.util.Consumer; import com.intellij.util.xml.impl.DomFileElementImpl; import com.intellij.util.xml.impl.DomManagerImpl; @@ -28,7 +28,7 @@ import java.util.concurrent.atomic.AtomicReference; /** * @author peter */ -public class DomIncludesTest extends JavaCodeInsightFixtureTestCase { +public class DomIncludesTest extends CodeInsightFixtureTestCase { public void testGetChildrenHonorsIncludes() throws Throwable { final MyElement rootElement = createDomFile("a.xml", "<root xmlns:xi=\"http://www.w3.org/2001/XInclude\">" + @@ -204,7 +204,7 @@ public class DomIncludesTest extends JavaCodeInsightFixtureTestCase { private PsiFile createFile(final String fileName, final String fileText) throws IOException { final VirtualFile file = myFixture.getTempDirFixture().createFile(fileName); VfsUtil.saveText(file, fileText); - return getPsiManager().findFile(file); + return myFixture.getPsiManager().findFile(file); } private DomManagerImpl getDomManager() { diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java index 93c5e11271ce..c5ec2d4bd9b8 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java @@ -9,7 +9,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFileFactory; import com.intellij.psi.xml.XmlFile; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import org.jetbrains.annotations.Nullable; import org.xml.sax.SAXException; @@ -18,7 +18,7 @@ import java.io.IOException; /** * @author peter */ -public class DomSaxParserTest extends LightCodeInsightFixtureTestCase { +public class DomSaxParserTest extends LightPlatformCodeInsightFixtureTestCase { public void testGetRootTagNameWithoutNamespace() throws Throwable { assertData("<root>", "root", null, null, null); diff --git a/xml/impl/src/com/intellij/application/options/emmet/CssEditPrefixesListPanel.java b/xml/impl/src/com/intellij/application/options/emmet/CssEditPrefixesListPanel.java index 765c00e4d051..9980cb841342 100644 --- a/xml/impl/src/com/intellij/application/options/emmet/CssEditPrefixesListPanel.java +++ b/xml/impl/src/com/intellij/application/options/emmet/CssEditPrefixesListPanel.java @@ -21,6 +21,7 @@ import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.table.TableView; import com.intellij.util.ui.ColumnInfo; import com.intellij.util.ui.ListTableModel; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -57,11 +58,10 @@ public class CssEditPrefixesListPanel { myPrefixesTableView.setStriped(true); myPrefixesTableView.getRowSorter().toggleSortOrder(0); - new TableViewSpeedSearch(myPrefixesTableView) { + new TableViewSpeedSearch<CssPrefixInfo>(myPrefixesTableView) { @Override - protected String getElementText(final Object element) { - CssPrefixInfo prefixInfo = (CssPrefixInfo)element; - return prefixInfo.getPropertyName(); + protected String getItemText(@NotNull CssPrefixInfo element) { + return element.getPropertyName(); } }; } diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/FetchExtResourceAction.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/FetchExtResourceAction.java index c86533c23e21..8e6a4ff00d16 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/FetchExtResourceAction.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/FetchExtResourceAction.java @@ -41,7 +41,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.psi.PsiReference; -import com.intellij.psi.impl.source.xml.XmlEntityRefImpl; +import com.intellij.psi.impl.source.xml.XmlEntityCache; import com.intellij.psi.search.PsiElementProcessor; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.*; @@ -395,7 +395,7 @@ public class FetchExtResourceAction extends BaseExtResourceAction implements Wat private static Set<String> extractEmbeddedFileReferences(XmlFile file, XmlFile context, final String url) { final Set<String> result = new LinkedHashSet<String>(); if (context != null) { - XmlEntityRefImpl.copyEntityCaches(file, context); + XmlEntityCache.copyEntityCaches(file, context); } XmlUtil.processXmlElements( diff --git a/xml/impl/src/com/intellij/codeInsight/template/HtmlTextContextType.java b/xml/impl/src/com/intellij/codeInsight/template/HtmlTextContextType.java index 63b95935d854..35bb8de01d99 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/HtmlTextContextType.java +++ b/xml/impl/src/com/intellij/codeInsight/template/HtmlTextContextType.java @@ -23,6 +23,7 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.XmlComment; import com.intellij.psi.xml.XmlDocument; import com.intellij.psi.xml.XmlText; +import com.intellij.psi.xml.XmlTokenType; import org.jetbrains.annotations.NotNull; /** @@ -49,6 +50,9 @@ public class HtmlTextContextType extends TemplateContextType { if (PsiTreeUtil.getParentOfType(element, XmlText.class) != null) { return true; } + if (element.getNode().getElementType() == XmlTokenType.XML_START_TAG_START) { + return true; + } PsiElement parent = element.getParent(); if (parent instanceof PsiErrorElement) { parent = parent.getParent(); diff --git a/xml/impl/src/com/intellij/codeInsight/template/XslTextContextType.java b/xml/impl/src/com/intellij/codeInsight/template/XslTextContextType.java index b9d0ba39c297..8c162c32b6a1 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/XslTextContextType.java +++ b/xml/impl/src/com/intellij/codeInsight/template/XslTextContextType.java @@ -18,6 +18,7 @@ import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author Eugene.Kudelevsky @@ -29,10 +30,15 @@ public class XslTextContextType extends TemplateContextType { @Override public boolean isInContext(@NotNull PsiFile file, int offset) { - if (file.getFileType() == StdFileTypes.XML && FileUtilRt.extensionEquals(file.getName(), "xsl")) { + if (isXslOrXsltFile(file)) { PsiElement element = file.findElementAt(offset); return element == null || HtmlTextContextType.isInContext(element); } return false; } + + public static boolean isXslOrXsltFile(@Nullable PsiFile file) { + return file != null && file.getFileType() == StdFileTypes.XML + && (FileUtilRt.extensionEquals(file.getName(), "xsl") || FileUtilRt.extensionEquals(file.getName(), "xslt")); + } } diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/filters/XslZenCodingFilter.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/filters/XslZenCodingFilter.java index 086fa7d3f60d..362efa35bc65 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/filters/XslZenCodingFilter.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/filters/XslZenCodingFilter.java @@ -15,13 +15,13 @@ */ package com.intellij.codeInsight.template.emmet.filters; +import com.intellij.codeInsight.template.XslTextContextType; import com.intellij.codeInsight.template.emmet.generators.XmlZenCodingGenerator; import com.intellij.codeInsight.template.emmet.generators.XmlZenCodingGeneratorImpl; import com.intellij.codeInsight.template.emmet.nodes.GenerationNode; import com.intellij.codeInsight.template.emmet.tokens.TemplateToken; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.util.Pair; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlDocument; @@ -90,7 +90,6 @@ public class XslZenCodingFilter extends ZenCodingFilter { @Override public boolean isAppliedByDefault(@NotNull PsiElement context) { - VirtualFile vFile = context.getContainingFile().getVirtualFile(); - return vFile != null && "xsl".equals(vFile.getExtension()); + return XslTextContextType.isXslOrXsltFile(context.getContainingFile()); } } diff --git a/xml/impl/src/com/intellij/ide/browsers/LocalFileUrl.java b/xml/impl/src/com/intellij/ide/browsers/LocalFileUrl.java index 4a1f4cfdf6a6..85993b40cf85 100644 --- a/xml/impl/src/com/intellij/ide/browsers/LocalFileUrl.java +++ b/xml/impl/src/com/intellij/ide/browsers/LocalFileUrl.java @@ -71,4 +71,4 @@ public final class LocalFileUrl implements Url { public int hashCode() { return path.hashCode(); } -} +}
\ No newline at end of file diff --git a/xml/impl/src/com/intellij/ide/browsers/OpenFileInBrowserAction.java b/xml/impl/src/com/intellij/ide/browsers/OpenFileInBrowserAction.java index 634907f48726..130fd1fc17f9 100644 --- a/xml/impl/src/com/intellij/ide/browsers/OpenFileInBrowserAction.java +++ b/xml/impl/src/com/intellij/ide/browsers/OpenFileInBrowserAction.java @@ -23,6 +23,7 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.Pair; import com.intellij.psi.PsiFile; import com.intellij.xml.XmlBundle; import com.intellij.xml.util.HtmlUtil; @@ -32,6 +33,7 @@ import java.awt.event.InputEvent; public class OpenFileInBrowserAction extends DumbAwareAction { private static final Logger LOG = Logger.getInstance("#com.intellij.ide.browsers.OpenFileInBrowserAction"); + @Override public void update(AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final PsiFile file = LangDataKeys.PSI_FILE.getData(dataContext); @@ -40,7 +42,7 @@ public class OpenFileInBrowserAction extends DumbAwareAction { if (file != null && file.getVirtualFile() != null) { presentation.setVisible(true); - final WebBrowserUrlProvider browserUrlProvider = WebBrowserServiceImpl.getProvider(file); + Pair<WebBrowserUrlProvider, Url> browserUrlProvider = WebBrowserServiceImpl.getProvider(file); final boolean isHtmlFile = HtmlUtil.isHtmlFile(file); presentation.setEnabled(browserUrlProvider != null || isHtmlFile); @@ -48,11 +50,11 @@ public class OpenFileInBrowserAction extends DumbAwareAction { String description = getTemplatePresentation().getDescription(); if (browserUrlProvider != null) { - final String customText = browserUrlProvider.getOpenInBrowserActionText(file); + final String customText = browserUrlProvider.first.getOpenInBrowserActionText(file); if (customText != null) { text = customText; } - final String customDescription = browserUrlProvider.getOpenInBrowserActionDescription(file); + final String customDescription = browserUrlProvider.first.getOpenInBrowserActionDescription(file); if (customDescription != null) { description = customDescription; } @@ -82,6 +84,7 @@ public class OpenFileInBrowserAction extends DumbAwareAction { } } + @Override public void actionPerformed(AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final PsiFile psiFile = LangDataKeys.PSI_FILE.getData(dataContext); diff --git a/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java b/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java index 67dba80e0d6b..bb477c2e5c19 100644 --- a/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java +++ b/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java @@ -20,6 +20,8 @@ import com.intellij.ide.browsers.Urls; import com.intellij.ide.browsers.WebBrowserService; import com.intellij.ide.browsers.WebBrowserUrlProvider; import com.intellij.openapi.project.DumbService; +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.Ref; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.impl.http.HttpVirtualFile; import com.intellij.psi.PsiElement; @@ -55,11 +57,17 @@ public class WebBrowserServiceImpl extends WebBrowserService { } if (!(preferLocalUrl && HtmlUtil.isHtmlFile(psiFile))) { - WebBrowserUrlProvider provider = getProvider(psiElement); + Pair<WebBrowserUrlProvider, Url> provider = getProvider(psiElement); if (provider != null) { + if (provider.second != null) { + return provider.second; + } + try { - // I (develar) don't want to change API right now, so, just wrap result - return Urls.newFromIdea(provider.getUrl(psiElement, psiFile, virtualFile)); + Url url = provider.first.getUrl(psiElement, psiFile, virtualFile); + if (url != null) { + return url; + } } catch (WebBrowserUrlProvider.BrowserException e) { if (!HtmlUtil.isHtmlFile(psiFile)) { @@ -71,29 +79,31 @@ public class WebBrowserServiceImpl extends WebBrowserService { return Urls.newFromVirtualFile(virtualFile); } + @Override @Nullable public Url getUrlToOpen(@NotNull PsiElement psiElement) { try { return getUrlToOpen(psiElement, false); } - catch (WebBrowserUrlProvider.BrowserException e) { + catch (WebBrowserUrlProvider.BrowserException ignored) { return null; } } @Nullable - public static WebBrowserUrlProvider getProvider(@Nullable PsiElement element) { - if (element == null) { + public static Pair<WebBrowserUrlProvider, Url> getProvider(@Nullable PsiElement element) { + PsiFile psiFile = element == null ? null : element.getContainingFile(); + if (psiFile == null) { return null; } - final List<WebBrowserUrlProvider> allProviders = Arrays.asList(WebBrowserUrlProvider.EP_NAME.getExtensions()); + Ref<Url> result = Ref.create(); + List<WebBrowserUrlProvider> allProviders = Arrays.asList(WebBrowserUrlProvider.EP_NAME.getExtensions()); for (WebBrowserUrlProvider urlProvider : DumbService.getInstance(element.getProject()).filterByDumbAwareness(allProviders)) { - if (urlProvider.canHandleElement(element)) { - return urlProvider; + if (urlProvider.canHandleElement(element, psiFile, result)) { + return Pair.create(urlProvider, result.get()); } } - return null; } } diff --git a/xml/impl/src/com/intellij/ide/highlighter/HtmlFileType.java b/xml/impl/src/com/intellij/ide/highlighter/HtmlFileType.java index f0638e0f81e9..a3c2e9ac703d 100644 --- a/xml/impl/src/com/intellij/ide/highlighter/HtmlFileType.java +++ b/xml/impl/src/com/intellij/ide/highlighter/HtmlFileType.java @@ -22,8 +22,8 @@ import com.intellij.lang.html.HTMLLanguage; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.text.XmlCharsetDetector; import com.intellij.xml.util.HtmlUtil; -import com.intellij.xml.util.XmlUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -65,7 +65,7 @@ public class HtmlFileType extends XmlLikeFileType { } public String getCharset(@NotNull final VirtualFile file, final byte[] content) { - String charset = XmlUtil.extractXmlEncodingFromProlog(content); + String charset = XmlCharsetDetector.extractXmlEncodingFromProlog(content); if (charset != null) return charset; @NonNls String strContent; try { @@ -79,7 +79,7 @@ public class HtmlFileType extends XmlLikeFileType { } public Charset extractCharsetFromFileContent(@Nullable final Project project, @Nullable final VirtualFile file, @NotNull final String content) { - String name = XmlUtil.extractXmlEncodingFromProlog(content); + String name = XmlCharsetDetector.extractXmlEncodingFromProlog(content); Charset charset = CharsetToolkit.forName(name); if (charset != null) { diff --git a/xml/impl/src/com/intellij/lang/dtd/DTDLanguage.java b/xml/impl/src/com/intellij/lang/dtd/DTDLanguage.java deleted file mode 100644 index 29ce449875f1..000000000000 --- a/xml/impl/src/com/intellij/lang/dtd/DTDLanguage.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.lang.dtd; - -import com.intellij.ide.highlighter.XmlFileHighlighter; -import com.intellij.lang.xml.XMLLanguage; -import com.intellij.openapi.fileTypes.SingleLazyInstanceSyntaxHighlighterFactory; -import com.intellij.openapi.fileTypes.SyntaxHighlighter; -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; -import org.jetbrains.annotations.NotNull; - -/** - * @author max - */ -public class DTDLanguage extends XMLLanguage { - - public static final DTDLanguage INSTANCE = new DTDLanguage(); - - protected DTDLanguage() { - super(XMLLanguage.INSTANCE, "DTD", "text/dtd", "text/x-dtd"); - SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new SingleLazyInstanceSyntaxHighlighterFactory() { - @NotNull - protected SyntaxHighlighter createHighlighter() { - return new XmlFileHighlighter(true); - } - }); - } -} diff --git a/xml/impl/src/com/intellij/lang/dtd/DtdSyntaxHighlighterFactory.java b/xml/impl/src/com/intellij/lang/dtd/DtdSyntaxHighlighterFactory.java new file mode 100644 index 000000000000..8095517bcdb5 --- /dev/null +++ b/xml/impl/src/com/intellij/lang/dtd/DtdSyntaxHighlighterFactory.java @@ -0,0 +1,13 @@ +package com.intellij.lang.dtd; + +import com.intellij.ide.highlighter.XmlFileHighlighter; +import com.intellij.openapi.fileTypes.SingleLazyInstanceSyntaxHighlighterFactory; +import com.intellij.openapi.fileTypes.SyntaxHighlighter; +import org.jetbrains.annotations.NotNull; + +public class DtdSyntaxHighlighterFactory extends SingleLazyInstanceSyntaxHighlighterFactory { + @NotNull + protected SyntaxHighlighter createHighlighter() { + return new XmlFileHighlighter(true); + } +} diff --git a/xml/impl/src/com/intellij/lang/html/HTMLLanguage.java b/xml/impl/src/com/intellij/lang/html/HTMLLanguage.java deleted file mode 100644 index 4c4cbca0d6d1..000000000000 --- a/xml/impl/src/com/intellij/lang/html/HTMLLanguage.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.lang.html; - -import com.intellij.ide.highlighter.HtmlFileHighlighter; -import com.intellij.lang.xml.XMLLanguage; -import com.intellij.openapi.fileTypes.SingleLazyInstanceSyntaxHighlighterFactory; -import com.intellij.openapi.fileTypes.SyntaxHighlighter; -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; -import com.intellij.psi.impl.source.xml.XmlPsiPolicy; -import org.jetbrains.annotations.NotNull; - -/** - * @author max - */ -public class HTMLLanguage extends XMLLanguage { - - public static final HTMLLanguage INSTANCE = new HTMLLanguage(); - - private HTMLLanguage() { - super(XMLLanguage.INSTANCE, "HTML", "text/html", "text/htmlh"); - SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new SingleLazyInstanceSyntaxHighlighterFactory() { - @NotNull - protected SyntaxHighlighter createHighlighter() { - return new HtmlFileHighlighter(); - } - }); - - } - - public XmlPsiPolicy getPsiPolicy() { - return ENCODE_EACH_SYMBOL_POLICY; - } -} diff --git a/xml/impl/src/com/intellij/lang/html/HtmlSyntaxHighlighterFactory.java b/xml/impl/src/com/intellij/lang/html/HtmlSyntaxHighlighterFactory.java new file mode 100644 index 000000000000..25c491355495 --- /dev/null +++ b/xml/impl/src/com/intellij/lang/html/HtmlSyntaxHighlighterFactory.java @@ -0,0 +1,13 @@ +package com.intellij.lang.html; + +import com.intellij.ide.highlighter.HtmlFileHighlighter; +import com.intellij.openapi.fileTypes.SingleLazyInstanceSyntaxHighlighterFactory; +import com.intellij.openapi.fileTypes.SyntaxHighlighter; +import org.jetbrains.annotations.NotNull; + +public class HtmlSyntaxHighlighterFactory extends SingleLazyInstanceSyntaxHighlighterFactory { + @NotNull + protected SyntaxHighlighter createHighlighter() { + return new HtmlFileHighlighter(); + } +} diff --git a/xml/impl/src/com/intellij/lang/xhtml/XHTMLLanguage.java b/xml/impl/src/com/intellij/lang/xhtml/XHTMLLanguage.java deleted file mode 100644 index 52bb56d9e3d0..000000000000 --- a/xml/impl/src/com/intellij/lang/xhtml/XHTMLLanguage.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.lang.xhtml; - -import com.intellij.ide.highlighter.XmlFileHighlighter; -import com.intellij.lang.xml.XMLLanguage; -import com.intellij.openapi.fileTypes.SingleLazyInstanceSyntaxHighlighterFactory; -import com.intellij.openapi.fileTypes.SyntaxHighlighter; -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; -import com.intellij.psi.impl.source.xml.XmlPsiPolicy; -import org.jetbrains.annotations.NotNull; - -/** - * @author max - */ -public class XHTMLLanguage extends XMLLanguage { - - public static final XHTMLLanguage INSTANCE = new XHTMLLanguage(); - - private XHTMLLanguage() { - super(XMLLanguage.INSTANCE, "XHTML", "text/xhtml", "application/xhtml+xml"); - SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new SingleLazyInstanceSyntaxHighlighterFactory() { - @NotNull - protected SyntaxHighlighter createHighlighter() { - return new XmlFileHighlighter(false, true); - } - }); - } - - public XmlPsiPolicy getPsiPolicy() { - return ENCODE_EACH_SYMBOL_POLICY; - } -} diff --git a/xml/impl/src/com/intellij/lang/xhtml/XhtmlSyntaxHighlighterFactory.java b/xml/impl/src/com/intellij/lang/xhtml/XhtmlSyntaxHighlighterFactory.java new file mode 100644 index 000000000000..108fed274c14 --- /dev/null +++ b/xml/impl/src/com/intellij/lang/xhtml/XhtmlSyntaxHighlighterFactory.java @@ -0,0 +1,13 @@ +package com.intellij.lang.xhtml; + +import com.intellij.ide.highlighter.XmlFileHighlighter; +import com.intellij.openapi.fileTypes.SingleLazyInstanceSyntaxHighlighterFactory; +import com.intellij.openapi.fileTypes.SyntaxHighlighter; +import org.jetbrains.annotations.NotNull; + +public class XhtmlSyntaxHighlighterFactory extends SingleLazyInstanceSyntaxHighlighterFactory { + @NotNull + protected SyntaxHighlighter createHighlighter() { + return new XmlFileHighlighter(false, true); + } +} diff --git a/xml/impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java b/xml/impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java index c9154bd2d67b..19089b62405f 100644 --- a/xml/impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java +++ b/xml/impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java @@ -18,6 +18,7 @@ package com.intellij.lang.xml; import com.intellij.find.impl.HelpID; import com.intellij.lang.LangBundle; import com.intellij.lang.cacheBuilder.WordsScanner; +import com.intellij.lang.findUsages.DescriptiveNameUtil; import com.intellij.lang.findUsages.FindUsagesProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; @@ -25,7 +26,6 @@ import com.intellij.psi.PsiNamedElement; import com.intellij.psi.meta.PsiMetaData; import com.intellij.psi.xml.*; import com.intellij.usageView.UsageViewBundle; -import com.intellij.usageView.UsageViewUtil; import org.jetbrains.annotations.NotNull; /** @@ -98,7 +98,7 @@ public class XmlFindUsagesProvider implements FindUsagesProvider { if (element instanceof XmlTag) { final XmlTag xmlTag = (XmlTag)element; final PsiMetaData metaData = xmlTag.getMetaData(); - final String name = metaData != null ? UsageViewUtil.getMetaDataName(metaData) : xmlTag.getName(); + final String name = metaData != null ? DescriptiveNameUtil.getMetaDataName(metaData) : xmlTag.getName(); return UsageViewBundle.message("usage.target.xml.tag.of.file", metaData == null ? "<" + name + ">" : name, xmlTag.getContainingFile().getName()); } else if (element instanceof XmlAttributeValue) { diff --git a/xml/impl/src/com/intellij/lang/xml/XmlSurroundDescriptor.java b/xml/impl/src/com/intellij/lang/xml/XmlSurroundDescriptor.java index f0683d3bbb06..1cce551e293d 100644 --- a/xml/impl/src/com/intellij/lang/xml/XmlSurroundDescriptor.java +++ b/xml/impl/src/com/intellij/lang/xml/XmlSurroundDescriptor.java @@ -24,7 +24,7 @@ import com.intellij.lang.surroundWith.Surrounder; import com.intellij.openapi.util.Pair; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; -import com.intellij.psi.util.PsiUtilBase; +import com.intellij.psi.util.PsiUtilCore; import com.intellij.psi.xml.XmlTagChild; import com.intellij.psi.xml.XmlToken; import com.intellij.psi.xml.XmlTokenType; @@ -57,7 +57,7 @@ public class XmlSurroundDescriptor implements SurroundDescriptor { first = first.getNextSibling(); } - return PsiUtilBase.toPsiElementArray(result); + return PsiUtilCore.toPsiElementArray(result); } @NotNull public Surrounder[] getSurrounders() { diff --git a/xml/impl/src/com/intellij/lang/xml/XmlSyntaxHighlighterFactory.java b/xml/impl/src/com/intellij/lang/xml/XmlSyntaxHighlighterFactory.java new file mode 100644 index 000000000000..152b2bb28bcd --- /dev/null +++ b/xml/impl/src/com/intellij/lang/xml/XmlSyntaxHighlighterFactory.java @@ -0,0 +1,13 @@ +package com.intellij.lang.xml; + +import com.intellij.ide.highlighter.XmlFileHighlighter; +import com.intellij.openapi.fileTypes.SingleLazyInstanceSyntaxHighlighterFactory; +import com.intellij.openapi.fileTypes.SyntaxHighlighter; +import org.jetbrains.annotations.NotNull; + +public class XmlSyntaxHighlighterFactory extends SingleLazyInstanceSyntaxHighlighterFactory { + @NotNull + protected SyntaxHighlighter createHighlighter() { + return new XmlFileHighlighter(); + } +} diff --git a/xml/impl/src/com/intellij/lexer/BaseHtmlLexer.java b/xml/impl/src/com/intellij/lexer/BaseHtmlLexer.java index 20f3a5a47e25..80ac2a3129e3 100644 --- a/xml/impl/src/com/intellij/lexer/BaseHtmlLexer.java +++ b/xml/impl/src/com/intellij/lexer/BaseHtmlLexer.java @@ -156,6 +156,12 @@ abstract class BaseHtmlLexer extends DelegateLexer { } @Nullable + protected Language getScriptLanguage() { + Collection<Language> instancesByMimeType = Language.findInstancesByMimeType(scriptType != null ? scriptType.trim() : null); + return instancesByMimeType.isEmpty() ? null : instancesByMimeType.iterator().next(); + } + + @Nullable protected IElementType getCurrentScriptElementType() { HtmlScriptContentProvider scriptContentProvider = findScriptContentProvider(scriptType); return scriptContentProvider == null ? null : scriptContentProvider.getScriptElementType(); diff --git a/xml/impl/src/com/intellij/lexer/HtmlLexer.java b/xml/impl/src/com/intellij/lexer/HtmlLexer.java index ea5126b2ba05..a1dd51a45b3e 100644 --- a/xml/impl/src/com/intellij/lexer/HtmlLexer.java +++ b/xml/impl/src/com/intellij/lexer/HtmlLexer.java @@ -20,6 +20,7 @@ import com.intellij.lang.Language; import com.intellij.lang.LanguageHtmlInlineScriptTokenTypesProvider; import com.intellij.openapi.extensions.Extensions; import com.intellij.psi.TokenType; +import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.psi.tree.IElementType; import com.intellij.psi.xml.XmlTokenType; @@ -75,7 +76,9 @@ public class HtmlLexer extends BaseHtmlLexer { tokenType = ourInlineStyleElementType; } } else if (hasSeenScript()) { - if (hasSeenTag() && isStartOfEmbeddmentTagContent(tokenType)) { + Language scriptLanguage = getScriptLanguage(); + boolean canInject = scriptLanguage == null || InjectedLanguageUtil.isInjectableLanguage(scriptLanguage); + if (hasSeenTag() && isStartOfEmbeddmentTagContent(tokenType) && canInject) { myTokenEnd = skipToTheEndOfTheEmbeddment(); IElementType currentScriptElementType = getCurrentScriptElementType(); tokenType = currentScriptElementType == null ? XmlTokenType.XML_DATA_CHARACTERS : currentScriptElementType; diff --git a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlAttributeSetImpl.java b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlAttributeSetImpl.java index df7ac29de0a4..2f9f08e4a7e0 100644 --- a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlAttributeSetImpl.java +++ b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlAttributeSetImpl.java @@ -18,7 +18,6 @@ package com.intellij.pom.xml.impl.events; import com.intellij.pom.PomModel; import com.intellij.pom.event.PomModelEvent; import com.intellij.pom.xml.XmlAspect; -import com.intellij.pom.xml.XmlChangeVisitor; import com.intellij.pom.xml.events.XmlAttributeSet; import com.intellij.pom.xml.impl.XmlAspectChangeSetImpl; import com.intellij.psi.util.PsiTreeUtil; @@ -60,8 +59,4 @@ public class XmlAttributeSetImpl implements XmlAttributeSet { public String toString() { return "Attribute \"" + getName() + "\" for tag \"" + getTag().getName() + "\" set to \"" + getValue() + "\""; } - - public void accept(XmlChangeVisitor visitor) { - visitor.visitXmlAttributeSet(this); - } } diff --git a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlDocumentChangedImpl.java b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlDocumentChangedImpl.java index 508831b47b0e..8c1ce7e448f9 100644 --- a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlDocumentChangedImpl.java +++ b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlDocumentChangedImpl.java @@ -18,7 +18,6 @@ package com.intellij.pom.xml.impl.events; import com.intellij.pom.PomModel; import com.intellij.pom.event.PomModelEvent; import com.intellij.pom.xml.XmlAspect; -import com.intellij.pom.xml.XmlChangeVisitor; import com.intellij.pom.xml.events.XmlDocumentChanged; import com.intellij.pom.xml.impl.XmlAspectChangeSetImpl; import com.intellij.psi.xml.XmlDocument; @@ -48,8 +47,4 @@ public class XmlDocumentChangedImpl implements XmlDocumentChanged { public String toString() { return "Xml document changed"; } - - public void accept(XmlChangeVisitor visitor) { - visitor.visitDocumentChanged(this); - } } diff --git a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlElementChangedImpl.java b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlElementChangedImpl.java index 50b1632fc013..6c694ac7b365 100644 --- a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlElementChangedImpl.java +++ b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlElementChangedImpl.java @@ -15,7 +15,6 @@ */ package com.intellij.pom.xml.impl.events; -import com.intellij.pom.xml.XmlChangeVisitor; import com.intellij.pom.xml.events.XmlElementChanged; import com.intellij.psi.xml.XmlElement; @@ -30,10 +29,6 @@ public class XmlElementChangedImpl implements XmlElementChanged { return myElement; } - public void accept(XmlChangeVisitor visitor) { - visitor.visitXmlElementChanged(this); - } - public String toString() { return "Xml element changed: " + myElement; } diff --git a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildAddImpl.java b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildAddImpl.java index 3ee06ba99d3c..21024aa15bbc 100644 --- a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildAddImpl.java +++ b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildAddImpl.java @@ -15,7 +15,6 @@ */ package com.intellij.pom.xml.impl.events; -import com.intellij.pom.xml.XmlChangeVisitor; import com.intellij.pom.xml.events.XmlTagChildAdd; import com.intellij.psi.xml.XmlTag; import com.intellij.psi.xml.XmlTagChild; @@ -40,8 +39,4 @@ public class XmlTagChildAddImpl implements XmlTagChildAdd { public String toString() { return "child added to " + getTag().getName() + " child: " + myChild.toString(); } - - public void accept(XmlChangeVisitor visitor) { - visitor.visitXmlTagChildAdd(this); - } } diff --git a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildChangedImpl.java b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildChangedImpl.java index 2568cb945946..0550fcd24232 100644 --- a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildChangedImpl.java +++ b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildChangedImpl.java @@ -18,11 +18,8 @@ package com.intellij.pom.xml.impl.events; import com.intellij.pom.PomModel; import com.intellij.pom.event.PomModelEvent; import com.intellij.pom.xml.XmlAspect; -import com.intellij.pom.xml.XmlChangeVisitor; -import com.intellij.pom.xml.events.XmlChange; import com.intellij.pom.xml.events.XmlTagChildChanged; import com.intellij.pom.xml.impl.XmlAspectChangeSetImpl; -import com.intellij.pom.xml.XmlChangeVisitor; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; @@ -55,8 +52,4 @@ public class XmlTagChildChangedImpl implements XmlTagChildChanged { public String toString() { return "child changed in " + getTag().getName() + " child: " + myChild.toString(); } - - public void accept(XmlChangeVisitor visitor) { - visitor.visitXmlTagChildChanged(this); - } } diff --git a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildRemovedImpl.java b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildRemovedImpl.java index dd92cac98792..63e9336059eb 100644 --- a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildRemovedImpl.java +++ b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildRemovedImpl.java @@ -15,7 +15,6 @@ */ package com.intellij.pom.xml.impl.events; -import com.intellij.pom.xml.XmlChangeVisitor; import com.intellij.pom.xml.events.XmlTagChildRemoved; import com.intellij.psi.xml.XmlTag; import com.intellij.psi.xml.XmlTagChild; @@ -40,8 +39,4 @@ public class XmlTagChildRemovedImpl implements XmlTagChildRemoved { public String toString() { return "child removed from " + getTag().getName() + " child: " + myChild.toString(); } - - public void accept(XmlChangeVisitor visitor) { - visitor.visitXmlTagChildRemoved(this); - } } diff --git a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagNameChangedImpl.java b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagNameChangedImpl.java index 3457fe141466..db972eb8536d 100644 --- a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagNameChangedImpl.java +++ b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagNameChangedImpl.java @@ -19,7 +19,6 @@ import com.intellij.pom.PomModel; import com.intellij.pom.event.PomModelEvent; import com.intellij.pom.xml.XmlAspect; import com.intellij.pom.xml.impl.XmlAspectChangeSetImpl; -import com.intellij.pom.xml.XmlChangeVisitor; import com.intellij.pom.xml.events.XmlTagNameChanged; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.XmlFile; @@ -54,8 +53,4 @@ public class XmlTagNameChangedImpl implements XmlTagNameChanged { public String toString() { return "tag name changed to " + getTag().getName() + " was: " + getOldName(); } - - public void accept(XmlChangeVisitor visitor) { - visitor.visitXmlTagNameChanged(this); - } } diff --git a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTextChangedImpl.java b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTextChangedImpl.java index b191996f54e6..78fa37e03b49 100644 --- a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTextChangedImpl.java +++ b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTextChangedImpl.java @@ -19,10 +19,8 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.pom.PomModel; import com.intellij.pom.event.PomModelEvent; import com.intellij.pom.xml.XmlAspect; -import com.intellij.pom.xml.events.XmlChange; import com.intellij.pom.xml.events.XmlTextChanged; import com.intellij.pom.xml.impl.XmlAspectChangeSetImpl; -import com.intellij.pom.xml.XmlChangeVisitor; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlText; @@ -56,8 +54,4 @@ public class XmlTextChangedImpl implements XmlTextChanged { return "text changed to '" + StringUtil.escapeStringCharacters(myText.getValue()) + "' was: '" + StringUtil.escapeStringCharacters(myOldText) + "'"; } - - public void accept(XmlChangeVisitor visitor) { - visitor.visitXmlTextChanged(this); - } } diff --git a/xml/impl/src/com/intellij/psi/impl/source/html/HtmlScriptLanguageInjector.java b/xml/impl/src/com/intellij/psi/impl/source/html/HtmlScriptLanguageInjector.java index e24c100f9f49..3dbcc25cecb5 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/html/HtmlScriptLanguageInjector.java +++ b/xml/impl/src/com/intellij/psi/impl/source/html/HtmlScriptLanguageInjector.java @@ -16,13 +16,16 @@ package com.intellij.psi.impl.source.html; import com.intellij.lang.Language; +import com.intellij.lang.StdLanguages; import com.intellij.lang.injection.MultiHostInjector; import com.intellij.lang.injection.MultiHostRegistrar; import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiLanguageInjectionHost; +import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.psi.xml.XmlTag; import com.intellij.psi.xml.XmlText; +import com.intellij.xml.util.HtmlUtil; import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -32,7 +35,7 @@ import java.util.List; public class HtmlScriptLanguageInjector implements MultiHostInjector { @Override public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement host) { - if (!(host instanceof XmlText)) { + if (!(host instanceof XmlText) || !HtmlUtil.isHtmlTagContainingFile(host)) { return; } XmlTag scriptTag = ((XmlText)host).getParentTag(); @@ -41,9 +44,10 @@ public class HtmlScriptLanguageInjector implements MultiHostInjector { } String mimeType = scriptTag.getAttributeValue("type"); Collection<Language> languages = Language.findInstancesByMimeType(mimeType); - if (!languages.isEmpty()) { + Language language = languages.isEmpty() ? StdLanguages.TEXT : languages.iterator().next(); + if (InjectedLanguageUtil.isInjectableLanguage(language)) { registrar - .startInjecting(languages.iterator().next()) + .startInjecting(language) .addPlace(null, null, (PsiLanguageInjectionHost)host, TextRange.create(0, host.getTextLength())) .doneInjecting(); } diff --git a/xml/impl/src/com/intellij/psi/impl/source/html/dtd/HtmlAttributeDescriptorImpl.java b/xml/impl/src/com/intellij/psi/impl/source/html/dtd/HtmlAttributeDescriptorImpl.java index 75f8ae526b88..445a5503a855 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/html/dtd/HtmlAttributeDescriptorImpl.java +++ b/xml/impl/src/com/intellij/psi/impl/source/html/dtd/HtmlAttributeDescriptorImpl.java @@ -85,4 +85,9 @@ public class HtmlAttributeDescriptorImpl implements XmlAttributeDescriptor { public Object[] getDependences() { return ArrayUtil.EMPTY_OBJECT_ARRAY; } + + @Override + public String toString() { + return delegate.toString(); + } } diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/LanguageXmlPsiPolicy.java b/xml/impl/src/com/intellij/psi/impl/source/xml/LanguageXmlPsiPolicy.java new file mode 100644 index 000000000000..a67b4603cb6a --- /dev/null +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/LanguageXmlPsiPolicy.java @@ -0,0 +1,15 @@ +package com.intellij.psi.impl.source.xml; + +import com.intellij.lang.LanguageExtension; +import com.intellij.psi.impl.source.xml.behavior.CDATAOnAnyEncodedPolicy; + +/** + * @author yole + */ +public class LanguageXmlPsiPolicy extends LanguageExtension<XmlPsiPolicy> { + public static LanguageXmlPsiPolicy INSTANCE = new LanguageXmlPsiPolicy(); + + private LanguageXmlPsiPolicy() { + super("com.intellij.xml.psiPolicy", new CDATAOnAnyEncodedPolicy()); + } +} diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java b/xml/impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java index 3f01ad53da9d..1c4498e025d1 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java @@ -338,7 +338,7 @@ public class TagNameReference implements PsiReference { } else{ // Don't use default namespace in case there are other namespaces in scope - // If there are tags from default namespace they will be handeled via + // If there are tags from default namespace they will be handled via // their element descriptors (prev if section) if (namespace == null) return; if(namespace.length() == 0 && !visited.isEmpty()) return; diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java index d3caa299f3c1..2accea933892 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java @@ -416,8 +416,6 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute { return setName(newName); } - // TODO[ik]: namespace support - public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException { if (element instanceof PsiMetaOwner) { final PsiMetaOwner owner = (PsiMetaOwner)element; @@ -475,7 +473,8 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute { if (separator > 0) { element = element.withLookupString(name.substring(separator + 1)); } - variants.add(element.withCaseSensitivity(caseSensitive).withInsertHandler(XmlAttributeInsertHandler.INSTANCE)); + element = element.withCaseSensitivity(caseSensitive).withInsertHandler(XmlAttributeInsertHandler.INSTANCE); + variants.add(descriptor.isRequired() ? PrioritizedLookupElement.withPriority(element.appendTailText("(required)", true), 100) : element); } } } @@ -483,7 +482,7 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute { private boolean isValidVariant(@NotNull XmlAttributeDescriptor descriptor, final XmlAttribute[] attributes, final XmlExtension extension) { if (extension.isIndirectSyntax(descriptor)) return false; - String descriptorName = descriptor.getName(); + String descriptorName = descriptor.getName(getParent()); if (descriptorName == null) { LOG.error("Null descriptor name for " + descriptor + " " + descriptor.getClass() + " "); return false; diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlConditionalSectionImpl.java b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlConditionalSectionImpl.java index 426e221d50c4..26c0bec1f622 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlConditionalSectionImpl.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlConditionalSectionImpl.java @@ -52,7 +52,7 @@ public class XmlConditionalSectionImpl extends XmlElementImpl implements XmlCond final String text = xmlEntityRef.getText(); String name = text.substring(1,text.length() - 1); - PsiElement psiElement = targetFile != null ? XmlEntityRefImpl.getCachedEntity( targetFile, name): null; + PsiElement psiElement = targetFile != null ? XmlEntityCache.getCachedEntity(targetFile, name): null; if (psiElement instanceof XmlEntityDecl) { final XmlEntityDecl decl = (XmlEntityDecl)psiElement; diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlContentDFA.java b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlContentDFA.java index cf49e5ae339c..60b5584db01f 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlContentDFA.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlContentDFA.java @@ -15,6 +15,7 @@ */ package com.intellij.psi.impl.source.xml; +import com.intellij.psi.templateLanguages.TemplateLanguageUtil; import com.intellij.psi.xml.XmlTag; import com.intellij.xml.XmlElementDescriptor; import org.jetbrains.annotations.NotNull; @@ -33,6 +34,9 @@ public abstract class XmlContentDFA { @Nullable public static XmlContentDFA getContentDFA(@NotNull XmlTag parentTag) { + + if (TemplateLanguageUtil.isInsideTemplateFile(parentTag)) return null; + XmlContentDFA contentDFA = XsContentDFA.createContentDFA(parentTag); if (contentDFA != null) return contentDFA; return XmlContentDFAImpl.createContentDFA(parentTag); diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java index 45b65260a5cc..6d32e94f03aa 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java @@ -15,7 +15,7 @@ */ package com.intellij.psi.impl.source.xml; -import com.intellij.openapi.fileTypes.StdFileTypes; +import com.intellij.ide.highlighter.DTDFileType; import com.intellij.openapi.util.Key; import com.intellij.psi.*; import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry; @@ -33,7 +33,6 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -41,7 +40,6 @@ import java.util.Map; * @author mike */ public class XmlEntityRefImpl extends XmlElementImpl implements XmlEntityRef { - private static final Key<Map<String,CachedValue<XmlEntityDecl>>> XML_ENTITY_DECL_MAP = Key.create("XML_ENTITY_DECL_MAP"); @NonNls private static final String GT_ENTITY = ">"; @NonNls private static final String QUOT_ENTITY = """; @@ -57,37 +55,6 @@ public class XmlEntityRefImpl extends XmlElementImpl implements XmlEntityRef { return resolveEntity(this, text, targetFile); } - public static XmlEntityDecl getCachedEntity(PsiFile file, String name) { - CachedValue<XmlEntityDecl> cachedValue; - synchronized(PsiLock.LOCK) { - final Map<String, CachedValue<XmlEntityDecl>> cachingMap = getCachingMap(file); - cachedValue = cachingMap.get(name); - } - return cachedValue != null ? cachedValue.getValue():null; - } - - public static void cacheParticularEntity(PsiFile file, XmlEntityDecl decl) { - synchronized(PsiLock.LOCK) { - final Map<String, CachedValue<XmlEntityDecl>> cachingMap = getCachingMap(file); - final String name = decl.getName(); - if (cachingMap.containsKey(name)) return; - final SmartPsiElementPointer declPointer = SmartPointerManager.getInstance(file.getProject()).createSmartPsiElementPointer(decl); - - cachingMap.put( - name, CachedValuesManager.getManager(file.getProject()).createCachedValue(new CachedValueProvider<XmlEntityDecl>() { - public Result<XmlEntityDecl> compute() { - PsiElement declElement = declPointer.getElement(); - if (declElement instanceof XmlEntityDecl && declElement.isValid() && name.equals(((XmlEntityDecl)declElement).getName())) - return new Result<XmlEntityDecl>((XmlEntityDecl)declElement, declElement); - cachingMap.put(name,null); - return new Result<XmlEntityDecl>(null,null); - } - }, - false - )); - } - } - public static XmlEntityDecl resolveEntity(final XmlElement element, final String text, PsiFile targetFile) { if (targetFile instanceof XmlFile) { XmlDocument document = ((XmlFile)targetFile).getDocument(); @@ -99,7 +66,7 @@ public class XmlEntityRefImpl extends XmlElementImpl implements XmlEntityRef { final PsiElement targetElement = targetFile != null ? targetFile : element; CachedValue<XmlEntityDecl> value; synchronized(PsiLock.LOCK) { - Map<String, CachedValue<XmlEntityDecl>> map = getCachingMap(targetElement); + Map<String, CachedValue<XmlEntityDecl>> map = XmlEntityCache.getCachingMap(targetElement); value = map.get(entityName); final PsiFile containingFile = element.getContainingFile(); @@ -122,15 +89,6 @@ public class XmlEntityRefImpl extends XmlElementImpl implements XmlEntityRef { return value.getValue(); } - private static Map<String, CachedValue<XmlEntityDecl>> getCachingMap(final PsiElement targetElement) { - Map<String, CachedValue<XmlEntityDecl>> map = targetElement.getUserData(XML_ENTITY_DECL_MAP); - if (map == null){ - map = new HashMap<String,CachedValue<XmlEntityDecl>>(); - targetElement.putUserData(XML_ENTITY_DECL_MAP, map); - } - return map; - } - private static final Key<Boolean> DISABLE_ENTITY_EXPAND = Key.create("disable.entity.expand"); private static CachedValueProvider.Result<XmlEntityDecl> resolveEntity(final PsiElement targetElement, final String entityName, PsiFile contextFile) { @@ -188,7 +146,7 @@ public class XmlEntityRefImpl extends XmlElementImpl implements XmlEntityRef { if (notfound && // no dtd ref at all targetElement instanceof XmlFile && deps.size() == 1 && - ((XmlFile)targetElement).getFileType() != StdFileTypes.DTD + ((XmlFile)targetElement).getFileType() != DTDFileType.INSTANCE ) { XmlDocument document = ((XmlFile)targetElement).getDocument(); final XmlTag rootTag = document.getRootTag(); @@ -253,16 +211,6 @@ public class XmlEntityRefImpl extends XmlElementImpl implements XmlEntityRef { } } - public static void copyEntityCaches(final PsiFile file, final PsiFile context) { - synchronized (PsiLock.LOCK) { - final Map<String, CachedValue<XmlEntityDecl>> cachingMap = getCachingMap(file); - for(Map.Entry<String,CachedValue<XmlEntityDecl>> entry:getCachingMap(context).entrySet()) { - cachingMap.put(entry.getKey(), entry.getValue()); - } - } - - } - public static void setNoEntityExpandOutOfDocument(XmlDocument doc, boolean b) { if (b) doc.putUserData(DISABLE_ENTITY_EXPAND, Boolean.TRUE); else doc.putUserData(DISABLE_ENTITY_EXPAND, null); diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlTextImpl.java b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlTextImpl.java index b33ae845abb0..b3806b606028 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlTextImpl.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlTextImpl.java @@ -18,7 +18,6 @@ package com.intellij.psi.impl.source.xml; import com.intellij.lang.ASTFactory; import com.intellij.lang.ASTNode; import com.intellij.lang.injection.InjectedLanguageManager; -import com.intellij.lang.xml.XMLLanguage; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; @@ -228,7 +227,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI } private XmlPsiPolicy getPolicy() { - return ((XMLLanguage)getLanguage()).getPsiPolicy(); + return LanguageXmlPsiPolicy.INSTANCE.forLanguage(getLanguage()); } public void insertText(String text, int displayOffset) throws IncorrectOperationException { diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java b/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java index 3aff250f2d54..31d51ac55ef7 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java @@ -45,6 +45,7 @@ import org.apache.xerces.xs.XSTypeDefinition; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; @@ -182,7 +183,22 @@ class XsContentDFA extends XmlContentDFA { return parser; } }; - handler.setErrorReporter(handler.new TestErrorReporter()); + handler.setErrorReporter(handler.new ErrorReporter() { + + int count; + @Override + public void processError(SAXParseException ex, ValidateXmlActionHandler.ProblemType warning) throws SAXException { + if (warning != ValidateXmlActionHandler.ProblemType.WARNING && count++ > 100) { + throw new SAXException(ex); + } + } + + @Override + public boolean isUniqueProblem(SAXParseException e) { + return true; + } + }); + handler.doValidate(file); XMLGrammarPool grammarPool = ValidateXmlActionHandler.getGrammarPool(file); if (grammarPool == null) { diff --git a/xml/impl/src/com/intellij/xml/actions/GenerateXmlTagAction.java b/xml/impl/src/com/intellij/xml/actions/GenerateXmlTagAction.java index ff74f8f335a7..25d0248ce6eb 100644 --- a/xml/impl/src/com/intellij/xml/actions/GenerateXmlTagAction.java +++ b/xml/impl/src/com/intellij/xml/actions/GenerateXmlTagAction.java @@ -16,6 +16,7 @@ package com.intellij.xml.actions; import com.intellij.codeInsight.CodeInsightUtilBase; +import com.intellij.codeInsight.CodeInsightUtilCore; import com.intellij.codeInsight.actions.SimpleCodeInsightAction; import com.intellij.codeInsight.hint.HintManager; import com.intellij.codeInsight.lookup.impl.LookupCellRenderer; @@ -103,7 +104,7 @@ public class GenerateXmlTagAction extends SimpleCodeInsightAction { int offset = editor.getCaretModel().getOffset(); Document document = editor.getDocument(); document.insertString(offset, newTag.getText()); - PsiDocumentManager.getInstance(getProject()).commitDocument(document); + PsiDocumentManager.getInstance(project).commitDocument(document); newTag = PsiTreeUtil.getParentOfType(file.findElementAt(offset + 1), XmlTag.class, false); } else { @@ -170,7 +171,7 @@ public class GenerateXmlTagAction extends SimpleCodeInsightAction { public static void generateTag(XmlTag newTag) { generateRaw(newTag); - final XmlTag restored = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(newTag); + final XmlTag restored = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(newTag); if (restored == null) { LOG.error("Could not restore tag: " + newTag.getText()); } diff --git a/xml/impl/src/com/intellij/xml/actions/ValidateXmlActionHandler.java b/xml/impl/src/com/intellij/xml/actions/ValidateXmlActionHandler.java index aa7a8ae8bbd6..d413af047c16 100644 --- a/xml/impl/src/com/intellij/xml/actions/ValidateXmlActionHandler.java +++ b/xml/impl/src/com/intellij/xml/actions/ValidateXmlActionHandler.java @@ -108,9 +108,11 @@ public class ValidateXmlActionHandler { return null; } + public enum ProblemType { WARNING, ERROR, FATAL } + public abstract class ErrorReporter { protected final Set<String> ourErrorsSet = new HashSet<String>(); - public abstract void processError(SAXParseException ex,boolean warning); + public abstract void processError(SAXParseException ex, ProblemType warning) throws SAXException; public boolean filterValidationException(Exception ex) { if (ex instanceof ProcessCanceledException) throw (ProcessCanceledException)ex; @@ -172,7 +174,7 @@ public class ValidateXmlActionHandler { return errors.add(ex.getMessage()); } - public void processError(SAXParseException ex, boolean warning) { + public void processError(SAXParseException ex, ProblemType warning) { errors.add(buildMessageString(ex)); } @@ -267,7 +269,7 @@ public class ValidateXmlActionHandler { } } - public void processError(final SAXParseException ex, final boolean warning) { + public void processError(final SAXParseException ex, final ProblemType problemType) { if (LOG.isDebugEnabled()) { String error = buildMessageString(ex); LOG.debug("enter: processError(error='" + error + "')"); @@ -281,7 +283,7 @@ public class ValidateXmlActionHandler { public void run() { final VirtualFile file = getFile(ex.getPublicId(), ex.getSystemId()); myErrorsView.addMessage( - warning ? MessageCategory.WARNING : MessageCategory.ERROR, + problemType == ProblemType.WARNING ? MessageCategory.WARNING : MessageCategory.ERROR, new String[]{ex.getLocalizedMessage()}, file, ex.getLineNumber() - 1, @@ -383,16 +385,16 @@ public class ValidateXmlActionHandler { private void doParse() { try { myParser.parse(new InputSource(new StringReader(myFile.getText())), new DefaultHandler() { - public void warning(SAXParseException e) { - if (myErrorReporter.isUniqueProblem(e)) myErrorReporter.processError(e, true); + public void warning(SAXParseException e) throws SAXException { + if (myErrorReporter.isUniqueProblem(e)) myErrorReporter.processError(e, ProblemType.WARNING); } - public void error(SAXParseException e) { - if (myErrorReporter.isUniqueProblem(e)) myErrorReporter.processError(e, false); + public void error(SAXParseException e) throws SAXException { + if (myErrorReporter.isUniqueProblem(e)) myErrorReporter.processError(e, ProblemType.ERROR); } - public void fatalError(SAXParseException e) { - if (myErrorReporter.isUniqueProblem(e)) myErrorReporter.processError(e, false); + public void fatalError(SAXParseException e) throws SAXException { + if (myErrorReporter.isUniqueProblem(e)) myErrorReporter.processError(e, ProblemType.FATAL); } public InputSource resolveEntity(String publicId, String systemId) { diff --git a/xml/impl/src/com/intellij/xml/arrangement/XmlRearranger.java b/xml/impl/src/com/intellij/xml/arrangement/XmlRearranger.java index c167236ae7d8..add2e0d87a5d 100644 --- a/xml/impl/src/com/intellij/xml/arrangement/XmlRearranger.java +++ b/xml/impl/src/com/intellij/xml/arrangement/XmlRearranger.java @@ -34,7 +34,7 @@ public class XmlRearranger private static final Set<ArrangementSettingsToken> SUPPORTED_TYPES = ContainerUtilRt.newLinkedHashSet(XML_TAG, XML_ATTRIBUTE); private static final List<StdArrangementMatchRule> DEFAULT_MATCH_RULES = new ArrayList<StdArrangementMatchRule>(); - private static final StdArrangementSettings DEFAULT_SETTINGS = new StdArrangementSettings( + private static final StdArrangementSettings DEFAULT_SETTINGS = new StdRulePriorityAwareSettings( Collections.<ArrangementGroupingRule>emptyList(), DEFAULT_MATCH_RULES); @Nullable diff --git a/xml/impl/src/com/intellij/xml/impl/BasicXmlAttributeDescriptor.java b/xml/impl/src/com/intellij/xml/impl/BasicXmlAttributeDescriptor.java index 020baa8205b1..1aa72c3f7ffc 100644 --- a/xml/impl/src/com/intellij/xml/impl/BasicXmlAttributeDescriptor.java +++ b/xml/impl/src/com/intellij/xml/impl/BasicXmlAttributeDescriptor.java @@ -73,4 +73,9 @@ public abstract class BasicXmlAttributeDescriptor implements XmlAttributeDescrip public boolean isEnumerated(@Nullable XmlElement context) { return isEnumerated(); } + + @Override + public String toString() { + return getName(); + } } diff --git a/xml/impl/src/com/intellij/xml/impl/ExternalDocumentValidator.java b/xml/impl/src/com/intellij/xml/impl/ExternalDocumentValidator.java index e8371ca0b881..5c4ed10b0228 100644 --- a/xml/impl/src/com/intellij/xml/impl/ExternalDocumentValidator.java +++ b/xml/impl/src/com/intellij/xml/impl/ExternalDocumentValidator.java @@ -129,7 +129,7 @@ public class ExternalDocumentValidator { return true; } - public void processError(final SAXParseException e, final boolean warning) { + public void processError(final SAXParseException e, final ValidateXmlActionHandler.ProblemType warning) { try { ApplicationManager.getApplication().runReadAction(new Runnable() { public void run() { @@ -146,6 +146,7 @@ public class ExternalDocumentValidator { return; } + int problemType = getProblemType(warning); int offset = Math.max(0, document.getLineStartOffset(e.getLineNumber() - 1) + e.getColumnNumber() - 2); if (offset >= document.getTextLength()) return; PsiElement currentElement = PsiDocumentManager.getInstance(project).getPsiFile(document).findElementAt(offset); @@ -179,70 +180,72 @@ public class ExternalDocumentValidator { //return; } else if (localizedMessage.startsWith(VALUE_ERROR_PREFIX)) { addProblemToTagName(currentElement, originalElement, localizedMessage, warning); - } else if (messageId.startsWith(ATTRIBUTE_MESSAGE_PREFIX)) { - @NonNls String prefix = "of attribute "; - final int i = localizedMessage.indexOf(prefix); - - if (i != -1) { - int messagePrefixLength = prefix.length() + i; - final int nextQuoteIndex = localizedMessage.indexOf(localizedMessage.charAt(messagePrefixLength), messagePrefixLength + 1); - String attrName = nextQuoteIndex == -1 ? null : localizedMessage.substring(messagePrefixLength + 1, nextQuoteIndex); - - XmlTag parent = PsiTreeUtil.getParentOfType(originalElement,XmlTag.class); - currentElement = parent.getAttribute(attrName,null); - - if (currentElement != null) { - currentElement = ((XmlAttribute)currentElement).getValueElement(); + } else { + if (messageId.startsWith(ATTRIBUTE_MESSAGE_PREFIX)) { + @NonNls String prefix = "of attribute "; + final int i = localizedMessage.indexOf(prefix); + + if (i != -1) { + int messagePrefixLength = prefix.length() + i; + final int nextQuoteIndex = localizedMessage.indexOf(localizedMessage.charAt(messagePrefixLength), messagePrefixLength + 1); + String attrName = nextQuoteIndex == -1 ? null : localizedMessage.substring(messagePrefixLength + 1, nextQuoteIndex); + + XmlTag parent = PsiTreeUtil.getParentOfType(originalElement,XmlTag.class); + currentElement = parent.getAttribute(attrName,null); + + if (currentElement != null) { + currentElement = ((XmlAttribute)currentElement).getValueElement(); + } } - } - if (currentElement!=null) { - assertValidElement(currentElement, originalElement,localizedMessage); - myHost.addMessage(currentElement,localizedMessage,warning ? Validator.ValidationHost.WARNING:Validator.ValidationHost.ERROR); - } else { - addProblemToTagName(originalElement, originalElement, localizedMessage, warning); + if (currentElement!=null) { + assertValidElement(currentElement, originalElement,localizedMessage); + myHost.addMessage(currentElement,localizedMessage, problemType); + } else { + addProblemToTagName(originalElement, originalElement, localizedMessage, warning); + } } - } - else if (localizedMessage.startsWith(ATTRIBUTE_ERROR_PREFIX)) { - final int messagePrefixLength = ATTRIBUTE_ERROR_PREFIX.length(); - - if ( localizedMessage.charAt(messagePrefixLength) == '"' || - localizedMessage.charAt(messagePrefixLength) == '\'' - ) { - // extract the attribute name from message and get it from tag! - final int nextQuoteIndex = localizedMessage.indexOf(localizedMessage.charAt(messagePrefixLength), messagePrefixLength + 1); - String attrName = nextQuoteIndex == -1 ? null : localizedMessage.substring(messagePrefixLength + 1, nextQuoteIndex); - - XmlTag parent = PsiTreeUtil.getParentOfType(originalElement,XmlTag.class); - currentElement = parent.getAttribute(attrName,null); + else if (localizedMessage.startsWith(ATTRIBUTE_ERROR_PREFIX)) { + final int messagePrefixLength = ATTRIBUTE_ERROR_PREFIX.length(); + + if ( localizedMessage.charAt(messagePrefixLength) == '"' || + localizedMessage.charAt(messagePrefixLength) == '\'' + ) { + // extract the attribute name from message and get it from tag! + final int nextQuoteIndex = localizedMessage.indexOf(localizedMessage.charAt(messagePrefixLength), messagePrefixLength + 1); + String attrName = nextQuoteIndex == -1 ? null : localizedMessage.substring(messagePrefixLength + 1, nextQuoteIndex); + + XmlTag parent = PsiTreeUtil.getParentOfType(originalElement,XmlTag.class); + currentElement = parent.getAttribute(attrName,null); + + if (currentElement!=null) { + currentElement = SourceTreeToPsiMap.treeElementToPsi( + XmlChildRole.ATTRIBUTE_NAME_FINDER.findChild( + SourceTreeToPsiMap.psiElementToTree(currentElement) + ) + ); + } + } else { + currentElement = PsiTreeUtil.getParentOfType(currentElement, XmlTag.class, false); + } if (currentElement!=null) { - currentElement = SourceTreeToPsiMap.treeElementToPsi( - XmlChildRole.ATTRIBUTE_NAME_FINDER.findChild( - SourceTreeToPsiMap.psiElementToTree(currentElement) - ) - ); + assertValidElement(currentElement, originalElement,localizedMessage); + myHost.addMessage(currentElement,localizedMessage, problemType); + } else { + addProblemToTagName(originalElement, originalElement, localizedMessage, warning); + } + } else if (localizedMessage.startsWith(STRING_ERROR_PREFIX)) { + if (currentElement != null) { + myHost.addMessage(currentElement,localizedMessage,Validator.ValidationHost.WARNING); } - } else { - currentElement = PsiTreeUtil.getParentOfType(currentElement, XmlTag.class, false); } - - if (currentElement!=null) { + else { + currentElement = getNodeForMessage(currentElement != null ? currentElement:originalElement); assertValidElement(currentElement, originalElement,localizedMessage); - myHost.addMessage(currentElement,localizedMessage,warning ? Validator.ValidationHost.WARNING:Validator.ValidationHost.ERROR); - } else { - addProblemToTagName(originalElement, originalElement, localizedMessage, warning); - } - } else if (localizedMessage.startsWith(STRING_ERROR_PREFIX)) { - if (currentElement != null) { - myHost.addMessage(currentElement,localizedMessage,Validator.ValidationHost.WARNING); - } - } - else { - currentElement = getNodeForMessage(currentElement != null ? currentElement:originalElement); - assertValidElement(currentElement, originalElement,localizedMessage); - if (currentElement!=null) { - myHost.addMessage(currentElement,localizedMessage,warning ? Validator.ValidationHost.WARNING:Validator.ValidationHost.ERROR); + if (currentElement!=null) { + myHost.addMessage(currentElement,localizedMessage, problemType); + } } } } @@ -266,6 +269,10 @@ public class ExternalDocumentValidator { addAllInfos(host,results); } + private int getProblemType(ValidateXmlActionHandler.ProblemType warning) { + return warning == ValidateXmlActionHandler.ProblemType.WARNING ? Validator.ValidationHost.WARNING : Validator.ValidationHost.ERROR; + } + private static PsiElement getNodeForMessage(final PsiElement currentElement) { PsiElement parentOfType = PsiTreeUtil.getNonStrictParentOfType( currentElement, @@ -297,7 +304,7 @@ public class ExternalDocumentValidator { private PsiElement addProblemToTagName(PsiElement currentElement, final PsiElement originalElement, final String localizedMessage, - final boolean warning) { + final ValidateXmlActionHandler.ProblemType problemType) { currentElement = PsiTreeUtil.getParentOfType(currentElement,XmlTag.class,false); if (currentElement==null) { currentElement = PsiTreeUtil.getParentOfType(originalElement,XmlElementDecl.class,false); @@ -308,7 +315,7 @@ public class ExternalDocumentValidator { assertValidElement(currentElement, originalElement,localizedMessage); if (currentElement!=null) { - myHost.addMessage(currentElement,localizedMessage,warning ? Validator.ValidationHost.WARNING:Validator.ValidationHost.ERROR); + myHost.addMessage(currentElement,localizedMessage, getProblemType(problemType)); } return currentElement; diff --git a/xml/impl/src/com/intellij/xml/impl/schema/XmlAttributeDescriptorImpl.java b/xml/impl/src/com/intellij/xml/impl/schema/XmlAttributeDescriptorImpl.java index 24591d37c2be..195449b9ef02 100644 --- a/xml/impl/src/com/intellij/xml/impl/schema/XmlAttributeDescriptorImpl.java +++ b/xml/impl/src/com/intellij/xml/impl/schema/XmlAttributeDescriptorImpl.java @@ -243,9 +243,4 @@ public class XmlAttributeDescriptorImpl extends BasicXmlAttributeDescriptor impl public void setName(String name) throws IncorrectOperationException { NamedObjectDescriptor.setName(myTag, name); } - - @Override - public String toString() { - return getName(); - } } diff --git a/xml/impl/src/com/intellij/xml/index/XmlNamespaceIndex.java b/xml/impl/src/com/intellij/xml/index/XmlNamespaceIndex.java index 6e07c9447009..62e66f46b247 100644 --- a/xml/impl/src/com/intellij/xml/index/XmlNamespaceIndex.java +++ b/xml/impl/src/com/intellij/xml/index/XmlNamespaceIndex.java @@ -194,6 +194,36 @@ public class XmlNamespaceIndex extends XmlIndex<XsdNamespaceBuilder> { String dtdFileName = new File(dtdUri).getName(); List<IndexedRelevantResource<String, XsdNamespaceBuilder>> list = getResourcesByNamespace(dtdFileName, baseFile.getProject(), ModuleUtilCore.findModuleForPsiElement(baseFile)); - return list.isEmpty() ? null : findSchemaFile(list.get(0).getFile(), baseFile); + if (list.isEmpty()) { + return null; + } + IndexedRelevantResource<String, XsdNamespaceBuilder> resource; + if (list.size() > 1) { + final String[] split = dtdUri.split("/"); + resource = Collections.max(list, new Comparator<IndexedRelevantResource<String, XsdNamespaceBuilder>>() { + @Override + public int compare(IndexedRelevantResource<String, XsdNamespaceBuilder> o1, + IndexedRelevantResource<String, XsdNamespaceBuilder> o2) { + + return weight(o1) - weight(o2); + } + + int weight(IndexedRelevantResource<String, XsdNamespaceBuilder> o1) { + VirtualFile file = o1.getFile(); + for (int i = split.length - 1; i >= 0 && file != null; i--) { + String s = split[i]; + if (!s.equals(file.getName())) { + return split.length - i; + } + file = file.getParent(); + } + return 0; + } + }); + } + else { + resource = list.get(0); + } + return findSchemaFile(resource.getFile(), baseFile); } } diff --git a/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameDialog.java b/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameDialog.java index 342a2e54e765..f811a0aa8393 100644 --- a/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameDialog.java +++ b/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameDialog.java @@ -24,6 +24,7 @@ package com.intellij.xml.refactoring; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupManager; +import com.intellij.lang.findUsages.DescriptiveNameUtil; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; @@ -39,7 +40,6 @@ import com.intellij.psi.xml.XmlTag; import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.ui.NameSuggestionsField; import com.intellij.refactoring.ui.RefactoringDialog; -import com.intellij.ui.IdeBorderFactory; import com.intellij.usageView.UsageViewUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.xml.XmlBundle; @@ -91,7 +91,7 @@ public class XmlTagRenameDialog extends RefactoringDialog { } private static String getFullName(@NotNull final XmlTag tag) { - final String name = UsageViewUtil.getDescriptiveName(tag); + final String name = DescriptiveNameUtil.getDescriptiveName(tag); return (UsageViewUtil.getType(tag) + " " + name).trim(); } diff --git a/xml/impl/src/com/intellij/xml/util/HtmlUtil.java b/xml/impl/src/com/intellij/xml/util/HtmlUtil.java index f687b6aacf3e..552f12794ec8 100644 --- a/xml/impl/src/com/intellij/xml/util/HtmlUtil.java +++ b/xml/impl/src/com/intellij/xml/util/HtmlUtil.java @@ -42,7 +42,6 @@ import com.intellij.psi.impl.source.parsing.xml.XmlBuilder; import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.psi.impl.source.xml.XmlAttributeImpl; import com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider; -import com.intellij.psi.templateLanguages.TemplateLanguageUtil; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.*; import com.intellij.util.ArrayUtil; @@ -230,14 +229,7 @@ public class HtmlUtil { @Nullable public static XmlDocument getRealXmlDocument(@Nullable XmlDocument doc) { - if (doc == null) return null; - final PsiFile containingFile = doc.getContainingFile(); - - final PsiFile templateFile = TemplateLanguageUtil.getTemplateFile(containingFile); - if (templateFile instanceof XmlFile) { - return ((XmlFile)templateFile).getDocument(); - } - return doc; + return HtmlPsiUtil.getRealXmlDocument(doc); } public static String[] getHtmlTagNames() { @@ -257,10 +249,12 @@ public class HtmlUtil { if (customName.length() == 0) continue; descriptors[index++] = new XmlAttributeDescriptorImpl() { + @Override public String getName(PsiElement context) { return customName; } + @Override public String getName() { return customName; } @@ -283,14 +277,17 @@ public class HtmlUtil { if (tagName.length() == 0) continue; descriptors[index++] = new XmlElementDescriptorImpl(context instanceof XmlTag ? (XmlTag)context : null) { + @Override public String getName(PsiElement context) { return tagName; } + @Override public String getDefaultName() { return tagName; } + @Override public boolean allowElementsFromNamespace(final String namespace, final XmlTag context) { return true; } @@ -348,10 +345,12 @@ public class HtmlUtil { descriptors = ArrayUtil.append( descriptors, new XmlAttributeDescriptorImpl() { + @Override public String getName(PsiElement context) { return JSFC; } + @Override public String getName() { return JSFC; } @@ -462,6 +461,7 @@ public class HtmlUtil { public static void processInjectedContent(final XmlTag element, @NotNull final Processor<XmlTag> tagProcessor) { final PsiLanguageInjectionHost.InjectedPsiVisitor injectedPsiVisitor = new PsiLanguageInjectionHost.InjectedPsiVisitor() { + @Override public void visit(@NotNull PsiFile injectedPsi, @NotNull List<PsiLanguageInjectionHost.Shred> places) { if (injectedPsi instanceof XmlFile) { final XmlDocument injectedDocument = ((XmlFile)injectedPsi).getDocument(); @@ -516,12 +516,14 @@ public class HtmlUtil { @NonNls final Set<String> inTag = new THashSet<String>(); boolean metHttpEquiv = false; + @Override public void doctype(@Nullable final CharSequence publicId, @Nullable final CharSequence systemId, final int startOffset, final int endOffset) { } + @Override public ProcessingOrder startTag(final CharSequence localName, final String namespace, final int startoffset, final int endoffset, final int headerEndOffset) { @NonNls String name = localName.toString().toLowerCase(); @@ -534,6 +536,7 @@ public class HtmlUtil { throw TerminateException.INSTANCE; } + @Override public void endTag(final CharSequence localName, final String namespace, final int startoffset, final int endoffset) { @NonNls final String name = localName.toString().toLowerCase(); if ("meta".equals(name) && metHttpEquiv && contentAttributeValue != null) { @@ -556,6 +559,7 @@ public class HtmlUtil { private String contentAttributeValue; + @Override public void attribute(final CharSequence localName, final CharSequence v, final int startoffset, final int endoffset) { @NonNls final String name = localName.toString().toLowerCase(); if (inTag.contains("meta")) { @@ -569,20 +573,23 @@ public class HtmlUtil { } } + @Override public void textElement(final CharSequence display, final CharSequence physical, final int startoffset, final int endoffset) { } + @Override public void entityRef(final CharSequence ref, final int startOffset, final int endOffset) { } + @Override public void error(String message, int startOffset, int endOffset) { } }); } - catch (TerminateException e) { + catch (TerminateException ignored) { //ignore } - catch (Exception e) { + catch (Exception ignored) { // some weird things can happen, like unbalanaced tree } diff --git a/xml/impl/src/com/intellij/xml/util/UserColorLookup.java b/xml/impl/src/com/intellij/xml/util/UserColorLookup.java index cb6337eb4f59..dbc248031c21 100644 --- a/xml/impl/src/com/intellij/xml/util/UserColorLookup.java +++ b/xml/impl/src/com/intellij/xml/util/UserColorLookup.java @@ -22,7 +22,6 @@ import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.codeInsight.lookup.LookupElementDecorator; import com.intellij.codeInsight.lookup.LookupValueWithPriority; -import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.wm.WindowManager; import com.intellij.psi.PsiElement; @@ -30,7 +29,10 @@ import com.intellij.psi.xml.XmlToken; import com.intellij.ui.ColorChooser; import com.intellij.ui.ColorPickerListener; import com.intellij.ui.ColorPickerListenerFactory; +import com.intellij.ui.ColorUtil; +import com.intellij.util.Function; import com.intellij.xml.XmlBundle; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.awt.*; @@ -40,18 +42,28 @@ import java.awt.*; */ public class UserColorLookup extends LookupElementDecorator<LookupElement> { private static final String COLOR_STRING = XmlBundle.message("choose.color.in.color.lookup"); + private static final Function<Color,String> COLOR_TO_STRING_CONVERTER = new Function<Color, String>() { + @Override + public String fun(Color color) { + return '#' + ColorUtil.toHex(color); + } + }; public UserColorLookup() { + this(COLOR_TO_STRING_CONVERTER); + } + + public UserColorLookup(final Function<Color, String> colorToStringConverter) { super(PrioritizedLookupElement.withPriority(LookupElementBuilder.create(COLOR_STRING).withInsertHandler( new InsertHandler<LookupElement>() { @Override public void handleInsert(InsertionContext context, LookupElement item) { - handleUserSelection(context); + handleUserSelection(context, colorToStringConverter); } }), LookupValueWithPriority.HIGH)); } - private static void handleUserSelection(InsertionContext context) { + private static void handleUserSelection(InsertionContext context, @NotNull Function<Color, String> colorToStringConverter) { Color myColorAtCaret = null; Editor selectedTextEditor = context.getEditor(); @@ -68,16 +80,8 @@ public class UserColorLookup extends LookupElementDecorator<LookupElement> { XmlBundle.message("choose.color.dialog.title"), myColorAtCaret, true, listeners, true); if (color != null) { - String s = Integer.toHexString(color.getRGB() & 0xFFFFFF); - if (s.length() != 6) { - StringBuilder buf = new StringBuilder(s); - for (int i = 6 - buf.length(); i > 0; --i) { - buf.insert(0, '0'); - } - s = buf.toString(); - } - s = "#" + s; - context.getDocument().insertString(context.getStartOffset(), s); + String colorString = colorToStringConverter.fun(color); + context.getDocument().insertString(context.getStartOffset(), colorString); context.getEditor().getCaretModel().moveToOffset(context.getTailOffset()); } } diff --git a/xml/impl/src/com/intellij/xml/util/XmlResourceResolver.java b/xml/impl/src/com/intellij/xml/util/XmlResourceResolver.java index 018aee23a3d7..8af1beed8040 100644 --- a/xml/impl/src/com/intellij/xml/util/XmlResourceResolver.java +++ b/xml/impl/src/com/intellij/xml/util/XmlResourceResolver.java @@ -40,6 +40,7 @@ import org.apache.xerces.xni.parser.XMLEntityResolver; import org.apache.xerces.xni.parser.XMLInputSource; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; +import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import java.io.File; @@ -238,9 +239,14 @@ public class XmlResourceResolver implements XMLEntityResolver { } if (psiFile == null) { - if (publicId != null && publicId.indexOf(":/") != -1) { - myErrorReporter.processError( - new SAXParseException(XmlBundle.message("xml.validate.external.resource.is.not.registered", publicId), publicId, null, 0,0), false); + if (publicId != null && publicId.contains(":/")) { + try { + myErrorReporter.processError( + new SAXParseException(XmlBundle.message("xml.validate.external.resource.is.not.registered", publicId), publicId, null, 0,0), ValidateXmlActionHandler.ProblemType.ERROR); + } + catch (SAXException ignore) { + + } final XMLInputSource source = new XMLInputSource(xmlResourceIdentifier); source.setPublicId(publicId); source.setCharacterStream(new StringReader("")); diff --git a/xml/impl/src/com/intellij/xml/util/XmlUtil.java b/xml/impl/src/com/intellij/xml/util/XmlUtil.java index 757fc9a4ea0d..ca79e8801a3d 100644 --- a/xml/impl/src/com/intellij/xml/util/XmlUtil.java +++ b/xml/impl/src/com/intellij/xml/util/XmlUtil.java @@ -51,13 +51,11 @@ import com.intellij.psi.filters.position.FilterPattern; import com.intellij.psi.impl.source.html.HtmlDocumentImpl; import com.intellij.psi.impl.source.tree.CompositeElement; import com.intellij.psi.impl.source.tree.LeafElement; +import com.intellij.psi.impl.source.xml.XmlEntityCache; import com.intellij.psi.impl.source.xml.XmlEntityRefImpl; import com.intellij.psi.scope.processor.FilterElementProcessor; import com.intellij.psi.search.PsiElementProcessor; import com.intellij.psi.tree.IElementType; -import com.intellij.psi.util.CachedValue; -import com.intellij.psi.util.CachedValueProvider; -import com.intellij.psi.util.CachedValuesManager; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.*; import com.intellij.util.ArrayUtil; @@ -97,7 +95,7 @@ public class XmlUtil { @NonNls public static final String XML_SCHEMA_INSTANCE_URI = "http://www.w3.org/2001/XMLSchema-instance"; @NonNls public static final String XSLT_URI = "http://www.w3.org/1999/XSL/Transform"; - @NonNls public static final String XINCLUDE_URI = "http://www.w3.org/2001/XInclude"; + @NonNls public static final String XINCLUDE_URI = XmlPsiUtil.XINCLUDE_URI; @NonNls public static final String ANT_URI = "http://ant.apache.org/schema.xsd"; @NonNls public static final String XHTML_URI = "http://www.w3.org/1999/xhtml"; @@ -152,7 +150,6 @@ public class XmlUtil { @NonNls public static final String ENUMERATION_TAG_NAME = "enumeration"; @NonNls public static final String HTML4_LOOSE_URI = "http://www.w3.org/TR/html4/loose.dtd"; @NonNls public static final String WSDL_SCHEMA_URI = "http://schemas.xmlsoap.org/wsdl/"; - public static final Key<PsiAnchor> ORIGINAL_ELEMENT = Key.create("ORIGINAL_ELEMENT"); public static final String XHTML4_SCHEMA_LOCATION; public final static Key<Boolean> BUILDING_DOM_STUBS = Key.create("building dom stubs..."); @@ -318,13 +315,11 @@ public class XmlUtil { } public static boolean processXmlElements(XmlElement element, PsiElementProcessor processor, boolean deepFlag) { - return processXmlElements(element, processor, deepFlag, false); + return XmlPsiUtil.processXmlElements(element, processor, deepFlag); } public static boolean processXmlElements(XmlElement element, PsiElementProcessor processor, boolean deepFlag, boolean wideFlag) { - if (element == null) return true; - PsiFile baseFile = element.isValid() ? element.getContainingFile() : null; - return processXmlElements(element, processor, deepFlag, wideFlag, baseFile); + return XmlPsiUtil.processXmlElements(element, processor, deepFlag, wideFlag); } public static boolean processXmlElements(final XmlElement element, @@ -332,7 +327,7 @@ public class XmlUtil { final boolean deepFlag, final boolean wideFlag, final PsiFile baseFile) { - return processXmlElements(element, processor, deepFlag, wideFlag, baseFile, true); + return XmlPsiUtil.processXmlElements(element, processor, deepFlag, wideFlag, baseFile); } public static boolean processXmlElements(final XmlElement element, @@ -341,18 +336,11 @@ public class XmlUtil { final boolean wideFlag, final PsiFile baseFile, boolean processIncludes) { - return new XmlElementProcessor(processor, baseFile).processXmlElements(element, deepFlag, wideFlag, processIncludes); + return XmlPsiUtil.processXmlElements(element, processor, deepFlag, wideFlag, baseFile, processIncludes); } public static boolean processXmlElementChildren(final XmlElement element, final PsiElementProcessor processor, final boolean deepFlag) { - final XmlElementProcessor p = new XmlElementProcessor(processor, element.getContainingFile()); - - final boolean wideFlag = false; - for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) { - if (!p.processElement(child, deepFlag, wideFlag, true) && !wideFlag) return false; - } - - return true; + return XmlPsiUtil.processXmlElementChildren(element, processor, deepFlag); } public static boolean tagFromTemplateFramework(@NotNull final XmlTag tag) { @@ -613,172 +601,6 @@ public class XmlUtil { return Boolean.TRUE.equals(file.getUserData(BUILDING_DOM_STUBS)); } - private static class XmlElementProcessor { - private final PsiElementProcessor processor; - private final PsiFile targetFile; - - XmlElementProcessor(PsiElementProcessor _processor, PsiFile _targetFile) { - processor = _processor; - targetFile = _targetFile; - } - - private boolean processXmlElements(PsiElement element, boolean deepFlag, boolean wideFlag, boolean processIncludes) { - if (deepFlag) if (!processor.execute(element)) return false; - - PsiElement startFrom = element.getFirstChild(); - - if (element instanceof XmlEntityRef) { - XmlEntityRef ref = (XmlEntityRef)element; - - PsiElement newElement = parseEntityRef(targetFile, ref); - - while (newElement != null) { - if (!processElement(newElement, deepFlag, wideFlag, processIncludes)) return false; - newElement = newElement.getNextSibling(); - } - - return true; - } - else if (element instanceof XmlConditionalSection) { - XmlConditionalSection xmlConditionalSection = (XmlConditionalSection)element; - if (!xmlConditionalSection.isIncluded(targetFile)) return true; - startFrom = xmlConditionalSection.getBodyStart(); - } - else if (processIncludes && XmlIncludeHandler.isXInclude(element)) { - for (PsiElement psiElement : InclusionProvider.getIncludedTags((XmlTag)element)) { - if (!processElement(psiElement, deepFlag, wideFlag, true)) return false; - } - } - - for (PsiElement child = startFrom; child != null; child = child.getNextSibling()) { - if (!processElement(child, deepFlag, wideFlag, processIncludes) && !wideFlag) return false; - } - - return true; - } - - private boolean processElement(PsiElement child, boolean deepFlag, boolean wideFlag, boolean processIncludes) { - if (deepFlag) { - if (!processXmlElements(child, true, wideFlag, processIncludes)) { - return false; - } - } - else { - if (child instanceof XmlEntityRef) { - if (!processXmlElements(child, false, wideFlag, processIncludes)) return false; - } - else if (child instanceof XmlConditionalSection) { - if (!processXmlElements(child, false, wideFlag, processIncludes)) return false; - } - else if (processIncludes && XmlIncludeHandler.isXInclude(child)) { - if (!processXmlElements(child, false, wideFlag, processIncludes)) return false; - } - else if (!processor.execute(child)) return false; - } - if (targetFile != null && child instanceof XmlEntityDecl) { - XmlEntityDecl xmlEntityDecl = (XmlEntityDecl)child; - XmlEntityRefImpl.cacheParticularEntity(targetFile, xmlEntityDecl); - } - return true; - } - } - - private static PsiElement parseEntityRef(PsiFile targetFile, XmlEntityRef ref) { - XmlEntityDecl.EntityContextType type = getContextType(ref); - - { - final XmlEntityDecl entityDecl = ref.resolve(targetFile); - if (entityDecl != null) return parseEntityDecl(entityDecl, targetFile, type, ref); - } - - PsiElement e = ref; - while (e != null) { - if (e.getUserData(XmlElement.INCLUDING_ELEMENT) != null) { - e = e.getUserData(XmlElement.INCLUDING_ELEMENT); - final PsiFile f = e.getContainingFile(); - if (f != null) { - final XmlEntityDecl entityDecl = ref.resolve(targetFile); - if (entityDecl != null) return parseEntityDecl(entityDecl, targetFile, type, ref); - } - - continue; - } - if (e instanceof PsiFile) { - PsiFile refFile = (PsiFile)e; - final XmlEntityDecl entityDecl = ref.resolve(refFile); - if (entityDecl != null) return parseEntityDecl(entityDecl, targetFile, type, ref); - break; - } - - e = e.getParent(); - } - - final PsiElement element = ref.getUserData(XmlElement.DEPENDING_ELEMENT); - if (element instanceof XmlFile) { - final XmlEntityDecl entityDecl = ref.resolve((PsiFile)element); - if (entityDecl != null) return parseEntityDecl(entityDecl, targetFile, type, ref); - } - - return null; - } - - private static XmlEntityDecl.EntityContextType getContextType(XmlEntityRef ref) { - XmlEntityDecl.EntityContextType type = XmlEntityDecl.EntityContextType.GENERIC_XML; - PsiElement temp = ref; - while (temp != null) { - if (temp instanceof XmlAttributeDecl) { - type = XmlEntityDecl.EntityContextType.ATTRIBUTE_SPEC; - } - else if (temp instanceof XmlElementDecl) { - type = XmlEntityDecl.EntityContextType.ELEMENT_CONTENT_SPEC; - } - else if (temp instanceof XmlAttlistDecl) { - type = XmlEntityDecl.EntityContextType.ATTLIST_SPEC; - } - else if (temp instanceof XmlEntityDecl) { - type = XmlEntityDecl.EntityContextType.ENTITY_DECL_CONTENT; - } - else if (temp instanceof XmlEnumeratedType) { - type = XmlEntityDecl.EntityContextType.ENUMERATED_TYPE; - } - else if (temp instanceof XmlAttributeValue) { - type = XmlEntityDecl.EntityContextType.ATTR_VALUE; - } - else { - temp = temp.getContext(); - continue; - } - break; - } - return type; - } - - private static final Key<CachedValue<PsiElement>> PARSED_DECL_KEY = Key.create("PARSED_DECL_KEY"); - - private static PsiElement parseEntityDecl(final XmlEntityDecl entityDecl, - final PsiFile targetFile, - final XmlEntityDecl.EntityContextType type, - final XmlEntityRef entityRef) { - synchronized (PsiLock.LOCK) { // we depend on targetFile and entityRef - CachedValue<PsiElement> value = entityRef.getUserData(PARSED_DECL_KEY); - // return entityDecl.parse(targetFile, type); - - if (value == null) { - value = CachedValuesManager.getManager(entityDecl.getProject()).createCachedValue(new CachedValueProvider<PsiElement>() { - public Result<PsiElement> compute() { - final PsiElement res = entityDecl.parse(targetFile, type, entityRef); - if (res == null) return new Result<PsiElement>(res, targetFile); - if (!entityDecl.isInternalReference()) XmlEntityRefImpl.copyEntityCaches(res.getContainingFile(), targetFile); - return new Result<PsiElement>(res, res.getUserData(XmlElement.DEPENDING_ELEMENT), entityDecl, targetFile, entityRef); - } - }, false); - entityRef.putUserData(PARSED_DECL_KEY, value); - } - - return value.getValue(); - } - } - /** * add child to the parent according to DTD/Schema element ordering * @@ -1236,7 +1058,7 @@ public class XmlUtil { if (currentElement != null) { final String name = _element.getName(); if (_element instanceof XmlEntityDecl) { - final XmlEntityDecl cachedEntity = XmlEntityRefImpl.getCachedEntity((PsiFile)currentElement, name); + final XmlEntityDecl cachedEntity = XmlEntityCache.getCachedEntity((PsiFile)currentElement, name); if (cachedEntity != null) return cachedEntity; } diff --git a/xml/impl/src/com/intellij/xml/util/documentation/svgtable.xml b/xml/impl/src/com/intellij/xml/util/documentation/svgtable.xml index 414169b51e9c..478a2b2bac79 100644 --- a/xml/impl/src/com/intellij/xml/util/documentation/svgtable.xml +++ b/xml/impl/src/com/intellij/xml/util/documentation/svgtable.xml @@ -1,4 +1,12 @@ <html-property-table baseHelpRef="http://www.w3.org/TR/SVG/"> +<tag name = "a" + helpref = "linking.html#AElement" + description = "" + startTag = "true" + endTag = "true" + empty = "false" + dtd = "" +/> <tag name = "altGlyph" helpref = "text.html#AltGlyphElement" description = "" @@ -32,7 +40,7 @@ dtd = "" /> <tag name = "animateColor" - helpref = "text.html#AnimateColorElement" + helpref = "animate.html#AnimateColorElement" description = "" startTag = "true" endTag = "true" @@ -40,7 +48,7 @@ dtd = "" /> <tag name = "animateMotion" - helpref = "text.html#AnimateMotionElement" + helpref = "animate.html#AnimateMotionElement" description = "" startTag = "true" endTag = "true" @@ -48,7 +56,7 @@ dtd = "" /> <tag name = "animateTransform" - helpref = "text.html#AnimateTransformElement" + helpref = "animate.html#AnimateTransformElement" description = "" startTag = "true" endTag = "true" @@ -151,7 +159,7 @@ empty = "false" dtd = "" /> -<tag name = "feDiffuseLightingElement" +<tag name = "feDiffuseLighting" helpref = "filters.html#feDiffuseLightingElement" description = "" startTag = "true" @@ -159,7 +167,7 @@ empty = "false" dtd = "" /> -<tag name = "feDisplacementMapElement" +<tag name = "feDisplacementMap" helpref = "filters.html#feDisplacementMapElement" description = "" startTag = "true" @@ -311,6 +319,62 @@ empty = "false" dtd = "" /> +<tag name = "font" + helpref = "fonts.html#FontElement" + description = "" + startTag = "true" + endTag = "true" + empty = "false" + dtd = "" +/> +<tag name = "font-face" + helpref = "fonts.html#FontFaceElement" + description = "" + startTag = "true" + endTag = "true" + empty = "false" + dtd = "" +/> +<tag name = "font-face-format" + helpref = "fonts.html#FontFaceFormatElement" + description = "" + startTag = "true" + endTag = "true" + empty = "false" + dtd = "" +/> +<tag name = "font-face-name" + helpref = "fonts.html#FontFaceNamecElement" + description = "" + startTag = "true" + endTag = "true" + empty = "false" + dtd = "" +/> +<tag name = "font-face-src" + helpref = "fonts.html#FontFaceSrcElement" + description = "" + startTag = "true" + endTag = "true" + empty = "false" + dtd = "" +/> +<tag name = "font-face-uri" + helpref = "fonts.html#FontFaceURIElement" + description = "" + startTag = "true" + endTag = "true" + empty = "false" + dtd = "" +/> +<tag name = "foreignObject" + helpref = "extend.html#ForeignObjectElement" + description = "" + startTag = "true" + endTag = "true" + empty = "false" + dtd = "" +/> <tag name = "g" helpref = "struct.html#GElement" description = "" @@ -319,7 +383,6 @@ empty = "false" dtd = "" /> -/> <tag name = "glyph" helpref = "fonts.html#GlyphElement" description = "" @@ -408,14 +471,6 @@ empty = "false" dtd = "" /> -<tag name = "foreignObject" - helpref = "extend.html#ForeignObjectElement" - description = "" - startTag = "true" - endTag = "true" - empty = "false" - dtd = "" -/> <tag name = "path" helpref = "paths.html#PathElement" description = "" @@ -480,6 +535,14 @@ empty = "false" dtd = "" /> +<tag name = "style" + helpref = "styling.html#StyleElement" + description = "" + startTag = "true" + endTag = "true" + empty = "false" + dtd = "" +/> <tag name = "svg" helpref = "struct.html#SVGElement" description = "" @@ -504,8 +567,32 @@ empty = "false" dtd = "" /> -<tag name = "switch" - helpref = "struct.html#SwitchElement" +<tag name = "text" + helpref = "text.html#TextElement" + description = "" + startTag = "true" + endTag = "true" + empty = "false" + dtd = "" +/> +<tag name = "textPath" + helpref = "text.html#TextPathElement" + description = "" + startTag = "true" + endTag = "true" + empty = "false" + dtd = "" +/> +<tag name = "title" + helpref = "struct.html#TitleElement" + description = "" + startTag = "true" + endTag = "true" + empty = "false" + dtd = "" +/> +<tag name = "tref" + helpref = "text.html#TRefElement" description = "" startTag = "true" endTag = "true" @@ -520,6 +607,22 @@ empty = "false" dtd = "" /> +<tag name = "use" + helpref = "struct.html#UseElement" + description = "" + startTag = "true" + endTag = "true" + empty = "false" + dtd = "" +/> +<tag name = "view" + helpref = "linking.html#ViewElement" + description = "" + startTag = "true" + endTag = "true" + empty = "false" + dtd = "" +/> <tag name = "vkern" helpref = "fonts.html#VKernElement" description = "" diff --git a/xml/impl/xml.iml b/xml/impl/xml.iml index 840cd2b93576..d97dde3209d6 100644 --- a/xml/impl/xml.iml +++ b/xml/impl/xml.iml @@ -17,6 +17,7 @@ <orderEntry type="module" module-name="platform-resources" /> <orderEntry type="module" module-name="vcs-api" /> <orderEntry type="library" name="Guava" level="project" /> + <orderEntry type="module" module-name="xml-psi-impl" exported="" /> </component> <component name="copyright"> <Base> diff --git a/xml/openapi/src/com/intellij/ide/browsers/WebBrowserUrlProvider.java b/xml/openapi/src/com/intellij/ide/browsers/WebBrowserUrlProvider.java index e5795d1d6db5..688191fcef19 100644 --- a/xml/openapi/src/com/intellij/ide/browsers/WebBrowserUrlProvider.java +++ b/xml/openapi/src/com/intellij/ide/browsers/WebBrowserUrlProvider.java @@ -16,6 +16,7 @@ package com.intellij.ide.browsers; import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.util.Ref; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; @@ -34,16 +35,30 @@ public abstract class WebBrowserUrlProvider { } } - @NotNull - /** - * URL must not be encoded (space as is) - */ - public abstract String getUrl(@NotNull PsiElement element, @NotNull PsiFile psiFile, @NotNull VirtualFile virtualFile) throws BrowserException; + public boolean canHandleElement(@NotNull PsiElement element, @NotNull PsiFile psiFile, Ref<Url> result) { + VirtualFile file = psiFile.getVirtualFile(); + if (file == null) { + return false; + } - /** - * Invariant: element has not null containing psi file with not null virtual file - */ - public abstract boolean canHandleElement(@NotNull final PsiElement element); + Url url; + try { + url = getUrl(element, psiFile, file); + } + catch (BrowserException ignored) { + return false; + } + + if (url == null) { + return false; + } + + result.set(url); + return true; + } + + @Nullable + public abstract Url getUrl(@NotNull PsiElement element, @NotNull PsiFile psiFile, @NotNull VirtualFile virtualFile) throws BrowserException; @Nullable public String getOpenInBrowserActionText(@NotNull PsiFile file) { diff --git a/xml/openapi/src/com/intellij/pom/xml/XmlChangeVisitor.java b/xml/openapi/src/com/intellij/pom/xml/XmlChangeVisitor.java deleted file mode 100644 index 387c3901cba6..000000000000 --- a/xml/openapi/src/com/intellij/pom/xml/XmlChangeVisitor.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.intellij.pom.xml; - -import com.intellij.pom.xml.events.*; - -/** - * @author peter - */ -@Deprecated -public interface XmlChangeVisitor { - void visitXmlAttributeSet(final XmlAttributeSet xmlAttributeSet); - - void visitDocumentChanged(final XmlDocumentChanged xmlDocumentChanged); - - void visitXmlElementChanged(final XmlElementChanged xmlElementChanged); - - void visitXmlTagChildAdd(final XmlTagChildAdd xmlTagChildAdd); - - void visitXmlTagChildChanged(final XmlTagChildChanged xmlTagChildChanged); - - void visitXmlTagChildRemoved(final XmlTagChildRemoved xmlTagChildRemoved); - - void visitXmlTagNameChanged(final XmlTagNameChanged xmlTagNameChanged); - - void visitXmlTextChanged(final XmlTextChanged xmlTextChanged); -} diff --git a/xml/openapi/src/com/intellij/pom/xml/XmlChangeVisitorBase.java b/xml/openapi/src/com/intellij/pom/xml/XmlChangeVisitorBase.java deleted file mode 100644 index 9295e688408d..000000000000 --- a/xml/openapi/src/com/intellij/pom/xml/XmlChangeVisitorBase.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.pom.xml; - -import com.intellij.pom.xml.events.*; - -public class XmlChangeVisitorBase implements XmlChangeVisitor{ - public void visitXmlAttributeSet(final XmlAttributeSet xmlAttributeSet) { - - } - - public void visitDocumentChanged(final XmlDocumentChanged xmlDocumentChanged) { - - } - - public void visitXmlElementChanged(final XmlElementChanged xmlElementChanged) { - - } - - public void visitXmlTagChildAdd(final XmlTagChildAdd xmlTagChildAdd) { - - } - - public void visitXmlTagChildChanged(final XmlTagChildChanged xmlTagChildChanged) { - - } - - public void visitXmlTagChildRemoved(final XmlTagChildRemoved xmlTagChildRemoved) { - - } - - public void visitXmlTagNameChanged(final XmlTagNameChanged xmlTagNameChanged) { - - } - - public void visitXmlTextChanged(final XmlTextChanged xmlTextChanged) { - - } -} diff --git a/xml/openapi/xml-openapi.iml b/xml/openapi/xml-openapi.iml index 8e89609fb173..934360bb80c9 100644 --- a/xml/openapi/xml-openapi.iml +++ b/xml/openapi/xml-openapi.iml @@ -8,6 +8,7 @@ <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="module" module-name="lang-api" /> + <orderEntry type="module" module-name="xml-psi-api" exported="" /> </component> <component name="copyright"> <Base> diff --git a/xml/relaxng/lib/trang-core.jar b/xml/relaxng/lib/trang-core.jar Binary files differindex dee727817010..ecf139a3c9c5 100644 --- a/xml/relaxng/lib/trang-core.jar +++ b/xml/relaxng/lib/trang-core.jar diff --git a/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngElementDescriptor.java b/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngElementDescriptor.java index 48fa59d514e4..6abb42080052 100644 --- a/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngElementDescriptor.java +++ b/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngElementDescriptor.java @@ -125,4 +125,16 @@ public class RelaxedHtmlFromRngElementDescriptor implements XmlElementDescriptor public boolean allowElementsFromNamespace(String namespace, XmlTag context) { return true; } + + @Override + public int hashCode() { + return myDelegate.hashCode(); + } + + @Override + public boolean equals(Object obj) { + return obj == this || + (obj instanceof RelaxedHtmlFromRngElementDescriptor + && myDelegate.equals(((RelaxedHtmlFromRngElementDescriptor)obj).myDelegate)); + } } diff --git a/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngNSDescriptor.java b/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngNSDescriptor.java index 8724b3eabf63..984f50d0ec5a 100644 --- a/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngNSDescriptor.java +++ b/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngNSDescriptor.java @@ -37,10 +37,12 @@ public class RelaxedHtmlFromRngNSDescriptor extends RngNsDescriptor implements R public XmlElementDescriptor getElementDescriptor(@NotNull XmlTag tag) { XmlElementDescriptor elementDescriptor = super.getElementDescriptor(tag); - LOG.debug("Descriptor from rng for tag " + - tag.getName() + - " is " + - (elementDescriptor != null ? elementDescriptor.getClass().getCanonicalName() : "NULL")); + if (LOG.isDebugEnabled()) { + LOG.debug("Descriptor from rng for tag " + + tag.getName() + + " is " + + (elementDescriptor != null ? elementDescriptor.getClass().getCanonicalName() : "NULL")); + } String namespace; if (elementDescriptor == null && diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/lexer/CompactSyntaxLexerAdapter.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/lexer/CompactSyntaxLexerAdapter.java index 06ba2f21c6a3..7ae13da3c863 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/lexer/CompactSyntaxLexerAdapter.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/lexer/CompactSyntaxLexerAdapter.java @@ -33,6 +33,8 @@ import java.io.FileReader; import java.io.IOException; import java.io.Reader; import java.lang.reflect.Field; +import java.net.URL; +import java.security.CodeSource; import java.util.Arrays; import java.util.LinkedList; @@ -199,12 +201,24 @@ public class CompactSyntaxLexerAdapter extends LexerBase { final Class<CompactSyntaxTokenManager> managerClass = CompactSyntaxTokenManager.class; LOG.error("Unsupported version of RNGOM in classpath", e, "Actual parameter types: " + Arrays.toString(managerClass.getConstructors()[0].getParameterTypes()), - "Location of " + managerClass.getName() + ": " + managerClass.getProtectionDomain().getCodeSource(), - "Location of " + CharStream.class.getName() + ": " + CharStream.class.getProtectionDomain().getCodeSource()); + "Location of " + managerClass.getName() + ": " + getSourceLocation(managerClass), + "Location of " + CharStream.class.getName() + ": " + getSourceLocation(CharStream.class)); throw e; } } + private static String getSourceLocation(Class<?> clazz) { + final CodeSource source = clazz.getProtectionDomain().getCodeSource(); + if (source != null) { + final URL location = source.getLocation(); + if (location != null) { + return location.toExternalForm(); + } + } + final URL resource = clazz.getClassLoader().getResource(clazz.getName().replace('.', '/') + ".class"); + return resource != null ? resource.toExternalForm() : "<unknown>"; + } + public static void main(String[] args) throws IOException { final CompactSyntaxLexerAdapter lexer = new CompactSyntaxLexerAdapter(); lexer.start(new CharArrayCharSequence(FileUtil.adaptiveLoadText(new FileReader(args[0])))); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/CommonAnnotationHolder.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/CommonAnnotationHolder.java index b16c391194ce..da1b326f9f6b 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/CommonAnnotationHolder.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/CommonAnnotationHolder.java @@ -60,7 +60,7 @@ abstract class CommonAnnotationHolder<C> { return myHolder.createErrorAnnotation(element, message); } else if (severity == HighlightSeverity.WARNING) { return myHolder.createWarningAnnotation(element, message); - } else if (severity == HighlightSeverity.WEAK_WARNING || severity == HighlightSeverity.INFO) { + } else if (severity == HighlightSeverity.WEAK_WARNING) { return myHolder.createWeakWarningAnnotation(element, message); } else { return myHolder.createInfoAnnotation(element, message); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java index 10c37222bdb9..6f9a5c7dd51b 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java @@ -18,7 +18,9 @@ package org.intellij.plugins.relaxNG.validation; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; +import com.intellij.openapi.util.AtomicNotNullLazyValue; import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -30,6 +32,7 @@ import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.CachedValuesManager; import com.intellij.psi.xml.XmlFile; import com.intellij.xml.util.XmlUtil; +import com.thaiopensource.datatype.xsd.DatatypeLibraryFactoryImpl; import com.thaiopensource.relaxng.impl.SchemaReaderImpl; import com.thaiopensource.util.PropertyMap; import com.thaiopensource.util.PropertyMapBuilder; @@ -38,17 +41,26 @@ import com.thaiopensource.xml.sax.Sax2XMLReaderCreator; import com.thaiopensource.xml.sax.XMLReaderCreator; import org.intellij.plugins.relaxNG.compact.RncFileType; import org.intellij.plugins.relaxNG.model.resolve.RelaxIncludeIndex; +import org.jetbrains.annotations.NotNull; import org.kohsuke.rngom.ast.builder.BuildException; import org.kohsuke.rngom.ast.builder.IncludedGrammar; import org.kohsuke.rngom.ast.builder.SchemaBuilder; import org.kohsuke.rngom.ast.om.ParsedPattern; import org.kohsuke.rngom.binary.SchemaBuilderImpl; +import org.kohsuke.rngom.binary.SchemaPatternBuilder; import org.kohsuke.rngom.digested.DPattern; import org.kohsuke.rngom.digested.DSchemaBuilderImpl; +import org.kohsuke.rngom.dt.CachedDatatypeLibraryFactory; +import org.kohsuke.rngom.dt.CascadingDatatypeLibraryFactory; +import org.kohsuke.rngom.dt.DoNothingDatatypeLibraryFactoryImpl; +import org.kohsuke.rngom.dt.builtin.BuiltinDatatypeLibraryFactory; import org.kohsuke.rngom.parse.IllegalSchemaException; import org.kohsuke.rngom.parse.Parseable; import org.kohsuke.rngom.parse.compact.CompactParseable; import org.kohsuke.rngom.parse.xml.SAXParseable; +import org.relaxng.datatype.DatatypeLibrary; +import org.relaxng.datatype.DatatypeLibraryFactory; +import org.relaxng.datatype.helpers.DatatypeLibraryLoader; import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -65,6 +77,29 @@ import java.io.StringReader; public class RngParser { private static final Logger LOG = Logger.getInstance("#org.intellij.plugins.relaxNG.validation.RngParser"); + private static final NotNullLazyValue<DatatypeLibraryFactory> DT_LIBRARY_FACTORY = new AtomicNotNullLazyValue<DatatypeLibraryFactory>() { + @NotNull + @Override + protected DatatypeLibraryFactory compute() { + return new BuiltinDatatypeLibraryFactory(new CachedDatatypeLibraryFactory( + new CascadingDatatypeLibraryFactory(createXsdDatatypeFactory(), new DatatypeLibraryLoader())) { + @Override + public synchronized DatatypeLibrary createDatatypeLibrary(String namespaceURI) { + return super.createDatatypeLibrary(namespaceURI); + } + }); + } + }; + + private static DatatypeLibraryFactory createXsdDatatypeFactory() { + try { + return new DatatypeLibraryFactoryImpl(); + } catch (Throwable e) { + LOG.error("Could not create DT library implementation 'com.thaiopensource.datatype.xsd.DatatypeLibraryFactoryImpl'. Plugin's classpath seems to be broken.", e); + return new DoNothingDatatypeLibraryFactoryImpl(); + } + } + static final Key<CachedValue<Schema>> SCHEMA_KEY = Key.create("SCHEMA"); static final Key<CachedValue<DPattern>> PATTERN_KEY = Key.create("PATTERN"); @@ -91,14 +126,21 @@ public class RngParser { try { final Parseable p = createParsable(file, eh); if (checking) { - p.parse(new SchemaBuilderImpl(eh)); + p.parse(new SchemaBuilderImpl(eh, DT_LIBRARY_FACTORY.getValue(), new SchemaPatternBuilder())); } else { return p.parse(new DSchemaBuilderImpl()); } } catch (BuildException e) { LOG.info(e); } catch (IllegalSchemaException e) { - LOG.info("invalid schema: " + file.getVirtualFile().getPresentableUrl()); + final VirtualFile virtualFile = file.getVirtualFile(); + if (virtualFile != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("invalid schema: " + virtualFile.getPresentableUrl(), e); + } else { + LOG.info("invalid schema: " + virtualFile.getPresentableUrl() + ". [" + e.getMessage() + "]"); + } + } } return null; } @@ -151,6 +193,9 @@ public class RngParser { // "file://tmp/foo.bar" (produced by com.intellij.openapi.vfs.VfsUtil.fixIDEAUrl) doesn't work: "java.net.UnknownHostException: tmp" // "file:/tmp/foo.bar" (produced by File.toURL()) works fine s = s.replaceFirst("file:/+", "file:/"); + if (LOG.isDebugEnabled()) { + LOG.debug("Fixed URL: " + url + " -> " + s); + } } return s; } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/RngSchemaValidator.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/RngSchemaValidator.java index f102f2a7b070..99c1b6c1a6ff 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/RngSchemaValidator.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/RngSchemaValidator.java @@ -92,6 +92,9 @@ public class RngSchemaValidator extends ExternalAnnotator { public static void handleError(SAXParseException ex, PsiFile file, Document document, ValidationMessageConsumer consumer) { final String systemId = ex.getSystemId(); + if (LOG.isDebugEnabled()) { + LOG.debug("RNG Schema error: " + ex.getMessage() + " [" + systemId + "]"); + } if (systemId != null) { final VirtualFile virtualFile = findVirtualFile(systemId); diff --git a/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java b/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java index acb90d91a0ac..85f01c54b656 100644 --- a/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java +++ b/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java @@ -671,7 +671,7 @@ public class XmlParsingTest extends ParsingTestCase { doTest("<script type=\"application/custom\">Custom Script</script>", "test.html"); } - static class MyLanguage extends Language { + static class MyLanguage extends Language implements InjectableLanguage { protected MyLanguage() { super("MyLanguage", "application/custom"); } diff --git a/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java b/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java index d1e5463e6c3d..574942bc1207 100644 --- a/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java +++ b/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java @@ -18,6 +18,8 @@ import com.intellij.psi.statistics.impl.StatisticsManagerImpl; import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; import com.intellij.xml.util.XmlUtil; +import java.util.List; + /** * @by Maxim.Mossienko */ @@ -612,5 +614,37 @@ public class XmlCompletionTest extends LightCodeInsightFixtureTestCase { configureByFiles("foo.xsd", "bar.xsd"); basicDoTest(""); } + + public void testDoNotSuggestExistingAttributes() throws Exception { + myFixture.configureByFile("DoNotSuggestExistingAttributes.xml"); + myFixture.completeBasic(); + List<String> strings = myFixture.getLookupElementStrings(); + assertNotNull(strings); + assertFalse(strings.contains("xsi:schemaLocation")); + assertSameElements(strings, "attributeFormDefault", + "blockDefault", + "elementFormDefault", + "finalDefault", + "id", + "targetNamespace", + "version", + "xml:base", + "xml:id", + "xml:lang", + "xml:space", + "xsi:nill", + "xsi:noNamespaceSchemaLocation", + "xsi:type"); + } + + public void testRequiredAttributesOnTop() throws Exception { + myFixture.configureByText("foo.html", "<img <caret>"); + myFixture.completeBasic(); + List<String> strings = myFixture.getLookupElementStrings(); + assertNotNull(strings); + assertEquals("alt", strings.get(0)); + assertEquals("src", strings.get(1)); + assertEquals("align", strings.get(2)); + } } diff --git a/xml/tests/src/com/intellij/xml/index/XmlSchemaIndexTest.java b/xml/tests/src/com/intellij/xml/index/XmlSchemaIndexTest.java index f610b15ee1ae..b0a6380d9a92 100644 --- a/xml/tests/src/com/intellij/xml/index/XmlSchemaIndexTest.java +++ b/xml/tests/src/com/intellij/xml/index/XmlSchemaIndexTest.java @@ -4,6 +4,7 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiFile; import com.intellij.testFramework.IdeaTestCase; import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase; import com.intellij.util.Function; @@ -108,6 +109,19 @@ public class XmlSchemaIndexTest extends CodeInsightFixtureTestCase { assertEquals(Arrays.asList("web-app"), builder.getTags()); } + public void testGuessDTD() throws Exception { + myFixture.copyDirectoryToProject("", ""); + final List<IndexedRelevantResource<String, XsdNamespaceBuilder>> files = + XmlNamespaceIndex.getResourcesByNamespace("foo.dtd", + getProject(), + myModule); + assertEquals(2, files.size()); + + PsiFile file = myFixture.configureByFile("foo.xml"); + assertTrue(XmlNamespaceIndex.guessDtd("foo://bar/1/foo.dtd", file).getVirtualFile().getPath().endsWith("/1/foo.dtd")); + assertTrue(XmlNamespaceIndex.guessDtd("foo://bar/2/foo.dtd", file).getVirtualFile().getPath().endsWith("/2/foo.dtd")); + } + @Override protected String getBasePath() { return "/xml/tests/testData/index"; diff --git a/xml/tests/testData/completion/DoNotSuggestExistingAttributes.xml b/xml/tests/testData/completion/DoNotSuggestExistingAttributes.xml new file mode 100644 index 000000000000..3fface37878f --- /dev/null +++ b/xml/tests/testData/completion/DoNotSuggestExistingAttributes.xml @@ -0,0 +1,6 @@ +<xsd:schema xmlns="http://www.foo.org/test" + <caret> + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.foo.org/test foo.xsd http://www.bar.org/test bar.xsd" > +</xsd:schema> diff --git a/xml/tests/testData/index/1/foo.dtd b/xml/tests/testData/index/1/foo.dtd new file mode 100644 index 000000000000..be05ea6ba4a5 --- /dev/null +++ b/xml/tests/testData/index/1/foo.dtd @@ -0,0 +1 @@ +<!ELEMENT foo (#PCDATA)>
\ No newline at end of file diff --git a/xml/tests/testData/index/2/foo.dtd b/xml/tests/testData/index/2/foo.dtd new file mode 100644 index 000000000000..be05ea6ba4a5 --- /dev/null +++ b/xml/tests/testData/index/2/foo.dtd @@ -0,0 +1 @@ +<!ELEMENT foo (#PCDATA)>
\ No newline at end of file diff --git a/xml/tests/testData/index/foo.xml b/xml/tests/testData/index/foo.xml new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/xml/tests/testData/index/foo.xml diff --git a/xml/openapi/src/com/intellij/html/RelaxedHtmlNSDescriptor.java b/xml/xml-psi-api/src/com/intellij/html/RelaxedHtmlNSDescriptor.java index 275cbe9c93a3..275cbe9c93a3 100644 --- a/xml/openapi/src/com/intellij/html/RelaxedHtmlNSDescriptor.java +++ b/xml/xml-psi-api/src/com/intellij/html/RelaxedHtmlNSDescriptor.java diff --git a/xml/xml-psi-api/src/com/intellij/lang/dtd/DTDLanguage.java b/xml/xml-psi-api/src/com/intellij/lang/dtd/DTDLanguage.java new file mode 100644 index 000000000000..2a4dda4fc022 --- /dev/null +++ b/xml/xml-psi-api/src/com/intellij/lang/dtd/DTDLanguage.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.lang.dtd; + +import com.intellij.lang.xml.XMLLanguage; + +/** + * @author max + */ +public class DTDLanguage extends XMLLanguage { + + public static final DTDLanguage INSTANCE = new DTDLanguage(); + + protected DTDLanguage() { + super(XMLLanguage.INSTANCE, "DTD", "text/dtd", "text/x-dtd"); + } +} diff --git a/xml/xml-psi-api/src/com/intellij/lang/html/HTMLLanguage.java b/xml/xml-psi-api/src/com/intellij/lang/html/HTMLLanguage.java new file mode 100644 index 000000000000..b401e7a65496 --- /dev/null +++ b/xml/xml-psi-api/src/com/intellij/lang/html/HTMLLanguage.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.lang.html; + +import com.intellij.lang.xml.XMLLanguage; + +/** + * @author max + */ +public class HTMLLanguage extends XMLLanguage { + + public static final HTMLLanguage INSTANCE = new HTMLLanguage(); + + private HTMLLanguage() { + super(XMLLanguage.INSTANCE, "HTML", "text/html", "text/htmlh"); + } +} diff --git a/xml/xml-psi-api/src/com/intellij/lang/xhtml/XHTMLLanguage.java b/xml/xml-psi-api/src/com/intellij/lang/xhtml/XHTMLLanguage.java new file mode 100644 index 000000000000..f5f65b86a495 --- /dev/null +++ b/xml/xml-psi-api/src/com/intellij/lang/xhtml/XHTMLLanguage.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.lang.xhtml; + +import com.intellij.lang.xml.XMLLanguage; + +/** + * @author max + */ +public class XHTMLLanguage extends XMLLanguage { + + public static final XHTMLLanguage INSTANCE = new XHTMLLanguage(); + + private XHTMLLanguage() { + super(XMLLanguage.INSTANCE, "XHTML", "text/xhtml", "application/xhtml+xml"); + } +} diff --git a/xml/impl/src/com/intellij/lang/xml/XMLLanguage.java b/xml/xml-psi-api/src/com/intellij/lang/xml/XMLLanguage.java index 872cc7564883..db9d3c516bce 100644 --- a/xml/impl/src/com/intellij/lang/xml/XMLLanguage.java +++ b/xml/xml-psi-api/src/com/intellij/lang/xml/XMLLanguage.java @@ -15,17 +15,9 @@ */ package com.intellij.lang.xml; -import com.intellij.ide.highlighter.XmlFileHighlighter; import com.intellij.lang.CompositeLanguage; import com.intellij.lang.Language; -import com.intellij.openapi.fileTypes.SingleLazyInstanceSyntaxHighlighterFactory; -import com.intellij.openapi.fileTypes.SyntaxHighlighter; -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; -import com.intellij.psi.impl.source.xml.XmlPsiPolicy; -import com.intellij.psi.impl.source.xml.behavior.CDATAOnAnyEncodedPolicy; -import com.intellij.psi.impl.source.xml.behavior.EncodeEachSymbolPolicy; import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; /** * @author max @@ -34,18 +26,8 @@ public class XMLLanguage extends CompositeLanguage { public final static XMLLanguage INSTANCE = new XMLLanguage(); - protected static final CDATAOnAnyEncodedPolicy CDATA_ON_ANY_ENCODED_POLICY = new CDATAOnAnyEncodedPolicy(); - protected static final EncodeEachSymbolPolicy ENCODE_EACH_SYMBOL_POLICY = new EncodeEachSymbolPolicy(); - private XMLLanguage() { super("XML", "text/xml"); - - SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new SingleLazyInstanceSyntaxHighlighterFactory() { - @NotNull - protected SyntaxHighlighter createHighlighter() { - return new XmlFileHighlighter(); - } - }); } @Deprecated @@ -56,9 +38,4 @@ public class XMLLanguage extends CompositeLanguage { protected XMLLanguage(Language baseLanguage, @NonNls String name, @NonNls String... mime) { super(baseLanguage, name, mime); } - - - public XmlPsiPolicy getPsiPolicy() { - return CDATA_ON_ANY_ENCODED_POLICY; - } } diff --git a/xml/openapi/src/com/intellij/pom/package.html b/xml/xml-psi-api/src/com/intellij/pom/package.html index 6d18672a089d..6d18672a089d 100644 --- a/xml/openapi/src/com/intellij/pom/package.html +++ b/xml/xml-psi-api/src/com/intellij/pom/package.html diff --git a/xml/openapi/src/com/intellij/pom/xml/XmlAspect.java b/xml/xml-psi-api/src/com/intellij/pom/xml/XmlAspect.java index 8f75a8ee3914..8f75a8ee3914 100644 --- a/xml/openapi/src/com/intellij/pom/xml/XmlAspect.java +++ b/xml/xml-psi-api/src/com/intellij/pom/xml/XmlAspect.java diff --git a/xml/openapi/src/com/intellij/pom/xml/XmlChangeSet.java b/xml/xml-psi-api/src/com/intellij/pom/xml/XmlChangeSet.java index 4ea483566105..4ea483566105 100644 --- a/xml/openapi/src/com/intellij/pom/xml/XmlChangeSet.java +++ b/xml/xml-psi-api/src/com/intellij/pom/xml/XmlChangeSet.java diff --git a/xml/openapi/src/com/intellij/pom/xml/events/XmlAttributeSet.java b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlAttributeSet.java index 657b62af4fda..657b62af4fda 100644 --- a/xml/openapi/src/com/intellij/pom/xml/events/XmlAttributeSet.java +++ b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlAttributeSet.java diff --git a/xml/openapi/src/com/intellij/pom/xml/events/XmlChange.java b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlChange.java index c4cfe82dda4c..04dce4bec92c 100644 --- a/xml/openapi/src/com/intellij/pom/xml/events/XmlChange.java +++ b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlChange.java @@ -15,10 +15,5 @@ */ package com.intellij.pom.xml.events; -import com.intellij.pom.xml.XmlChangeVisitor; - - public interface XmlChange { - @Deprecated - void accept(XmlChangeVisitor visitor); } diff --git a/xml/openapi/src/com/intellij/pom/xml/events/XmlDocumentChanged.java b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlDocumentChanged.java index 489282317514..489282317514 100644 --- a/xml/openapi/src/com/intellij/pom/xml/events/XmlDocumentChanged.java +++ b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlDocumentChanged.java diff --git a/xml/openapi/src/com/intellij/pom/xml/events/XmlElementChanged.java b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlElementChanged.java index 938f1f77af49..938f1f77af49 100644 --- a/xml/openapi/src/com/intellij/pom/xml/events/XmlElementChanged.java +++ b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlElementChanged.java diff --git a/xml/openapi/src/com/intellij/pom/xml/events/XmlTagChildAdd.java b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlTagChildAdd.java index 2e2961901206..2e2961901206 100644 --- a/xml/openapi/src/com/intellij/pom/xml/events/XmlTagChildAdd.java +++ b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlTagChildAdd.java diff --git a/xml/openapi/src/com/intellij/pom/xml/events/XmlTagChildChanged.java b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlTagChildChanged.java index b2219eda2d0a..b2219eda2d0a 100644 --- a/xml/openapi/src/com/intellij/pom/xml/events/XmlTagChildChanged.java +++ b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlTagChildChanged.java diff --git a/xml/openapi/src/com/intellij/pom/xml/events/XmlTagChildRemoved.java b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlTagChildRemoved.java index a65e1b3018ff..a65e1b3018ff 100644 --- a/xml/openapi/src/com/intellij/pom/xml/events/XmlTagChildRemoved.java +++ b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlTagChildRemoved.java diff --git a/xml/openapi/src/com/intellij/pom/xml/events/XmlTagNameChanged.java b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlTagNameChanged.java index dd3a5b23251d..dd3a5b23251d 100644 --- a/xml/openapi/src/com/intellij/pom/xml/events/XmlTagNameChanged.java +++ b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlTagNameChanged.java diff --git a/xml/openapi/src/com/intellij/pom/xml/events/XmlTextChanged.java b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlTextChanged.java index 0b26198dfd55..0b26198dfd55 100644 --- a/xml/openapi/src/com/intellij/pom/xml/events/XmlTextChanged.java +++ b/xml/xml-psi-api/src/com/intellij/pom/xml/events/XmlTextChanged.java diff --git a/xml/openapi/src/com/intellij/psi/XmlElementFactory.java b/xml/xml-psi-api/src/com/intellij/psi/XmlElementFactory.java index d94b87dbffad..d94b87dbffad 100644 --- a/xml/openapi/src/com/intellij/psi/XmlElementFactory.java +++ b/xml/xml-psi-api/src/com/intellij/psi/XmlElementFactory.java diff --git a/xml/openapi/src/com/intellij/psi/XmlElementVisitor.java b/xml/xml-psi-api/src/com/intellij/psi/XmlElementVisitor.java index 53a9f061f2b5..53a9f061f2b5 100644 --- a/xml/openapi/src/com/intellij/psi/XmlElementVisitor.java +++ b/xml/xml-psi-api/src/com/intellij/psi/XmlElementVisitor.java diff --git a/xml/openapi/src/com/intellij/psi/XmlRecursiveElementVisitor.java b/xml/xml-psi-api/src/com/intellij/psi/XmlRecursiveElementVisitor.java index 6c99c53fc424..6c99c53fc424 100644 --- a/xml/openapi/src/com/intellij/psi/XmlRecursiveElementVisitor.java +++ b/xml/xml-psi-api/src/com/intellij/psi/XmlRecursiveElementVisitor.java diff --git a/xml/openapi/src/com/intellij/psi/html/HtmlTag.java b/xml/xml-psi-api/src/com/intellij/psi/html/HtmlTag.java index 2507a17ac788..2507a17ac788 100644 --- a/xml/openapi/src/com/intellij/psi/html/HtmlTag.java +++ b/xml/xml-psi-api/src/com/intellij/psi/html/HtmlTag.java diff --git a/xml/openapi/src/com/intellij/psi/html/package.html b/xml/xml-psi-api/src/com/intellij/psi/html/package.html index b7198c1b02e6..b7198c1b02e6 100644 --- a/xml/openapi/src/com/intellij/psi/html/package.html +++ b/xml/xml-psi-api/src/com/intellij/psi/html/package.html diff --git a/xml/openapi/src/com/intellij/psi/tree/xml/IDTDElementType.java b/xml/xml-psi-api/src/com/intellij/psi/tree/xml/IDTDElementType.java index 05f186dfb817..fd51a11a1877 100644 --- a/xml/openapi/src/com/intellij/psi/tree/xml/IDTDElementType.java +++ b/xml/xml-psi-api/src/com/intellij/psi/tree/xml/IDTDElementType.java @@ -15,7 +15,7 @@ */ package com.intellij.psi.tree.xml; -import com.intellij.openapi.fileTypes.StdFileTypes; +import com.intellij.lang.dtd.DTDLanguage; import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NonNls; @@ -24,6 +24,6 @@ import org.jetbrains.annotations.NonNls; */ public class IDTDElementType extends IElementType { public IDTDElementType(@NonNls String debugName) { - super(debugName, StdFileTypes.DTD.getLanguage()); + super(debugName, DTDLanguage.INSTANCE); } } diff --git a/xml/openapi/src/com/intellij/psi/tree/xml/IXmlElementType.java b/xml/xml-psi-api/src/com/intellij/psi/tree/xml/IXmlElementType.java index 63510acc0281..4c2ee9c52c57 100644 --- a/xml/openapi/src/com/intellij/psi/tree/xml/IXmlElementType.java +++ b/xml/xml-psi-api/src/com/intellij/psi/tree/xml/IXmlElementType.java @@ -15,7 +15,7 @@ */ package com.intellij.psi.tree.xml; -import com.intellij.openapi.fileTypes.StdFileTypes; +import com.intellij.lang.xml.XMLLanguage; import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NonNls; @@ -24,6 +24,6 @@ import org.jetbrains.annotations.NonNls; */ public class IXmlElementType extends IElementType { public IXmlElementType(@NonNls String debugName) { - super(debugName, StdFileTypes.XML.getLanguage()); + super(debugName, XMLLanguage.INSTANCE); } } diff --git a/xml/openapi/src/com/intellij/psi/tree/xml/IXmlLeafElementType.java b/xml/xml-psi-api/src/com/intellij/psi/tree/xml/IXmlLeafElementType.java index b6e5c63b6faa..b6e5c63b6faa 100644 --- a/xml/openapi/src/com/intellij/psi/tree/xml/IXmlLeafElementType.java +++ b/xml/xml-psi-api/src/com/intellij/psi/tree/xml/IXmlLeafElementType.java diff --git a/xml/openapi/src/com/intellij/psi/tree/xml/package.html b/xml/xml-psi-api/src/com/intellij/psi/tree/xml/package.html index c7062616cad0..c7062616cad0 100644 --- a/xml/openapi/src/com/intellij/psi/tree/xml/package.html +++ b/xml/xml-psi-api/src/com/intellij/psi/tree/xml/package.html diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlAttlistDecl.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlAttlistDecl.java index 489af379c1c3..489af379c1c3 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlAttlistDecl.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlAttlistDecl.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlAttribute.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlAttribute.java index 3c49760b03f7..3c49760b03f7 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlAttribute.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlAttribute.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlAttributeDecl.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlAttributeDecl.java index 4854c66c49c2..4854c66c49c2 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlAttributeDecl.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlAttributeDecl.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlAttributeValue.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlAttributeValue.java index ea879230c57f..ea879230c57f 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlAttributeValue.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlAttributeValue.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlComment.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlComment.java index 212ba2cec3a4..212ba2cec3a4 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlComment.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlComment.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlConditionalSection.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlConditionalSection.java index bbbfc4f9a89a..bbbfc4f9a89a 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlConditionalSection.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlConditionalSection.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlContentParticle.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlContentParticle.java index de82e69372ff..de82e69372ff 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlContentParticle.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlContentParticle.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlDecl.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlDecl.java index 32408335090c..32408335090c 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlDecl.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlDecl.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlDoctype.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlDoctype.java index 461329c7a565..461329c7a565 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlDoctype.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlDoctype.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlDocument.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlDocument.java index d4441a5bcad4..d4441a5bcad4 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlDocument.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlDocument.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlElement.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlElement.java index 555bd672e4a0..555bd672e4a0 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlElement.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlElement.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlElementContentGroup.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlElementContentGroup.java index c2c22c438649..c2c22c438649 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlElementContentGroup.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlElementContentGroup.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlElementContentSpec.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlElementContentSpec.java index 8721c88877c6..8721c88877c6 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlElementContentSpec.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlElementContentSpec.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlElementDecl.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlElementDecl.java index d18b990b12b1..d18b990b12b1 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlElementDecl.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlElementDecl.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlEntityDecl.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlEntityDecl.java index 268b41c8b6b3..268b41c8b6b3 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlEntityDecl.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlEntityDecl.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlEntityRef.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlEntityRef.java index 5388b3e5a642..5388b3e5a642 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlEntityRef.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlEntityRef.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlEnumeratedType.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlEnumeratedType.java index 38b1dcbdea35..38b1dcbdea35 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlEnumeratedType.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlEnumeratedType.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlFile.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlFile.java index df2326fbdd51..df2326fbdd51 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlFile.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlFile.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlFileNSInfoProvider.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlFileNSInfoProvider.java index 1076de29ed7f..1076de29ed7f 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlFileNSInfoProvider.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlFileNSInfoProvider.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlMarkupDecl.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlMarkupDecl.java index 8592866f5f40..8592866f5f40 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlMarkupDecl.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlMarkupDecl.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlNotationDecl.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlNotationDecl.java index 6ca788c237be..6ca788c237be 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlNotationDecl.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlNotationDecl.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlProcessingInstruction.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlProcessingInstruction.java index 5233fac645b8..5233fac645b8 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlProcessingInstruction.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlProcessingInstruction.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlProlog.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlProlog.java index e05d380b73b2..e05d380b73b2 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlProlog.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlProlog.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlTag.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlTag.java index 8ca8bb01d5fa..8ca8bb01d5fa 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlTag.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlTag.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlTagChild.java index d1a322e39cb4..d1a322e39cb4 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlTagChild.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlTagValue.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlTagValue.java index aedef5bbb975..aedef5bbb975 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlTagValue.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlTagValue.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlText.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlText.java index 4c9a84d38b1a..4c9a84d38b1a 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlText.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlText.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlToken.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlToken.java index 202f9d203b06..202f9d203b06 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlToken.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlToken.java diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlTokenType.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlTokenType.java index 151afe206da7..151afe206da7 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlTokenType.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlTokenType.java diff --git a/xml/openapi/src/com/intellij/psi/xml/package.html b/xml/xml-psi-api/src/com/intellij/psi/xml/package.html index 4fa33e34bc11..4fa33e34bc11 100644 --- a/xml/openapi/src/com/intellij/psi/xml/package.html +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/package.html diff --git a/xml/openapi/src/com/intellij/xml/XmlAttributeDescriptor.java b/xml/xml-psi-api/src/com/intellij/xml/XmlAttributeDescriptor.java index 56a9604a1af8..56a9604a1af8 100644 --- a/xml/openapi/src/com/intellij/xml/XmlAttributeDescriptor.java +++ b/xml/xml-psi-api/src/com/intellij/xml/XmlAttributeDescriptor.java diff --git a/xml/openapi/src/com/intellij/xml/XmlElementDescriptor.java b/xml/xml-psi-api/src/com/intellij/xml/XmlElementDescriptor.java index 6627ca0e7eea..6627ca0e7eea 100644 --- a/xml/openapi/src/com/intellij/xml/XmlElementDescriptor.java +++ b/xml/xml-psi-api/src/com/intellij/xml/XmlElementDescriptor.java diff --git a/xml/openapi/src/com/intellij/xml/XmlElementDescriptorAwareAboutChildren.java b/xml/xml-psi-api/src/com/intellij/xml/XmlElementDescriptorAwareAboutChildren.java index 412a4b7e3082..412a4b7e3082 100644 --- a/xml/openapi/src/com/intellij/xml/XmlElementDescriptorAwareAboutChildren.java +++ b/xml/xml-psi-api/src/com/intellij/xml/XmlElementDescriptorAwareAboutChildren.java diff --git a/xml/openapi/src/com/intellij/xml/XmlElementDescriptorWithCDataContent.java b/xml/xml-psi-api/src/com/intellij/xml/XmlElementDescriptorWithCDataContent.java index e25fad9a66c2..e25fad9a66c2 100644 --- a/xml/openapi/src/com/intellij/xml/XmlElementDescriptorWithCDataContent.java +++ b/xml/xml-psi-api/src/com/intellij/xml/XmlElementDescriptorWithCDataContent.java diff --git a/xml/openapi/src/com/intellij/xml/XmlElementsGroup.java b/xml/xml-psi-api/src/com/intellij/xml/XmlElementsGroup.java index ed3af8bc520b..ed3af8bc520b 100644 --- a/xml/openapi/src/com/intellij/xml/XmlElementsGroup.java +++ b/xml/xml-psi-api/src/com/intellij/xml/XmlElementsGroup.java diff --git a/xml/openapi/src/com/intellij/xml/XmlNSDescriptor.java b/xml/xml-psi-api/src/com/intellij/xml/XmlNSDescriptor.java index 43228719cd27..43228719cd27 100644 --- a/xml/openapi/src/com/intellij/xml/XmlNSDescriptor.java +++ b/xml/xml-psi-api/src/com/intellij/xml/XmlNSDescriptor.java diff --git a/xml/openapi/src/com/intellij/xml/XmlNSDescriptorEx.java b/xml/xml-psi-api/src/com/intellij/xml/XmlNSDescriptorEx.java index bfd463f4d894..bfd463f4d894 100644 --- a/xml/openapi/src/com/intellij/xml/XmlNSDescriptorEx.java +++ b/xml/xml-psi-api/src/com/intellij/xml/XmlNSDescriptorEx.java diff --git a/xml/openapi/src/com/intellij/xml/XmlSchemaProvider.java b/xml/xml-psi-api/src/com/intellij/xml/XmlSchemaProvider.java index 8302e635f44a..25e4f1d7e87d 100644 --- a/xml/openapi/src/com/intellij/xml/XmlSchemaProvider.java +++ b/xml/xml-psi-api/src/com/intellij/xml/XmlSchemaProvider.java @@ -19,7 +19,7 @@ package com.intellij.xml; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.util.Condition; import com.intellij.psi.PsiDirectory; @@ -63,7 +63,7 @@ public abstract class XmlSchemaProvider { @Nullable public static XmlFile findSchema(@NotNull @NonNls String namespace, @NotNull PsiFile baseFile) { final PsiDirectory directory = baseFile.getParent(); - final Module module = ModuleUtil.findModuleForPsiElement(directory == null ? baseFile : directory); + final Module module = ModuleUtilCore.findModuleForPsiElement(directory == null ? baseFile : directory); return findSchema(namespace, module, baseFile); } diff --git a/xml/openapi/src/com/intellij/xml/util/XmlTagUtil.java b/xml/xml-psi-api/src/com/intellij/xml/util/XmlTagUtil.java index 62bb50e506e5..62bb50e506e5 100644 --- a/xml/openapi/src/com/intellij/xml/util/XmlTagUtil.java +++ b/xml/xml-psi-api/src/com/intellij/xml/util/XmlTagUtil.java diff --git a/xml/xml-psi-api/xml-psi-api.iml b/xml/xml-psi-api/xml-psi-api.iml new file mode 100644 index 000000000000..c571537f090b --- /dev/null +++ b/xml/xml-psi-api/xml-psi-api.iml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="module" module-name="core-api" /> + <orderEntry type="module" module-name="projectModel-api" /> + </component> +</module> + diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/XmlErrorMessages.java b/xml/xml-psi-impl/src/com/intellij/codeInsight/daemon/XmlErrorMessages.java index 77d0c1ee4b3b..77d0c1ee4b3b 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/XmlErrorMessages.java +++ b/xml/xml-psi-impl/src/com/intellij/codeInsight/daemon/XmlErrorMessages.java diff --git a/xml/impl/src/com/intellij/ide/highlighter/DTDFileType.java b/xml/xml-psi-impl/src/com/intellij/ide/highlighter/DTDFileType.java index 276837d5b869..276837d5b869 100644 --- a/xml/impl/src/com/intellij/ide/highlighter/DTDFileType.java +++ b/xml/xml-psi-impl/src/com/intellij/ide/highlighter/DTDFileType.java diff --git a/xml/impl/src/com/intellij/ide/highlighter/DomSupportEnabled.java b/xml/xml-psi-impl/src/com/intellij/ide/highlighter/DomSupportEnabled.java index ff27af059112..ff27af059112 100644 --- a/xml/impl/src/com/intellij/ide/highlighter/DomSupportEnabled.java +++ b/xml/xml-psi-impl/src/com/intellij/ide/highlighter/DomSupportEnabled.java diff --git a/xml/impl/src/com/intellij/ide/highlighter/XmlFileType.java b/xml/xml-psi-impl/src/com/intellij/ide/highlighter/XmlFileType.java index 7c0447d83261..7c0447d83261 100644 --- a/xml/impl/src/com/intellij/ide/highlighter/XmlFileType.java +++ b/xml/xml-psi-impl/src/com/intellij/ide/highlighter/XmlFileType.java diff --git a/xml/impl/src/com/intellij/ide/highlighter/XmlLikeFileType.java b/xml/xml-psi-impl/src/com/intellij/ide/highlighter/XmlLikeFileType.java index 5ac48880cf6c..db8d1fa40b1e 100644 --- a/xml/impl/src/com/intellij/ide/highlighter/XmlLikeFileType.java +++ b/xml/xml-psi-impl/src/com/intellij/ide/highlighter/XmlLikeFileType.java @@ -20,7 +20,7 @@ import com.intellij.openapi.fileTypes.LanguageFileType; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.xml.util.XmlUtil; +import com.intellij.util.text.XmlCharsetDetector; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -31,12 +31,12 @@ public abstract class XmlLikeFileType extends LanguageFileType { super(language); } public String getCharset(@NotNull VirtualFile file, final byte[] content) { - String charset = XmlUtil.extractXmlEncodingFromProlog(content); + String charset = XmlCharsetDetector.extractXmlEncodingFromProlog(content); return charset == null ? CharsetToolkit.UTF8 : charset; } public Charset extractCharsetFromFileContent(final Project project, @Nullable final VirtualFile file, @NotNull final String content) { - String name = XmlUtil.extractXmlEncodingFromProlog(content); + String name = XmlCharsetDetector.extractXmlEncodingFromProlog(content); Charset charset = CharsetToolkit.forName(name); return charset == null ? CharsetToolkit.UTF8_CHARSET : charset; } diff --git a/xml/impl/src/com/intellij/lang/xml/XMLParserDefinition.java b/xml/xml-psi-impl/src/com/intellij/lang/xml/XMLParserDefinition.java index a25df7758b13..a25df7758b13 100644 --- a/xml/impl/src/com/intellij/lang/xml/XMLParserDefinition.java +++ b/xml/xml-psi-impl/src/com/intellij/lang/xml/XMLParserDefinition.java diff --git a/xml/impl/src/com/intellij/lexer/DtdLexer.java b/xml/xml-psi-impl/src/com/intellij/lexer/DtdLexer.java index e7f14f0ef929..e7f14f0ef929 100644 --- a/xml/impl/src/com/intellij/lexer/DtdLexer.java +++ b/xml/xml-psi-impl/src/com/intellij/lexer/DtdLexer.java diff --git a/xml/impl/src/com/intellij/lexer/XmlLexer.java b/xml/xml-psi-impl/src/com/intellij/lexer/XmlLexer.java index c215e77f2a10..c215e77f2a10 100644 --- a/xml/impl/src/com/intellij/lexer/XmlLexer.java +++ b/xml/xml-psi-impl/src/com/intellij/lexer/XmlLexer.java diff --git a/xml/impl/src/com/intellij/lexer/_DtdLexer.flex b/xml/xml-psi-impl/src/com/intellij/lexer/_DtdLexer.flex index 0869996e5e6e..0869996e5e6e 100644 --- a/xml/impl/src/com/intellij/lexer/_DtdLexer.flex +++ b/xml/xml-psi-impl/src/com/intellij/lexer/_DtdLexer.flex diff --git a/xml/impl/src/com/intellij/lexer/_DtdLexer.java b/xml/xml-psi-impl/src/com/intellij/lexer/_DtdLexer.java index a9308edbafdb..a9308edbafdb 100644 --- a/xml/impl/src/com/intellij/lexer/_DtdLexer.java +++ b/xml/xml-psi-impl/src/com/intellij/lexer/_DtdLexer.java diff --git a/xml/impl/src/com/intellij/lexer/_XmlLexer.flex b/xml/xml-psi-impl/src/com/intellij/lexer/_XmlLexer.flex index 7715b9675800..7715b9675800 100644 --- a/xml/impl/src/com/intellij/lexer/_XmlLexer.flex +++ b/xml/xml-psi-impl/src/com/intellij/lexer/_XmlLexer.flex diff --git a/xml/impl/src/com/intellij/lexer/_XmlLexer.java b/xml/xml-psi-impl/src/com/intellij/lexer/_XmlLexer.java index d78deb86e315..d78deb86e315 100644 --- a/xml/impl/src/com/intellij/lexer/_XmlLexer.java +++ b/xml/xml-psi-impl/src/com/intellij/lexer/_XmlLexer.java diff --git a/xml/impl/src/com/intellij/lexer/__XmlLexer.java b/xml/xml-psi-impl/src/com/intellij/lexer/__XmlLexer.java index 6fb8b5cbd447..6fb8b5cbd447 100644 --- a/xml/impl/src/com/intellij/lexer/__XmlLexer.java +++ b/xml/xml-psi-impl/src/com/intellij/lexer/__XmlLexer.java diff --git a/xml/impl/src/com/intellij/psi/impl/source/html/ScriptSupportUtil.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/ScriptSupportUtil.java index 55d68f81d419..0cb4c12407a8 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/html/ScriptSupportUtil.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/ScriptSupportUtil.java @@ -27,8 +27,8 @@ import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.CachedValuesManager; import com.intellij.psi.xml.*; import com.intellij.xml.XmlElementDescriptor; -import com.intellij.xml.util.HtmlUtil; -import com.intellij.xml.util.XmlUtil; +import com.intellij.xml.util.HtmlPsiUtil; +import com.intellij.xml.util.XmlPsiUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -62,7 +62,7 @@ public class ScriptSupportUtil { @Override public Result<XmlTag[]> compute() { final List<XmlTag> scriptTags = new ArrayList<XmlTag>(); - final XmlDocument document = HtmlUtil.getRealXmlDocument(element.getDocument()); + final XmlDocument document = HtmlPsiUtil.getRealXmlDocument(element.getDocument()); if (document != null) { PsiElementProcessor psiElementProcessor = new PsiElementProcessor() { @@ -80,7 +80,7 @@ public class ScriptSupportUtil { return true; } }; - XmlUtil.processXmlElements(document, psiElementProcessor, true); + XmlPsiUtil.processXmlElements(document, psiElementProcessor, true); } return new Result<XmlTag[]>(scriptTags.toArray(new XmlTag[scriptTags.size()]), element); diff --git a/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/DtdParsing.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/DtdParsing.java index 06a1bea5fb6f..27c63443723d 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/DtdParsing.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/DtdParsing.java @@ -34,7 +34,6 @@ import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; import com.intellij.psi.xml.XmlElementType; import com.intellij.psi.xml.XmlEntityDecl; -import com.intellij.xml.XmlBundle; /** * @author Mike @@ -246,7 +245,7 @@ public class DtdParsing extends XmlParsing implements XmlElementType { if (myBuilder.getTokenType() == XML_LEFT_PAREN) { parseGroup(); } else { - myBuilder.error(XmlBundle.message("dtd.parser.message.name.expected")); + myBuilder.error(XmlErrorMessages.message("dtd.parser.message.name.expected")); return true; } } @@ -258,7 +257,7 @@ public class DtdParsing extends XmlParsing implements XmlElementType { if (tokenType != XML_ATTRIBUTE_VALUE_START_DELIMITER && tokenType != XML_DOCTYPE_PUBLIC && tokenType != XML_DOCTYPE_SYSTEM) { - myBuilder.error(XmlBundle.message("dtd.parser.message.literal.public.system.expected")); + myBuilder.error(XmlErrorMessages.message("dtd.parser.message.literal.public.system.expected")); return; } @@ -513,7 +512,7 @@ public class DtdParsing extends XmlParsing implements XmlElementType { private void doParseContentSpec(boolean topLevel) { if (!topLevel && myBuilder.rawLookup(0) != XML_WHITE_SPACE) { - myBuilder.error(XmlBundle.message("dtd.parser.message.whitespace.expected")); + myBuilder.error(XmlErrorMessages.message("dtd.parser.message.whitespace.expected")); } else if (!topLevel) { final IElementType tokenType = myBuilder.getTokenType(); String tokenText; @@ -526,7 +525,7 @@ public class DtdParsing extends XmlParsing implements XmlElementType { ) { PsiBuilder.Marker spec = myBuilder.mark(); spec.done(XML_ELEMENT_CONTENT_SPEC); - myBuilder.error(XmlBundle.message("dtd.parser.message.left.paren.or.entityref.or.empty.or.any.expected")); + myBuilder.error(XmlErrorMessages.message("dtd.parser.message.left.paren.or.entityref.or.empty.or.any.expected")); return; } } @@ -571,7 +570,7 @@ public class DtdParsing extends XmlParsing implements XmlElementType { endedWithDelimiter = false; } else { - myBuilder.error(XmlBundle.message("dtd.parser.message.name.or.entity.ref.expected")); + myBuilder.error(XmlErrorMessages.message("dtd.parser.message.name.or.entity.ref.expected")); return false; } @@ -597,7 +596,7 @@ public class DtdParsing extends XmlParsing implements XmlElementType { } if (endedWithDelimiter && tokenType == XML_RIGHT_PAREN) { - myBuilder.error(XmlBundle.message("dtd.parser.message.name.or.entity.ref.expected")); + myBuilder.error(XmlErrorMessages.message("dtd.parser.message.name.or.entity.ref.expected")); } return true; } @@ -611,7 +610,7 @@ public class DtdParsing extends XmlParsing implements XmlElementType { group.done(XML_ELEMENT_CONTENT_GROUP); return true; } else if (b) { - myBuilder.error(XmlBundle.message("dtd.parser.message.rbrace.expected")); + myBuilder.error(XmlErrorMessages.message("dtd.parser.message.rbrace.expected")); group.done(XML_ELEMENT_CONTENT_GROUP); return false; } @@ -632,7 +631,7 @@ public class DtdParsing extends XmlParsing implements XmlElementType { if (tokenType == XML_LEFT_PAREN) { parseGroup(); } else { - myBuilder.error(XmlBundle.message("dtd.parser.message.name.expected")); + myBuilder.error(XmlErrorMessages.message("dtd.parser.message.name.expected")); decl.done(XML_ATTLIST_DECL); return; } diff --git a/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/XmlBuilder.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/XmlBuilder.java index 0594a7063c06..0594a7063c06 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/XmlBuilder.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/XmlBuilder.java diff --git a/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParser.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParser.java index 02f336a348e1..02f336a348e1 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParser.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParser.java diff --git a/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParsing.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParsing.java index a98e5dbc5c53..a98e5dbc5c53 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParsing.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParsing.java diff --git a/xml/impl/src/com/intellij/psi/impl/source/tree/injected/XmlCommentLiteralEscaper.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/injected/XmlCommentLiteralEscaper.java index 8426623a835e..8426623a835e 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/tree/injected/XmlCommentLiteralEscaper.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/injected/XmlCommentLiteralEscaper.java diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlAttlistDeclImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttlistDeclImpl.java index 828e801d98a7..828e801d98a7 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlAttlistDeclImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttlistDeclImpl.java diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlCommentImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlCommentImpl.java index 9b3faa535ecb..9b3faa535ecb 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlCommentImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlCommentImpl.java diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlElementImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementImpl.java index 86b15fbdf979..e0ec1ad033c6 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlElementImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementImpl.java @@ -26,9 +26,7 @@ package com.intellij.psi.impl.source.xml; import com.intellij.lang.ASTNode; import com.intellij.lang.Language; -import com.intellij.psi.PsiAnchor; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; import com.intellij.psi.TokenType; import com.intellij.psi.impl.source.tree.CompositeElement; import com.intellij.psi.impl.source.tree.CompositePsiElement; @@ -40,7 +38,7 @@ import com.intellij.psi.tree.IElementType; import com.intellij.psi.xml.XmlElement; import com.intellij.psi.xml.XmlElementType; import com.intellij.psi.xml.XmlTag; -import com.intellij.xml.util.XmlUtil; +import com.intellij.xml.util.XmlPsiUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -50,11 +48,11 @@ public abstract class XmlElementImpl extends CompositePsiElement implements XmlE } public boolean processElements(PsiElementProcessor processor, PsiElement place){ - return XmlUtil.processXmlElements(this, processor, false); + return XmlPsiUtil.processXmlElements(this, processor, false); } public boolean processChildren(PsiElementProcessor processor){ - return XmlUtil.processXmlElementChildren(this, processor, false); + return XmlPsiUtil.processXmlElementChildren(this, processor, false); } public XmlElement findElementByTokenType(final IElementType type){ @@ -84,43 +82,9 @@ public abstract class XmlElementImpl extends CompositePsiElement implements XmlE return super.getParent(); } - @Nullable - private PsiElement findIncludedRoot() { - PsiElement cur = this; - while (cur != null && !(cur instanceof PsiFile)) { - final PsiElement parent = cur instanceof XmlElementImpl ? ((XmlElementImpl)cur).getAstParent() : cur.getParent(); - if (parent instanceof PsiFile && cur.getUserData(INCLUDING_ELEMENT) != null) { - return cur; - } - - cur = parent; - } - return null; - } - @NotNull public PsiElement getNavigationElement() { if (!isPhysical()) { - final PsiElement root = findIncludedRoot(); - if (root != null) { - final PsiAnchor anchor = root.getUserData(XmlUtil.ORIGINAL_ELEMENT); - if (anchor != null) { - final PsiElement original = anchor.retrieve(); - if (original != null) { - final int endOffset = getTextRange().getEndOffset() + original.getTextRange().getStartOffset(); - - PsiElement candidate = original.findElementAt(getTextRange().getStartOffset() - root.getTextRange().getStartOffset()); - while (candidate != null && candidate.getStartOffsetInParent() == 0 && candidate.getTextRange().getEndOffset() < endOffset) { - candidate = candidate.getParent(); - } - - if (candidate != null && candidate.getTextRange().getEndOffset() == endOffset) { - return candidate.getNavigationElement(); - } - } - } - } - final XmlElement including = getUserData(INCLUDING_ELEMENT); if (including != null) { return including; diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityCache.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityCache.java new file mode 100644 index 000000000000..b361463749a3 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityCache.java @@ -0,0 +1,65 @@ +package com.intellij.psi.impl.source.xml; + +import com.intellij.openapi.util.Key; +import com.intellij.psi.*; +import com.intellij.psi.util.CachedValue; +import com.intellij.psi.util.CachedValueProvider; +import com.intellij.psi.util.CachedValuesManager; +import com.intellij.psi.xml.XmlEntityDecl; + +import java.util.HashMap; +import java.util.Map; + +public class XmlEntityCache { + private static final Key<Map<String,CachedValue<XmlEntityDecl>>> XML_ENTITY_DECL_MAP = Key.create("XML_ENTITY_DECL_MAP"); + + public static void cacheParticularEntity(PsiFile file, XmlEntityDecl decl) { + synchronized(PsiLock.LOCK) { + final Map<String, CachedValue<XmlEntityDecl>> cachingMap = getCachingMap(file); + final String name = decl.getName(); + if (cachingMap.containsKey(name)) return; + final SmartPsiElementPointer declPointer = SmartPointerManager.getInstance(file.getProject()).createSmartPsiElementPointer(decl); + + cachingMap.put( + name, CachedValuesManager.getManager(file.getProject()).createCachedValue(new CachedValueProvider<XmlEntityDecl>() { + public Result<XmlEntityDecl> compute() { + PsiElement declElement = declPointer.getElement(); + if (declElement instanceof XmlEntityDecl && declElement.isValid() && name.equals(((XmlEntityDecl)declElement).getName())) + return new Result<XmlEntityDecl>((XmlEntityDecl)declElement, declElement); + cachingMap.put(name,null); + return new Result<XmlEntityDecl>(null,null); + } + }, + false + )); + } + } + + static Map<String, CachedValue<XmlEntityDecl>> getCachingMap(final PsiElement targetElement) { + Map<String, CachedValue<XmlEntityDecl>> map = targetElement.getUserData(XML_ENTITY_DECL_MAP); + if (map == null){ + map = new HashMap<String,CachedValue<XmlEntityDecl>>(); + targetElement.putUserData(XML_ENTITY_DECL_MAP, map); + } + return map; + } + + public static void copyEntityCaches(final PsiFile file, final PsiFile context) { + synchronized (PsiLock.LOCK) { + final Map<String, CachedValue<XmlEntityDecl>> cachingMap = getCachingMap(file); + for(Map.Entry<String,CachedValue<XmlEntityDecl>> entry:getCachingMap(context).entrySet()) { + cachingMap.put(entry.getKey(), entry.getValue()); + } + } + + } + + public static XmlEntityDecl getCachedEntity(PsiFile file, String name) { + CachedValue<XmlEntityDecl> cachedValue; + synchronized(PsiLock.LOCK) { + final Map<String, CachedValue<XmlEntityDecl>> cachingMap = getCachingMap(file); + cachedValue = cachingMap.get(name); + } + return cachedValue != null ? cachedValue.getValue():null; + } +} diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlFileImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlFileImpl.java index 6c9fd3c064cb..c85085f41c66 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlFileImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlFileImpl.java @@ -18,7 +18,7 @@ package com.intellij.psi.impl.source.xml; import com.intellij.lang.html.HTMLLanguage; import com.intellij.lang.xhtml.XHTMLLanguage; import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.FileTypeManager; +import com.intellij.openapi.fileTypes.FileTypeRegistry; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.impl.source.PsiFileImpl; @@ -83,7 +83,7 @@ public class XmlFileImpl extends PsiFileImpl implements XmlFile { myType = getLanguage().getAssociatedFileType(); if (myType == null) { VirtualFile virtualFile = getOriginalFile().getVirtualFile(); - myType = virtualFile == null ? FileTypeManager.getInstance().getFileTypeByFileName(getName()) : virtualFile.getFileType(); + myType = virtualFile == null ? FileTypeRegistry.getInstance().getFileTypeByFileName(getName()) : virtualFile.getFileType(); } } return myType; diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlPrologImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlPrologImpl.java index 88b534951634..88b534951634 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlPrologImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlPrologImpl.java diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlTagValueImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagValueImpl.java index 887cce5eeaee..887cce5eeaee 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlTagValueImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagValueImpl.java diff --git a/xml/impl/src/com/intellij/psi/xml/XmlChildRole.java b/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlChildRole.java index 0e39ab22e2ab..0e39ab22e2ab 100644 --- a/xml/impl/src/com/intellij/psi/xml/XmlChildRole.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlChildRole.java diff --git a/xml/impl/src/com/intellij/psi/xml/XmlElementType.java b/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlElementType.java index 4b33722b7876..4b33722b7876 100644 --- a/xml/impl/src/com/intellij/psi/xml/XmlElementType.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlElementType.java diff --git a/xml/impl/src/com/intellij/psi/xml/XmlTextElementType.java b/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlTextElementType.java index 911981f03d69..911981f03d69 100644 --- a/xml/impl/src/com/intellij/psi/xml/XmlTextElementType.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlTextElementType.java diff --git a/xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java b/xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java new file mode 100644 index 000000000000..347e04cd3571 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java @@ -0,0 +1,28 @@ +package com.intellij.xml; + +import com.intellij.core.CoreApplicationEnvironment; +import com.intellij.core.CoreProjectEnvironment; +import com.intellij.ide.highlighter.DTDFileType; +import com.intellij.ide.highlighter.XmlFileType; +import com.intellij.lang.LanguageParserDefinitions; +import com.intellij.lang.xml.XMLLanguage; +import com.intellij.lang.xml.XMLParserDefinition; +import com.intellij.openapi.extensions.Extensions; +import com.intellij.psi.xml.XmlChildRole; + +/** + * @author yole + */ +public class XmlCoreEnvironment { + public static void register(CoreApplicationEnvironment appEnvironment, CoreProjectEnvironment projectEnvironment) { + //appEnvironment.registerFileType(HtmlFileType.INSTANCE, "html;htm;sht;shtm;shtml"); + //appEnvironment.registerFileType(XHtmlFileType.INSTANCE, "xhtml"); + appEnvironment.registerFileType(DTDFileType.INSTANCE, "dtd;ent;mod;elt"); + + appEnvironment.registerFileType(XmlFileType.INSTANCE, "xml;xsd;tld;xsl;jnlp;wsdl;jhm;ant;xul;xslt;rng;fxml"); + + appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, XMLLanguage.INSTANCE, new XMLParserDefinition()); + + CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlChildRole.EP_NAME, XmlChildRole.StartTagEndTokenProvider.class); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlPsiUtil.java b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlPsiUtil.java new file mode 100644 index 000000000000..00e81f9caca4 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlPsiUtil.java @@ -0,0 +1,21 @@ +package com.intellij.xml.util; + +import com.intellij.psi.PsiFile; +import com.intellij.psi.templateLanguages.TemplateLanguageUtil; +import com.intellij.psi.xml.XmlDocument; +import com.intellij.psi.xml.XmlFile; +import org.jetbrains.annotations.Nullable; + +public class HtmlPsiUtil { + @Nullable + public static XmlDocument getRealXmlDocument(@Nullable XmlDocument doc) { + if (doc == null) return null; + final PsiFile containingFile = doc.getContainingFile(); + + final PsiFile templateFile = TemplateLanguageUtil.getTemplateFile(containingFile); + if (templateFile instanceof XmlFile) { + return ((XmlFile)templateFile).getDocument(); + } + return doc; + } +} diff --git a/xml/impl/src/com/intellij/xml/util/IncludedXmlAttribute.java b/xml/xml-psi-impl/src/com/intellij/xml/util/IncludedXmlAttribute.java index 988b7d00be12..988b7d00be12 100644 --- a/xml/impl/src/com/intellij/xml/util/IncludedXmlAttribute.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/IncludedXmlAttribute.java diff --git a/xml/impl/src/com/intellij/xml/util/IncludedXmlElement.java b/xml/xml-psi-impl/src/com/intellij/xml/util/IncludedXmlElement.java index ed92f434decc..ed92f434decc 100644 --- a/xml/impl/src/com/intellij/xml/util/IncludedXmlElement.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/IncludedXmlElement.java diff --git a/xml/impl/src/com/intellij/xml/util/IncludedXmlTag.java b/xml/xml-psi-impl/src/com/intellij/xml/util/IncludedXmlTag.java index 22481b1f7876..22481b1f7876 100644 --- a/xml/impl/src/com/intellij/xml/util/IncludedXmlTag.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/IncludedXmlTag.java diff --git a/xml/impl/src/com/intellij/xml/util/IncludedXmlText.java b/xml/xml-psi-impl/src/com/intellij/xml/util/IncludedXmlText.java index b98a360193b0..b98a360193b0 100644 --- a/xml/impl/src/com/intellij/xml/util/IncludedXmlText.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/IncludedXmlText.java diff --git a/xml/impl/src/com/intellij/xml/util/InclusionProvider.java b/xml/xml-psi-impl/src/com/intellij/xml/util/InclusionProvider.java index 9f637d59a193..f0970b7031b9 100644 --- a/xml/impl/src/com/intellij/xml/util/InclusionProvider.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/InclusionProvider.java @@ -76,7 +76,7 @@ class InclusionProvider implements CachedValueProvider<PsiElement[]> { final XmlDocument document = included != null ? included.getDocument() : null; final XmlTag rootTag = document != null ? document.getRootTag() : null; if (rootTag != null) { - final String xpointer = xincludeTag.getAttributeValue("xpointer", XmlUtil.XINCLUDE_URI); + final String xpointer = xincludeTag.getAttributeValue("xpointer", XmlPsiUtil.XINCLUDE_URI); final XmlTag[] includeTag = extractXpointer(rootTag, xpointer); PsiElement[] result = new PsiElement[includeTag.length]; for (int i = 0; i < includeTag.length; i++) { diff --git a/xml/impl/src/com/intellij/xml/util/XmlIncludeHandler.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlIncludeHandler.java index 68273799cbb4..5a7033bde3eb 100644 --- a/xml/impl/src/com/intellij/xml/util/XmlIncludeHandler.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlIncludeHandler.java @@ -17,11 +17,15 @@ package com.intellij.xml.util; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; -import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; import com.intellij.psi.xml.*; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + /** * @author mike */ @@ -34,7 +38,7 @@ public class XmlIncludeHandler { if (xmlTag.getParent() instanceof XmlDocument) return false; if (xmlTag.getLocalName().equals(INCLUDE_TAG_NAME) && xmlTag.getAttributeValue("href") != null) { - if (xmlTag.getNamespace().equals(XmlUtil.XINCLUDE_URI)) { + if (xmlTag.getNamespace().equals(XmlPsiUtil.XINCLUDE_URI)) { return true; } } @@ -51,14 +55,19 @@ public class XmlIncludeHandler { final XmlAttributeValue xmlAttributeValue = hrefAttribute.getValueElement(); if (xmlAttributeValue == null) return null; - final FileReferenceSet referenceSet = FileReferenceSet.createSet(xmlAttributeValue, false, true, false); - - final PsiReference reference = referenceSet.getLastReference(); - if (reference == null) return null; - - final PsiElement target = reference.resolve(); - - if (!(target instanceof XmlFile)) return null; - return (XmlFile)target; + List<PsiReference> references = Arrays.asList(xmlAttributeValue.getReferences()); + if (references.size() > 0) { + Collections.sort(references, new Comparator<PsiReference>() { + @Override + public int compare(PsiReference reference1, PsiReference reference2) { + return reference2.getRangeInElement().getStartOffset() - reference1.getRangeInElement().getStartOffset(); + } + }); + PsiElement target = references.get(0).resolve(); + if (target instanceof XmlFile) { + return (XmlFile) target; + } + } + return null; } } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlPsiUtil.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlPsiUtil.java new file mode 100644 index 000000000000..57cff1c08069 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlPsiUtil.java @@ -0,0 +1,223 @@ +package com.intellij.xml.util; + +import com.intellij.openapi.util.Key; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiLock; +import com.intellij.psi.impl.source.xml.XmlEntityCache; +import com.intellij.psi.search.PsiElementProcessor; +import com.intellij.psi.util.CachedValue; +import com.intellij.psi.util.CachedValueProvider; +import com.intellij.psi.util.CachedValuesManager; +import com.intellij.psi.xml.*; +import org.jetbrains.annotations.NonNls; + +public class XmlPsiUtil { + private static final Key<CachedValue<PsiElement>> PARSED_DECL_KEY = Key.create("PARSED_DECL_KEY"); + @NonNls public static final String XINCLUDE_URI = "http://www.w3.org/2001/XInclude"; + + public static boolean processXmlElements(XmlElement element, PsiElementProcessor processor, boolean deepFlag) { + return processXmlElements(element, processor, deepFlag, false); + } + + public static boolean processXmlElements(XmlElement element, PsiElementProcessor processor, boolean deepFlag, boolean wideFlag) { + if (element == null) return true; + PsiFile baseFile = element.isValid() ? element.getContainingFile() : null; + return processXmlElements(element, processor, deepFlag, wideFlag, baseFile); + } + + public static boolean processXmlElements(final XmlElement element, + final PsiElementProcessor processor, + final boolean deepFlag, + final boolean wideFlag, + final PsiFile baseFile) { + return processXmlElements(element, processor, deepFlag, wideFlag, baseFile, true); + } + + public static boolean processXmlElements(final XmlElement element, + final PsiElementProcessor processor, + final boolean deepFlag, + final boolean wideFlag, + final PsiFile baseFile, + boolean processIncludes) { + return new XmlElementProcessor(processor, baseFile).processXmlElements(element, deepFlag, wideFlag, processIncludes); + } + + public static boolean processXmlElementChildren(final XmlElement element, final PsiElementProcessor processor, final boolean deepFlag) { + final XmlPsiUtil.XmlElementProcessor p = new XmlPsiUtil.XmlElementProcessor(processor, element.getContainingFile()); + + final boolean wideFlag = false; + for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) { + if (!p.processElement(child, deepFlag, wideFlag, true) && !wideFlag) return false; + } + + return true; + } + + private static class XmlElementProcessor { + private final PsiElementProcessor processor; + private final PsiFile targetFile; + + XmlElementProcessor(PsiElementProcessor _processor, PsiFile _targetFile) { + processor = _processor; + targetFile = _targetFile; + } + + private boolean processXmlElements(PsiElement element, boolean deepFlag, boolean wideFlag, boolean processIncludes) { + if (deepFlag) if (!processor.execute(element)) return false; + + PsiElement startFrom = element.getFirstChild(); + + if (element instanceof XmlEntityRef) { + XmlEntityRef ref = (XmlEntityRef)element; + + PsiElement newElement = parseEntityRef(targetFile, ref); + + while (newElement != null) { + if (!processElement(newElement, deepFlag, wideFlag, processIncludes)) return false; + newElement = newElement.getNextSibling(); + } + + return true; + } + else if (element instanceof XmlConditionalSection) { + XmlConditionalSection xmlConditionalSection = (XmlConditionalSection)element; + if (!xmlConditionalSection.isIncluded(targetFile)) return true; + startFrom = xmlConditionalSection.getBodyStart(); + } + else if (processIncludes && XmlIncludeHandler.isXInclude(element)) { + for (PsiElement psiElement : InclusionProvider.getIncludedTags((XmlTag)element)) { + if (!processElement(psiElement, deepFlag, wideFlag, true)) return false; + } + } + + for (PsiElement child = startFrom; child != null; child = child.getNextSibling()) { + if (!processElement(child, deepFlag, wideFlag, processIncludes) && !wideFlag) return false; + } + + return true; + } + + private boolean processElement(PsiElement child, boolean deepFlag, boolean wideFlag, boolean processIncludes) { + if (deepFlag) { + if (!processXmlElements(child, true, wideFlag, processIncludes)) { + return false; + } + } + else { + if (child instanceof XmlEntityRef) { + if (!processXmlElements(child, false, wideFlag, processIncludes)) return false; + } + else if (child instanceof XmlConditionalSection) { + if (!processXmlElements(child, false, wideFlag, processIncludes)) return false; + } + else if (processIncludes && XmlIncludeHandler.isXInclude(child)) { + if (!processXmlElements(child, false, wideFlag, processIncludes)) return false; + } + else if (!processor.execute(child)) return false; + } + if (targetFile != null && child instanceof XmlEntityDecl) { + XmlEntityDecl xmlEntityDecl = (XmlEntityDecl)child; + XmlEntityCache.cacheParticularEntity(targetFile, xmlEntityDecl); + } + return true; + } + } + + private static PsiElement parseEntityRef(PsiFile targetFile, XmlEntityRef ref) { + XmlEntityDecl.EntityContextType type = getContextType(ref); + + { + final XmlEntityDecl entityDecl = ref.resolve(targetFile); + if (entityDecl != null) return parseEntityDecl(entityDecl, targetFile, type, ref); + } + + PsiElement e = ref; + while (e != null) { + if (e.getUserData(XmlElement.INCLUDING_ELEMENT) != null) { + e = e.getUserData(XmlElement.INCLUDING_ELEMENT); + final PsiFile f = e.getContainingFile(); + if (f != null) { + final XmlEntityDecl entityDecl = ref.resolve(targetFile); + if (entityDecl != null) return parseEntityDecl(entityDecl, targetFile, type, ref); + } + + continue; + } + if (e instanceof PsiFile) { + PsiFile refFile = (PsiFile)e; + final XmlEntityDecl entityDecl = ref.resolve(refFile); + if (entityDecl != null) return parseEntityDecl(entityDecl, targetFile, type, ref); + break; + } + + e = e.getParent(); + } + + final PsiElement element = ref.getUserData(XmlElement.DEPENDING_ELEMENT); + if (element instanceof XmlFile) { + final XmlEntityDecl entityDecl = ref.resolve((PsiFile)element); + if (entityDecl != null) return parseEntityDecl(entityDecl, targetFile, type, ref); + } + + return null; + } + + private static XmlEntityDecl.EntityContextType getContextType(XmlEntityRef ref) { + XmlEntityDecl.EntityContextType type = XmlEntityDecl.EntityContextType.GENERIC_XML; + PsiElement temp = ref; + while (temp != null) { + if (temp instanceof XmlAttributeDecl) { + type = XmlEntityDecl.EntityContextType.ATTRIBUTE_SPEC; + } + else if (temp instanceof XmlElementDecl) { + type = XmlEntityDecl.EntityContextType.ELEMENT_CONTENT_SPEC; + } + else if (temp instanceof XmlAttlistDecl) { + type = XmlEntityDecl.EntityContextType.ATTLIST_SPEC; + } + else if (temp instanceof XmlEntityDecl) { + type = XmlEntityDecl.EntityContextType.ENTITY_DECL_CONTENT; + } + else if (temp instanceof XmlEnumeratedType) { + type = XmlEntityDecl.EntityContextType.ENUMERATED_TYPE; + } + else if (temp instanceof XmlAttributeValue) { + type = XmlEntityDecl.EntityContextType.ATTR_VALUE; + } + else { + temp = temp.getContext(); + continue; + } + break; + } + return type; + } + + private static PsiElement parseEntityDecl(final XmlEntityDecl entityDecl, + final PsiFile targetFile, + final XmlEntityDecl.EntityContextType type, + final XmlEntityRef entityRef) { + synchronized (PsiLock.LOCK) { // we depend on targetFile and entityRef + CachedValue<PsiElement> value = entityRef.getUserData(PARSED_DECL_KEY); + // return entityDecl.parse(targetFile, type); + + if (value == null) { + value = CachedValuesManager.getManager(entityDecl.getProject()).createCachedValue(new CachedValueProvider<PsiElement>() { + public Result<PsiElement> compute() { + final PsiElement res = entityDecl.parse(targetFile, type, entityRef); + if (res == null) return new Result<PsiElement>(res, targetFile); + if (!entityDecl.isInternalReference()) XmlEntityCache.copyEntityCaches(res.getContainingFile(), targetFile); + return new Result<PsiElement>(res, res.getUserData(XmlElement.DEPENDING_ELEMENT), entityDecl, targetFile, entityRef); + } + }, false); + entityRef.putUserData(PARSED_DECL_KEY, value); + } + + return value.getValue(); + } + } + + + +} diff --git a/xml/xml-psi-impl/src/messages/XmlErrorMessages.properties b/xml/xml-psi-impl/src/messages/XmlErrorMessages.properties new file mode 100644 index 000000000000..41e0b335a04f --- /dev/null +++ b/xml/xml-psi-impl/src/messages/XmlErrorMessages.properties @@ -0,0 +1,85 @@ +plugin.reference.message.problem=Reference with class ''{0}'' provides invalid message pattern ''{1}'' +unknown.html.tag=Unknown html tag {0} +unescaped.ampersand=Unescaped \\& +escape.ampersand.quickfix=Escape Ampersand +rename.start.tag.name.intention=Rename start tag ''{0}'' to ''{1}'' +rename.end.tag.name.intention=Rename end tag ''{0}'' to ''{1}'' +extra.closing.tag.for.empty.element=Extra closing tag for empty element +wrong.closing.tag.name=Wrong closing tag name +tag.has.wrong.closing.tag.name=Start tag has wrong closing tag +element.is.not.allowed.here=Element {0} is not allowed here +element.must.be.declared=Element {0} must be declared +element.doesnt.have.required.attribute=Element {0} doesn''t have required attribute {1} +wrong.root.element=Wrong root element +unbound.namespace=Namespace ''{0}'' is not bound +unbound.namespace.no.param=Namespace is not bound +attribute.is.not.allowed.here=Attribute {0} is not allowed here +empty.attribute.is.not.allowed=Empty attribute {0} is not allowed +duplicate.attribute=Duplicate attribute {0} +duplicate.id.reference=Duplicate id reference +invalid.id.reference=Invalid id reference +uri.is.not.registered=URI is not registered (Settings | Project Settings | Schemas and DTDs) +registered.resource.is.not.recognized=Resource registered by this uri is not recognized (Settings | Project Settings | Schemas and DTDs) +# 0 - attr name, 1 - expected default value +attribute.should.have.fixed.value=Attribute {0} should have fixed value {1} + +#quickfixes +insert.required.attribute.quickfix.text=Insert Required Attribute {0} +insert.required.attribute.quickfix.family=Insert Required Attribute +create.tagfile.attribute.text=Create Tag File Attribute {0} +create.tagfile.attribute.family=Create Tag File Attribute +remove.attribute.quickfix.text=Remove Attribute {0} +remove.attribute.quickfix.family=Remove Attribute +remove.extra.closing.tag.quickfix=Remove Extra Closing Tag +create.namespace.declaration.quickfix=Create {0} Declaration +select.namespace.title={0} To Import +select.namespace.location.title=Select Namespace Location +declare.id.in.comment.quickfix=Declare Invalid Id In Comment Annotation +switch.to.html5.quickfix.text=Switch to HTML5 language level + +element.is.not.closed=Element is not closed +named.element.is.not.closed=Element {0} is not closed +top.level.element.is.not.completed=Top level element is not completed +expected.attribute.eq.sign='=' expected +tag.start.is.not.closed=Tag start is not closed +unescaped.ampersand.or.nonterminated.character.entity.reference=Unescaped \\& or nonterminated character/entity reference +expected.prologue.tag.termination.expected='?>' expected +expected.whitespace=Whitespace expected +wrong.attribute.value=Wrong attribute value +way.too.unbalanced=Way too unbalanced. Stopping attempt to balance tags properly at this point + +cannot.resolve.taglib.uri=Cannot resolve taglib with uri {0} +jsp.unparseable.content=Unparseable content +jsp.directive.end.expected=Directive end expected +attribute.value.expected=Attribute value expected +quote.expected=Quote expected +looking.in.tlds=Looking in available tag libraries +finding.acceptable.uri=Finding Acceptable URIs +looking.in.schemas=Looking in registered xml schemas +unknown.encoding.0=Unknown encoding: ''{0}'' + +# parsing errors +xml.parsing.absent.root.tag=Valid XML document must have a root tag +xml.parsing.unexpected.tokens=Unexpected tokens +xml.parsing.unexpected.end.of.file=Unexpected end of file +xml.parsing.unexpected.token=Unexpected token +xml.parsing.multiple.root.tags=Multiple root tags +xml.parsing.tag.name.expected=Tag name expected +xml.parsing.bad.character=Bad character +xml.parsing.unclosed.attribute.value=Attribute value is not closed +xml.parsing.attribute.value.expected=Attribute value expected +xml.parsing.processing.instruction.name.expected=Processing instruction name expected +xml.parsing.unterminated.processing.instruction=Processing instruction not terminated +xml.parsing.closing.tag.matches.nothing=Closing tag matches nothing +xml.parsing.closing.tag.name.missing=Closing tag name missing +xml.parsing.closing.tag.is.not.done=Closing tag is not done +attribute.should.be.preceded.with.space=There should be a space between attribute and previous attribute +cdata.end.should.not.appear.in.content.unless.to.mark.end.of.cdata.section=Character sequence ']]>' must not appear in content unless used to mark the end of a CDATA section +xml.declaration.should.precede.all.document.content=Xml declaration should precede all document content + +dtd.parser.message.whitespace.expected=Whitespace expected +dtd.parser.message.left.paren.or.entityref.or.empty.or.any.expected=( or entity ref or EMPTY or ANY expected +dtd.parser.message.name.expected=xml name expected +dtd.parser.message.literal.public.system.expected=Literal, PUBLIC or SYSTEM expected +dtd.parser.message.name.or.entity.ref.expected=Xml name or entity ref expected +dtd.parser.message.rbrace.expected=) expected diff --git a/xml/xml-psi-impl/xml-psi-impl.iml b/xml/xml-psi-impl/xml-psi-impl.iml new file mode 100644 index 000000000000..f5e4ab737ec8 --- /dev/null +++ b/xml/xml-psi-impl/xml-psi-impl.iml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="module" module-name="core-api" /> + <orderEntry type="module" module-name="xml-psi-api" /> + <orderEntry type="module" module-name="core-impl" /> + </component> +</module> + |