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


Java XmlElement.getContainingFile方法代码示例

本文整理汇总了Java中com.intellij.psi.xml.XmlElement.getContainingFile方法的典型用法代码示例。如果您正苦于以下问题:Java XmlElement.getContainingFile方法的具体用法?Java XmlElement.getContainingFile怎么用?Java XmlElement.getContainingFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.xml.XmlElement的用法示例。


在下文中一共展示了XmlElement.getContainingFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findAlternativeDoms

import com.intellij.psi.xml.XmlElement; //导入方法依赖的package包/类
private static Collection<XmlAttributeValue> findAlternativeDoms(@NotNull final ItemType source) {
    final String code = source.getCode().getStringValue();

    if (StringUtil.isEmpty(code)) {
        return Collections.emptyList();
    }
    final XmlElement element = source.getXmlElement();
    final PsiFile psiFile = element == null ? null : element.getContainingFile();

    if (psiFile == null) {
        return Collections.emptyList();
    }
    final TSMetaModel externalModel = TSMetaModelAccess.getInstance(psiFile.getProject()).
        getExternalTypeSystemMeta(psiFile);

    return Optional.ofNullable(externalModel.findMetaClassForDom(source))
                   .map(TSMetaClass::retrieveAllDomsStream)
                   .orElse(Stream.empty())
                   .filter(dom -> !dom.equals(source))
                   .map(ItemType::getCode)
                   .map(GenericAttributeValue::getXmlAttributeValue)
                   .collect(Collectors.toList());
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:24,代码来源:TypeSystemGutterAnnotator.java

示例2: getExtendingMetaClassNamesStream

import com.intellij.psi.xml.XmlElement; //导入方法依赖的package包/类
@NotNull
private static Stream<TSMetaClass> getExtendingMetaClassNamesStream(@NotNull final ItemType source) {
    final String code = source.getCode().getStringValue();

    if (StringUtil.isEmpty(code)) {
        return Stream.empty();
    }
    final XmlElement xmlElement = source.getXmlElement();
    final PsiFile psiFile = xmlElement == null ? null : xmlElement.getContainingFile();

    if (psiFile == null) {
        return Stream.empty();
    }
    final TSMetaModel metaModel = TSMetaModelAccess.getInstance(psiFile.getProject()).getTypeSystemMeta(psiFile);
    final TSMetaClass sourceMeta = metaModel.findMetaClassForDom(source);

    if (sourceMeta == null) {
        return Stream.empty();
    }
    return metaModel
        .getMetaClassesStream()
        .map(TSMetaClass.class::cast)
        .filter(meta -> sourceMeta.getName().equals(meta.getExtendedMetaClassName()));
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:25,代码来源:TypeSystemGutterAnnotator.java

示例3: getContextAntProject

import com.intellij.psi.xml.XmlElement; //导入方法依赖的package包/类
public final AntDomProject getContextAntProject() {
  final AntConfigurationBase antConfig = AntConfigurationBase.getInstance(getManager().getProject());
  final XmlElement xmlElement = getXmlElement();
  if (xmlElement == null) {
    return getAntProject();
  }
  PsiFile containingFile = xmlElement.getContainingFile();
  if (containingFile != null) {
    containingFile = containingFile.getOriginalFile();
  }
  if (!(containingFile instanceof XmlFile)) {
    return getAntProject();
  }
  final XmlFile contextFile = antConfig.getEffectiveContextFile(((XmlFile)containingFile));
  if (contextFile == null) {
    return getAntProject();
  }
  return AntSupport.getAntDomProject(contextFile);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AntDomElement.java

示例4: highlightResult

import com.intellij.psi.xml.XmlElement; //导入方法依赖的package包/类
/**
 * <p>Process the result of an XPath query.</p>
 * <p>If the result is a <code>java.util.List</code> object, iterate over all elements and
 * add a highlighter object in the editor if the element is of type <code>PsiElement</code>.
 * <p>If the result is a primitive value (String, Number, Boolean) a message box displaying
 * the value will be displayed. </p>
 *
 * @param editor The editor object to apply the highlighting to
 */
private void highlightResult(XmlElement contextNode, @NotNull final Editor editor, final List<?> list) {

    final Config cfg = myComponent.getConfig();
    int lowestOffset = Integer.MAX_VALUE;

    for (final Object o : list) {
        LOG.assertTrue(o != null, "null element?");

        if (o instanceof PsiElement) {
            final PsiElement element = (PsiElement)o;

            if (element.getContainingFile() == contextNode.getContainingFile()) {
                lowestOffset = highlightElement(editor, element, cfg, lowestOffset);
            }
        } else {
            LOG.info("Don't know what to do with " + o + " in a list context");
        }
        LOG.debug("o = " + o);
    }

    if (cfg.isScrollToFirst() && lowestOffset != Integer.MAX_VALUE) {
        editor.getScrollingModel().scrollTo(editor.offsetToLogicalPosition(lowestOffset), ScrollType.MAKE_VISIBLE);
        editor.getCaretModel().moveToOffset(lowestOffset);
    }

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            final StatusBar statusBar = WindowManager.getInstance().getStatusBar(editor.getProject());
            final String s = StringUtil.pluralize("match", list.size());
            statusBar.setInfo(list.size() + " XPath " + s + " found (press Escape to remove the highlighting)");
        }
    });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:XPathEvalAction.java

示例5: checkReferences

import com.intellij.psi.xml.XmlElement; //导入方法依赖的package包/类
private static void checkReferences(final XmlElement xmlElement, final @NonNls DomElementAnnotationHolder holder, DomElement domElement) {
  if (xmlElement == null) {
    return;
  }
  Set<PsiReference> processed = null;
  Collection<PropertiesFile> propertyFiles = null; // to be initialized lazily
  for (final PsiReference ref : xmlElement.getReferences()) {
    if (!(ref instanceof AntDomReference)) {
      continue;
    }
    final AntDomReference antDomRef = (AntDomReference)ref;
    if (antDomRef.shouldBeSkippedByAnnotator()) {
      continue;
    }
    if (processed != null && processed.contains(ref)) {
      continue;
    }

    if (!isResolvable(ref)) {
      final List<LocalQuickFix> quickFixList = new SmartList<LocalQuickFix>();
      quickFixList.add(new AntChangeContextLocalFix());

      if (ref instanceof AntDomPropertyReference) {
        final String canonicalText = ref.getCanonicalText();
        quickFixList.add(new AntCreatePropertyFix(canonicalText, null));
        final PsiFile containingFile = xmlElement.getContainingFile();
        if (containingFile != null) {
          if (propertyFiles == null) {
            propertyFiles = getPropertyFiles(AntSupport.getAntDomProject(containingFile), xmlElement);
          }
          for (PropertiesFile propertyFile : propertyFiles) {
            quickFixList.add(new AntCreatePropertyFix(canonicalText, propertyFile));
          }
        }
      }
      else if (ref instanceof AntDomTargetReference) {
        quickFixList.add(new AntCreateTargetFix(ref.getCanonicalText()));
      }

      holder.createProblem(
        domElement,
        ProblemHighlightType.LIKE_UNKNOWN_SYMBOL,
        antDomRef.getUnresolvedMessagePattern(),
        ref.getRangeInElement(),
        quickFixList.toArray((new LocalQuickFix[quickFixList.size()]))
      );

      if (ref instanceof AntDomFileReference) {
        if (processed == null) {
          processed = new HashSet<PsiReference>();
        }
        ContainerUtil.addAll(processed, ((AntDomFileReference)ref).getFileReferenceSet().getAllReferences());
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:57,代码来源:AntResolveInspection.java


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