IDEADEV-42022: merge schema provided by xsd file and by java class for ui.xml files

This commit is contained in:
nik
2010-01-22 16:22:17 +03:00
parent 6221594d7b
commit 51ecbfbb9e
5 changed files with 50 additions and 6 deletions
@@ -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) {
@@ -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;
@@ -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) {
@@ -48,7 +48,7 @@ import java.util.*;
* @author Mike
*/
@SuppressWarnings({"HardCodedStringLiteral"})
public class XmlNSDescriptorImpl implements XmlNSDescriptor,Validator<XmlDocument>, DumbAware {
public class XmlNSDescriptorImpl implements XmlNSDescriptor,Validator<XmlDocument>, DumbAware, XmlNSTypeDescriptorProvider {
@NonNls private static final Set<String> STD_TYPES = new HashSet<String>();
private static final Set<String> UNDECLARED_STD_TYPES = new HashSet<String>();
private XmlFile myFile;
@@ -335,7 +335,7 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptor,Validator<XmlDocumen
return new XmlAttributeDescriptorImpl(tag);
}
protected TypeDescriptor getTypeDescriptor(XmlTag descriptorTag) {
public TypeDescriptor getTypeDescriptor(XmlTag descriptorTag) {
String type = descriptorTag.getAttributeValue("type");
if (type != null) {
@@ -405,20 +405,23 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptor,Validator<XmlDocumen
return defaultNSDescriptor;
}
@Nullable
protected TypeDescriptor findTypeDescriptor(final String qname) {
return findTypeDescriptor(qname, myTag);
}
@Nullable
protected TypeDescriptor findTypeDescriptor(final String qname, XmlTag context) {
String namespace = context.getNamespaceByPrefix(XmlUtil.findPrefixByQualifiedName(qname));
return findTypeDescriptor(XmlUtil.findLocalNameByQualifiedName(qname), namespace);
}
@Nullable
private TypeDescriptor findTypeDescriptor(String localName, String namespace) {
TypeDescriptor typeDescriptor = findTypeDescriptorImpl(myTag, localName, namespace, null);
return typeDescriptor;
return findTypeDescriptorImpl(myTag, localName, namespace, null);
}
@Nullable
protected TypeDescriptor findTypeDescriptorImpl(XmlTag rootTag, final String name, String namespace, Set<XmlTag> visited) {
XmlNSDescriptorImpl responsibleDescriptor = this;
if (namespace != null && namespace.length() != 0 && !namespace.equals(getDefaultNamespace())) {
@@ -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);
}