本文整理汇总了Java中com.intellij.xml.util.XmlUtil.findPrefixByQualifiedName方法的典型用法代码示例。如果您正苦于以下问题:Java XmlUtil.findPrefixByQualifiedName方法的具体用法?Java XmlUtil.findPrefixByQualifiedName怎么用?Java XmlUtil.findPrefixByQualifiedName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.xml.util.XmlUtil
的用法示例。
在下文中一共展示了XmlUtil.findPrefixByQualifiedName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getType
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Nullable
public TypeDescriptor getType(XmlElement context) {
final XmlNSDescriptor nsDescriptor = getNSDescriptor(context);
if (!(nsDescriptor instanceof XmlNSTypeDescriptorProvider)) return null;
TypeDescriptor type = ((XmlNSTypeDescriptorProvider) nsDescriptor).getTypeDescriptor(myDescriptorTag);
if (type == null) {
String substAttr = myDescriptorTag.getAttributeValue("substitutionGroup");
if (substAttr != null) {
final String namespacePrefix = XmlUtil.findPrefixByQualifiedName(substAttr);
final String namespace = namespacePrefix.isEmpty() ?
getDefaultNamespace() :
myDescriptorTag.getNamespaceByPrefix(namespacePrefix);
final String local = XmlUtil.findLocalNameByQualifiedName(substAttr);
final XmlElementDescriptorImpl originalElement = (XmlElementDescriptorImpl)((XmlNSDescriptorImpl)getNSDescriptor()).getElementDescriptor(local, namespace);
if (originalElement != null && originalElement != this) {
type = originalElement.getType(context);
}
}
}
return type;
}
示例2: getNamespace
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
private static String getNamespace(final XmlTag tag, final String text) {
final String namespacePrefix = XmlUtil.findPrefixByQualifiedName(text);
final String namespaceByPrefix = tag.getNamespaceByPrefix(namespacePrefix);
if (!namespaceByPrefix.isEmpty()) return namespaceByPrefix;
final XmlTag rootTag = ((XmlFile)tag.getContainingFile()).getRootTag();
if (rootTag != null &&
"schema".equals(rootTag.getLocalName()) &&
XmlUtil.ourSchemaUrisList.indexOf(rootTag.getNamespace()) != -1 ) {
final String targetNS = rootTag.getAttributeValue(TARGET_NAMESPACE);
if (targetNS != null) {
final String targetNsPrefix = rootTag.getPrefixByNamespace(targetNS);
if (namespacePrefix.equals(targetNsPrefix) ||
(namespaceByPrefix.isEmpty() && targetNsPrefix == null)) {
return targetNS;
}
}
}
return namespaceByPrefix;
}
示例3: getAttributeDescriptor
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Override
public XmlAttributeDescriptor getAttributeDescriptor(String attributeName, final XmlTag context) {
String caseSensitiveAttributeName = !myCaseSensitive ? attributeName.toLowerCase() : attributeName;
XmlAttributeDescriptor descriptor = super.getAttributeDescriptor(caseSensitiveAttributeName, context);
if (descriptor == null) descriptor = RelaxedHtmlFromSchemaElementDescriptor.getAttributeDescriptorFromFacelets(attributeName, context);
if (descriptor == null) {
String prefix = XmlUtil.findPrefixByQualifiedName(attributeName);
if ("xml".equals(prefix)) { // todo this is not technically correct dtd document references namespaces but we should handle it at least for xml stuff
XmlNSDescriptor nsdescriptor = context.getNSDescriptor(XmlUtil.XML_NAMESPACE_URI, true);
if (nsdescriptor instanceof XmlNSDescriptorImpl) {
descriptor = ((XmlNSDescriptorImpl)nsdescriptor).getAttribute(
XmlUtil.findLocalNameByQualifiedName(caseSensitiveAttributeName), XmlUtil.XML_NAMESPACE_URI, context);
}
}
}
if (descriptor == null && HtmlUtil.isHtml5Context(context)) {
descriptor = myDelegate.getAttributeDescriptor(attributeName, context);
}
return descriptor;
}
示例4: isElementWithEmbeddedType
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
public static boolean isElementWithEmbeddedType(XmlTagImpl xml, final String typeName, final String typeNsPrefix) {
final String localName = xml.getLocalName();
if (! (XmlUtil.XML_SCHEMA_URI.equals(xml.getNamespace()) && "element".equals(localName))) {
return false;
}
final XmlAttribute nameAttr = getNameAttr(xml);
if (nameAttr == null || nameAttr.getValue() == null) return false;
final String localTypeName = XmlUtil.findLocalNameByQualifiedName(nameAttr.getValue());
final String prefix = XmlUtil.findPrefixByQualifiedName(nameAttr.getValue());
if (! typeName.equals(localTypeName) || ! typeNsPrefix.equals(prefix)) {
return false;
}
final XmlTag[] tags = xml.getSubTags();
for (XmlTag tag : tags) {
if (isTypeElement((XmlTagImpl)tag)) {
return true;
}
}
return false;
}
示例5: getNamespace
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
public String getNamespace(){
String name = getName();
if (name == null) return XmlUtil.EMPTY_URI;
if (getNSDescriptor() == null || myDescriptorTag == null) return XmlUtil.EMPTY_URI;
final String namespacePrefix = XmlUtil.findPrefixByQualifiedName(name);
return namespacePrefix.isEmpty() ?
getDefaultNamespace() :
myDescriptorTag.getNamespaceByPrefix(namespacePrefix);
}
示例6: getAttributeDescriptorImpl
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Nullable
private XmlAttributeDescriptor getAttributeDescriptorImpl(final String attributeName, XmlTag context) {
final String localName = XmlUtil.findLocalNameByQualifiedName(attributeName);
final String namespacePrefix = XmlUtil.findPrefixByQualifiedName(attributeName);
final String namespace = namespacePrefix.isEmpty() ?
getDefaultNamespace() :
context.getNamespaceByPrefix(namespacePrefix);
XmlAttributeDescriptor attribute = getAttribute(localName, namespace, context, attributeName);
if (attribute instanceof AnyXmlAttributeDescriptor) {
final ComplexTypeDescriptor.CanContainAttributeType containAttributeType =
((AnyXmlAttributeDescriptor)attribute).getCanContainAttributeType();
if (containAttributeType != ComplexTypeDescriptor.CanContainAttributeType.CanContainAny && !namespace.isEmpty()) {
final XmlNSDescriptor candidateNSDescriptor = context.getNSDescriptor(namespace, true);
if (candidateNSDescriptor instanceof XmlNSDescriptorImpl) {
final XmlNSDescriptorImpl nsDescriptor = (XmlNSDescriptorImpl)candidateNSDescriptor;
final XmlAttributeDescriptor xmlAttributeDescriptor = nsDescriptor.getAttribute(localName, namespace, context);
if (xmlAttributeDescriptor != null) return xmlAttributeDescriptor;
else {
if (containAttributeType == ComplexTypeDescriptor.CanContainAttributeType.CanContainButDoNotSkip) {
attribute = null;
}
}
}
}
}
return attribute;
}
示例7: getElementDescriptor
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Nullable
public XmlElementDescriptor getElementDescriptor(final String name) {
final String localName = XmlUtil.findLocalNameByQualifiedName(name);
final String namespacePrefix = XmlUtil.findPrefixByQualifiedName(name);
final String namespace = namespacePrefix.isEmpty() ?
getDefaultNamespace() :
myDescriptorTag.getNamespaceByPrefix(namespacePrefix);
return getElementDescriptor(localName, namespace, null, name);
}
示例8: getNSDescriptorToSearchIn
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
static @NotNull XmlNSDescriptorImpl getNSDescriptorToSearchIn(XmlTag rootTag, final String name, XmlNSDescriptorImpl defaultNSDescriptor) {
if (name == null) return defaultNSDescriptor;
final String namespacePrefix = XmlUtil.findPrefixByQualifiedName(name);
if (namespacePrefix.length() > 0) {
final String namespace = rootTag.getNamespaceByPrefix(namespacePrefix);
final XmlNSDescriptor nsDescriptor = rootTag.getNSDescriptor(namespace, true);
if (nsDescriptor instanceof XmlNSDescriptorImpl) {
return (XmlNSDescriptorImpl)nsDescriptor;
}
}
return defaultNSDescriptor;
}
示例9: createSchemaPrefixReference
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Nullable
private static PsiReference createSchemaPrefixReference(final PsiElement element) {
if (element instanceof XmlAttributeValue) {
final XmlAttributeValue attributeValue = (XmlAttributeValue)element;
final String prefix = XmlUtil.findPrefixByQualifiedName(attributeValue.getValue());
if (!prefix.isEmpty()) {
return new SchemaPrefixReference(attributeValue, TextRange.from(1, prefix.length()), prefix, null);
}
}
return null;
}
示例10: getReferences
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Override
@NotNull
public PsiReference[] getReferences() {
ProgressManager.checkCanceled();
final ASTNode startTagName = XmlChildRole.START_TAG_NAME_FINDER.findChild(this);
if (startTagName == null) return PsiReference.EMPTY_ARRAY;
final ASTNode endTagName = XmlChildRole.CLOSING_TAG_NAME_FINDER.findChild(this);
List<PsiReference> refs = new ArrayList<PsiReference>();
String prefix = getNamespacePrefix();
TagNameReference startTagRef = TagNameReference.createTagNameReference(this, startTagName, true);
if (startTagRef != null) {
refs.add(startTagRef);
}
if (!prefix.isEmpty()) {
refs.add(createPrefixReference(startTagName, prefix, startTagRef));
}
if (endTagName != null) {
TagNameReference endTagRef = TagNameReference.createTagNameReference(this, endTagName, false);
if (endTagRef != null) {
refs.add(endTagRef);
}
prefix = XmlUtil.findPrefixByQualifiedName(endTagName.getText());
if (StringUtil.isNotEmpty(prefix)) {
refs.add(createPrefixReference(endTagName, prefix, endTagRef));
}
}
// ArrayList.addAll() makes a clone of the collection
//noinspection ManualArrayToCollectionCopy
for (PsiReference ref : ReferenceProvidersRegistry.getReferencesFromProviders(this, XmlTag.class)) {
refs.add(ref);
}
return ContainerUtil.toArray(refs, new PsiReference[refs.size()]);
}
示例11: getNamespace
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Override
@NotNull
public String getNamespace() {
final String name = getName();
final String prefixByQualifiedName = XmlUtil.findPrefixByQualifiedName(name);
// The namespace name for an unprefixed attribute name always has no value. Namespace recommendation section 6.2, third paragraph
if (prefixByQualifiedName.isEmpty()) return XmlUtil.EMPTY_URI;
return getParent().getNamespaceByPrefix(prefixByQualifiedName);
}
示例12: getNamespacePrefix
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Override
@NotNull
public String getNamespacePrefix() {
return XmlUtil.findPrefixByQualifiedName(getName());
}
示例13: getNamespacePrefix
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Override
@NonNls
@NotNull
public String getNamespacePrefix() {
return XmlUtil.findPrefixByQualifiedName(getName());
}