本文整理汇总了Java中org.intellij.lang.xpath.XPathFile类的典型用法代码示例。如果您正苦于以下问题:Java XPathFile类的具体用法?Java XPathFile怎么用?Java XPathFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XPathFile类属于org.intellij.lang.xpath包,在下文中一共展示了XPathFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitXPathFile
import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
@Override
public void visitXPathFile(XPathFile file) {
final XmlAttribute context = PsiTreeUtil.getContextOfType(file, XmlAttribute.class, true);
if (context != null) {
if (XsltSupport.isPatternAttribute(context)) {
XsltPatternValidator.validate(myHolder, file);
} else {
if (file.getText().trim().length() == 0 && file.getExpression() == null) {
myHolder.createErrorAnnotation(file, "Empty XPath expression");
}
}
if (XsltSupport.isXsltAttribute(context) && !XsltSupport.mayBeAVT(context)) {
final ASTNode node = file.getNode();
if (node != null && node.findChildByType(XPathTokenTypes.LBRACE) != null) {
myHolder.createErrorAnnotation(file, "Attribute Value Template is not allowed here");
}
}
}
}
示例2: getRelatedFiles
import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
public PsiFile[] getRelatedFiles(final XPathFile file) {
final XmlAttribute attribute = PsiTreeUtil.getContextOfType(file, XmlAttribute.class, false);
assert attribute != null;
final PsiFile psiFile = attribute.getContainingFile();
assert psiFile != null;
final List<PsiFile> files = new ArrayList<PsiFile>();
psiFile.accept(new XmlRecursiveElementVisitor() {
@Override
public void visitXmlAttribute(XmlAttribute attribute) {
final PsiFile[] _files = XsltSupport.getFiles(attribute);
for (PsiFile _file : _files) {
if (_file != file) files.add(_file);
}
}
});
return PsiUtilCore.toPsiFileArray(files);
}
示例3: getFiles
import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
@NotNull
public static PsiFile[] getFiles(XmlAttribute attribute) {
final XmlAttributeValue value = attribute.getValueElement();
if (value != null) {
final List<PsiFile> files = new SmartList<PsiFile>();
InjectedLanguageUtil.enumerate(value, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
public void visit(@NotNull PsiFile injectedPsi, @NotNull List<PsiLanguageInjectionHost.Shred> places) {
if (injectedPsi instanceof XPathFile) {
files.add(injectedPsi);
}
}
});
return files.isEmpty() ? PsiFile.EMPTY_ARRAY : PsiUtilCore.toPsiFileArray(files);
}
return PsiFile.EMPTY_ARRAY;
}
示例4: acceptChar
import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
@Nullable
@Override
public CharFilter.Result acceptChar(char c, int prefixLength, Lookup lookup) {
if (c != '.' || !lookup.isCompletion()) {
return null;
}
if (!(lookup.getPsiFile() instanceof XPathFile)) {
// could be an XML file during XML autocompletion
final LookupElement item = lookup.getCurrentItem();
if (item == null || !(item.getObject() instanceof org.intellij.lang.xpath.completion.Lookup)) {
// current completion item isn't something XPath related, continue with other handlers
return null;
}
}
// typed '.' should appear literally in editor, it has no meaning for completion
return Result.HIDE_LOOKUP;
}
示例5: validate
import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
public static void validate(AnnotationHolder annotationHolder, PsiFile file) {
final XPathExpression expression = ((XPathFile)file).getExpression();
if (expression != null) {
if (!checkPattern(expression)) {
annotationHolder.createErrorAnnotation(expression, "Bad pattern");
}
} else {
annotationHolder.createErrorAnnotation(TextRange.from(0, 1), "Missing pattern");
}
}
示例6: accepts
import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
public boolean accepts(XPathFile file) {
final PsiElement context = file.getContext();
if (!(context instanceof XmlElement)) return false;
final XmlAttribute att = PsiTreeUtil.getParentOfType(context, XmlAttribute.class);
if (att == null) return false;
return XsltSupport.isXPathAttribute(att) ? acceptsLanguage(file.getLanguage()) : false;
}
示例7: isAvailable
import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
@Override
public boolean isAvailable(@NotNull PsiElement context) {
PsiFile containingFile = context.getContainingFile();
if (containingFile instanceof XPathFile) {
final XmlFile xmlFile = PsiTreeUtil.getContextOfType(containingFile, XmlFile.class);
if (xmlFile != null && XsltSupport.isXsltFile(xmlFile)) {
return true;
}
}
return false;
}
示例8: addNameCompletions
import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
private static void addNameCompletions(ContextProvider contextProvider, final XPathNodeTest element, final Set<Lookup> list) {
final PrefixedName prefixedName = element.getQName();
final XPathNodeTest.PrincipalType principalType = element.getPrincipalType();
final Set<PsiFile> files = new HashSet<PsiFile>();
final XPathFile file = (XPathFile)element.getContainingFile();
files.add(file);
ContainerUtil.addAll(files, contextProvider.getRelatedFiles(file));
for (PsiFile xpathFile : files) {
xpathFile.accept(new PsiRecursiveElementVisitor() {
public void visitElement(PsiElement e) {
if (e instanceof XPathNodeTest) {
final XPathNodeTest nodeTest = (XPathNodeTest)e;
final XPathNodeTest.PrincipalType _principalType = nodeTest.getPrincipalType();
if (_principalType == principalType) {
final PrefixedName _prefixedName = nodeTest.getQName();
if (_prefixedName != null && prefixedName != null) {
final String localName = _prefixedName.getLocalName();
if (!"*".equals(localName) && !localName.contains(INTELLIJ_IDEA_RULEZ)) {
if (Comparing.equal(_prefixedName.getPrefix(), prefixedName.getPrefix())) {
list.add(new NodeLookup(localName, _principalType));
} else if (prefixedName.getPrefix() == null) {
list.add(new NodeLookup(_prefixedName.toString(), _principalType));
}
}
}
}
}
super.visitElement(e);
}
});
}
}
示例9: copy
import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
@SuppressWarnings({ "ClassReferencesSubclass" })
public static void copy(@NotNull PsiFile file1, @NotNull XPathFile file2) {
final ContextProvider contextProvider = getContextProvider(file1);
if (!(contextProvider instanceof DefaultProvider)) {
contextProvider.attachTo(file2);
}
}
示例10: getFromExtensionOrDefault
import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
@SuppressWarnings({ "ClassReferencesSubclass" })
private static ContextProvider getFromExtensionOrDefault(PsiFile psiFile) {
if (psiFile instanceof XPathFile) {
final ContextProvider instance = ContextProviderExtension.getInstance((XPathFile)psiFile);
if (instance != null) {
instance.attachTo(psiFile);
return instance;
}
}
return new DefaultProvider(PsiTreeUtil.getContextOfType(psiFile, XmlElement.class, true), psiFile.getLanguage());
}
示例11: getContextProvider
import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
@SuppressWarnings({ "ClassReferencesSubclass" })
@NotNull
public static ContextProvider getContextProvider(PsiElement element) {
return element instanceof XPathElement ?
getContextProvider(element instanceof XPathFile ?
(PsiFile)element :
element.getContainingFile()) :
new DefaultProvider(PsiTreeUtil.getParentOfType(element, XmlElement.class, false));
}
示例12: getInstance
import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
@Nullable
public static ContextProvider getInstance(XPathFile file) {
final ContextProviderExtension[] extensions = Extensions.getExtensions(EXTENSION_POINT_NAME);
for (ContextProviderExtension extension : extensions) {
if (extension.accepts(file)) {
return extension.getContextProvider(file);
}
}
return null;
}
示例13: getContextProvider
import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
@NotNull
public ContextProvider getContextProvider(XPathFile file) {
final XmlElement xmlElement = (XmlElement)file.getContext();
assert xmlElement != null;
return create(xmlElement);
}
示例14: getFunctionCompletions
import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
public static Collection<Lookup> getFunctionCompletions(XPathElement element) {
final XPathFile xpathFile = (XPathFile)element.getContainingFile();
final ContextProvider contextProvider = ContextProvider.getContextProvider(xpathFile);
final NamespaceContext nsContext = contextProvider.getNamespaceContext();
String uri;
PrefixedName qn = null;
if (element instanceof QNameElement) {
qn = ((QNameElement)element).getQName();
if (qn != null) {
QName qName = contextProvider.getQName(qn, element);
if (qn.getPrefix() != null) {
if (qName != null) {
uri = qName.getNamespaceURI();
} else {
return Collections.emptySet();
}
} else {
uri = null;
}
} else {
uri = null;
}
} else {
uri = null;
}
final Map<Pair<QName, Integer>, ? extends Function> functions = contextProvider.getFunctionContext().getFunctions();
final List<Lookup> lookups = new ArrayList<Lookup>(functions.size());
for (Map.Entry<Pair<QName, Integer>, ? extends Function> entry : functions.entrySet()) {
final Function functionDecl = entry.getValue();
final QName f = entry.getKey().first;
final String p;
if (nsContext != null) {
String namespaceURI = f.getNamespaceURI();
if (uri != null && !namespaceURI.equals(uri)) {
continue;
}
final String prefixForURI = nsContext.getPrefixForURI(namespaceURI, PsiTreeUtil.getContextOfType(element, XmlElement.class, true));
if (prefixForURI == null && namespaceURI.length() > 0) {
continue;
}
p = qn == null || qn.getPrefix() == null ? makePrefix(prefixForURI) : "";
} else {
p = "";
}
lookups.add(FunctionLookup.newFunctionLookup(p + f.getLocalPart(), functionDecl));
}
return lookups;
}
示例15: getRelatedFiles
import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
public PsiFile[] getRelatedFiles(XPathFile file) {
return PsiFile.EMPTY_ARRAY;
}