本文整理汇总了Java中com.intellij.xml.util.XmlUtil.processXmlElements方法的典型用法代码示例。如果您正苦于以下问题:Java XmlUtil.processXmlElements方法的具体用法?Java XmlUtil.processXmlElements怎么用?Java XmlUtil.processXmlElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.xml.util.XmlUtil
的用法示例。
在下文中一共展示了XmlUtil.processXmlElements方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Override
public void validate(@NotNull XmlDocument document, @NotNull ValidationHost host) {
if (document.getLanguage() == DTDLanguage.INSTANCE) {
final List<XmlElementDecl> decls = new ArrayList<XmlElementDecl>(3);
XmlUtil.processXmlElements(document, new PsiElementProcessor() {
@Override
public boolean execute(@NotNull final PsiElement element) {
if (element instanceof XmlElementDecl) decls.add((XmlElementDecl)element);
return true;
}
}, false);
XmlUtil.doDuplicationCheckForElements(
decls.toArray(new XmlElementDecl[decls.size()]),
new HashMap<String, XmlElementDecl>(decls.size()),
XML_ELEMENT_DECL_PROVIDER,
host
);
return;
}
ExternalDocumentValidator.doValidation(document,host);
}
示例2: get
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Override
public Object[] get(final PsiElement context, CompletionContext completionContext) {
final List<String> results = new LinkedList<String>();
final PsiElementProcessor processor = new PsiElementProcessor() {
@Override
public boolean execute(@NotNull final PsiElement element) {
if (element instanceof XmlEntityDecl) {
final XmlEntityDecl xmlEntityDecl = (XmlEntityDecl)element;
if (xmlEntityDecl.isInternalReference()) {
results.add(xmlEntityDecl.getName());
}
}
return true;
}
};
XmlUtil.processXmlElements((XmlFile)context.getContainingFile().getOriginalFile(), processor, true);
return ArrayUtil.toObjectArray(results);
}
示例3: getUrlFor
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Override
public List<String> getUrlFor(PsiElement element, PsiElement originalElement) {
if (element instanceof XmlTag) {
XmlTag tag = (XmlTag)element;
MyPsiElementProcessor processor = new MyPsiElementProcessor();
XmlUtil.processXmlElements(tag,processor, true);
if (processor.url == null) {
XmlTag declaration = getComplexOrSimpleTypeDefinition(element, originalElement);
if (declaration != null) {
XmlUtil.processXmlElements(declaration,processor, true);
}
}
return processor.url != null ? Collections.singletonList(processor.url) : null;
}
return null;
}
示例4: doCollectXmlDescriptors
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Override
protected final XmlElementDescriptor[] doCollectXmlDescriptors(final XmlTag context) {
final LinkedHashSet<XmlElementDescriptor> result = new LinkedHashSet<XmlElementDescriptor>();
final XmlElementContentSpec contentSpecElement = myElementDecl.getContentSpecElement();
final XmlNSDescriptor nsDescriptor = getNSDescriptor();
final XmlNSDescriptor NSDescriptor = nsDescriptor != null? nsDescriptor:getNsDescriptorFrom(context);
XmlUtil.processXmlElements(contentSpecElement, new PsiElementProcessor(){
@Override
public boolean execute(@NotNull PsiElement child){
if (child instanceof XmlToken) {
final XmlToken token = (XmlToken)child;
if (token.getTokenType() == XmlTokenType.XML_NAME) {
final String text = child.getText();
XmlElementDescriptor element = getElementDescriptor(text, NSDescriptor);
if (element != null) {
result.add(element);
}
}
else if (token.getTokenType() == XmlTokenType.XML_CONTENT_ANY) {
if (NSDescriptor instanceof XmlNSDescriptorImpl) {
ContainerUtil.addAll(result, ((XmlNSDescriptorImpl)NSDescriptor).getElements());
} else if (NSDescriptor instanceof XmlNSDescriptorSequence) {
for (XmlNSDescriptor xmlNSDescriptor : ((XmlNSDescriptorSequence)NSDescriptor).getSequence()) {
if (xmlNSDescriptor instanceof XmlNSDescriptorImpl) {
ContainerUtil.addAll(result, ((XmlNSDescriptorImpl)xmlNSDescriptor).getElements());
}
}
}
}
}
return true;
}
}, true, false, XmlUtil.getContainingFile(getDeclaration()));
return result.toArray(new XmlElementDescriptor[result.size()]);
}
示例5: visitXmlElement
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Override
public void visitXmlElement(XmlElement element) {
if (element instanceof XmlEntityRef) {
XmlUtil.processXmlElements(element, this, false, true);
}
super.visitXmlElement(element);
}
示例6: doCollectAttlistDeclarations
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
private static XmlAttlistDecl[] doCollectAttlistDeclarations(XmlElement xmlElement) {
final List<XmlAttlistDecl> result = new ArrayList<XmlAttlistDecl>();
XmlUtil.processXmlElements(xmlElement, new FilterElementProcessor(new ClassFilter(XmlAttlistDecl.class), result), false, false, XmlUtil.getContainingFile(xmlElement));
return result.toArray(new XmlAttlistDecl[result.size()]);
}
示例7: extractEmbeddedFileReferences
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
private static Set<String> extractEmbeddedFileReferences(XmlFile file, XmlFile context, final String url) {
final Set<String> result = new LinkedHashSet<String>();
if (context != null) {
XmlEntityCache.copyEntityCaches(file, context);
}
XmlUtil.processXmlElements(
file,
new PsiElementProcessor() {
@Override
public boolean execute(@NotNull PsiElement element) {
if (element instanceof XmlEntityDecl) {
String candidateName = null;
for (PsiElement e = element.getLastChild(); e != null; e = e.getPrevSibling()) {
if (e instanceof XmlAttributeValue && candidateName == null) {
candidateName = e.getText().substring(1, e.getTextLength() - 1);
}
else if (e instanceof XmlToken &&
candidateName != null &&
(((XmlToken)e).getTokenType() == XmlTokenType.XML_DOCTYPE_PUBLIC ||
((XmlToken)e).getTokenType() == XmlTokenType.XML_DOCTYPE_SYSTEM
)
) {
if (!result.contains(candidateName)) {
result.add(candidateName);
}
break;
}
}
}
else if (element instanceof XmlTag) {
final XmlTag tag = (XmlTag)element;
String schemaLocation = tag.getAttributeValue(XmlUtil.SCHEMA_LOCATION_ATT);
if (schemaLocation != null) {
// processing xsd:import && xsd:include
final PsiReference[] references = tag.getAttribute(XmlUtil.SCHEMA_LOCATION_ATT).getValueElement().getReferences();
if (references.length > 0) {
String extension = FileUtilRt.getExtension(new File(url).getName());
final String namespace = tag.getAttributeValue("namespace");
if (namespace != null &&
schemaLocation.indexOf('/') == -1 &&
!extension.equals(FileUtilRt.getExtension(schemaLocation))) {
result.add(namespace.substring(0, namespace.lastIndexOf('/') + 1) + schemaLocation);
}
else {
result.add(schemaLocation);
}
}
}
else {
schemaLocation = tag.getAttributeValue(XmlUtil.SCHEMA_LOCATION_ATT, XmlUtil.XML_SCHEMA_INSTANCE_URI);
if (schemaLocation != null) {
final StringTokenizer tokenizer = new StringTokenizer(schemaLocation);
while (tokenizer.hasMoreTokens()) {
tokenizer.nextToken();
if (!tokenizer.hasMoreTokens()) break;
String location = tokenizer.nextToken();
result.add(location);
}
}
}
}
return true;
}
},
true,
true
);
return result;
}