summaryrefslogtreecommitdiff
path: root/xml/impl
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2013-07-08 11:26:24 -0700
committerTor Norbye <tnorbye@google.com>2013-07-08 11:26:24 -0700
commitc1ace1f7e1e49c81bb4b75377c99f07be340abfe (patch)
tree9d0db96bd3d86ddfec80e7e3554cad9dcc066553 /xml/impl
parentc6218e46d5d2017e987ecdbd99b318a95c42abc0 (diff)
downloadidea-c1ace1f7e1e49c81bb4b75377c99f07be340abfe.tar.gz
Snapshot aea001abfc1b38fec3a821bcd5174cc77dc75787 from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: Icdea2a2bd7ad43b4d05967b1f0479db3bda1c93c
Diffstat (limited to 'xml/impl')
-rw-r--r--xml/impl/resources/com/intellij/codeInsight/completion/TagNameReferenceCompletionProvider.java23
-rw-r--r--xml/impl/resources/liveTemplates/zen_html.xml40
-rw-r--r--xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java4
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java8
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/tokens/TemplateToken.java35
-rw-r--r--xml/impl/src/com/intellij/ide/browsers/OpenFileInBrowserAction.java80
-rw-r--r--xml/impl/src/com/intellij/ide/browsers/OpenUrlHyperlinkInfo.java5
-rw-r--r--xml/impl/src/com/intellij/ide/browsers/UrlImpl.java36
-rw-r--r--xml/impl/src/com/intellij/ide/browsers/Urls.java22
-rw-r--r--xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java16
-rw-r--r--xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java24
-rw-r--r--xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.java48
-rw-r--r--xml/impl/src/com/intellij/ide/util/treeView/XmlDoctypeNodeDescriptor.java3
-rw-r--r--xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java562
-rw-r--r--xml/impl/src/com/intellij/javaee/InternalResourceProvider.java66
-rw-r--r--xml/impl/src/com/intellij/javaee/ResourceRegistrarImpl.java84
-rw-r--r--xml/impl/src/com/intellij/javaee/XMLCatalogManager.java92
-rw-r--r--xml/impl/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.java8
-rw-r--r--xml/impl/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.java5
-rw-r--r--xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java6
-rw-r--r--xml/impl/src/com/intellij/lang/html/structureView/HtmlFileTreeElement.java7
-rw-r--r--xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.java10
-rw-r--r--xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java12
-rw-r--r--xml/impl/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.java84
-rw-r--r--xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java5
-rw-r--r--xml/impl/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.java7
-rw-r--r--xml/impl/src/com/intellij/xml/arrangement/XmlArrangementVisitor.java8
-rw-r--r--xml/impl/src/com/intellij/xml/arrangement/XmlElementArrangementEntry.java16
-rw-r--r--xml/impl/src/com/intellij/xml/arrangement/XmlRearranger.java23
-rw-r--r--xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java23
-rw-r--r--xml/impl/src/com/intellij/xml/impl/schema/SchemaDefinitionsSearch.java9
-rw-r--r--xml/impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java2
32 files changed, 381 insertions, 992 deletions
diff --git a/xml/impl/resources/com/intellij/codeInsight/completion/TagNameReferenceCompletionProvider.java b/xml/impl/resources/com/intellij/codeInsight/completion/TagNameReferenceCompletionProvider.java
index fa2f1609c3b9..45220b08a552 100644
--- a/xml/impl/resources/com/intellij/codeInsight/completion/TagNameReferenceCompletionProvider.java
+++ b/xml/impl/resources/com/intellij/codeInsight/completion/TagNameReferenceCompletionProvider.java
@@ -23,9 +23,11 @@ import com.intellij.codeInsight.lookup.TailTypeDecorator;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
+import com.intellij.psi.impl.source.xml.SchemaPrefixReference;
import com.intellij.psi.impl.source.xml.TagNameReference;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.Consumer;
+import com.intellij.util.PairConsumer;
import com.intellij.util.ProcessingContext;
import com.intellij.xml.XmlTagNameProvider;
import org.jetbrains.annotations.NotNull;
@@ -48,12 +50,21 @@ public class TagNameReferenceCompletionProvider extends CompletionProvider<Compl
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
- @NotNull CompletionResultSet result) {
- PsiReference reference = parameters.getPosition().getContainingFile().findReferenceAt(parameters.getOffset());
- if (reference instanceof TagNameReference) {
- TagNameReference tagNameReference = (TagNameReference)reference;
- collectCompletionVariants(tagNameReference, result);
- }
+ @NotNull final CompletionResultSet result) {
+ LegacyCompletionContributor.processReferences(parameters, result, new PairConsumer<PsiReference, CompletionResultSet>() {
+ @Override
+ public void consume(PsiReference reference, CompletionResultSet set) {
+ if (reference instanceof TagNameReference) {
+ collectCompletionVariants((TagNameReference)reference, set);
+ }
+ else if (reference instanceof SchemaPrefixReference) {
+ TagNameReference tagNameReference = ((SchemaPrefixReference)reference).getTagNameReference();
+ if (tagNameReference != null && !tagNameReference.isStartTagFlag()) {
+ set.consume(createClosingTagLookupElement((XmlTag)tagNameReference.getElement(), true, tagNameReference.getNameElement()));
+ }
+ }
+ }
+ });
}
public static void collectCompletionVariants(TagNameReference tagNameReference,
diff --git a/xml/impl/resources/liveTemplates/zen_html.xml b/xml/impl/resources/liveTemplates/zen_html.xml
index 0f77507510b2..58009a6ab885 100644
--- a/xml/impl/resources/liveTemplates/zen_html.xml
+++ b/xml/impl/resources/liveTemplates/zen_html.xml
@@ -62,7 +62,7 @@
</context>
</template>
<template description="" name="!" toReformat="true" toShortenFQNames="true"
- value="&lt;!doctype html&gt;&#10;&lt;html lang=&quot;$ENV_LOCALE$&quot;&gt;&#10;&lt;head&gt;&#10; &lt;meta charset=&quot;UTF-8&quot;&gt;&#10; &lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
+ value="&lt;!doctype html&gt;&#10;&lt;html lang=&quot;$ENV_LOCALE$&quot;&gt;&#10;&lt;head&gt;&#10;&lt;meta charset=&quot;UTF-8&quot;&gt;&#10;&lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
<variable alwaysStopAt="true" defaultValue="&quot;en&quot;" expression="" name="ENV_LOCALE"/>
<variable alwaysStopAt="true" defaultValue="&quot;Document&quot;" expression="" name="TITLE"/>
<context>
@@ -1032,21 +1032,21 @@
</context>
</template>
<template description="" name="doc" toReformat="true" toShortenFQNames="true"
- value="&lt;html&gt;&#10;&lt;head&gt;&#10; &lt;meta charset=&quot;UTF-8&quot;&gt;&#10; &lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
+ value="&lt;html&gt;&#10;&lt;head&gt;&#10;&lt;meta charset=&quot;UTF-8&quot;&gt;&#10;&lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
<variable alwaysStopAt="true" defaultValue="&quot;Document&quot;" expression="" name="TITLE"/>
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
<template description="" name="doc4" toReformat="true" toShortenFQNames="true"
- value="&lt;html&gt;&#10;&lt;head&gt;&#10; &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=UTF-8&quot;&gt;&#10; &lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
+ value="&lt;html&gt;&#10;&lt;head&gt;&#10;&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=UTF-8&quot;&gt;&#10;&lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
<variable alwaysStopAt="true" defaultValue="&quot;Document&quot;" expression="" name="TITLE"/>
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
<template description="" name="html:4t" toReformat="true" toShortenFQNames="true"
- value="&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;&#10;&lt;html lang=&quot;$ENV_LANG$&quot;&gt;&#10;&lt;head&gt;&#10; &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=UTF-8&quot;&gt;&#10; &lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
+ value="&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;&#10;&lt;html lang=&quot;$ENV_LANG$&quot;&gt;&#10;&lt;head&gt;&#10;&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=UTF-8&quot;&gt;&#10;&lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
<variable alwaysStopAt="true" defaultValue="&quot;en&quot;" expression="" name="ENV_LANG"/>
<variable alwaysStopAt="true" defaultValue="&quot;Document&quot;" expression="" name="TITLE"/>
<context>
@@ -1054,7 +1054,7 @@
</context>
</template>
<template description="" name="html:4s" toReformat="true" toShortenFQNames="true"
- value="&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;&#10;&lt;html lang=&quot;$ENV_LANG$&quot;&gt;&#10;&lt;head&gt;&#10; &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=UTF-8&quot;&gt;&#10; &lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
+ value="&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;&#10;&lt;html lang=&quot;$ENV_LANG$&quot;&gt;&#10;&lt;head&gt;&#10;&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=UTF-8&quot;&gt;&#10;&lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
<variable alwaysStopAt="true" defaultValue="&quot;en&quot;" expression="" name="ENV_LANG"/>
<variable alwaysStopAt="true" defaultValue="&quot;Document&quot;" expression="" name="TITLE"/>
<context>
@@ -1062,7 +1062,7 @@
</context>
</template>
<template description="" name="html:xt" toReformat="true" toShortenFQNames="true"
- value="&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;&#10;&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;$ENV_LANG$&quot;&gt;&#10;&lt;head&gt;&#10; &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=UTF-8&quot;&gt;&#10; &lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
+ value="&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;&#10;&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;$ENV_LANG$&quot;&gt;&#10;&lt;head&gt;&#10;&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=UTF-8&quot;&gt;&#10;&lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
<variable alwaysStopAt="true" defaultValue="&quot;en&quot;" expression="" name="ENV_LANG"/>
<variable alwaysStopAt="true" defaultValue="&quot;Document&quot;" expression="" name="TITLE"/>
<context>
@@ -1070,7 +1070,7 @@
</context>
</template>
<template description="" name="html:xs" toReformat="true" toShortenFQNames="true"
- value="&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;&#10;&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;$ENV_LANG$&quot;&gt;&#10;&lt;head&gt;&#10; &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=UTF-8&quot;&gt;&#10; &lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
+ value="&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;&#10;&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;$ENV_LANG$&quot;&gt;&#10;&lt;head&gt;&#10;&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=UTF-8&quot;&gt;&#10;&lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
<variable alwaysStopAt="true" defaultValue="&quot;en&quot;" expression="" name="ENV_LANG"/>
<variable alwaysStopAt="true" defaultValue="&quot;Document&quot;" expression="" name="TITLE"/>
<context>
@@ -1078,7 +1078,7 @@
</context>
</template>
<template description="" name="html:xxs" toReformat="true" toShortenFQNames="true"
- value="&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot; &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;&#10;&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;$ENV_LANG$&quot;&gt;&#10;&lt;head&gt;&#10; &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=UTF-8&quot;&gt;&#10; &lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
+ value="&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot; &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;&#10;&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;$ENV_LANG$&quot;&gt;&#10;&lt;head&gt;&#10;&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=UTF-8&quot;&gt;&#10;&lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
<variable alwaysStopAt="true" defaultValue="&quot;en&quot;" expression="" name="ENV_LANG"/>
<variable alwaysStopAt="true" defaultValue="&quot;Document&quot;" expression="" name="TITLE"/>
<context>
@@ -1086,30 +1086,30 @@
</context>
</template>
<template description="" name="html:5" toReformat="true" toShortenFQNames="true"
- value="&lt;!doctype html&gt;&#10;&lt;html lang=&quot;$ENV_LOCALE$&quot;&gt;&#10;&lt;head&gt;&#10; &lt;meta charset=&quot;UTF-8&quot;&gt;&#10; &lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
+ value="&lt;!doctype html&gt;&#10;&lt;html lang=&quot;$ENV_LOCALE$&quot;&gt;&#10;&lt;head&gt;&#10;&lt;meta charset=&quot;UTF-8&quot;&gt;&#10;&lt;title&gt;$TITLE$&lt;/title&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10; $END$&#10;&lt;/body&gt;&#10;&lt;/html&gt;">
<variable alwaysStopAt="true" defaultValue="&quot;en&quot;" expression="" name="ENV_LOCALE"/>
<variable alwaysStopAt="true" defaultValue="&quot;Document&quot;" expression="" name="TITLE"/>
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="ol+" toReformat="true" toShortenFQNames="true" value="&lt;ol&gt;&#10; &lt;li&gt;$END$&lt;/li&gt;&#10;&lt;/ol&gt;">
+ <template description="" name="ol+" toReformat="true" toShortenFQNames="true" value="&lt;ol&gt;&#10;&lt;li&gt;$END$&lt;/li&gt;&#10;&lt;/ol&gt;">
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="ul+" toReformat="true" toShortenFQNames="true" value="&lt;ul&gt;&#10; &lt;li&gt;$END$&lt;/li&gt;&#10;&lt;/ul&gt;">
+ <template description="" name="ul+" toReformat="true" toShortenFQNames="true" value="&lt;ul&gt;&#10;&lt;li&gt;$END$&lt;/li&gt;&#10;&lt;/ul&gt;">
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="dl+" toReformat="true" toShortenFQNames="true" value="&lt;dl&gt;&#10; &lt;dt&gt;$VAR0$&lt;/dt&gt;&#10; &lt;dd&gt;$END$&lt;/dd&gt;&#10;&lt;/dl&gt;">
+ <template description="" name="dl+" toReformat="true" toShortenFQNames="true" value="&lt;dl&gt;&#10;&lt;dt&gt;$VAR0$&lt;/dt&gt;&#10;&lt;dd&gt;$END$&lt;/dd&gt;&#10;&lt;/dl&gt;">
<variable alwaysStopAt="true" defaultValue="&quot;&quot;" expression="" name="VAR0"/>
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="map+" toReformat="true" toShortenFQNames="true" value="&lt;map name=&quot;$VAR0$&quot;&gt;&#10; &lt;area shape=&quot;$VAR1$&quot; coords=&quot;$VAR2$&quot; href=&quot;$VAR3$&quot; alt=&quot;$VAR4$&quot;/&gt;$END$&#10;&lt;/map&gt;">
+ <template description="" name="map+" toReformat="true" toShortenFQNames="true" value="&lt;map name=&quot;$VAR0$&quot;&gt;&#10;&lt;area shape=&quot;$VAR1$&quot; coords=&quot;$VAR2$&quot; href=&quot;$VAR3$&quot; alt=&quot;$VAR4$&quot;/&gt;$END$&#10;&lt;/map&gt;">
<variable alwaysStopAt="true" defaultValue="&quot;&quot;" expression="" name="VAR0"/>
<variable alwaysStopAt="true" defaultValue="&quot;&quot;" expression="" name="VAR1"/>
<variable alwaysStopAt="true" defaultValue="&quot;&quot;" expression="" name="VAR2"/>
@@ -1119,27 +1119,27 @@
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="table+" toReformat="true" toShortenFQNames="true" value="&lt;table&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;$END$&lt;/td&gt;&#10; &lt;/tr&gt;&#10;&lt;/table&gt;">
+ <template description="" name="table+" toReformat="true" toShortenFQNames="true" value="&lt;table&gt;&#10;&lt;tr&gt;&#10;&lt;td&gt;$END$&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/table&gt;">
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="colgroup+" toReformat="true" toShortenFQNames="true" value="&lt;colgroup&gt;&#10; &lt;col/&gt;&#10;&lt;/colgroup&gt;">
+ <template description="" name="colgroup+" toReformat="true" toShortenFQNames="true" value="&lt;colgroup&gt;&#10;&lt;col/&gt;&#10;&lt;/colgroup&gt;">
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="colg+" toReformat="true" toShortenFQNames="true" value="&lt;colgroup&gt;&#10; &lt;col/&gt;&#10;&lt;/colgroup&gt;">
+ <template description="" name="colg+" toReformat="true" toShortenFQNames="true" value="&lt;colgroup&gt;&#10;&lt;col/&gt;&#10;&lt;/colgroup&gt;">
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="tr+" toReformat="true" toShortenFQNames="true" value="&lt;tr&gt;&#10; &lt;td&gt;$END$&lt;/td&gt;&#10;&lt;/tr&gt;">
+ <template description="" name="tr+" toReformat="true" toShortenFQNames="true" value="&lt;tr&gt;&#10;&lt;td&gt;$END$&lt;/td&gt;&#10;&lt;/tr&gt;">
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="select+" toReformat="true" toShortenFQNames="true" value="&lt;select name=&quot;$VAR0$&quot; id=&quot;$VAR1$&quot;&gt;&#10; &lt;option value=&quot;$VAR2$&quot;&gt;$END$&lt;/option&gt;&#10;&lt;/select&gt;">
+ <template description="" name="select+" toReformat="true" toShortenFQNames="true" value="&lt;select name=&quot;$VAR0$&quot; id=&quot;$VAR1$&quot;&gt;&#10;&lt;option value=&quot;$VAR2$&quot;&gt;$END$&lt;/option&gt;&#10;&lt;/select&gt;">
<variable alwaysStopAt="true" defaultValue="&quot;&quot;" expression="" name="VAR0"/>
<variable alwaysStopAt="true" defaultValue="&quot;&quot;" expression="" name="VAR1"/>
<variable alwaysStopAt="true" defaultValue="&quot;&quot;" expression="" name="VAR2"/>
@@ -1147,13 +1147,13 @@
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="optgroup+" toReformat="true" toShortenFQNames="true" value="&lt;optgroup&gt;&#10; &lt;option value=&quot;$VAR0$&quot;&gt;$END$&lt;/option&gt;&#10;&lt;/optgroup&gt;">
+ <template description="" name="optgroup+" toReformat="true" toShortenFQNames="true" value="&lt;optgroup&gt;&#10;&lt;option value=&quot;$VAR0$&quot;&gt;$END$&lt;/option&gt;&#10;&lt;/optgroup&gt;">
<variable alwaysStopAt="true" defaultValue="&quot;&quot;" expression="" name="VAR0"/>
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="optg+" toReformat="true" toShortenFQNames="true" value="&lt;optgroup&gt;&#10; &lt;option value=&quot;$VAR0$&quot;&gt;$END$&lt;/option&gt;&#10;&lt;/optgroup&gt;">
+ <template description="" name="optg+" toReformat="true" toShortenFQNames="true" value="&lt;optgroup&gt;&#10;&lt;option value=&quot;$VAR0$&quot;&gt;$END$&lt;/option&gt;&#10;&lt;/optgroup&gt;">
<variable alwaysStopAt="true" defaultValue="&quot;&quot;" expression="" name="VAR0"/>
<context>
<option name="HTML_TEXT" value="true"/>
diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java
index d39630b07288..0509068e1dcf 100644
--- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java
+++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java
@@ -685,12 +685,12 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV
}
@Override
- public void addMessage(PsiElement context, String message, ErrorType type) {
+ public void addMessage(PsiElement context, String message, @NotNull ErrorType type) {
addMessageWithFixes(context, message, type);
}
@Override
- public void addMessageWithFixes(final PsiElement context, final String message, final ErrorType type, final IntentionAction... fixes) {
+ public void addMessageWithFixes(final PsiElement context, final String message, @NotNull final ErrorType type, final IntentionAction... fixes) {
if (message != null && !message.isEmpty()) {
final PsiFile containingFile = context.getContainingFile();
final HighlightInfoType defaultInfoType = type == ErrorType.ERROR ? HighlightInfoType.ERROR : type == ErrorType.WARNING ? HighlightInfoType.WARNING : HighlightInfoType.WEAK_WARNING;
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
index b945ca3fdd92..a57464ba7e20 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
@@ -65,7 +65,7 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
}
@Nullable
- private static ZenCodingNode parse(@NotNull String text,
+ public static ZenCodingNode parse(@NotNull String text,
@NotNull CustomTemplateCallback callback,
@NotNull ZenCodingGenerator generator, @Nullable String surroundedText) {
List<ZenCodingToken> tokens = new EmmetLexer().lex(text);
@@ -154,12 +154,14 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
}
- private static void expand(String key,
+ public static void expand(String key,
@NotNull CustomTemplateCallback callback,
String surroundedText,
@NotNull ZenCodingGenerator defaultGenerator) {
ZenCodingNode node = parse(key, callback, defaultGenerator, surroundedText);
- assert node != null;
+ if (node == null) {
+ return;
+ }
if (surroundedText == null) {
if (node instanceof TemplateNode) {
if (key.equals(((TemplateNode)node).getTemplateToken().getKey()) &&
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/tokens/TemplateToken.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/tokens/TemplateToken.java
index 25a4c5b1f054..c64946d65010 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/tokens/TemplateToken.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/tokens/TemplateToken.java
@@ -17,7 +17,6 @@ package com.intellij.codeInsight.template.emmet.tokens;
import com.intellij.codeInsight.template.CustomTemplateCallback;
import com.intellij.codeInsight.template.impl.TemplateImpl;
-import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.undo.UndoConstants;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.util.Pair;
@@ -25,7 +24,6 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFileFactory;
import com.intellij.psi.XmlElementFactory;
import com.intellij.psi.xml.XmlAttribute;
-import com.intellij.psi.xml.XmlDocument;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.ArrayUtil;
@@ -76,22 +74,12 @@ public class TemplateToken extends ZenCodingToken {
public boolean setTemplate(TemplateImpl template, CustomTemplateCallback callback) {
myTemplate = template;
- final XmlFile xmlFile = parseXmlFileInTemplate(template.getString(), callback, true);
+ final XmlFile xmlFile = parseXmlFileInTemplate(template, callback, getAttribute2Value());
setFile(xmlFile);
- XmlDocument document = xmlFile.getDocument();
- final XmlTag tag = document != null ? document.getRootTag() : null;
+ final XmlTag tag = xmlFile.getRootTag();
if (getAttribute2Value().size() > 0 && tag == null) {
return false;
}
- if (tag != null) {
- if (!containsAttrsVar(template) && getAttribute2Value().size() > 0) {
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- public void run() {
- addMissingAttributes(tag, getAttribute2Value());
- }
- });
- }
- }
return true;
}
@@ -107,9 +95,22 @@ public class TemplateToken extends ZenCodingToken {
}
@NotNull
- private static XmlFile parseXmlFileInTemplate(String templateString, CustomTemplateCallback callback, boolean createPhysicalFile) {
- XmlFile xmlFile = (XmlFile)PsiFileFactory.getInstance(callback.getProject())
- .createFileFromText("dummy.xml", StdFileTypes.XML, templateString, LocalTimeCounter.currentTime(), createPhysicalFile);
+ private static XmlFile parseXmlFileInTemplate(TemplateImpl template,
+ CustomTemplateCallback callback,
+ List<Pair<String, String>> attributes) {
+ XmlTag dummyRootTag = null;
+ String templateString = template.getString();
+ final PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(callback.getProject());
+ if (!containsAttrsVar(template)) {
+ XmlFile dummyFile = (XmlFile)psiFileFactory.createFileFromText("dummy.xml", StdFileTypes.XML, templateString);
+ dummyRootTag = dummyFile.getRootTag();
+ if (dummyRootTag != null) {
+ addMissingAttributes(dummyRootTag, attributes);
+ }
+ }
+
+ templateString = dummyRootTag != null ? dummyRootTag.getContainingFile().getText() : templateString;
+ XmlFile xmlFile = (XmlFile)psiFileFactory.createFileFromText("dummy.xml", StdFileTypes.XML, templateString, LocalTimeCounter.currentTime(), true);
VirtualFile vFile = xmlFile.getVirtualFile();
if (vFile != null) {
vFile.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
diff --git a/xml/impl/src/com/intellij/ide/browsers/OpenFileInBrowserAction.java b/xml/impl/src/com/intellij/ide/browsers/OpenFileInBrowserAction.java
index 130fd1fc17f9..969e7f8b3793 100644
--- a/xml/impl/src/com/intellij/ide/browsers/OpenFileInBrowserAction.java
+++ b/xml/impl/src/com/intellij/ide/browsers/OpenFileInBrowserAction.java
@@ -25,6 +25,7 @@ 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.testFramework.LightVirtualFile;
import com.intellij.xml.XmlBundle;
import com.intellij.xml.util.HtmlUtil;
@@ -39,48 +40,59 @@ public class OpenFileInBrowserAction extends DumbAwareAction {
final PsiFile file = LangDataKeys.PSI_FILE.getData(dataContext);
final Presentation presentation = e.getPresentation();
- if (file != null && file.getVirtualFile() != null) {
- presentation.setVisible(true);
-
- Pair<WebBrowserUrlProvider, Url> browserUrlProvider = WebBrowserServiceImpl.getProvider(file);
- final boolean isHtmlFile = HtmlUtil.isHtmlFile(file);
- presentation.setEnabled(browserUrlProvider != null || isHtmlFile);
-
- String text = getTemplatePresentation().getText();
- String description = getTemplatePresentation().getDescription();
+ if (file == null || file.getVirtualFile() == null) {
+ presentation.setVisible(false);
+ presentation.setEnabled(false);
+ return;
+ }
- if (browserUrlProvider != null) {
- final String customText = browserUrlProvider.first.getOpenInBrowserActionText(file);
- if (customText != null) {
- text = customText;
- }
- final String customDescription = browserUrlProvider.first.getOpenInBrowserActionDescription(file);
- if (customDescription != null) {
- description = customDescription;
- }
- if (isHtmlFile) {
- description += " (hold Shift to open URL of local file)";
- }
+ Pair<WebBrowserUrlProvider, Url> browserUrlProvider = WebBrowserServiceImpl.getProvider(file);
+ final boolean isHtmlFile = HtmlUtil.isHtmlFile(file);
+ if (browserUrlProvider == null) {
+ if (file.getVirtualFile() instanceof LightVirtualFile) {
+ presentation.setVisible(false);
+ presentation.setEnabled(false);
+ return;
}
+ else {
+ presentation.setEnabled(isHtmlFile);
+ }
+ }
+ else {
+ presentation.setEnabled(true);
+ }
+ presentation.setVisible(true);
- presentation.setText(text);
- presentation.setDescription(description);
+ String text = getTemplatePresentation().getText();
+ String description = getTemplatePresentation().getDescription();
- GeneralSettings settings = GeneralSettings.getInstance();
- if (!settings.isUseDefaultBrowser()) {
- BrowsersConfiguration.BrowserFamily family = BrowsersConfiguration.getInstance().findFamilyByPath(settings.getBrowserPath());
- if (family != null) {
- presentation.setIcon(family.getIcon());
- }
+ if (browserUrlProvider != null) {
+ final String customText = browserUrlProvider.first.getOpenInBrowserActionText(file);
+ if (customText != null) {
+ text = customText;
}
+ final String customDescription = browserUrlProvider.first.getOpenInBrowserActionDescription(file);
+ if (customDescription != null) {
+ description = customDescription;
+ }
+ if (isHtmlFile) {
+ description += " (hold Shift to open URL of local file)";
+ }
+ }
+
+ presentation.setText(text);
+ presentation.setDescription(description);
- if (ActionPlaces.isPopupPlace(e.getPlace())) {
- presentation.setVisible(presentation.isEnabled());
+ GeneralSettings settings = GeneralSettings.getInstance();
+ if (!settings.isUseDefaultBrowser()) {
+ BrowsersConfiguration.BrowserFamily family = BrowsersConfiguration.getInstance().findFamilyByPath(settings.getBrowserPath());
+ if (family != null) {
+ presentation.setIcon(family.getIcon());
}
}
- else {
- presentation.setVisible(false);
- presentation.setEnabled(false);
+
+ if (ActionPlaces.isPopupPlace(e.getPlace())) {
+ presentation.setVisible(presentation.isEnabled());
}
}
diff --git a/xml/impl/src/com/intellij/ide/browsers/OpenUrlHyperlinkInfo.java b/xml/impl/src/com/intellij/ide/browsers/OpenUrlHyperlinkInfo.java
index fe8fe0632216..79ce4a53a234 100644
--- a/xml/impl/src/com/intellij/ide/browsers/OpenUrlHyperlinkInfo.java
+++ b/xml/impl/src/com/intellij/ide/browsers/OpenUrlHyperlinkInfo.java
@@ -24,6 +24,7 @@ import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Conditions;
import com.intellij.util.PlatformIcons;
import org.jetbrains.annotations.NotNull;
@@ -34,11 +35,11 @@ import java.awt.event.MouseEvent;
* @author nik
*/
public class OpenUrlHyperlinkInfo implements HyperlinkWithPopupMenuInfo {
- private String myUrl;
+ private final String myUrl;
private final Condition<BrowsersConfiguration.BrowserFamily> mySuitableBrowsers;
public OpenUrlHyperlinkInfo(@NotNull String url) {
- this(url, Condition.TRUE);
+ this(url, Conditions.<BrowsersConfiguration.BrowserFamily>alwaysTrue());
}
public OpenUrlHyperlinkInfo(@NotNull String url, @NotNull Condition<BrowsersConfiguration.BrowserFamily> suitableBrowsers) {
diff --git a/xml/impl/src/com/intellij/ide/browsers/UrlImpl.java b/xml/impl/src/com/intellij/ide/browsers/UrlImpl.java
index c89c6c5bb7dd..05fa403faf67 100644
--- a/xml/impl/src/com/intellij/ide/browsers/UrlImpl.java
+++ b/xml/impl/src/com/intellij/ide/browsers/UrlImpl.java
@@ -13,6 +13,7 @@ import java.net.URISyntaxException;
public final class UrlImpl implements Url {
private String raw;
+
private final String scheme;
private final String authority;
@@ -21,6 +22,8 @@ public final class UrlImpl implements Url {
private final String parameters;
+ private String externalFormWithoutParameters;
+
public UrlImpl(@Nullable String raw, @NotNull String scheme, @Nullable String authority, @Nullable String path, @Nullable String parameters) {
this.raw = raw;
this.scheme = scheme;
@@ -85,28 +88,41 @@ public final class UrlImpl implements Url {
@Override
@NotNull
public String toExternalForm(boolean skipQueryAndFragment) {
- if (raw != null && (parameters == null || !skipQueryAndFragment)) {
- return raw;
+ if (parameters == null || !skipQueryAndFragment) {
+ if (raw != null) {
+ return raw;
+ }
+ }
+ else if (externalFormWithoutParameters != null) {
+ return externalFormWithoutParameters;
}
+ String result;
try {
String externalPath = path;
boolean inLocalFileSystem = isInLocalFileSystem();
if (inLocalFileSystem && SystemInfo.isWindows && externalPath.charAt(0) != '/') {
externalPath = '/' + externalPath;
}
- String result = new URI(scheme, inLocalFileSystem ? "" : authority, externalPath, null, null).toASCIIString();
- if (!skipQueryAndFragment) {
- if (parameters != null) {
- result += parameters;
- }
- raw = result;
- }
- return result;
+ result = new URI(scheme, inLocalFileSystem ? "" : authority, externalPath, null, null).toASCIIString();
}
catch (URISyntaxException e) {
throw new RuntimeException(e);
}
+
+ if (skipQueryAndFragment) {
+ externalFormWithoutParameters = result;
+ if (parameters == null) {
+ raw = externalFormWithoutParameters;
+ }
+ }
+ else {
+ if (parameters != null) {
+ result += parameters;
+ }
+ raw = result;
+ }
+ return result;
}
@NotNull
diff --git a/xml/impl/src/com/intellij/ide/browsers/Urls.java b/xml/impl/src/com/intellij/ide/browsers/Urls.java
index f6aa46e10067..a7e13061ec01 100644
--- a/xml/impl/src/com/intellij/ide/browsers/Urls.java
+++ b/xml/impl/src/com/intellij/ide/browsers/Urls.java
@@ -2,6 +2,7 @@ package com.intellij.ide.browsers;
import com.google.common.base.CharMatcher;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.StandardFileSystems;
import com.intellij.openapi.vfs.VfsUtil;
@@ -40,15 +41,32 @@ public final class Urls {
}
@Nullable
- private static Url parseUrl(String url, boolean urlAsRaw) {
- Matcher matcher = URI_PATTERN.matcher(url);
+ private static Url parseUrl(@NotNull String url, boolean urlAsRaw) {
+ String urlToParse;
+ if (url.startsWith("jar:file://")) {
+ urlToParse = url.substring("jar:".length());
+ }
+ else {
+ urlToParse = url;
+ }
+
+ Matcher matcher = URI_PATTERN.matcher(urlToParse);
if (!matcher.matches()) {
LOG.warn("Cannot parse url " + url);
return null;
}
String scheme = matcher.group(1);
+ if (urlToParse != url) {
+ scheme = "jar:" + scheme;
+ }
+
String authority = StringUtil.nullize(matcher.group(2));
+
String path = StringUtil.nullize(matcher.group(3));
+ if (path != null) {
+ path = FileUtil.toCanonicalUriPath(path);
+ }
+
String parameters = matcher.group(4);
if (authority != null && StandardFileSystems.FILE_PROTOCOL.equals(scheme)) {
path = path == null ? authority : (authority + path);
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 bb477c2e5c19..bee53af627be 100644
--- a/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java
+++ b/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java
@@ -26,6 +26,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.impl.http.HttpVirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
+import com.intellij.testFramework.LightVirtualFile;
import com.intellij.xml.util.HtmlUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -36,9 +37,10 @@ import java.util.List;
public class WebBrowserServiceImpl extends WebBrowserService {
@Override
public boolean canOpenInBrowser(@NotNull PsiElement psiElement) {
- final PsiFile psiFile = psiElement instanceof PsiFile ? (PsiFile)psiElement : psiElement.getContainingFile();
- return psiFile != null && psiFile.getVirtualFile() != null &&
- (HtmlUtil.isHtmlFile(psiFile) || getProvider(psiElement) != null);
+ PsiFile psiFile = psiElement instanceof PsiFile ? (PsiFile)psiElement : psiElement.getContainingFile();
+ VirtualFile virtualFile = psiFile == null ? null : psiFile.getVirtualFile();
+ return virtualFile != null &&
+ ((HtmlUtil.isHtmlFile(psiFile) && !(virtualFile instanceof LightVirtualFile)) || getProvider(psiElement, psiFile) != null);
}
@Override
@@ -76,7 +78,7 @@ public class WebBrowserServiceImpl extends WebBrowserService {
}
}
}
- return Urls.newFromVirtualFile(virtualFile);
+ return virtualFile instanceof LightVirtualFile ? null : Urls.newFromVirtualFile(virtualFile);
}
@Override
@@ -93,10 +95,10 @@ public class WebBrowserServiceImpl extends WebBrowserService {
@Nullable
public static Pair<WebBrowserUrlProvider, Url> getProvider(@Nullable PsiElement element) {
PsiFile psiFile = element == null ? null : element.getContainingFile();
- if (psiFile == null) {
- return null;
- }
+ return psiFile == null ? null : getProvider(element, psiFile);
+ }
+ private static Pair<WebBrowserUrlProvider, Url> getProvider(PsiElement element, PsiFile psiFile) {
Ref<Url> result = Ref.create();
List<WebBrowserUrlProvider> allProviders = Arrays.asList(WebBrowserUrlProvider.EP_NAME.getExtensions());
for (WebBrowserUrlProvider urlProvider : DumbService.getInstance(element.getProject()).filterByDumbAwareness(allProviders)) {
diff --git a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java b/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java
index 71212d1d4e37..19408e7eff1c 100644
--- a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java
+++ b/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.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.
@@ -21,48 +21,51 @@ import com.intellij.ide.structureView.StructureViewTreeElement;
import com.intellij.ide.structureView.TextEditorBasedStructureViewModel;
import com.intellij.ide.util.treeView.smartTree.Sorter;
import com.intellij.lang.dtd.DTDLanguage;
+import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.xml.*;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
-import java.util.Collection;
-
-public class XmlStructureViewTreeModel extends TextEditorBasedStructureViewModel{
+public class XmlStructureViewTreeModel extends TextEditorBasedStructureViewModel {
private final XmlFile myFile;
private static final Class[] myClasses = new Class[]{XmlTag.class, XmlFile.class, XmlEntityDecl.class, XmlElementDecl.class, XmlAttlistDecl.class, XmlConditionalSection.class};
private static final Sorter[] mySorters = {Sorter.ALPHA_SORTER};
- public XmlStructureViewTreeModel(XmlFile file) {
- super(file);
+ public XmlStructureViewTreeModel(XmlFile file, @Nullable Editor editor) {
+ super(editor, file);
myFile = file;
}
+ @Override
@NotNull
public StructureViewTreeElement getRoot() {
if (myFile.getLanguage() == DTDLanguage.INSTANCE) return new DtdFileTreeElement(myFile);
return new XmlFileTreeElement(myFile);
}
+ @Override
public boolean shouldEnterElement(final Object element) {
return element instanceof XmlTag && ((XmlTag)element).getSubTags().length > 0;
}
+ @Override
protected PsiFile getPsiFile() {
return myFile;
}
+ @Override
@NotNull
protected Class[] getSuitableClasses() {
return myClasses;
}
+ @Override
public Object getCurrentEditorElement() {
final Object editorElement = super.getCurrentEditorElement();
if (editorElement instanceof XmlTag) {
- final Collection<StructureViewExtension> structureViewExtensions =
- StructureViewFactoryEx.getInstanceEx(myFile.getProject()).getAllExtensions(XmlTag.class);
- for(StructureViewExtension extension:structureViewExtensions) {
+ for (StructureViewExtension extension : StructureViewFactoryEx.getInstanceEx(myFile.getProject()).getAllExtensions(XmlTag.class)) {
final Object element = extension.getCurrentEditorElement(getEditor(), (PsiElement)editorElement);
if (element != null) return element;
}
@@ -70,8 +73,9 @@ public class XmlStructureViewTreeModel extends TextEditorBasedStructureViewModel
return editorElement;
}
+ @Override
@NotNull
public Sorter[] getSorters() {
return mySorters;
}
-}
+} \ No newline at end of file
diff --git a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.java b/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.java
index a2ecfd7cecac..ee75742ad237 100644
--- a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.java
+++ b/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.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.
@@ -15,6 +15,7 @@
*/
package com.intellij.ide.structureView.impl.xml;
+import com.intellij.ide.IdeBundle;
import com.intellij.ide.structureView.StructureViewTreeElement;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlTag;
@@ -32,33 +33,38 @@ public class XmlTagTreeElement extends AbstractXmlTagTreeElement<XmlTag>{
super(tag);
}
+ @Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
return getStructureViewTreeElements(getElement().getSubTags());
}
+ @Override
public String getPresentableText() {
final XmlTag element = getElement();
- if (element == null) return "*invalid*";
+ if (element == null) {
+ return IdeBundle.message("node.structureview.invalid");
+ }
String id = element.getAttributeValue(ID_ATTR_NAME);
- if (id == null) id = element.getAttributeValue(NAME_ATTR_NAME);
+ if (id == null) {
+ id = element.getAttributeValue(NAME_ATTR_NAME);
+ }
id = toCanonicalForm(id);
-
- if (id != null) return id + ":" + element.getLocalName();
- return element.getName();
+ return id != null ? id + ':' + element.getLocalName() : element.getName();
}
+ @Override
public String getLocationString() {
- final StringBuffer buffer = new StringBuffer();
+ final StringBuilder buffer = new StringBuilder();
final XmlTag element = getElement();
- final XmlAttribute[] attributes = element.getAttributes();
-
+ assert element != null;
String id = element.getAttributeValue(ID_ATTR_NAME);
String usedAttrName = null;
-
if (id == null) {
id = element.getAttributeValue(NAME_ATTR_NAME);
- if (id != null) usedAttrName = NAME_ATTR_NAME;
+ if (id != null) {
+ usedAttrName = NAME_ATTR_NAME;
+ }
}
else {
usedAttrName = ID_ATTR_NAME;
@@ -66,24 +72,18 @@ public class XmlTagTreeElement extends AbstractXmlTagTreeElement<XmlTag>{
id = toCanonicalForm(id);
- for (XmlAttribute attribute : attributes) {
+ for (XmlAttribute attribute : element.getAttributes()) {
if (buffer.length() != 0) {
- buffer.append(" ");
+ buffer.append(' ');
}
final String name = attribute.getName();
- if (usedAttrName != null &&
- id != null &&
- usedAttrName.equals(name)
- ) {
+ if (usedAttrName != null && id != null && usedAttrName.equals(name)) {
continue; // we output this name in name
}
buffer.append(name);
- buffer.append("=");
- buffer.append("\"");
- buffer.append(attribute.getValue());
- buffer.append("\"");
+ buffer.append('=').append('"').append(attribute.getValue()).append('"');
}
return buffer.toString();
}
@@ -92,8 +92,10 @@ public class XmlTagTreeElement extends AbstractXmlTagTreeElement<XmlTag>{
public static String toCanonicalForm(@Nullable String id) {
if (id != null) {
id = id.trim();
- if (id.length() == 0) id = null;
+ if (id.isEmpty()) {
+ return null;
+ }
}
return id;
}
-}
+} \ No newline at end of file
diff --git a/xml/impl/src/com/intellij/ide/util/treeView/XmlDoctypeNodeDescriptor.java b/xml/impl/src/com/intellij/ide/util/treeView/XmlDoctypeNodeDescriptor.java
index ea771e31e5fd..a6255affd086 100644
--- a/xml/impl/src/com/intellij/ide/util/treeView/XmlDoctypeNodeDescriptor.java
+++ b/xml/impl/src/com/intellij/ide/util/treeView/XmlDoctypeNodeDescriptor.java
@@ -17,12 +17,13 @@ package com.intellij.ide.util.treeView;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
/**
* @author Mike
*/
public class XmlDoctypeNodeDescriptor extends SmartElementDescriptor {
- public XmlDoctypeNodeDescriptor(Project project, NodeDescriptor parentDescriptor, PsiElement element) {
+ public XmlDoctypeNodeDescriptor(@NotNull Project project, NodeDescriptor parentDescriptor, PsiElement element) {
super(project, parentDescriptor, element);
//noinspection HardCodedStringLiteral
myName = "DOCTYPE";
diff --git a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java
index cd97d262957b..8606e11e899c 100644
--- a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java
+++ b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java
@@ -16,570 +16,28 @@
package com.intellij.javaee;
import com.intellij.application.options.PathMacrosImpl;
-import com.intellij.application.options.ReplacePathToMacroMap;
-import com.intellij.openapi.Disposable;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.components.*;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.extensions.Extensions;
-import com.intellij.openapi.fileTypes.FileType;
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.components.State;
+import com.intellij.openapi.components.Storage;
+import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.*;
-import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.xml.XmlFile;
-import com.intellij.util.ArrayUtil;
-import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.containers.HashMap;
-import com.intellij.xml.Html5SchemaProvider;
-import com.intellij.xml.XmlSchemaProvider;
-import com.intellij.xml.util.XmlUtil;
-import org.jdom.Element;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.annotations.TestOnly;
-
-import java.io.File;
-import java.net.URL;
-import java.util.*;
+import com.intellij.openapi.util.JDOMExternalizable;
+import com.intellij.openapi.util.NotNullLazyKey;
/**
* @author mike
*/
@State(name = "ExternalResourceManagerImpl",
storages = {@Storage( file = StoragePathMacros.APP_CONFIG + "/other.xml")})
-public class ExternalResourceManagerImpl extends ExternalResourceManagerEx implements JDOMExternalizable {
- static final Logger LOG = Logger.getInstance("#com.intellij.j2ee.openapi.impl.ExternalResourceManagerImpl");
-
- @NonNls public static final String J2EE_1_3 = "http://java.sun.com/dtd/";
- @NonNls public static final String J2EE_1_2 = "http://java.sun.com/j2ee/dtds/";
- @NonNls public static final String J2EE_NS = "http://java.sun.com/xml/ns/j2ee/";
- @NonNls public static final String JAVAEE_NS = "http://java.sun.com/xml/ns/javaee/";
- private static final String CATALOG_PROPERTIES_ELEMENT = "CATALOG_PROPERTIES";
-
-
- private final Map<String, Map<String, String>> myResources = new HashMap<String, Map<String, String>>();
- private final Set<String> myResourceLocations = new HashSet<String>();
-
- private final Set<String> myIgnoredResources = new HashSet<String>();
-
- private final AtomicNotNullLazyValue<Map<String, Map<String, Resource>>> myStdResources = new AtomicNotNullLazyValue<Map<String, Map<String, Resource>>>() {
-
- @NotNull
- @Override
- protected Map<String, Map<String, Resource>> compute() {
- return computeStdResources();
- }
- };
-
- private String myDefaultHtmlDoctype = HTML5_DOCTYPE_ELEMENT;
-
- private String myCatalogPropertiesFile;
- private XMLCatalogManager myCatalogManager;
- private static final String HTML5_DOCTYPE_ELEMENT = "HTML5";
-
- protected Map<String, Map<String, Resource>> computeStdResources() {
- ResourceRegistrarImpl registrar = new ResourceRegistrarImpl();
- for (StandardResourceProvider provider : Extensions.getExtensions(StandardResourceProvider.EP_NAME)) {
- provider.registerResources(registrar);
- }
- StandardResourceEP[] extensions = Extensions.getExtensions(StandardResourceEP.EP_NAME);
- for (StandardResourceEP extension : extensions) {
- registrar.addStdResource(extension.url, extension.version, extension.resourcePath, null, extension.getLoaderForClass());
- }
-
- myIgnoredResources.addAll(registrar.getIgnored());
- return registrar.getResources();
- }
-
- private final List<ExternalResourceListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
- private long myModificationCount = 0;
- private final PathMacrosImpl myPathMacros;
- @NonNls private static final String RESOURCE_ELEMENT = "resource";
- @NonNls private static final String URL_ATTR = "url";
- @NonNls private static final String LOCATION_ATTR = "location";
- @NonNls private static final String IGNORED_RESOURCE_ELEMENT = "ignored-resource";
- @NonNls private static final String HTML_DEFAULT_DOCTYPE_ELEMENT = "default-html-doctype";
- private static final String DEFAULT_VERSION = null;
-
+public class ExternalResourceManagerImpl extends ExternalResourceManagerExImpl implements JDOMExternalizable {
public ExternalResourceManagerImpl(PathMacrosImpl pathMacros) {
- myPathMacros = pathMacros;
- }
-
- public boolean isStandardResource(VirtualFile file) {
- VirtualFile parent = file.getParent();
- return parent != null && parent.getName().equals("standardSchemas");
- }
-
- @Override
- public boolean isUserResource(VirtualFile file) {
- return myResourceLocations.contains(file.getUrl());
- }
-
- @Nullable
- static <T> Map<String, T> getMap(@NotNull final Map<String, Map<String, T>> resources,
- @Nullable final String version,
- final boolean create) {
- Map<String, T> map = resources.get(version);
- if (map == null) {
- if (create) {
- map = ContainerUtil.newHashMap();
- resources.put(version, map);
- }
- else if (version == null || !version.equals(DEFAULT_VERSION)) {
- map = resources.get(DEFAULT_VERSION);
- }
- }
-
- return map;
- }
-
- public String getResourceLocation(String url) {
- return getResourceLocation(url, DEFAULT_VERSION);
- }
-
- public String getResourceLocation(@NonNls String url, String version) {
- String result = getUserResource(url, version);
- if (result == null) {
- XMLCatalogManager manager = getCatalogManager();
- if (manager != null) {
- result = manager.resolve(url);
- }
- }
- if (result == null) {
- result = getStdResource(url, version);
- }
- if (result == null) {
- result = url;
- }
- return result;
- }
-
- @Override
- @Nullable
- public String getUserResource(Project project, String url, String version) {
- String resource = getProjectResources(project).getUserResource(url, version);
- return resource == null ? getUserResource(url, version) : resource;
- }
-
- @Override
- @Nullable
- public String getStdResource(String url, String version) {
- Map<String, Resource> map = getMap(myStdResources.getValue(), version, false);
- if (map != null) {
- Resource resource = map.get(url);
- return resource == null ? null : resource.getResourceUrl();
- }
- else {
- return null;
- }
- }
-
- @Nullable
- private String getUserResource(String url, String version) {
- Map<String, String> map = getMap(myResources, version, false);
- return map != null ? map.get(url) : null;
- }
-
- public String getResourceLocation(@NonNls String url, @NotNull Project project) {
- String location = getProjectResources(project).getResourceLocation(url);
- return location == null || location.equals(url) ? getResourceLocation(url) : location;
- }
-
- public String getResourceLocation(@NonNls String url, String version, @NotNull Project project) {
- String location = getProjectResources(project).getResourceLocation(url, version);
- return location == null || location.equals(url) ? getResourceLocation(url, version) : location;
- }
-
- @Nullable
- public PsiFile getResourceLocation(@NotNull @NonNls final String url, @NotNull final PsiFile baseFile, final String version) {
- final XmlFile schema = XmlSchemaProvider.findSchema(url, baseFile);
- if (schema != null) {
- return schema;
- }
- final String location = getResourceLocation(url, version, baseFile.getProject());
- return XmlUtil.findXmlFile(baseFile, location);
- }
-
- public String[] getResourceUrls(FileType fileType, final boolean includeStandard) {
- return getResourceUrls(fileType, DEFAULT_VERSION, includeStandard);
- }
-
- public String[] getResourceUrls(@Nullable final FileType fileType, @NonNls final String version, final boolean includeStandard) {
- final List<String> result = new LinkedList<String>();
- addResourcesFromMap(result, version, myResources);
-
- if (includeStandard) {
- addResourcesFromMap(result, version, myStdResources.getValue());
- }
-
- return ArrayUtil.toStringArray(result);
- }
-
- private static <T> void addResourcesFromMap(final List<String> result,
- String version,
- Map<String, Map<String, T>> resourcesMap) {
- Map<String, T> resources = getMap(resourcesMap, version, false);
- if (resources == null) return;
- result.addAll(resources.keySet());
- }
-
- @TestOnly
- public static void addTestResource(final String url, final String location, Disposable parentDisposable) {
- final ExternalResourceManagerImpl instance = (ExternalResourceManagerImpl)getInstance();
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- public void run() {
- instance.addResource(url, location);
- }
- });
- Disposer.register(parentDisposable, new Disposable() {
- @Override
- public void dispose() {
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- public void run() {
- instance.removeResource(url);
- }
- });
- }
- });
- }
- public void addResource(String url, String location) {
- addResource(url, DEFAULT_VERSION, location);
- }
-
- public void addResource(@NonNls String url, @NonNls String version, @NonNls String location) {
- ApplicationManager.getApplication().assertWriteAccessAllowed();
- addSilently(url, version, location);
- fireExternalResourceChanged();
- }
-
- private void addSilently(String url, String version, String location) {
- final Map<String, String> map = getMap(myResources, version, true);
- assert map != null;
- map.put(url, location);
- myResourceLocations.add(location);
- myModificationCount++;
- }
-
- public void removeResource(String url) {
- removeResource(url, DEFAULT_VERSION);
- }
-
- public void removeResource(String url, String version) {
- ApplicationManager.getApplication().assertWriteAccessAllowed();
- Map<String, String> map = getMap(myResources, version, false);
- if (map != null) {
- String location = map.remove(url);
- if (location != null) {
- myResourceLocations.remove(location);
- }
- myModificationCount++;
- fireExternalResourceChanged();
- }
- }
-
- @Override
- public void removeResource(String url, @NotNull Project project) {
- getProjectResources(project).removeResource(url);
- }
-
- @Override
- public void addResource(@NonNls String url, @NonNls String location, @NotNull Project project) {
- getProjectResources(project).addResource(url, location);
- }
-
- public String[] getAvailableUrls() {
- Set<String> urls = new HashSet<String>();
- for (Map<String, String> map : myResources.values()) {
- urls.addAll(map.keySet());
- }
- return ArrayUtil.toStringArray(urls);
- }
-
- @Override
- public String[] getAvailableUrls(Project project) {
- return getProjectResources(project).getAvailableUrls();
- }
-
- public void clearAllResources() {
- myResources.clear();
- myIgnoredResources.clear();
- }
-
- public void clearAllResources(Project project) {
- ApplicationManager.getApplication().assertWriteAccessAllowed();
- clearAllResources();
- getProjectResources(project).clearAllResources();
- myModificationCount++;
- fireExternalResourceChanged();
+ super(pathMacros);
}
- public void addIgnoredResource(String url) {
- ApplicationManager.getApplication().assertWriteAccessAllowed();
- addIgnoredSilently(url);
- fireExternalResourceChanged();
- }
-
- private void addIgnoredSilently(String url) {
- myIgnoredResources.add(url);
- myModificationCount++;
- }
-
- public void removeIgnoredResource(String url) {
- ApplicationManager.getApplication().assertWriteAccessAllowed();
- if (myIgnoredResources.remove(url)) {
- myModificationCount++;
- fireExternalResourceChanged();
- }
- }
-
- public boolean isIgnoredResource(String url) {
- myStdResources.getValue(); // ensure ignored resources are loaded
- return myIgnoredResources.contains(url) || isImplicitNamespaceDescriptor(url);
- }
-
- private static boolean isImplicitNamespaceDescriptor(String url) {
- for (ImplicitNamespaceDescriptorProvider namespaceDescriptorProvider : Extensions
- .getExtensions(ImplicitNamespaceDescriptorProvider.EP_NAME)) {
- if (namespaceDescriptorProvider.getNamespaceDescriptor(null, url, null) != null) return true;
- }
- return false;
- }
-
- public String[] getIgnoredResources() {
- myStdResources.getValue(); // ensure ignored resources are loaded
- return ArrayUtil.toStringArray(myIgnoredResources);
- }
-
- public long getModificationCount() {
- return myModificationCount;
- }
-
- @Override
- public long getModificationCount(@NotNull Project project) {
- return getProjectResources(project).getModificationCount();
- }
-
- public void readExternal(Element element) throws InvalidDataException {
- final ExpandMacroToPathMap macroExpands = new ExpandMacroToPathMap();
- myPathMacros.addMacroExpands(macroExpands);
- macroExpands.substitute(element, SystemInfo.isFileSystemCaseSensitive);
-
- myModificationCount++;
- for (final Object o1 : element.getChildren(RESOURCE_ELEMENT)) {
- Element e = (Element)o1;
- addSilently(e.getAttributeValue(URL_ATTR), DEFAULT_VERSION, e.getAttributeValue(LOCATION_ATTR).replace('/', File.separatorChar));
- }
-
- for (final Object o : element.getChildren(IGNORED_RESOURCE_ELEMENT)) {
- Element e = (Element)o;
- addIgnoredSilently(e.getAttributeValue(URL_ATTR));
- }
-
- Element child = element.getChild(HTML_DEFAULT_DOCTYPE_ELEMENT);
- if (child != null) {
- String text = child.getText();
- if (FileUtil.toSystemIndependentName(text).endsWith(".jar!/resources/html5-schema/html5.rnc")) {
- text = HTML5_DOCTYPE_ELEMENT;
- }
- myDefaultHtmlDoctype = text;
- }
- Element catalogElement = element.getChild(CATALOG_PROPERTIES_ELEMENT);
- if (catalogElement != null) {
- myCatalogPropertiesFile = catalogElement.getTextTrim();
- }
- }
-
- public void writeExternal(Element element) throws WriteExternalException {
- final String[] urls = getAvailableUrls();
- for (String url : urls) {
- if (url == null) continue;
- String location = getResourceLocation(url);
- if (location == null) continue;
- final Element e = new Element(RESOURCE_ELEMENT);
-
- e.setAttribute(URL_ATTR, url);
- e.setAttribute(LOCATION_ATTR, location.replace(File.separatorChar, '/'));
- element.addContent(e);
- }
-
- final String[] ignoredResources = getIgnoredResources();
- for (String ignoredResource : ignoredResources) {
- final Element e = new Element(IGNORED_RESOURCE_ELEMENT);
-
- e.setAttribute(URL_ATTR, ignoredResource);
- element.addContent(e);
- }
-
- if (myDefaultHtmlDoctype != null && !HTML5_DOCTYPE_ELEMENT.equals(myDefaultHtmlDoctype)) {
- final Element e = new Element(HTML_DEFAULT_DOCTYPE_ELEMENT);
- e.setText(myDefaultHtmlDoctype);
- element.addContent(e);
- }
- if (myCatalogPropertiesFile != null) {
- Element properties = new Element(CATALOG_PROPERTIES_ELEMENT);
- properties.setText(myCatalogPropertiesFile);
- element.addContent(properties);
- }
- final ReplacePathToMacroMap macroReplacements = new ReplacePathToMacroMap();
- PathMacrosImpl.getInstanceEx().addMacroReplacements(macroReplacements);
- macroReplacements.substitute(element, SystemInfo.isFileSystemCaseSensitive);
- }
-
- public void addExternalResourceListener(ExternalResourceListener listener) {
- myListeners.add(listener);
- }
-
- public void removeExternalResourceListener(ExternalResourceListener listener) {
- myListeners.remove(listener);
- }
-
- private void fireExternalResourceChanged() {
- for (ExternalResourceListener listener : myListeners) {
- listener.externalResourceChanged();
- }
- }
-
- Collection<Map<String, Resource>> getStandardResources() {
- return myStdResources.getValue().values();
- }
-
-
private static final NotNullLazyKey<ProjectResources, Project> INSTANCE_CACHE = ServiceManager.createLazyKey(ProjectResources.class);
- private static ExternalResourceManagerImpl getProjectResources(Project project) {
- return INSTANCE_CACHE.getValue(project);
- }
-
- @Override
- @NotNull
- public String getDefaultHtmlDoctype(@NotNull Project project) {
- final String doctype = getProjectResources(project).myDefaultHtmlDoctype;
- if (XmlUtil.XHTML_URI.equals(doctype)) {
- return XmlUtil.XHTML4_SCHEMA_LOCATION;
- }
- else if (HTML5_DOCTYPE_ELEMENT.equals(doctype)) {
- return Html5SchemaProvider.getHtml5SchemaLocation();
- }
- else {
- return doctype;
- }
- }
-
- @Override
- public void setDefaultHtmlDoctype(@NotNull String defaultHtmlDoctype, @NotNull Project project) {
- getProjectResources(project).setDefaultHtmlDoctype(defaultHtmlDoctype);
- }
-
@Override
- public String getCatalogPropertiesFile() {
- return myCatalogPropertiesFile;
- }
-
- @Override
- public void setCatalogPropertiesFile(String filePath) {
- myCatalogManager = null;
- myCatalogPropertiesFile = filePath;
- myModificationCount++;
- }
-
- @Nullable
- private XMLCatalogManager getCatalogManager() {
- if (myCatalogManager == null && myCatalogPropertiesFile != null) {
- myCatalogManager = new XMLCatalogManager(myCatalogPropertiesFile);
- }
- return myCatalogManager;
- }
-
- private void setDefaultHtmlDoctype(String defaultHtmlDoctype) {
- myModificationCount++;
-
- if (Html5SchemaProvider.getHtml5SchemaLocation().equals(defaultHtmlDoctype)) {
- myDefaultHtmlDoctype = HTML5_DOCTYPE_ELEMENT;
- }
- else {
- myDefaultHtmlDoctype = defaultHtmlDoctype;
- }
- fireExternalResourceChanged();
- }
-
- @TestOnly
- public static void registerResourceTemporarily(final String url, final String location, Disposable disposable) {
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- public void run() {
- getInstance().addResource(url, location);
- }
- });
-
- Disposer.register(disposable, new Disposable() {
- @Override
- public void dispose() {
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- public void run() {
- getInstance().removeResource(url);
- }
- });
- }
- });
- }
-
- static class Resource {
- String file;
- ClassLoader classLoader;
- Class clazz;
-
- @Nullable
- String getResourceUrl() {
-
- if (classLoader == null && clazz == null) return file;
-
- final URL resource = clazz == null ? classLoader.getResource(file) : clazz.getResource(file);
- classLoader = null;
- clazz = null;
- if (resource == null) {
- String message = "Cannot find standard resource. filename:" + file + " class=" + classLoader;
- if (ApplicationManager.getApplication().isUnitTestMode()) {
- LOG.error(message);
- }
- else {
- LOG.warn(message);
- }
-
- return null;
- }
-
- String path = FileUtil.unquote(resource.toString());
- // this is done by FileUtil for windows
- path = path.replace('\\','/');
- file = path;
- return path;
- }
-
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Resource resource = (Resource)o;
-
- if (classLoader != resource.classLoader) return false;
- if (clazz != resource.clazz) return false;
- if (file != null ? !file.equals(resource.file) : resource.file != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return file.hashCode();
- }
-
- @Override
- public String toString() {
- return file + " for " + classLoader;
- }
+ protected ExternalResourceManagerExImpl getProjectResources(Project project) {
+ return INSTANCE_CACHE.getValue(project);
}
}
diff --git a/xml/impl/src/com/intellij/javaee/InternalResourceProvider.java b/xml/impl/src/com/intellij/javaee/InternalResourceProvider.java
deleted file mode 100644
index d9755ad98847..000000000000
--- a/xml/impl/src/com/intellij/javaee/InternalResourceProvider.java
+++ /dev/null
@@ -1,66 +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.javaee;
-
-import com.intellij.xml.util.HtmlUtil;
-import com.intellij.xml.util.XmlUtil;
-
-/**
- * @author Dmitry Avdeev
- */
-public class InternalResourceProvider implements StandardResourceProvider{
-
- public void registerResources(ResourceRegistrar registrar) {
- ResourceRegistrarImpl impl = (ResourceRegistrarImpl)registrar;
-
- impl.addInternalResource(XmlUtil.XSLT_URI,"xslt-1_0.xsd");
- impl.addInternalResource(XmlUtil.XSLT_URI,"2.0", "xslt-2_0.xsd");
- impl.addInternalResource(XmlUtil.XINCLUDE_URI,"xinclude.xsd");
- impl.addInternalResource(XmlUtil.XML_SCHEMA_URI, "XMLSchema.xsd");
- impl.addInternalResource(XmlUtil.XML_SCHEMA_URI + ".xsd", "XMLSchema.xsd");
- impl.addInternalResource("http://www.w3.org/2001/XMLSchema.dtd", "XMLSchema.dtd");
- impl.addInternalResource(XmlUtil.XML_SCHEMA_INSTANCE_URI, "XMLSchema-instance.xsd");
- impl.addInternalResource("http://www.w3.org/2001/xml.xsd","xml.xsd");
- impl.addInternalResource(XmlUtil.XML_NAMESPACE_URI,"xml.xsd");
- impl.addInternalResource(XmlUtil.XHTML_URI,"xhtml1-transitional.xsd");
- impl.addInternalResource("http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd","xhtml1-strict.xsd");
-
- impl.addInternalResource("http://www.w3.org/TR/html4/strict.dtd","xhtml1-strict.dtd");
- impl.addInternalResource(XmlUtil.HTML4_LOOSE_URI,"xhtml1-transitional.dtd");
- impl.addInternalResource("http://www.w3.org/TR/html4/frameset.dtd","xhtml1-frameset.dtd");
- impl.addInternalResource("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd","xhtml1-strict.dtd");
- impl.addInternalResource("http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd","xhtml1-transitional.dtd");
- impl.addInternalResource("http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd","xhtml1-frameset.dtd");
- impl.addInternalResource("http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd","xhtml11/xhtml11.dtd");
-
- impl.addInternalResource("urn:oasis:names:tc:entity:xmlns:xml:catalog", "catalog.xsd");
-
- // Plugins DTDs // stathik
- impl.addInternalResource("http://plugins.intellij.net/plugin.dtd", "plugin.dtd");
- impl.addInternalResource("http://plugins.intellij.net/plugin-repository.dtd", "plugin-repository.dtd");
-
- // mobile
- impl.addInternalResource("http://www.wapforum.org/DTD/xhtml-mobile10.dtd", "xhtml-mobile/xhtml-mobile10.dtd");
- impl.addInternalResource("http://www.wapforum.org/DTD/xhtml-mobile10-flat.dtd", "xhtml-mobile/xhtml-mobile10-flat.dtd");
- impl.addInternalResource("http://www.wapforum.org/DTD/xhtml-mobile12.dtd", "xhtml-mobile/xhtml-mobile12.dtd");
-
- impl.addInternalResource("http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd", "xhtml-mobile/xhtml-mobile12.dtd");
-
- // svg and mathML
- impl.addIgnoredResource(HtmlUtil.MATH_ML_NAMESPACE);
- impl.addIgnoredResource(HtmlUtil.SVG_NAMESPACE);
- }
-}
diff --git a/xml/impl/src/com/intellij/javaee/ResourceRegistrarImpl.java b/xml/impl/src/com/intellij/javaee/ResourceRegistrarImpl.java
deleted file mode 100644
index 10bb8528135f..000000000000
--- a/xml/impl/src/com/intellij/javaee/ResourceRegistrarImpl.java
+++ /dev/null
@@ -1,84 +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.javaee;
-
-import com.intellij.util.containers.HashMap;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Dmitry Avdeev
- */
-public class ResourceRegistrarImpl implements ResourceRegistrar {
-
- private final Map<String, Map<String, ExternalResourceManagerImpl.Resource>> myResources = new HashMap<String, Map<String, ExternalResourceManagerImpl.Resource>>();
- private final List<String> myIgnored = new ArrayList<String>();
-
- public void addStdResource(@NonNls String resource, @NonNls String fileName) {
- addStdResource(resource, null, fileName, getClass());
- }
-
- public void addStdResource(@NonNls String resource, @NonNls String fileName, Class klass) {
- addStdResource(resource, null, fileName, klass);
- }
-
- public void addStdResource(@NonNls String resource, @NonNls String version, @NonNls String fileName, @Nullable Class klass, @Nullable ClassLoader classLoader) {
- final Map<String, ExternalResourceManagerImpl.Resource> map = ExternalResourceManagerImpl.getMap(myResources, version, true);
- assert map != null;
- ExternalResourceManagerImpl.Resource res = new ExternalResourceManagerImpl.Resource();
- res.file = fileName;
- res.classLoader = classLoader;
- res.clazz = klass;
- map.put(resource, res);
- }
-
- public void addStdResource(@NonNls String resource, @Nullable @NonNls String version, @NonNls String fileName, Class klass) {
- addStdResource(resource, version, fileName, klass, null);
- }
-
- public void addIgnoredResource(@NonNls String url) {
- myIgnored.add(url);
- }
-
- public void addInternalResource(@NonNls String resource, @NonNls String fileName) {
- addInternalResource(resource, null, fileName, getClass());
- }
-
- public void addInternalResource(@NonNls String resource, @NonNls String fileName, Class clazz) {
- addInternalResource(resource, null, fileName, clazz);
- }
-
- public void addInternalResource(@NonNls String resource, @NonNls String version, @NonNls String fileName) {
- addInternalResource(resource, version, fileName, getClass());
- }
-
- public void addInternalResource(@NonNls String resource, @Nullable @NonNls String version, @NonNls String fileName, @Nullable Class clazz) {
- addStdResource(resource, version, ExternalResourceManagerEx.STANDARD_SCHEMAS + fileName, clazz);
- }
-
- public Map<String, Map<String, ExternalResourceManagerImpl.Resource>> getResources() {
- return myResources;
- }
-
- public List<String> getIgnored() {
- return myIgnored;
- }
-}
diff --git a/xml/impl/src/com/intellij/javaee/XMLCatalogManager.java b/xml/impl/src/com/intellij/javaee/XMLCatalogManager.java
deleted file mode 100644
index c9eacea92662..000000000000
--- a/xml/impl/src/com/intellij/javaee/XMLCatalogManager.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2000-2012 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.javaee;
-
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.util.io.FileUtil;
-import org.apache.xml.resolver.Catalog;
-import org.apache.xml.resolver.CatalogManager;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.annotations.TestOnly;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.StringReader;
-import java.lang.reflect.Field;
-import java.util.PropertyResourceBundle;
-
-/**
- * @author Dmitry Avdeev
- * Date: 7/20/12
- */
-public class XMLCatalogManager {
-
- private final static Logger LOG = Logger.getInstance(XMLCatalogManager.class);
-
- private static Field ourResources;
- private static Field ourPropertyFileUri;
-
- static {
- try {
- ourResources = CatalogManager.class.getDeclaredField("resources");
- ourResources.setAccessible(true);
- ourPropertyFileUri = CatalogManager.class.getDeclaredField("propertyFileURI");
- ourPropertyFileUri.setAccessible(true);
- }
- catch (NoSuchFieldException e) {
- LOG.error(e);
- }
- }
-
- private final CatalogManager myManager = new CatalogManager();
-
- public XMLCatalogManager(@NotNull String propertiesFilePath) {
-
- File file = new File(propertiesFilePath);
- try {
- String s = FileUtil.loadFile(file);
- PropertyResourceBundle bundle = new PropertyResourceBundle(new StringReader(s));
- ourResources.set(myManager, bundle);
- ourPropertyFileUri.set(myManager, file.toURI().toURL());
- }
- catch (IllegalAccessException e) {
- LOG.error(e);
- }
- catch (IOException e) {
- LOG.warn(e);
- }
- }
-
- @Nullable
- public String resolve(String uri) {
- try {
- Catalog catalog = myManager.getCatalog();
- if (catalog == null) return null;
- String resolved = catalog.resolveSystem(uri);
- return resolved == null ? catalog.resolvePublic(uri, null) : resolved;
- }
- catch (IOException e) {
- LOG.warn(e);
- return null;
- }
- }
-
- @TestOnly
- public CatalogManager getManager() {
- return myManager;
- }
-}
diff --git a/xml/impl/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.java b/xml/impl/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.java
index f88cafeb3ead..fcccefe44f88 100644
--- a/xml/impl/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.java
+++ b/xml/impl/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.java
@@ -24,17 +24,21 @@ import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.ide.structureView.TreeBasedStructureViewBuilder;
import com.intellij.ide.structureView.impl.xml.XmlStructureViewTreeModel;
import com.intellij.lang.PsiStructureViewFactory;
+import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiFile;
import com.intellij.psi.xml.XmlFile;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public class DtdStructureViewBuilderFactory implements PsiStructureViewFactory {
+ @Override
@NotNull
public StructureViewBuilder getStructureViewBuilder(final PsiFile psiFile) {
return new TreeBasedStructureViewBuilder() {
+ @Override
@NotNull
- public StructureViewModel createStructureViewModel() {
- return new XmlStructureViewTreeModel((XmlFile)psiFile);
+ public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
+ return new XmlStructureViewTreeModel((XmlFile)psiFile, editor);
}
};
}
diff --git a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.java b/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.java
index d300737e3388..f18222f69592 100644
--- a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.java
+++ b/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.java
@@ -37,11 +37,14 @@ class Html5SectionTreeElement extends PsiTreeElementBase<XmlTag> {
myHeader = header;
}
+ @Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
return myChildrenComputable.compute();
}
+ @Nullable
+ @Override
public String getPresentableText() {
if (myHeader != null) {
return HtmlTagTreeElement.normalizeSpacesAndShortenIfLong(myHeader);
@@ -51,6 +54,7 @@ class Html5SectionTreeElement extends PsiTreeElementBase<XmlTag> {
return tag == null ? null : HtmlTagTreeElement.normalizeSpacesAndShortenIfLong(tag.getValue().getTrimmedText());
}
+ @Override
public String getLocationString() {
final XmlTag tag = getElement();
if (tag == null) return null;
@@ -58,6 +62,7 @@ class Html5SectionTreeElement extends PsiTreeElementBase<XmlTag> {
return HtmlTagTreeElement.getTagPresentation(tag);
}
+ @Override
public boolean isSearchInLocationString() {
return true;
}
diff --git a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java b/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java
index a1cbc3555a89..dd3341df4133 100644
--- a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java
+++ b/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java
@@ -41,29 +41,35 @@ public class Html5SectionsNodeProvider implements FileStructureNodeProvider<Html
public static final String ACTION_ID = "HTML5_OUTLINE_MODE";
public static final String HTML5_OUTLINE_PROVIDER_PROPERTY = "html5.sections.node.provider";
+ @Override
@NotNull
public String getName() {
return ACTION_ID;
}
+ @Override
@NotNull
public ActionPresentation getPresentation() {
return new ActionPresentationData(XmlBundle.message("html5.outline.mode"), null, AllIcons.Xml.Html5);
}
+ @Override
public String getCheckBoxText() {
return XmlBundle.message("html5.outline.mode");
}
+ @Override
public Shortcut[] getShortcut() {
return KeymapManager.getInstance().getActiveKeymap().getShortcuts("FileStructurePopup");
}
+ @Override
@NotNull
public String getPropertyName() {
return HTML5_OUTLINE_PROVIDER_PROPERTY;
}
+ @Override
public Collection<Html5SectionTreeElement> provideNodes(final TreeElement node) {
if (!(node instanceof HtmlFileTreeElement)) return Collections.emptyList();
diff --git a/xml/impl/src/com/intellij/lang/html/structureView/HtmlFileTreeElement.java b/xml/impl/src/com/intellij/lang/html/structureView/HtmlFileTreeElement.java
index e819405babcd..39d5d6b39f58 100644
--- a/xml/impl/src/com/intellij/lang/html/structureView/HtmlFileTreeElement.java
+++ b/xml/impl/src/com/intellij/lang/html/structureView/HtmlFileTreeElement.java
@@ -31,7 +31,6 @@ import org.jetbrains.annotations.Nullable;
import java.util.*;
class HtmlFileTreeElement extends PsiTreeElementBase<XmlFile> {
-
private final boolean myInStructureViewPopup;
public HtmlFileTreeElement(final boolean inStructureViewPopup, final XmlFile xmlFile) {
@@ -39,6 +38,7 @@ class HtmlFileTreeElement extends PsiTreeElementBase<XmlFile> {
myInStructureViewPopup = inStructureViewPopup;
}
+ @Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
if (isHtml5SectionsMode()) {
@@ -71,11 +71,9 @@ class HtmlFileTreeElement extends PsiTreeElementBase<XmlFile> {
}
else {
final Collection<StructureViewTreeElement> result = new ArrayList<StructureViewTreeElement>();
-
for (XmlTag tag : rootTags) {
result.add(new HtmlTagTreeElement(tag));
}
-
return result;
}
}
@@ -97,8 +95,9 @@ class HtmlFileTreeElement extends PsiTreeElementBase<XmlFile> {
return false;
}
+ @Override
@Nullable
public String getPresentableText() {
return toString(); // root element is not visible
}
-}
+} \ No newline at end of file
diff --git a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.java b/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.java
index 3243fe7db7de..9a8741d308a8 100644
--- a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.java
+++ b/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.java
@@ -20,24 +20,28 @@ import com.intellij.ide.structureView.StructureViewBuilder;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.ide.structureView.TreeBasedStructureViewBuilder;
import com.intellij.ide.structureView.xml.XmlStructureViewBuilderProvider;
+import com.intellij.openapi.editor.Editor;
import com.intellij.psi.xml.XmlFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class HtmlStructureViewBuilderProvider implements XmlStructureViewBuilderProvider {
+ @Override
@Nullable
public StructureViewBuilder createStructureViewBuilder(@NotNull final XmlFile file) {
if (file.getViewProvider().getVirtualFile().getFileType() != HtmlFileType.INSTANCE) return null;
return new TreeBasedStructureViewBuilder() {
+ @Override
public boolean isRootNodeShown() {
return false;
}
+ @Override
@NotNull
- public StructureViewModel createStructureViewModel() {
- return new HtmlStructureViewTreeModel(file);
+ public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
+ return new HtmlStructureViewTreeModel(file, editor);
}
};
}
-}
+} \ No newline at end of file
diff --git a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java b/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java
index 230a89ae4c26..f2bc5c148b85 100644
--- a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java
+++ b/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java
@@ -20,9 +20,11 @@ import com.intellij.ide.structureView.StructureViewTreeElement;
import com.intellij.ide.structureView.impl.xml.XmlStructureViewTreeModel;
import com.intellij.ide.util.treeView.smartTree.NodeProvider;
import com.intellij.ide.util.treeView.smartTree.Sorter;
+import com.intellij.openapi.editor.Editor;
import com.intellij.psi.xml.XmlFile;
import com.intellij.ui.PlaceHolder;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.Collection;
@@ -33,29 +35,35 @@ class HtmlStructureViewTreeModel extends XmlStructureViewTreeModel implements Pl
private String myStructureViewPlace;
- public HtmlStructureViewTreeModel(final XmlFile file) {
- super(file);
+ public HtmlStructureViewTreeModel(final XmlFile file, @Nullable Editor editor) {
+ super(file, editor);
+
myNodeProviders = Arrays.<NodeProvider>asList(new Html5SectionsNodeProvider());
}
+ @Override
public void setPlace(final String place) {
myStructureViewPlace = place;
}
+ @Override
public String getPlace() {
return myStructureViewPlace;
}
+ @Override
@NotNull
public Sorter[] getSorters() {
return Sorter.EMPTY_ARRAY;
}
+ @Override
@NotNull
public Collection<NodeProvider> getNodeProviders() {
return myNodeProviders;
}
+ @Override
@NotNull
public StructureViewTreeElement getRoot() {
return new HtmlFileTreeElement(ViewStructureAction.isInStructureViewPopup(this), (XmlFile)getPsiFile());
diff --git a/xml/impl/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.java b/xml/impl/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.java
index b55e9e534a18..bf9c08ab8a5b 100644
--- a/xml/impl/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.java
+++ b/xml/impl/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.java
@@ -25,6 +25,7 @@ import com.intellij.psi.xml.XmlTag;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Collections;
@@ -37,80 +38,107 @@ class HtmlTagTreeElement extends PsiTreeElementBase<XmlTag> implements LocationP
super(tag);
}
+ @Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
final XmlTag tag = getElement();
if (tag == null || !tag.isValid()) return Collections.emptyList();
return ContainerUtil.map2List(tag.getSubTags(), new Function<XmlTag, StructureViewTreeElement>() {
+ @Override
public StructureViewTreeElement fun(final XmlTag subTag) {
return new HtmlTagTreeElement(subTag);
}
});
}
+ @Override
public String getPresentableText() {
final XmlTag tag = getElement();
- if (tag == null) return IdeBundle.message("node.structureview.invalid");
-
+ if (tag == null) {
+ return IdeBundle.message("node.structureview.invalid");
+ }
return getTagPresentation(tag);
}
+ @Nullable
+ @Override
public String getLocationString() {
final XmlTag tag = getElement();
- if (tag == null) return null;
+ if (tag == null) {
+ return null;
+ }
- final String text = normalizeSpacesAndShortenIfLong(tag.getValue().getTrimmedText());
- return text.isEmpty() ? null : text;
+ if (tag.getName().equalsIgnoreCase("img") || tag.getName().equalsIgnoreCase("script")) {
+ String src = tag.getAttributeValue("src");
+ if (StringUtil.isEmpty(src)) {
+ return null;
+ }
+ else {
+ assert src != null;
+ return StringUtil.shortenPathWithEllipsis(src, MAX_TEXT_LENGTH, true);
+ }
+ }
+ else {
+ return StringUtil.nullize(normalizeSpacesAndShortenIfLong(tag.getValue().getTrimmedText()));
+ }
}
+ @Override
public boolean isSearchInLocationString() {
return true;
}
public static String getTagPresentation(final @NotNull XmlTag tag) {
- final String id = XmlTagTreeElement.toCanonicalForm(tag.getAttributeValue("id"));
-
- final String classValue = tag.getAttributeValue("class");
- final List<String> classValues = classValue != null ? StringUtil.split(classValue, " ") : Collections.<String>emptyList();
-
- final StringBuilder text = new StringBuilder(tag.getLocalName());
+ StringBuilder builder = new StringBuilder(tag.getLocalName());
+ String id = XmlTagTreeElement.toCanonicalForm(tag.getAttributeValue("id"));
if (id != null) {
- text.append("#").append(id);
+ builder.append('#').append(id);
}
+ String classValue = tag.getAttributeValue("class");
+ List<String> classValues = classValue == null ? Collections.<String>emptyList() : StringUtil.split(classValue, " ");
if (!classValues.isEmpty()) {
- text.append('.').append(StringUtil.join(classValues, "."));
+ builder.append('.');
+ StringUtil.join(classValues, ".", builder);
}
- return text.toString();
+ return builder.toString();
}
- @NotNull
+ @Nullable
public static String normalizeSpacesAndShortenIfLong(final @NotNull String text) {
- return shortenTextIfLong(normalizeSpaces(text));
+ StringBuilder builder = normalizeSpaces(text);
+ return builder == null ? null : shortenTextIfLong(builder);
}
- private static String normalizeSpaces(final String text) {
- final StringBuilder buf = new StringBuilder();
+ @Nullable
+ private static StringBuilder normalizeSpaces(@NotNull String text) {
+ if (text.isEmpty()) {
+ return null;
+ }
- for (char ch : text.toCharArray()) {
- if (ch <= ' ' || Character.isSpaceChar(ch)) {
+ final StringBuilder buf = new StringBuilder(text.length());
+ for (int i = 0, length = text.length(); i < length; i++) {
+ char c = text.charAt(i);
+ if (c <= ' ' || Character.isSpaceChar(c)) {
if (buf.length() == 0 || buf.charAt(buf.length() - 1) != ' ') {
buf.append(' ');
}
}
else {
- buf.append(ch);
+ buf.append(c);
}
}
-
- return buf.toString();
+ return buf;
}
- private static String shortenTextIfLong(final String text) {
- if (text.length() <= MAX_TEXT_LENGTH) return text;
+ @Nullable
+ private static String shortenTextIfLong(@NotNull StringBuilder text) {
+ if (text.length() <= MAX_TEXT_LENGTH) {
+ return text.toString();
+ }
int index;
for (index = MAX_TEXT_LENGTH; index > MAX_TEXT_LENGTH - 20; index--) {
@@ -119,14 +147,16 @@ class HtmlTagTreeElement extends PsiTreeElementBase<XmlTag> implements LocationP
}
}
- final int endIndex = Character.isLetter(index) ? MAX_TEXT_LENGTH : index;
- return text.substring(0, endIndex) + "...";
+ text.setLength(Character.isLetter(index) ? MAX_TEXT_LENGTH : index);
+ return text.append("\u2026").toString();
}
+ @Override
public String getLocationPrefix() {
return " ";
}
+ @Override
public String getLocationSuffix() {
return "";
}
diff --git a/xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java b/xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java
index 1e2041c37c00..c77bebd7f2cd 100644
--- a/xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java
+++ b/xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java
@@ -29,6 +29,7 @@ import com.intellij.psi.xml.XmlTag;
import com.intellij.psi.xml.XmlToken;
import com.intellij.xml.XmlNSDescriptor;
import com.intellij.xml.util.XmlTagUtil;
+import org.jetbrains.annotations.NotNull;
/**
* @author ven
@@ -70,11 +71,11 @@ public class XMLExternalAnnotator extends ExternalAnnotator {
}
@Override
- public void addMessage(PsiElement context, String message, ErrorType type) {
+ public void addMessage(PsiElement context, String message, @NotNull ErrorType type) {
addMessageWithFixes(context, message, type);
}
- public void addMessageWithFixes(final PsiElement context, final String message, final ErrorType type, final IntentionAction... fixes) {
+ public void addMessageWithFixes(final PsiElement context, final String message, @NotNull final ErrorType type, final IntentionAction... fixes) {
if (message != null && message.length() > 0) {
if (context instanceof XmlTag) {
addMessagesForTag((XmlTag)context, message, type, fixes);
diff --git a/xml/impl/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.java b/xml/impl/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.java
index 2282b1787cdc..ba2721457763 100644
--- a/xml/impl/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.java
+++ b/xml/impl/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.java
@@ -27,6 +27,7 @@ import com.intellij.ide.structureView.xml.XmlStructureViewBuilderProvider;
import com.intellij.lang.Language;
import com.intellij.lang.LanguageStructureViewBuilder;
import com.intellij.lang.PsiStructureViewFactory;
+import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.psi.PsiFile;
import com.intellij.psi.xml.XmlFile;
@@ -34,6 +35,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class XmlStructureViewBuilderFactory implements PsiStructureViewFactory {
+ @Override
@Nullable
public StructureViewBuilder getStructureViewBuilder(final PsiFile psiFile) {
if (!(psiFile instanceof XmlFile)) {
@@ -52,9 +54,10 @@ public class XmlStructureViewBuilderFactory implements PsiStructureViewFactory {
}
return new TreeBasedStructureViewBuilder() {
+ @Override
@NotNull
- public StructureViewModel createStructureViewModel() {
- return new XmlStructureViewTreeModel((XmlFile)psiFile);
+ public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
+ return new XmlStructureViewTreeModel((XmlFile)psiFile, editor);
}
};
}
diff --git a/xml/impl/src/com/intellij/xml/arrangement/XmlArrangementVisitor.java b/xml/impl/src/com/intellij/xml/arrangement/XmlArrangementVisitor.java
index 907ca9151988..7f118e889588 100644
--- a/xml/impl/src/com/intellij/xml/arrangement/XmlArrangementVisitor.java
+++ b/xml/impl/src/com/intellij/xml/arrangement/XmlArrangementVisitor.java
@@ -44,15 +44,14 @@ public class XmlArrangementVisitor extends XmlElementVisitor {
@Override
public void visitXmlTag(XmlTag tag) {
final XmlElementArrangementEntry entry = createNewEntry(
- tag.getTextRange(), XML_TAG, null, true);
+ tag.getTextRange(), XML_TAG, null, null, true);
processEntry(entry, tag);
}
@Override
public void visitXmlAttribute(XmlAttribute attribute) {
- final String name = attribute.isNamespaceDeclaration() ? "" : attribute.getName();
final XmlElementArrangementEntry entry = createNewEntry(
- attribute.getTextRange(), XML_ATTRIBUTE, name, true);
+ attribute.getTextRange(), XML_ATTRIBUTE, attribute.getName(), attribute.getNamespace(), true);
processEntry(entry, null);
}
@@ -73,13 +72,14 @@ public class XmlArrangementVisitor extends XmlElementVisitor {
private XmlElementArrangementEntry createNewEntry(@NotNull TextRange range,
@NotNull ArrangementSettingsToken type,
@Nullable String name,
+ @Nullable String namespace,
boolean canBeMatched) {
if (!isWithinBounds(range)) {
return null;
}
final DefaultArrangementEntry current = getCurrent();
final XmlElementArrangementEntry entry = new XmlElementArrangementEntry(
- current, range, type, name, canBeMatched);
+ current, range, type, name, namespace, canBeMatched);
if (current == null) {
myInfo.addEntry(entry);
diff --git a/xml/impl/src/com/intellij/xml/arrangement/XmlElementArrangementEntry.java b/xml/impl/src/com/intellij/xml/arrangement/XmlElementArrangementEntry.java
index 164465d4b0ae..c6099fb96d61 100644
--- a/xml/impl/src/com/intellij/xml/arrangement/XmlElementArrangementEntry.java
+++ b/xml/impl/src/com/intellij/xml/arrangement/XmlElementArrangementEntry.java
@@ -1,10 +1,7 @@
package com.intellij.xml.arrangement;
import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.codeStyle.arrangement.ArrangementEntry;
-import com.intellij.psi.codeStyle.arrangement.DefaultArrangementEntry;
-import com.intellij.psi.codeStyle.arrangement.NameAwareArrangementEntry;
-import com.intellij.psi.codeStyle.arrangement.TypeAwareArrangementEntry;
+import com.intellij.psi.codeStyle.arrangement.*;
import com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -16,19 +13,22 @@ import java.util.Set;
* @author Eugene.Kudelevsky
*/
public class XmlElementArrangementEntry extends DefaultArrangementEntry
- implements TypeAwareArrangementEntry, NameAwareArrangementEntry {
+ implements TypeAwareArrangementEntry, NameAwareArrangementEntry, NamespaceAwareArrangementEntry {
private final ArrangementSettingsToken myType;
private final String myName;
+ private final String myNamespace;
public XmlElementArrangementEntry(@Nullable ArrangementEntry parent,
@NotNull TextRange range,
@NotNull ArrangementSettingsToken type,
@Nullable String name,
+ @Nullable String namespace,
boolean canBeMatched)
{
super(parent, range.getStartOffset(), range.getEndOffset(), canBeMatched);
myName = name;
+ myNamespace = namespace;
myType = type;
}
@@ -38,6 +38,12 @@ public class XmlElementArrangementEntry extends DefaultArrangementEntry
return myName;
}
+ @Nullable
+ @Override
+ public String getNamespace() {
+ return myNamespace;
+ }
+
@NotNull
@Override
public Set<ArrangementSettingsToken> getTypes() {
diff --git a/xml/impl/src/com/intellij/xml/arrangement/XmlRearranger.java b/xml/impl/src/com/intellij/xml/arrangement/XmlRearranger.java
index add2e0d87a5d..9e20743b76c9 100644
--- a/xml/impl/src/com/intellij/xml/arrangement/XmlRearranger.java
+++ b/xml/impl/src/com/intellij/xml/arrangement/XmlRearranger.java
@@ -6,10 +6,13 @@ import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.arrangement.ArrangementSettings;
+import com.intellij.psi.codeStyle.arrangement.ArrangementUtil;
import com.intellij.psi.codeStyle.arrangement.Rearranger;
import com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule;
import com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryMatcher;
+import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher;
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule;
+import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition;
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition;
import com.intellij.psi.codeStyle.arrangement.std.*;
import com.intellij.util.containers.ContainerUtilRt;
@@ -34,8 +37,24 @@ 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 StdRulePriorityAwareSettings(
- Collections.<ArrangementGroupingRule>emptyList(), DEFAULT_MATCH_RULES);
+ private static final StdArrangementSettings DEFAULT_SETTINGS;
+
+ static {
+ DEFAULT_MATCH_RULES.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(
+ new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.NAME, "xmlns:.*"))));
+ DEFAULT_SETTINGS = new StdRulePriorityAwareSettings(
+ Collections.<ArrangementGroupingRule>emptyList(), DEFAULT_MATCH_RULES);
+ }
+
+ @NotNull
+ public static StdArrangementMatchRule attrArrangementRule(@NotNull String nameFilter,
+ @NotNull String namespaceFilter,
+ @NotNull ArrangementSettingsToken orderType) {
+ return new StdArrangementMatchRule(new StdArrangementEntryMatcher(ArrangementUtil.combine(
+ new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.NAME, nameFilter),
+ new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.XML_NAMESPACE, namespaceFilter)
+ )), orderType);
+ }
@Nullable
@Override
diff --git a/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java b/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java
index 56b9b063d118..cd62adf16f1d 100644
--- a/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java
+++ b/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java
@@ -16,6 +16,8 @@
package com.intellij.xml.breadcrumbs;
import com.intellij.application.options.editor.WebEditorOptions;
+import com.intellij.ide.ui.UISettings;
+import com.intellij.ide.ui.UISettingsListener;
import com.intellij.lang.Language;
import com.intellij.lang.xml.XMLLanguage;
import com.intellij.openapi.Disposable;
@@ -84,17 +86,20 @@ public class BreadcrumbsXmlWrapper implements BreadcrumbsItemListener<Breadcrumb
final FileStatusManager manager = FileStatusManager.getInstance(project);
manager.addFileStatusListener(new FileStatusListener() {
public void fileStatusesChanged() {
- if (myComponent != null && myEditor != null) {
- final Font editorFont = myEditor.getColorsScheme().getFont(EditorFontType.PLAIN);
- myComponent.setFont(editorFont.deriveFont(Font.PLAIN, editorFont.getSize2D()));
- updateCrumbs(myEditor.getCaretModel().getLogicalPosition());
- }
+ updateCrumbs();
}
public void fileStatusChanged(@NotNull final VirtualFile virtualFile) {
}
}, this);
+ UISettings.getInstance().addUISettingsListener(new UISettingsListener() {
+ @Override
+ public void uiSettingsChanged(UISettings source) {
+ updateCrumbs();
+ }
+ }, this);
+
myInfoProvider = findInfoProvider(findViewProvider(myFile, myProject));
@@ -183,6 +188,14 @@ public class BreadcrumbsXmlWrapper implements BreadcrumbsItemListener<Breadcrumb
myWrapperPanel.add(myComponent, BorderLayout.CENTER);
}
+ private void updateCrumbs() {
+ if (myComponent != null && myEditor != null) {
+ final Font editorFont = myEditor.getColorsScheme().getFont(EditorFontType.PLAIN);
+ myComponent.setFont(editorFont.deriveFont(Font.PLAIN, editorFont.getSize2D()));
+ updateCrumbs(myEditor.getCaretModel().getLogicalPosition());
+ }
+ }
+
public void queueUpdate(Editor editor) {
myQueue.cancelAllUpdates();
myQueue.queue(new MyUpdate(this, editor));
diff --git a/xml/impl/src/com/intellij/xml/impl/schema/SchemaDefinitionsSearch.java b/xml/impl/src/com/intellij/xml/impl/schema/SchemaDefinitionsSearch.java
index fe3a323cc28c..6811ca9a9f2a 100644
--- a/xml/impl/src/com/intellij/xml/impl/schema/SchemaDefinitionsSearch.java
+++ b/xml/impl/src/com/intellij/xml/impl/schema/SchemaDefinitionsSearch.java
@@ -63,13 +63,18 @@ public class SchemaDefinitionsSearch implements QueryExecutor<PsiElement, PsiEle
});
if (infos != null && ! infos.isEmpty()) {
- XmlFile file = XmlUtil.getContainingFile(xml);
+ final XmlFile file = XmlUtil.getContainingFile(xml);
final Project project = file.getProject();
final Module module = ModuleUtil.findModuleForPsiElement(queryParameters);
//if (module == null) return false;
final VirtualFile vf = file.getVirtualFile();
- String thisNs = XmlNamespaceIndex.getNamespace(vf, project, file);
+ String thisNs = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
+ @Override
+ public String compute() {
+ return XmlNamespaceIndex.getNamespace(vf, project, file);
+ }
+ });
thisNs = thisNs == null ? getDefaultNs(file) : thisNs;
// so thisNs can be null
if (thisNs == null) return false;
diff --git a/xml/impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java b/xml/impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java
index 38fbf27d53ce..f1b829475a3b 100644
--- a/xml/impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java
+++ b/xml/impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java
@@ -37,7 +37,7 @@ public class XmlPrefixReferenceProvider extends PsiReferenceProvider {
int i = value.indexOf(':');
if (i > 0) {
return new PsiReference[] {
- new SchemaPrefixReference(attributeValue, TextRange.from(1, i), value.substring(0, i))
+ new SchemaPrefixReference(attributeValue, TextRange.from(1, i), value.substring(0, i), null)
};
}
}