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


Java XmlTag.addAfter方法代码示例

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


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

示例1: addEmptyTag

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
private XmlTag addEmptyTag(final EvaluatedXmlName tagName, int index) throws IncorrectOperationException {
  final XmlTag tag = ensureTagExists();
  final List<XmlTag> subTags = DomImplUtil.findSubTags(tag, tagName, getFile());
  if (subTags.size() < index) {
    index = subTags.size();
  }
  final boolean changing = myManager.setChanging(true);
  try {
    XmlTag newTag = createChildTag(tagName);
    if (index == 0) {
      if (subTags.isEmpty()) {
        return (XmlTag)tag.add(newTag);
      }

      return (XmlTag)tag.addBefore(newTag, subTags.get(0));
    }

    return (XmlTag)tag.addAfter(newTag, subTags.get(index - 1));
  }
  finally {
    myManager.setChanging(changing);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:DomInvocationHandler.java

示例2: applyFix

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
  PsiFile file = descriptor.getPsiElement().getContainingFile();
  DomFileElement<IdeaPlugin> fileElement = DomManager.getDomManager(project).getFileElement((XmlFile)file, IdeaPlugin.class);
  if (fileElement != null) {
    IdeaPlugin root = fileElement.getRootElement();
    XmlTag after = getLastSubTag(root, root.getId(), ContainerUtil.getLastItem(root.getDescriptions()), ContainerUtil.getLastItem(root.getVersions()), root.getName());
    XmlTag rootTag = root.getXmlTag();
    XmlTag vendorTag = rootTag.createChildTag("vendor", rootTag.getNamespace(), PluginManagerMain.JETBRAINS_VENDOR, false);
    if (after == null) {
      rootTag.addSubTag(vendorTag, true);
    }
    else {
      rootTag.addAfter(vendorTag, after);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PluginXmlDomInspection.java

示例3: addPropertyAfter

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@NotNull
public IProperty addPropertyAfter(String key, String value, @Nullable IProperty anchor, boolean addToEnd) {
  final XmlTag anchorTag = anchor == null ? null : (XmlTag)anchor.getPsiElement().getNavigationElement();
  final XmlTag rootTag = myFile.getRootTag();
  final XmlTag entry = createPropertyTag(key, value);
  final XmlTag addedEntry = (XmlTag) (anchorTag == null ? myFile.getRootTag().addSubTag(entry, !addToEnd) : rootTag.addAfter(entry, anchorTag));
  final XmlProperty property = new XmlProperty(addedEntry, this);
  return property;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:XmlPropertiesFileImpl.java

示例4: annotateExternally

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
private void annotateExternally(@NotNull final PsiModifierListOwner listOwner,
                                @NotNull final String annotationFQName,
                                @Nullable final XmlFile xmlFile,
                                @NotNull final PsiFile codeUsageFile,
                                @Nullable final PsiNameValuePair[] values) {
  if (xmlFile == null) {
    notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
    return;
  }
  try {
    final XmlDocument document = xmlFile.getDocument();
    if (document != null) {
      final XmlTag rootTag = document.getRootTag();
      final String externalName = getExternalName(listOwner, false);
      if (externalName == null) {
        LOG.info("member without external name: " + listOwner);
      }
      if (rootTag != null && externalName != null) {
        XmlTag anchor = null;
        for (XmlTag item : rootTag.getSubTags()) {
          int compare = Comparing.compare(externalName, StringUtil.unescapeXml(item.getAttributeValue("name")));
          if (compare == 0) {
            anchor = null;
            for (XmlTag annotation : item.getSubTags()) {
              compare = Comparing.compare(annotationFQName, annotation.getAttributeValue("name"));
              if (compare == 0) {
                annotation.delete();
                break;
              }
              anchor = annotation;
            }
            XmlTag newTag = XmlElementFactory.getInstance(myPsiManager.getProject()).createTagFromText(
              createAnnotationTag(annotationFQName, values));
            item.addAfter(newTag, anchor);
            commitChanges(xmlFile);
            notifyAfterAnnotationChanging(listOwner, annotationFQName, true);
            return;
          }
          if (compare < 0) break;
          anchor = item;
        }
        @NonNls String text =
          "<item name=\'" + StringUtil.escapeXml(externalName) + "\'>\n";
        text += createAnnotationTag(annotationFQName, values);
        text += "</item>";
        rootTag.addAfter(XmlElementFactory.getInstance(myPsiManager.getProject()).createTagFromText(text), anchor);
        commitChanges(xmlFile);
        notifyAfterAnnotationChanging(listOwner, annotationFQName, true);
        return;
      }
    }
    notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
  }
  catch (IncorrectOperationException e) {
    LOG.error(e);
    notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
  }
  finally {
    dropCache();
    if (codeUsageFile.getVirtualFile().isInLocalFileSystem()) {
      UndoUtil.markPsiFileForUndo(codeUsageFile);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:65,代码来源:ExternalAnnotationsManagerImpl.java

示例5: testAdd4

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
public void testAdd4() {
  final XmlTag tag = myElement.getXmlTag();
  tag.addAfter(createTag("<child-element/>"), tag.getSubTags()[3]);
  putExpected(new DomEvent(myElement, false));
  assertResultsAndClear();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:IncrementalUpdateEventsTest.java


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