本文整理汇总了Java中com.intellij.xml.util.XmlUtil.isUrlText方法的典型用法代码示例。如果您正苦于以下问题:Java XmlUtil.isUrlText方法的具体用法?Java XmlUtil.isUrlText怎么用?Java XmlUtil.isUrlText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.xml.util.XmlUtil
的用法示例。
在下文中一共展示了XmlUtil.isUrlText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUrlReference
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
static PsiReference getUrlReference(PsiElement element, String s) {
PsiElement parent = element.getParent();
if (XmlUtil.isUrlText(s, element.getProject()) ||
(parent instanceof XmlAttribute &&
( ((XmlAttribute)parent).isNamespaceDeclaration() ||
NAMESPACE_ATTR_NAME.equals(((XmlAttribute)parent).getName())
)
)
) {
if (!s.startsWith(XmlUtil.TAG_DIR_NS_PREFIX)) {
boolean namespaceSoftRef = parent instanceof XmlAttribute &&
NAMESPACE_ATTR_NAME.equals(((XmlAttribute)parent).getName()) &&
((XmlAttribute)parent).getParent().getAttributeValue(XmlUtil.SCHEMA_LOCATION_ATT) != null;
if (!namespaceSoftRef && parent instanceof XmlAttribute && ((XmlAttribute)parent).isNamespaceDeclaration()) {
namespaceSoftRef = parent.getContainingFile().getContext() != null;
}
return new URLReference(element, null, namespaceSoftRef);
}
}
return null;
}
示例2: resolve
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Override
@Nullable
public PsiElement resolve() {
final String canonicalText = getCanonicalText();
final PsiFile file = ExternalResourceManager.getInstance().getResourceLocation(canonicalText, myElement.getContainingFile(), null);
if (file != null) return file;
PsiElement element = myReference.resolve();
if (element == null && !myForceFetchResultValid && !XmlUtil.isUrlText(canonicalText, myElement.getProject())) return myElement; // file reference will highlight it
return element;
}
示例3: getReferencesByElement
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Override
@NotNull
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull final ProcessingContext context) {
final String text = element.getText();
String s = StringUtil.unquoteString(text);
final PsiElement parent = element.getParent();
if (parent instanceof XmlAttribute &&
XmlUtil.SCHEMA_LOCATION_ATT.equals(((XmlAttribute)parent).getLocalName()) &&
XmlUtil.XML_SCHEMA_INSTANCE_URI.equals(((XmlAttribute)parent).getNamespace())) {
final List<PsiReference> refs = new ArrayList<PsiReference>(2);
final StringTokenizer tokenizer = new StringTokenizer(s);
while(tokenizer.hasMoreElements()) {
final String namespace = tokenizer.nextToken();
int offset = text.indexOf(namespace);
TextRange range = new TextRange(offset, offset + namespace.length());
final URLReference urlReference = new URLReference(element, range, true) {
@Override
public boolean isSchemaLocation() {
return true;
}
};
refs.add(urlReference);
if (!tokenizer.hasMoreElements()) break;
String url = tokenizer.nextToken();
offset = text.indexOf(url);
refs.add(new DependentNSReference(element, new TextRange(offset,offset + url.length()), urlReference));
if (!XmlUtil.isUrlText(url, element.getProject())) {
ContainerUtil.addAll(refs, new FileReferenceSet(url, element, offset, this, false).getAllReferences());
}
}
return refs.toArray(new PsiReference[refs.size()]);
}
PsiReference reference = getUrlReference(element, s);
if (reference != null) return new PsiReference[] { reference };
s = s.substring(XmlUtil.getPrefixLength(s));
return new FileReferenceSet(s,element,text.indexOf(s), this,true).getAllReferences();
}