diff options
Diffstat (limited to 'xml/xml-psi-impl')
6 files changed, 48 insertions, 33 deletions
diff --git a/xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.java b/xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.java index 4d58a5524bfe..d5bec52f6091 100644 --- a/xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.java @@ -514,18 +514,23 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { 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; + try { + if (resource == null) { + String message = "Cannot find standard resource. filename:" + file + " class=" + clazz + ", classLoader:" + classLoader; + if (ApplicationManager.getApplication().isUnitTestMode()) { + LOG.error(message); + } + else { + LOG.warn(message); + } + + return null; + } + } + finally { + classLoader = null; + clazz = null; } String path = FileUtil.unquote(resource.toString()); @@ -535,7 +540,6 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { return path; } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/xml/xml-psi-impl/src/com/intellij/lang/html/HtmlParsing.java b/xml/xml-psi-impl/src/com/intellij/lang/html/HtmlParsing.java index 250d27e9a101..55ab6d28fdd8 100644 --- a/xml/xml-psi-impl/src/com/intellij/lang/html/HtmlParsing.java +++ b/xml/xml-psi-impl/src/com/intellij/lang/html/HtmlParsing.java @@ -76,7 +76,10 @@ public class HtmlParsing { error = flushError(error); parseProcessingInstruction(); } - else if (tt == XmlTokenType.XML_REAL_WHITE_SPACE || tt == XmlTokenType.XML_CHAR_ENTITY_REF || tt == XmlTokenType.XML_DATA_CHARACTERS) { + else if (tt == XmlTokenType.XML_CHAR_ENTITY_REF || tt == XmlTokenType.XML_ENTITY_REF_TOKEN) { + parseReference(); + } + else if (tt == XmlTokenType.XML_REAL_WHITE_SPACE || tt == XmlTokenType.XML_DATA_CHARACTERS) { error = flushError(error); advance(); } else if (tt == XmlTokenType.XML_END_TAG_START) { diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java index e666cdcea090..8bd39976fe44 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java @@ -152,27 +152,28 @@ public class XmlEntityRefImpl extends XmlElementImpl implements XmlEntityRef { ) { XmlDocument document = ((XmlFile)targetElement).getDocument(); final XmlTag rootTag = document.getRootTag(); + XmlFile descriptorFile = null; - if (rootTag != null && document.getUserData(DISABLE_ENTITY_EXPAND) == null) { + if (HtmlUtil.isHtml5Document(document)) { + descriptorFile = XmlUtil.findXmlFile((XmlFile)targetElement, Html5SchemaProvider.getCharsDtdLocation()); + } else if (rootTag != null && document.getUserData(DISABLE_ENTITY_EXPAND) == null) { final XmlElementDescriptor descriptor = rootTag.getDescriptor(); if (descriptor != null && !(descriptor instanceof AnyXmlElementDescriptor)) { - PsiElement element = !HtmlUtil.isHtml5Context(rootTag) ? descriptor.getDeclaration() : - XmlUtil.findXmlFile((XmlFile)targetElement, Html5SchemaProvider.getCharsDtdLocation()); + PsiElement element = descriptor.getDeclaration(); final PsiFile containingFile = element != null ? element.getContainingFile():null; - final XmlFile descriptorFile = containingFile instanceof XmlFile ? (XmlFile)containingFile:null; - - if (descriptorFile != null && - !descriptorFile.getName().equals(((XmlFile)targetElement).getName()+".dtd")) { - deps.add(descriptorFile); - XmlUtil.processXmlElements( - descriptorFile, - processor, - true - ); - } + descriptorFile = containingFile instanceof XmlFile ? (XmlFile)containingFile:null; } } + if (descriptorFile != null && + !descriptorFile.getName().equals(((XmlFile)targetElement).getName() + ".dtd")) { + deps.add(descriptorFile); + XmlUtil.processXmlElements( + descriptorFile, + processor, + true + ); + } } return new CachedValueProvider.Result<XmlEntityDecl>(result[0], ArrayUtil.toObjectArray(deps)); diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java index 36ae151d5964..5d35f0f4ae69 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java @@ -325,7 +325,11 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator<XmlDocum final CachedValue<XmlAttributeDescriptor> value = CachedValuesManager.getManager(includedDocument.getProject()).createCachedValue( new CachedValueProvider<XmlAttributeDescriptor>(){ public Result<XmlAttributeDescriptor> compute() { - return new Result<XmlAttributeDescriptor>(attributeDescriptor, attributeDescriptor.getDependences()); + Object[] deps = attributeDescriptor.getDependences(); + if (deps.length == 0) { + LOG.error(attributeDescriptor + " returned no dependencies"); + } + return new Result<XmlAttributeDescriptor>(attributeDescriptor, deps); } }, false diff --git a/xml/xml-psi-impl/src/com/intellij/xml/index/XmlIndex.java b/xml/xml-psi-impl/src/com/intellij/xml/index/XmlIndex.java index 1e549442011a..fb5242cb3e51 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/index/XmlIndex.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/index/XmlIndex.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -95,13 +95,15 @@ public abstract class XmlIndex<V> extends FileBasedIndexExtension<String, V> { }; } + @NotNull public KeyDescriptor<String> getKeyDescriptor() { return KEY_DESCRIPTOR; } + @NotNull public FileBasedIndex.InputFilter getInputFilter() { return new DefaultFileTypeSpecificInputFilter(XmlFileType.INSTANCE, DTDFileType.INSTANCE) { - public boolean acceptInput(final VirtualFile file) { + public boolean acceptInput(@NotNull final VirtualFile file) { FileType fileType = file.getFileType(); final String extension = file.getExtension(); return XmlFileType.INSTANCE.equals(fileType) && "xsd".equals(extension) || diff --git a/xml/xml-psi-impl/src/com/intellij/xml/index/XmlNamespaceIndex.java b/xml/xml-psi-impl/src/com/intellij/xml/index/XmlNamespaceIndex.java index 55cde705430c..923a5cfce4e0 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/index/XmlNamespaceIndex.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/index/XmlNamespaceIndex.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -107,11 +107,12 @@ public class XmlNamespaceIndex extends XmlIndex<XsdNamespaceBuilder> { }; } + @NotNull @Override public DataExternalizer<XsdNamespaceBuilder> getValueExternalizer() { return new DataExternalizer<XsdNamespaceBuilder>() { @Override - public void save(DataOutput out, XsdNamespaceBuilder value) throws IOException { + public void save(@NotNull DataOutput out, XsdNamespaceBuilder value) throws IOException { out.writeUTF(value.getNamespace() == null ? "" : value.getNamespace()); out.writeUTF(value.getVersion() == null ? "" : value.getVersion()); out.writeInt(value.getTags().size()); @@ -121,7 +122,7 @@ public class XmlNamespaceIndex extends XmlIndex<XsdNamespaceBuilder> { } @Override - public XsdNamespaceBuilder read(DataInput in) throws IOException { + public XsdNamespaceBuilder read(@NotNull DataInput in) throws IOException { int count; XsdNamespaceBuilder builder = new XsdNamespaceBuilder(in.readUTF(), in.readUTF(), new ArrayList<String>(count = in.readInt())); |