当前位置: 首页>>代码示例>>Java>>正文


Java XPathFile类代码示例

本文整理汇总了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");
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:XsltAnnotator.java

示例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);
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:XsltContextProviderBase.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:XsltSupport.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:XPathCharFilter.java

示例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");
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:XsltPatternValidator.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:XsltContextProviderExtensionBase.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:XPathRefactoringSupportProvider.java

示例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);
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:CompletionLists.java

示例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);
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ContextProvider.java

示例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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ContextProvider.java

示例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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ContextProvider.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ContextProviderExtension.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:XsltContextProviderExtensionBase.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:52,代码来源:CompletionLists.java

示例15: getRelatedFiles

import org.intellij.lang.xpath.XPathFile; //导入依赖的package包/类
public PsiFile[] getRelatedFiles(XPathFile file) {
    return PsiFile.EMPTY_ARRAY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:ContextProvider.java


注:本文中的org.intellij.lang.xpath.XPathFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。