From 51ecbfbb9e2a58b2a5d967b2beaefea8c4f89cfe Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 22 Jan 2010 16:22:17 +0300 Subject: [PATCH] IDEADEV-42022: merge schema provided by xsd file and by java class for ui.xml files --- .../src/com/intellij/openapi/vfs/VfsUtil.java | 3 +++ .../RelaxedHtmlFromSchemaElementDescriptor.java | 6 +++++ .../xml/impl/schema/XmlElementDescriptorImpl.java | 6 +++-- .../xml/impl/schema/XmlNSDescriptorImpl.java | 11 +++++--- .../impl/schema/XmlNSTypeDescriptorProvider.java | 30 ++++++++++++++++++++++ 5 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 xml/impl/src/com/intellij/xml/impl/schema/XmlNSTypeDescriptorProvider.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java index 53789168f0..b37ddc8f06 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java @@ -347,6 +347,9 @@ public class VfsUtil { if (file == null && uri.contains(JarFileSystem.JAR_SEPARATOR)) { file = JarFileSystem.getInstance().findFileByPath(uri); + if (file == null && base == null) { + file = VirtualFileManager.getInstance().findFileByUrl(uri); + } } if (file == null) { diff --git a/xml/impl/src/com/intellij/html/impl/RelaxedHtmlFromSchemaElementDescriptor.java b/xml/impl/src/com/intellij/html/impl/RelaxedHtmlFromSchemaElementDescriptor.java index c4e70f412b..396d12e686 100644 --- a/xml/impl/src/com/intellij/html/impl/RelaxedHtmlFromSchemaElementDescriptor.java +++ b/xml/impl/src/com/intellij/html/impl/RelaxedHtmlFromSchemaElementDescriptor.java @@ -16,6 +16,7 @@ package com.intellij.html.impl; import com.intellij.openapi.extensions.Extensions; +import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlTag; import com.intellij.util.ArrayUtil; import com.intellij.xml.XmlAttributeDescriptor; @@ -82,6 +83,11 @@ public class RelaxedHtmlFromSchemaElementDescriptor extends XmlElementDescriptor return descriptors; } + @Override + public XmlAttributeDescriptor getAttributeDescriptor(XmlAttribute attribute) { + return getAttributeDescriptor(attribute.getName(), attribute.getParent()); + } + public XmlAttributeDescriptor getAttributeDescriptor(String attributeName, final XmlTag context) { final XmlAttributeDescriptor descriptor = super.getAttributeDescriptor(attributeName.toLowerCase(), context); if (descriptor != null) return descriptor; diff --git a/xml/impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java b/xml/impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java index 7b378c71fd..d231ea7cc1 100644 --- a/xml/impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java +++ b/xml/impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java @@ -156,15 +156,17 @@ public class XmlElementDescriptorImpl implements XmlElementDescriptor, PsiWritab return nsDescriptor; } + @Nullable public TypeDescriptor getType() { return getType(null); } + @Nullable public TypeDescriptor getType(XmlElement context) { final XmlNSDescriptor nsDescriptor = getNSDescriptor(context); - if (!(nsDescriptor instanceof XmlNSDescriptorImpl)) return null; + if (!(nsDescriptor instanceof XmlNSTypeDescriptorProvider)) return null; - TypeDescriptor type = ((XmlNSDescriptorImpl) nsDescriptor).getTypeDescriptor(myDescriptorTag); + TypeDescriptor type = ((XmlNSTypeDescriptorProvider) nsDescriptor).getTypeDescriptor(myDescriptorTag); if (type == null) { String substAttr = myDescriptorTag.getAttributeValue("substitutionGroup"); if (substAttr != null) { diff --git a/xml/impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java b/xml/impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java index d1a88adfbb..d387b63c39 100644 --- a/xml/impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java +++ b/xml/impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java @@ -48,7 +48,7 @@ import java.util.*; * @author Mike */ @SuppressWarnings({"HardCodedStringLiteral"}) -public class XmlNSDescriptorImpl implements XmlNSDescriptor,Validator, DumbAware { +public class XmlNSDescriptorImpl implements XmlNSDescriptor,Validator, DumbAware, XmlNSTypeDescriptorProvider { @NonNls private static final Set STD_TYPES = new HashSet(); private static final Set UNDECLARED_STD_TYPES = new HashSet(); private XmlFile myFile; @@ -335,7 +335,7 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptor,Validator visited) { XmlNSDescriptorImpl responsibleDescriptor = this; if (namespace != null && namespace.length() != 0 && !namespace.equals(getDefaultNamespace())) { diff --git a/xml/impl/src/com/intellij/xml/impl/schema/XmlNSTypeDescriptorProvider.java b/xml/impl/src/com/intellij/xml/impl/schema/XmlNSTypeDescriptorProvider.java new file mode 100644 index 0000000000..1d82db04c6 --- /dev/null +++ b/xml/impl/src/com/intellij/xml/impl/schema/XmlNSTypeDescriptorProvider.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2010 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.xml.impl.schema; + +import com.intellij.psi.xml.XmlTag; +import org.jetbrains.annotations.Nullable; + +/** + * @author nik + */ +public interface XmlNSTypeDescriptorProvider { + @Nullable + TypeDescriptor getTypeDescriptor(String name, XmlTag context); + + @Nullable + TypeDescriptor getTypeDescriptor(XmlTag descriptorTag); +} -- 2.11.4.GIT