diff options
author | Tor Norbye <tnorbye@google.com> | 2013-08-23 08:59:39 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2013-08-23 09:01:04 -0700 |
commit | 926bc53d2e5f6a9f66c98baa1624ad809edb1456 (patch) | |
tree | d33f240d802ad99c2222c8a7f30ebf83f9c3de33 /xml | |
parent | ce0245dfc4d045479a910a98a0f8655e1ed1419a (diff) | |
download | idea-926bc53d2e5f6a9f66c98baa1624ad809edb1456.tar.gz |
Snapshot c27b4f50fbcb2a71ca2c7f2d85e67debfea58f27 from master branch of git://git.jetbrains.org/idea/community.git
c27b4f5: 2013-08-23 Bas Leijdekkers - don't report on final fields because those will already be highlighted as error
3422c86: 2013-08-23 Alexey Kudravtsev - stress gc to force collection
6ab46dc: 2013-08-23 nik - jps model: serialization for custom module source roots
ab676f6: 2013-08-23 Alexey Kudravtsev - Merge remote-tracking branch 'origin/master'
6e02b38: 2013-08-23 Anna Kozlova - Merge remote-tracking branch 'origin/master'
c0c7f84: 2013-08-23 Maxim.Mossienko - fixed typo
832256e: 2013-08-23 Anna Kozlova - extract enum: ensure normalized fields (IDEA-112590)
d0fb95d: 2013-08-23 Anna Kozlova - override/implement: allow members to be in primary/secondary sets at the same time - filter them from the result; preselect first element when no selection was set before (IDEA-112563)
09e8df0: 2013-08-23 Anna Kozlova - IDEA-112551 "Expand lambda" does not add imports
f095c6d: 2013-08-23 nik - deprecated methods and classes removed from API
eab9f6d: 2013-08-23 Roman Shevchenko - Restore Windows FS loading for tests
b68f03b: 2013-08-23 Alexey Kudravtsev - sometimes weak references are not collected under linux, try to stress gc to force them
d005b15: 2013-08-23 Sergey Evdokimov - EA-48997 - UOE: MvcFramework.addJavaHome
67c6b67: 2013-08-23 Roman Shevchenko - Typo
ee9f323: 2013-08-23 Sergey Evdokimov - EA-48888 - NPE: MavenModelPropertiesPatcher.patch
3a303b4: 2013-08-23 Gregory.Shrago - move Editor-based cell renderer to platform
40d766c: 2013-08-23 Sergey Simonchik - WEB-1887 Error run node from command window
295a5d8: 2013-08-23 Alexey Kudravtsev - cleanup
06a1d59: 2013-08-23 Alexey Kudravtsev - renamed
6b35c9d: 2013-08-23 Roman Shevchenko - test diagnostic
3f7e6c6: 2013-08-23 Roman Shevchenko - platform: unified loading of system libraries
d0b8432: 2013-08-22 Roman Shevchenko - platform: URL class loader builder
2a785d2: 2013-08-22 Roman Shevchenko - platform: class cache logging centralized; obsolete timing dropped
1dc531f: 2013-08-22 Roman Shevchenko - platform: typos and cleanup
a2e1fb4: 2013-08-23 Oleg Sukhodolsky - RUBY-14033: setShowFlattenMode() propagated to ChangesViewI so we could you it
52bffa9: 2013-08-23 Mikhail Golubev - Merge remote-tracking branch 'origin/master'
766a3a0: 2013-08-23 nik - manifest extensions extracted to separate file and moved to 'manifest' module so tests which don't depend on manifest support won't try to load its extensions
0d23c76: 2013-08-23 nik - remote servers: java-dependent classes extracted to separate modules
268559e: 2013-08-23 nik - set 'test' scope for dependencies on testFramework
524db30: 2013-08-22 nik - use API instead of impl
8d7b831: 2013-08-23 Dmitry Avdeev - IDEA-60895 No completion for enumerated and boolean values of xml tags: XmlEnumerationDescriptor introduced
58b6aca: 2013-08-22 Bas Leijdekkers - Respect code style "Use fully qualified names in javadoc" setting (for IDEA-111023)
23338f1: 2013-08-22 Max Medvedev - fix test data
3e6b3ff: 2013-08-22 Sergey Simonchik - One big read lock is splitted into several small read locks. WEB-8936 Karma: read access throwable exception for Coverage (attempt#2)
425a1e0: 2013-08-22 Anna Kozlova - avoid warnings on super abstract methods that they try to assign weaker access (IDEA-67584)
5ee69d4: 2013-08-22 Anna Kozlova - check overridden methods with different type params numbers for thrown exceptions (IDEA-67860)
1c787f1: 2013-08-22 Max Medvedev - IDEA-111192 Groovy: In-Place Introduce Field: Throwable GrIntroduceHandlerBase$4$1.run()
5130a52: 2013-08-22 Max Medvedev - Groovy: shorten references in completed types in templates
2004de2: 2013-08-22 Max Medvedev - Groovy: correct type template for introduce variable
e8c1b32: 2013-08-22 Max Medvedev - shorten references in completed type elements in groovy files
ffcc5d1: 2013-08-22 Bas Leijdekkers - IDEA-47151 (Settings of "Result of method call ignored" inspection should have choosers and/or completion for class and method names)
a4d1018: 2013-08-22 Gregory.Shrago - EA-48983 - E: SwingUtilities.convertPoint
a3b7858: 2013-08-22 peter - completion should insert qualified names in javadoc according to the code style settings (IDEA-111023)
3182137: 2013-08-22 Dmitry Trofimov - Updated libs.
fb1408a: 2013-08-22 Dmitry Trofimov - Merge remote-tracking branch 'origin/master'
ec043d6: 2013-08-22 Denis Fokin - IDEA-112130 Cannot type '{', '}' and '>' in editor when using a Czech keyboard
a4b1aec: 2013-08-22 Dmitry Trofimov - Draw image override.
64059a6: 2013-08-22 Dmitry Trofimov - Action handling fixed.
471882a: 2013-08-22 Dmitry Avdeev - IDEA-112519 Do not check enumerated xml attribute value in case of injection
cc07980: 2013-08-22 peter - correct javadoc completion test
6b486fd: 2013-08-22 Dmitry Avdeev - IDEA-64561 Provide navigation for XSD enum values: fix RNG
fc9843e: 2013-08-22 Mikhail Golubev - IDEA-110012 Not all Redmine Issues Available on "Open Task" (Limited to 100?)
b37c6d0: 2013-08-22 Maxim.Mossienko - do check cancelled during building file map / scanning file
1ff158b: 2013-08-22 Dmitry Trofimov - Fixed font selection.
48580bd: 2013-08-22 Dmitry Trofimov - Merge remote-tracking branch 'origin/master'
e622120: 2013-08-22 Dmitry Trofimov - Updated lib.
814a6ac: 2013-08-22 Bas Leijdekkers - separate warning for constructors
81ff306: 2013-08-22 Maxim.Mossienko - synchronized collection
cc869b4: 2013-08-22 Mikhail Golubev - Remove unused method
7e971f2: 2013-08-22 Maxim.Mossienko - proper caret position update on bulk mode end
b2b87f5: 2013-08-22 Mikhail Golubev - Adjust completion to suggest variants not only on word boundaries
9d36545: 2013-08-22 Anton Makeev - Platform: restrict initial frame size to reasonable value (IDEA-96644) +review CR-IC @kb
9758bfe: 2013-08-22 Bas Leijdekkers - IDEA-112442 (False positive 'Result of method call ignored')
fa1879e: 2013-08-22 Dmitry Avdeev - IDEA-64561 Provide navigation for XSD enum values
6ec1eb8: 2013-08-22 Dmitry Batkovich - CompilerOutputIndexer is enabled only in corresponding tests
e33a3e8: 2013-08-22 Mikhail Golubev - Use JPasswordTextField for rendering values of hidden template variables
2405d26: 2013-08-22 Dmitry Avdeev - IDEA-64561 Provide navigation for XSD enum values: documentation
0aafeeb: 2013-08-22 Mikhail Golubev - Add EditorTextField as cell editor in HighlightedSelectorsTable
e38a6a3: 2013-08-22 Nadya Zabrodina - Cosmetics
2ef0358: 2013-08-22 Evgeny Pasynkov - +prepend(byte, byte[])
74932df: 2013-08-22 Denis Fokin - IDEA-108265. Multiple recent tasks at once could be provided. Minor issues are fixed. AppId is now one per process.
4860452: 2013-08-22 Mikhail Golubev - Merge remote-tracking branch 'origin/master'
bc29214: 2013-08-22 Oleg Sukhodolsky - testFramework should not depend on remote-servers-impl (which depends on testFramework-java)
1b24edc: 2013-08-22 Roman Shevchenko - CR-IC-2008 (mock JRE update)
36e54e9: 2013-08-22 Dmitry Trofimov - Updated libs.
279fd2e: 2013-08-22 Dmitry Trofimov - Use dump aware actions.
d73433c: 2013-08-22 Dmitry Trofimov - Merge remote-tracking branch 'origin/master'
100257e: 2013-08-22 Dmitry Trofimov - Libs updated.
0801a5f: 2013-08-22 Dmitry Trofimov - Use idea action system.
1a172fe: 2013-08-21 Mikhail Golubev - Remove remaining references to selector names via string literals
8330324: 2013-08-21 Mikhail Golubev - Add support of 'Download tasks in separate requests' feature in GenericRepository
0f241d4: 2013-08-21 Dmitry Trofimov - Actions should work while indexing.
38fc2f4: 2013-08-21 Mikhail Golubev - Refactored common handlers functionality to SelectorBasedResponse Handler. Add max parameter support to JsonPath and Regex response handlers.
98fb926: 2013-08-21 Dmitry Trofimov - Don't close tab on remote terminal logout.
e4d5ad3: 2013-08-21 Mikhail Golubev - Results number limiting in GenericRepository and ResponseHandlers
ec92ca6: 2013-08-21 Mikhail Golubev - NotNull check in TaskManagerImpl
0b9e2be: 2013-08-21 Mikhail Golubev - Update XPathResponseHandler: add lazy XPath expressions compiling, make selectors names constants
1614c5d: 2013-08-21 Dmitry Trofimov - Hide terminal view on last tab close.
e49aa6c: 2013-08-20 Mikhail Golubev - Merge branch 'generic'
d9fc248: 2013-08-20 Mikhail Golubev - Update response handlers of GenericRepository
Change-Id: I84fdb10c62c68bfcd45967e9fdc4245052c31928
Diffstat (limited to 'xml')
16 files changed, 252 insertions, 206 deletions
diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/GenericValueReferenceProvider.java b/xml/dom-impl/src/com/intellij/util/xml/impl/GenericValueReferenceProvider.java index c36c2bfa2454..d817a7ee0ce0 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/GenericValueReferenceProvider.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/GenericValueReferenceProvider.java @@ -24,7 +24,7 @@ import com.intellij.psi.xml.*; import com.intellij.util.ProcessingContext; import com.intellij.util.ReflectionCache; import com.intellij.util.xml.*; -import com.intellij.xml.util.XmlAttributeValueReferenceProvider; +import com.intellij.xml.util.XmlEnumeratedValueReferenceProvider; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -92,7 +92,7 @@ public class GenericValueReferenceProvider extends PsiReferenceProvider { // will be handled by core XML return PsiReference.EMPTY_ARRAY; } - context.put(XmlAttributeValueReferenceProvider.SUPPRESS, Boolean.TRUE); + context.put(XmlEnumeratedValueReferenceProvider.SUPPRESS, Boolean.TRUE); } return references; } diff --git a/xml/impl/src/com/intellij/xml/util/XmlAttributeValueReferenceProvider.java b/xml/impl/src/com/intellij/xml/util/XmlEnumeratedValueReferenceProvider.java index 33d72010189d..590ae534eaa6 100644 --- a/xml/impl/src/com/intellij/xml/util/XmlAttributeValueReferenceProvider.java +++ b/xml/impl/src/com/intellij/xml/util/XmlEnumeratedValueReferenceProvider.java @@ -18,13 +18,15 @@ package com.intellij.xml.util; import com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitor; import com.intellij.openapi.util.Key; import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiLanguageInjectionHost; import com.intellij.psi.PsiReference; import com.intellij.psi.PsiReferenceProvider; +import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.util.ProcessingContext; import com.intellij.xml.XmlAttributeDescriptor; -import com.intellij.xml.impl.BasicXmlAttributeDescriptor; +import com.intellij.xml.impl.XmlEnumerationDescriptor; import com.intellij.xml.impl.schema.XmlSchemaTagsProcessor; import org.jetbrains.annotations.NotNull; @@ -32,7 +34,7 @@ import org.jetbrains.annotations.NotNull; * @author Dmitry Avdeev * Date: 15.08.13 */ -public class XmlAttributeValueReferenceProvider extends PsiReferenceProvider { +public class XmlEnumeratedValueReferenceProvider extends PsiReferenceProvider { public final static Key<Boolean> SUPPRESS = Key.create("suppress attribute value references"); @@ -44,6 +46,9 @@ public class XmlAttributeValueReferenceProvider extends PsiReferenceProvider { return PsiReference.EMPTY_ARRAY; } XmlAttributeValue value = (XmlAttributeValue)element; + if (value instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)value)) { + return PsiReference.EMPTY_ARRAY; + } String unquotedValue = value.getValue(); if (unquotedValue == null || XmlHighlightVisitor.skipValidation(value) || !XmlUtil.isSimpleXmlAttributeValue(unquotedValue, value)) { return PsiReference.EMPTY_ARRAY; @@ -51,9 +56,9 @@ public class XmlAttributeValueReferenceProvider extends PsiReferenceProvider { PsiElement parent = value.getParent(); if (parent instanceof XmlAttribute) { final XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor(); - if (descriptor instanceof BasicXmlAttributeDescriptor && + if (descriptor instanceof XmlEnumerationDescriptor && (descriptor.isFixed() || descriptor.isEnumerated() || unquotedValue.equals(descriptor.getDefaultValue()))) { // todo case insensitive - return ((BasicXmlAttributeDescriptor)descriptor).getValueReferences(value); + return ((XmlEnumerationDescriptor)descriptor).getValueReferences(value); } } return PsiReference.EMPTY_ARRAY; diff --git a/xml/impl/src/com/intellij/xml/util/XmlReferenceContributor.java b/xml/impl/src/com/intellij/xml/util/XmlReferenceContributor.java index 6fcd606e18fa..ae588622794a 100644 --- a/xml/impl/src/com/intellij/xml/util/XmlReferenceContributor.java +++ b/xml/impl/src/com/intellij/xml/util/XmlReferenceContributor.java @@ -89,6 +89,6 @@ public class XmlReferenceContributor extends PsiReferenceContributor { new XmlEncodingReferenceProvider()); registrar.registerReferenceProvider(xmlAttributeValue(), new XmlPrefixReferenceProvider()); - registrar.registerReferenceProvider(xmlAttributeValue(), new XmlAttributeValueReferenceProvider(), PsiReferenceRegistrar.LOWER_PRIORITY); + registrar.registerReferenceProvider(xmlAttributeValue(), new XmlEnumeratedValueReferenceProvider(), PsiReferenceRegistrar.LOWER_PRIORITY); } } diff --git a/xml/impl/src/com/intellij/xml/util/documentation/XmlDocumentationProvider.java b/xml/impl/src/com/intellij/xml/util/documentation/XmlDocumentationProvider.java index ff05952cf910..b464d56de0c4 100644 --- a/xml/impl/src/com/intellij/xml/util/documentation/XmlDocumentationProvider.java +++ b/xml/impl/src/com/intellij/xml/util/documentation/XmlDocumentationProvider.java @@ -91,7 +91,8 @@ public class XmlDocumentationProvider implements DocumentationProvider { if (curElement!=null) { return formatDocFromComment(curElement, ((XmlElementDecl)element).getNameElement().getText()); } - } else if (element instanceof XmlTag) { + } + else if (element instanceof XmlTag) { XmlTag tag = (XmlTag)element; MyPsiElementProcessor processor = new MyPsiElementProcessor(); String name = tag.getAttributeValue(NAME_ATTR_NAME); @@ -271,7 +272,7 @@ public class XmlDocumentationProvider implements DocumentationProvider { return generateDoc(text, name,null, null); } - private XmlTag getComplexOrSimpleTypeDefinition(PsiElement element, PsiElement originalElement) { + private static XmlTag getComplexOrSimpleTypeDefinition(PsiElement element, PsiElement originalElement) { XmlElementDescriptor descriptor = element.getUserData(DESCRIPTOR_KEY); XmlTag contextTag = null; @@ -421,14 +422,13 @@ public class XmlDocumentationProvider implements DocumentationProvider { if (object instanceof String && originalElement != null) { PsiElement result = findDeclWithName((String)object, originalElement); - PsiElement originalElementParent; - if (result == null && element instanceof XmlTag && (originalElementParent = originalElement.getParent()) instanceof XmlAttributeValue) { - PsiElement originalElementGrandParent = originalElementParent.getParent(); - XmlAttributeDescriptor descriptor = originalElementGrandParent instanceof XmlAttribute ? - ((XmlAttribute)originalElementGrandParent).getDescriptor():null; - - if (descriptor != null && descriptor.getDeclaration() instanceof XmlTag) { - result = findEnumerationValue((String)object, (XmlTag)descriptor.getDeclaration()); + if (result == null && element instanceof XmlTag) { + XmlAttribute attribute = PsiTreeUtil.getParentOfType(originalElement, XmlAttribute.class, false); + if (attribute != null) { + XmlAttributeDescriptor descriptor = attribute.getDescriptor(); + if (descriptor != null && descriptor.getDeclaration() instanceof XmlTag) { + result = findEnumerationValue((String)object, (XmlTag)descriptor.getDeclaration()); + } } } return result; diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngXmlAttributeDescriptor.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngXmlAttributeDescriptor.java index db3d85e44600..f9d9f7cbe23e 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngXmlAttributeDescriptor.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngXmlAttributeDescriptor.java @@ -17,9 +17,6 @@ package org.intellij.plugins.relaxNG.model.descriptors; import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.TextRange; -import com.intellij.openapi.util.text.DelimitedListProcessor; -import com.intellij.psi.ElementManipulators; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiReference; @@ -30,8 +27,8 @@ import com.intellij.psi.xml.XmlTag; import com.intellij.util.ArrayUtil; import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; -import com.intellij.xml.util.XmlAttributeValueReference; import com.intellij.xml.impl.BasicXmlAttributeDescriptor; +import com.intellij.xml.util.XmlEnumeratedValueReference; import gnu.trove.THashSet; import gnu.trove.TObjectHashingStrategy; import org.jetbrains.annotations.NonNls; @@ -212,19 +209,15 @@ public class RngXmlAttributeDescriptor extends BasicXmlAttributeDescriptor { public PsiReference[] getValueReferences(final XmlAttributeValue value) { String text = value.getValue(); if (text == null) return PsiReference.EMPTY_ARRAY; - final int offset = ElementManipulators.getValueTextRange(value).getStartOffset(); - final List<PsiReference> list = new ArrayList<PsiReference>(); - new DelimitedListProcessor("") { + return new PsiReference[] { new XmlEnumeratedValueReference(value, this) { + @Nullable @Override - protected boolean isDelimiter(char ch) { - return Character.isWhitespace(ch); - } - - @Override - protected void processToken(int start, int end, boolean delimitersOnly) { - list.add(new XmlAttributeValueReference(value, TextRange.create(offset + start, offset + end), RngXmlAttributeDescriptor.this)); + public PsiElement resolve() { + if (isTokenDatatype(getValue())) { + return getElement(); + } + return super.resolve(); } - }.processText(text); - return list.toArray(new PsiReference[list.size()]); + }}; } }
\ No newline at end of file diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/RngXmlHighlightingTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/RngXmlHighlightingTest.java index d813d2bcbf48..261ca4e2e98e 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/RngXmlHighlightingTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/RngXmlHighlightingTest.java @@ -17,7 +17,7 @@ package org.intellij.plugins.relaxNG; import com.intellij.javaee.ExternalResourceManagerEx; -import com.intellij.javaee.ExternalResourceManagerImpl; +import com.intellij.javaee.ExternalResourceManagerExImpl; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.fileTypes.StdFileTypes; @@ -41,13 +41,19 @@ public class RngXmlHighlightingTest extends HighlightingTestBase { ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { final ExternalResourceManagerEx m = ExternalResourceManagerEx.getInstanceEx(); - ExternalResourceManagerImpl.addTestResource("urn:test:simple.rng", toAbsolutePath("highlighting/simple.rng"), myTestRootDisposable); - ExternalResourceManagerImpl.addTestResource("urn:test:addressBook", toAbsolutePath("highlighting/rnc/addressbook.rnc"), myTestRootDisposable); + ExternalResourceManagerExImpl + .addTestResource("urn:test:simple.rng", toAbsolutePath("highlighting/simple.rng"), myTestRootDisposable); + ExternalResourceManagerExImpl.addTestResource("urn:test:addressBook", toAbsolutePath("highlighting/rnc/addressbook.rnc"), + myTestRootDisposable); //m.addResource("http://www.w3.org/1999/XSL/Transform", toAbsolutePath("highlighting/relaxng.rng")); - ExternalResourceManagerImpl.addTestResource("http://www.w3.org/1999/XSL/Format", toAbsolutePath("highlighting/rnc/fo/main.rnc"), myTestRootDisposable); - ExternalResourceManagerImpl.addTestResource("http://docbook.org/ns/docbook", toAbsolutePath("highlighting/docbook.rng"), myTestRootDisposable); - ExternalResourceManagerImpl.addTestResource("urn:intelliForm:AttachmentFilter", toAbsolutePath("highlighting/attachment-filter.rng"), myTestRootDisposable); - ExternalResourceManagerImpl.addTestResource("http://www.w3.org/1999/xhtml", toAbsolutePath("highlighting/html5/xhtml5.rnc"), myTestRootDisposable); + ExternalResourceManagerExImpl.addTestResource("http://www.w3.org/1999/XSL/Format", toAbsolutePath("highlighting/rnc/fo/main.rnc"), + myTestRootDisposable); + ExternalResourceManagerExImpl.addTestResource("http://docbook.org/ns/docbook", toAbsolutePath("highlighting/docbook.rng"), + myTestRootDisposable); + ExternalResourceManagerExImpl.addTestResource("urn:intelliForm:AttachmentFilter", + toAbsolutePath("highlighting/attachment-filter.rng"), myTestRootDisposable); + ExternalResourceManagerExImpl + .addTestResource("http://www.w3.org/1999/xhtml", toAbsolutePath("highlighting/html5/xhtml5.rnc"), myTestRootDisposable); m.addIgnoredResource("urn:intelliForm:Spaces"); m.addIgnoredResource("http://www.w3.org/1999/xlink"); diff --git a/xml/relaxng/testData/highlighting/token-datatype.xml b/xml/relaxng/testData/highlighting/token-datatype.xml index d6e508e77ec6..edd9b0063062 100644 --- a/xml/relaxng/testData/highlighting/token-datatype.xml +++ b/xml/relaxng/testData/highlighting/token-datatype.xml @@ -1,4 +1,4 @@ <token-datatype xmlns="urn:test:simple.rng" a=" v " b="v" c=" x y " s1="v" s2=" v " - s3=<error>" v "</error> />
\ No newline at end of file + s3="<error descr="Attribute should have fixed value v"> v </error>" />
\ No newline at end of file diff --git a/xml/tests/src/com/intellij/codeInsight/XmlDocumentationTest.java b/xml/tests/src/com/intellij/codeInsight/XmlDocumentationTest.java index 319d3941e267..1df551bc875c 100644 --- a/xml/tests/src/com/intellij/codeInsight/XmlDocumentationTest.java +++ b/xml/tests/src/com/intellij/codeInsight/XmlDocumentationTest.java @@ -79,7 +79,9 @@ public class XmlDocumentationTest extends DaemonAnalyzerTestCase { VirtualFile vfile = LocalFileSystem.getInstance().findFileByIoFile(new File(pathname)); assertNotNull(pathname + " not found", vfile); String expectedText = StringUtil.convertLineSeparators(VfsUtilCore.loadText(vfile)); - assertEquals(expectedText, StringUtil.convertLineSeparators(context.generateDoc())); + String text = context.generateDoc(); + assertNotNull(text); + assertEquals(expectedText, StringUtil.convertLineSeparators(text)); if (completionVariant != null) { vfile = LocalFileSystem.getInstance().findFileByIoFile(new File(getTestDataPath() +baseFileNames[0] + ".expected.completion.html")); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlAttributeDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlAttributeDescriptorImpl.java index d6bbd3ba3722..674ad163c0b2 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlAttributeDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlAttributeDescriptorImpl.java @@ -16,7 +16,6 @@ package com.intellij.psi.impl.source.html.dtd; import com.intellij.psi.PsiElement; -import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.psi.xml.XmlElement; import com.intellij.util.ArrayUtil; import com.intellij.xml.XmlAttributeDescriptor; @@ -94,7 +93,10 @@ public class HtmlAttributeDescriptorImpl extends BasicXmlAttributeDescriptor { } @Override - protected PsiElement getEnumeratedValueDeclaration(XmlAttributeValue attributeValue, String value) { - return super.getEnumeratedValueDeclaration(attributeValue, myCaseSensitive ? value : value.toLowerCase()); + public PsiElement getValueDeclaration(XmlElement attributeValue, String value) { + String s = myCaseSensitive ? value : value.toLowerCase(); + return delegate instanceof BasicXmlAttributeDescriptor ? + ((BasicXmlAttributeDescriptor)delegate).getValueDeclaration(attributeValue, s) : + super.getValueDeclaration(attributeValue, value); } } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/BasicXmlAttributeDescriptor.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/BasicXmlAttributeDescriptor.java index 83cf70f5ff37..fba46a2cec3d 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/BasicXmlAttributeDescriptor.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/BasicXmlAttributeDescriptor.java @@ -24,17 +24,13 @@ */ package com.intellij.xml.impl; -import com.intellij.openapi.util.Comparing; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiReference; -import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.psi.xml.XmlElement; import com.intellij.util.ArrayUtilRt; -import com.intellij.xml.util.XmlAttributeValueReference; import com.intellij.xml.XmlAttributeDescriptor; import org.jetbrains.annotations.Nullable; -public abstract class BasicXmlAttributeDescriptor implements XmlAttributeDescriptor { +public abstract class BasicXmlAttributeDescriptor extends XmlEnumerationDescriptor implements XmlAttributeDescriptor { public String validateValue(XmlElement context, String value) { return null; } @@ -48,24 +44,12 @@ public abstract class BasicXmlAttributeDescriptor implements XmlAttributeDescrip return getEnumeratedValues(); } - public boolean isEnumerated(@Nullable XmlElement context) { - return isEnumerated(); - } - @Override public String toString() { return getName(); } - public PsiElement getValueDeclaration(XmlAttributeValue attributeValue, String value) { - String defaultValue = getDefaultValue(); - if (Comparing.equal(defaultValue, value)) { - return getDefaultValueDeclaration(); - } - return isFixed() ? null : getEnumeratedValueDeclaration(attributeValue, value); - } - - protected PsiElement getEnumeratedValueDeclaration(XmlAttributeValue attributeValue, String value) { + protected PsiElement getEnumeratedValueDeclaration(XmlElement xmlElement, String value) { String[] values = getEnumeratedValues(); if (values == null || values.length == 0) return getDeclaration(); return ArrayUtilRt.find(values, value) != -1 ? getDeclaration() : null; @@ -74,8 +58,4 @@ public abstract class BasicXmlAttributeDescriptor implements XmlAttributeDescrip protected PsiElement getDefaultValueDeclaration() { return getDeclaration(); } - - public PsiReference[] getValueReferences(XmlAttributeValue value) { - return new PsiReference[] { new XmlAttributeValueReference(value, this)}; - } } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/XmlEnumerationDescriptor.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/XmlEnumerationDescriptor.java new file mode 100644 index 000000000000..bf7b988e899d --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/XmlEnumerationDescriptor.java @@ -0,0 +1,38 @@ +package com.intellij.xml.impl; + +import com.intellij.openapi.util.Comparing; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiReference; +import com.intellij.psi.xml.XmlAttributeValue; +import com.intellij.psi.xml.XmlElement; +import com.intellij.xml.util.XmlEnumeratedValueReference; + +/** + * @author Dmitry Avdeev + * Date: 22.08.13 + */ +public abstract class XmlEnumerationDescriptor { + + public abstract boolean isFixed(); + + public abstract String getDefaultValue(); + + public abstract String[] getEnumeratedValues(); + + public PsiElement getValueDeclaration(XmlElement attributeValue, String value) { + String defaultValue = getDefaultValue(); + if (Comparing.equal(defaultValue, value)) { + return getDefaultValueDeclaration(); + } + return isFixed() ? null : getEnumeratedValueDeclaration(attributeValue, value); + } + + protected abstract PsiElement getEnumeratedValueDeclaration(XmlElement value, String s); + + protected abstract PsiElement getDefaultValueDeclaration(); + + public PsiReference[] getValueReferences(XmlAttributeValue value) { + return new PsiReference[] { new XmlEnumeratedValueReference(value, this)}; + } + +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlAttributeDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlAttributeDescriptorImpl.java index 2248f003ab98..84fba9a1f6fc 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlAttributeDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlAttributeDescriptorImpl.java @@ -15,27 +15,24 @@ */ package com.intellij.xml.impl.schema; -import com.intellij.openapi.util.Ref; import com.intellij.psi.PsiElement; import com.intellij.psi.meta.PsiWritableMetaData; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.psi.xml.*; -import com.intellij.util.*; +import com.intellij.psi.xml.XmlElement; +import com.intellij.psi.xml.XmlFile; +import com.intellij.psi.xml.XmlTag; +import com.intellij.util.ArrayUtil; +import com.intellij.util.IncorrectOperationException; +import com.intellij.xml.XmlAttributeDescriptor; import com.intellij.xml.XmlElementDescriptor; -import com.intellij.xml.impl.BasicXmlAttributeDescriptor; -import com.intellij.xml.util.XmlUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; -import java.util.List; - /** * @author Mike */ -public class XmlAttributeDescriptorImpl extends BasicXmlAttributeDescriptor implements PsiWritableMetaData { +public class XmlAttributeDescriptorImpl extends XsdEnumerationDescriptor implements PsiWritableMetaData, XmlAttributeDescriptor { private XmlTag myTag; String myUse; - private boolean myExhaustiveEnum; @NonNls public static final String REQUIRED_ATTR_VALUE = "required"; @@ -49,7 +46,7 @@ public class XmlAttributeDescriptorImpl extends BasicXmlAttributeDescriptor impl public XmlAttributeDescriptorImpl() {} - public PsiElement getDeclaration(){ + public XmlTag getDeclaration(){ return myTag; } @@ -70,10 +67,6 @@ public class XmlAttributeDescriptorImpl extends BasicXmlAttributeDescriptor impl return REQUIRED_ATTR_VALUE.equals(myUse); } - public boolean isFixed() { - return myTag.getAttributeValue("fixed") != null; - } - private boolean hasSimpleSchemaType(@NonNls String type) { final String attributeValue = getType(); @@ -105,92 +98,14 @@ public class XmlAttributeDescriptorImpl extends BasicXmlAttributeDescriptor impl return hasSimpleSchemaType("IDREF"); } - public String getDefaultValue() { - if (isFixed()) { - return myTag.getAttributeValue("fixed"); - } - - return myTag.getAttributeValue("default"); - } - - public boolean isEnumerated(@Nullable XmlElement context) { - return processEnumeration(context, PairProcessor.TRUE); - } - public boolean isEnumerated() { return isEnumerated(null); } - public String[] getEnumeratedValues() { - return getEnumeratedValues(null); - } - - public String[] getEnumeratedValues(XmlElement context) { - final List<String> list = new SmartList<String>(); - processEnumeration(context, new PairProcessor<PsiElement, String>() { - @Override - public boolean process(PsiElement element, String s) { - list.add(s); - return true; - } - }); - String defaultValue = getDefaultValue(); - if (defaultValue != null) { - list.add(defaultValue); - } - return ArrayUtil.toStringArray(list); - } - - private boolean processEnumeration(XmlElement context, PairProcessor<PsiElement, String> processor) { - XmlTag contextTag = context != null ? PsiTreeUtil.getContextOfType(context, XmlTag.class, true) : null; - final XmlElementDescriptorImpl elementDescriptor = (XmlElementDescriptorImpl)XmlUtil.findXmlDescriptorByType(myTag, contextTag); - - if (elementDescriptor!=null && elementDescriptor.getType() instanceof ComplexTypeDescriptor) { - return processEnumerationImpl(((ComplexTypeDescriptor)elementDescriptor.getType()).getDeclaration(), processor); - } - - final String namespacePrefix = myTag.getNamespacePrefix(); - XmlTag type = myTag.findFirstSubTag( - ((namespacePrefix.length() > 0)?namespacePrefix+":":"")+"simpleType" - ); - - if (type != null) { - return processEnumerationImpl(type, processor); - } - - return false; - } - - private boolean processEnumerationImpl(final XmlTag declaration, final PairProcessor<PsiElement, String> pairProcessor) { - if ("boolean".equals(declaration.getAttributeValue("name"))) { - XmlAttributeValue valueElement = declaration.getAttribute("name").getValueElement(); - pairProcessor.process(valueElement, "true"); - pairProcessor.process(valueElement, "false"); - myExhaustiveEnum = true; - return true; - } - - else { - final Ref<Boolean> found = new Ref<Boolean>(Boolean.FALSE); - myExhaustiveEnum = XmlUtil.processEnumerationValues(declaration, new Processor<XmlTag>() { - @Override - public boolean process(XmlTag tag) { - found.set(Boolean.TRUE); - XmlAttribute name = tag.getAttribute("value"); - return name == null || pairProcessor.process(name.getValueElement(), name.getValue()); - } - }); - return found.get(); - } - } - + @Nullable @Override - public PsiElement getValueDeclaration(XmlAttributeValue attributeValue, String value) { - PsiElement declaration = super.getValueDeclaration(attributeValue, value); - if (declaration == null && !myExhaustiveEnum) { - return getDeclaration(); - } - return declaration; + public String validateValue(XmlElement context, String value) { + return null; } public String getName(PsiElement context) { @@ -246,20 +161,4 @@ public class XmlAttributeDescriptorImpl extends BasicXmlAttributeDescriptor impl public void setName(String name) throws IncorrectOperationException { NamedObjectDescriptor.setName(myTag, name); } - - @Override - protected PsiElement getEnumeratedValueDeclaration(XmlAttributeValue attributeValue, final String value) { - final Ref<PsiElement> result = new Ref<PsiElement>(); - processEnumeration(myTag, new PairProcessor<PsiElement, String>() { - @Override - public boolean process(PsiElement element, String s) { - if (value.equals(s)) { - result.set(element); - return false; - } - return true; - } - }); - return result.get(); - } } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorByType.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorByType.java index 1289008ae75c..5e1bbd182e68 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorByType.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorByType.java @@ -39,7 +39,7 @@ public class XmlElementDescriptorByType extends XmlElementDescriptorImpl { public XmlElementDescriptorByType() {} - public PsiElement getDeclaration(){ + public XmlTag getDeclaration(){ return myDescriptorTag; } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java index 22f37c594056..61c33c09cafc 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java @@ -16,12 +16,9 @@ package com.intellij.xml.impl.schema; import com.intellij.codeInsight.daemon.Validator; -import com.intellij.openapi.util.Key; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.meta.PsiWritableMetaData; -import com.intellij.psi.util.ParameterizedCachedValue; -import com.intellij.psi.util.ParameterizedCachedValueProvider; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.*; import com.intellij.util.ArrayUtil; @@ -39,7 +36,8 @@ import java.util.List; /** * @author Mike */ -public class XmlElementDescriptorImpl implements XmlElementDescriptor, PsiWritableMetaData, Validator<XmlTag>, +public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor + implements XmlElementDescriptor, PsiWritableMetaData, Validator<XmlTag>, XmlElementDescriptorAwareAboutChildren { protected XmlTag myDescriptorTag; protected volatile XmlNSDescriptor NSDescriptor; @@ -51,8 +49,6 @@ public class XmlElementDescriptorImpl implements XmlElementDescriptor, PsiWritab public static final String NONQUALIFIED_ATTR_VALUE = "unqualified"; @NonNls private static final String ELEMENT_FORM_DEFAULT = "elementFormDefault"; - private static final Key<ParameterizedCachedValue<XmlAttributeDescriptor[], XmlTag>> ATTRS_KEY = Key.create("attributes"); - private ParameterizedCachedValueProvider<XmlAttributeDescriptor[],XmlTag> myCachedValueProvider; public XmlElementDescriptorImpl(@Nullable XmlTag descriptorTag) { myDescriptorTag = descriptorTag; @@ -60,7 +56,7 @@ public class XmlElementDescriptorImpl implements XmlElementDescriptor, PsiWritab public XmlElementDescriptorImpl() {} - public PsiElement getDeclaration(){ + public XmlTag getDeclaration(){ return myDescriptorTag; } @@ -395,11 +391,6 @@ public class XmlElementDescriptorImpl implements XmlElementDescriptor, PsiWritab return CONTENT_TYPE_MIXED; } - @Override - public String getDefaultValue() { - return myDescriptorTag.getAttributeValue("default"); - } - @Nullable public XmlElementDescriptor getElementDescriptor(final String name) { final String localName = XmlUtil.findLocalNameByQualifiedName(name); diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XsdEnumerationDescriptor.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XsdEnumerationDescriptor.java new file mode 100644 index 000000000000..0a1c341f6825 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XsdEnumerationDescriptor.java @@ -0,0 +1,139 @@ +package com.intellij.xml.impl.schema; + +import com.intellij.openapi.util.Ref; +import com.intellij.psi.PsiElement; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.xml.XmlAttribute; +import com.intellij.psi.xml.XmlAttributeValue; +import com.intellij.psi.xml.XmlElement; +import com.intellij.psi.xml.XmlTag; +import com.intellij.util.ArrayUtil; +import com.intellij.util.PairProcessor; +import com.intellij.util.Processor; +import com.intellij.util.SmartList; +import com.intellij.xml.impl.XmlEnumerationDescriptor; +import com.intellij.xml.util.XmlUtil; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +/** + * @author Dmitry Avdeev + * Date: 22.08.13 + */ +public abstract class XsdEnumerationDescriptor extends XmlEnumerationDescriptor { + + private boolean myExhaustiveEnum; + + public abstract XmlTag getDeclaration(); + + public String getDefaultValue() { + if (isFixed()) { + return getDeclaration().getAttributeValue("fixed"); + } + + return getDeclaration().getAttributeValue("default"); + } + + public boolean isFixed() { + return getDeclaration().getAttributeValue("fixed") != null; + } + + public String[] getEnumeratedValues() { + return getEnumeratedValues(null); + } + + public String[] getEnumeratedValues(XmlElement context) { + final List<String> list = new SmartList<String>(); + processEnumeration(context, new PairProcessor<PsiElement, String>() { + @Override + public boolean process(PsiElement element, String s) { + list.add(s); + return true; + } + }); + String defaultValue = getDefaultValue(); + if (defaultValue != null) { + list.add(defaultValue); + } + return ArrayUtil.toStringArray(list); + } + + private boolean processEnumeration(XmlElement context, PairProcessor<PsiElement, String> processor) { + XmlTag contextTag = context != null ? PsiTreeUtil.getContextOfType(context, XmlTag.class, true) : null; + final XmlElementDescriptorImpl elementDescriptor = (XmlElementDescriptorImpl)XmlUtil.findXmlDescriptorByType(getDeclaration(), contextTag); + + if (elementDescriptor!=null && elementDescriptor.getType() instanceof ComplexTypeDescriptor) { + return processEnumerationImpl(((ComplexTypeDescriptor)elementDescriptor.getType()).getDeclaration(), processor); + } + + final String namespacePrefix = getDeclaration().getNamespacePrefix(); + XmlTag type = getDeclaration().findFirstSubTag( + ((namespacePrefix.length() > 0) ? namespacePrefix + ":" : "") + "simpleType" + ); + + if (type != null) { + return processEnumerationImpl(type, processor); + } + + return false; + } + + private boolean processEnumerationImpl(final XmlTag declaration, final PairProcessor<PsiElement, String> pairProcessor) { + if ("boolean".equals(declaration.getAttributeValue("name"))) { + XmlAttributeValue valueElement = declaration.getAttribute("name").getValueElement(); + pairProcessor.process(valueElement, "true"); + pairProcessor.process(valueElement, "false"); + myExhaustiveEnum = true; + return true; + } + + else { + final Ref<Boolean> found = new Ref<Boolean>(Boolean.FALSE); + myExhaustiveEnum = XmlUtil.processEnumerationValues(declaration, new Processor<XmlTag>() { + @Override + public boolean process(XmlTag tag) { + found.set(Boolean.TRUE); + XmlAttribute name = tag.getAttribute("value"); + return name == null || pairProcessor.process(tag, name.getValue()); + } + }); + return found.get(); + } + } + + @Override + public PsiElement getValueDeclaration(XmlElement attributeValue, String value) { + PsiElement declaration = super.getValueDeclaration(attributeValue, value); + if (declaration == null && !myExhaustiveEnum) { + return getDeclaration(); + } + return declaration; + } + + + public boolean isEnumerated(@Nullable XmlElement context) { + return processEnumeration(context, PairProcessor.TRUE); + } + + @Override + public PsiElement getEnumeratedValueDeclaration(XmlElement xmlElement, final String value) { + final Ref<PsiElement> result = new Ref<PsiElement>(); + processEnumeration(getDeclaration(), new PairProcessor<PsiElement, String>() { + @Override + public boolean process(PsiElement element, String s) { + if (value.equals(s)) { + result.set(element); + return false; + } + return true; + } + }); + return result.get(); + } + + @Override + protected PsiElement getDefaultValueDeclaration() { + return getDeclaration(); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlAttributeValueReference.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlEnumeratedValueReference.java index 75a604b520c8..5cf994a2deac 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlAttributeValueReference.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlEnumeratedValueReference.java @@ -17,13 +17,11 @@ package com.intellij.xml.util; import com.intellij.codeInsight.daemon.EmptyResolveMessageProvider; import com.intellij.codeInsight.daemon.XmlErrorMessages; -import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReferenceBase; import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.util.ArrayUtil; -import com.intellij.xml.XmlAttributeDescriptor; -import com.intellij.xml.impl.BasicXmlAttributeDescriptor; +import com.intellij.xml.impl.XmlEnumerationDescriptor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -31,25 +29,18 @@ import org.jetbrains.annotations.Nullable; * @author Dmitry Avdeev * Date: 16.08.13 */ -public class XmlAttributeValueReference extends PsiReferenceBase<XmlAttributeValue> implements EmptyResolveMessageProvider { - private final XmlAttributeDescriptor myDescriptor; +public class XmlEnumeratedValueReference extends PsiReferenceBase<XmlAttributeValue> implements EmptyResolveMessageProvider { + private final XmlEnumerationDescriptor myDescriptor; - public XmlAttributeValueReference(XmlAttributeValue value, XmlAttributeDescriptor descriptor) { + public XmlEnumeratedValueReference(XmlAttributeValue value, XmlEnumerationDescriptor descriptor) { super(value); myDescriptor = descriptor; } - public XmlAttributeValueReference(XmlAttributeValue element, - TextRange range, - XmlAttributeDescriptor descriptor) { - super(element, range); - myDescriptor = descriptor; - } - @Nullable @Override public PsiElement resolve() { - return ((BasicXmlAttributeDescriptor)myDescriptor).getValueDeclaration(getElement(), getValue()); + return myDescriptor.getValueDeclaration(getElement(), getValue()); } @NotNull |