com.intellij.psi.xml.XmlTag.setAttribute()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中com.intellij.psi.xml.XmlTag.setAttribute()方法的一些代码示例,展示了XmlTag.setAttribute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlTag.setAttribute()方法的具体详情如下:
包路径:com.intellij.psi.xml.XmlTag
类名称:XmlTag
方法名:setAttribute

XmlTag.setAttribute介绍

暂无

代码示例

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@Override
  public void insert(@NotNull String selected) {
    // set type="service" for lazy devs
    if(ContainerUtil.find(argumentTag.getAttributes(), xmlAttribute -> "type".equals(xmlAttribute.getName())) == null) {
      argumentTag.setAttribute("type", "service");
    }
    // append type="SERVICE"
    argumentTag.setAttribute("id", selected);
  }
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

transUnit.setAttribute("id", String.valueOf(getIdForNewXlfUnit(body, "trans-unit")));
transUnit.setAttribute("id", String.valueOf(String.valueOf(getIdForNewXlfUnit(body, "unit"))));

代码示例来源:origin: misakuo/svgtoandroid

private static void copyAttr(XmlTag target, String attrName, Map<String, String> attrs) {
  if (target.getAttribute(attrName) == null && attrs.get(attrName) != null) {
    target.setAttribute(attrName, attrs.get(attrName));
  }
}

代码示例来源:origin: misakuo/svgtoandroid

private void parseGroup(XmlTag svgTag, XmlTag target) {
  XmlTag groupElement = target.createChildTag("group", target.getNamespace(), null, false);
  //set group's attrs
  Map<String, String> svgGroupAttrs = svgParser.getChildAttrs(svgTag);
  List<String> acceptedAttrs = Arrays.asList("id", "transform");
  for (String key : svgGroupAttrs.keySet()) {
    if (AttrMapper.getAttrName(key) != null && acceptedAttrs.contains(key)) {
      groupElement.setAttribute(AttrMapper.getAttrName(key), svgGroupAttrs.get(key));
    }
  }
  if (svgGroupAttrs.keySet().contains("transform")) {
    Map<String, String> trans = AttrMapper.getTranslateAttrs(svgGroupAttrs.get("transform"));
    for (String key : trans.keySet()) {
      groupElement.setAttribute(key, CommonUtil.formatString(trans.get(key)));
    }
  }
  //add child tags
  //<g> was processed.
  processSubGroups(svgTag, groupElement);
  svgGroupAttrs.remove("id");
  svgGroupAttrs.remove("transform");
  parseShapeNode(svgTag, groupElement, svgGroupAttrs);
  target.addSubTag(groupElement, false);
}

代码示例来源:origin: misakuo/svgtoandroid

public static XmlTag mergeAttrs(XmlTag src, Map<String, String> attrs) {
  Logger.debug("MergeAttrs: " + src.getName() + ", " + attrs.toString());
  copyAttr(src, "id", attrs);
  copyAttr(src, "fill", attrs);
  copyAttr(src, "fill-rule", attrs);
  copyAttr(src, "stroke", attrs);
  copyAttr(src, "stroke-width", attrs);
  if (src.getAttribute("transform") != null) {
    if (attrs.get("transform") != null) {
      String translate = attrs.get("transform");
      src.setAttribute("transform", merge(translate, src.getAttribute("transform").getValue()));
    }
  } else {
    if (attrs.get("transform") != null) {
      src.setAttribute("transform", attrs.get("transform"));
    }
  }
  if (attrs.get("transform") != null) {
    Logger.debug("Transform attrs merged:" + src.getAttribute("transform").getValue());
  }
  return src;
}

代码示例来源:origin: misakuo/svgtoandroid

for (XmlAttribute attribute : useTag.getAttributes()) {
    if (!"xlink:href".equalsIgnoreCase(attribute.getName())) {
      clonedTag.setAttribute(attribute.getName(), attribute.getValue());
String idValue = id == null ? null : id.getValue();
if (idValue != null) {
  pathElement.setAttribute("android:name", idValue);
pathElement.setAttribute("android:fillColor", decideFillColor(srcTag, child));
    pathElement.setAttribute(AttrMapper.getAttrName(svgElementAttribute), StdColorUtil.formatColor(myAttrs.get(svgElementAttribute)));
  } else if (AttrMapper.getAttrName(svgElementAttribute) != null) {
    if (AttrMapper.getAttrName(svgElementAttribute).equals("android:fillType")) {
        xmlValue = "evenOdd";
      pathElement.setAttribute("android:fillType", xmlValue);
    } else {
      pathElement.setAttribute(AttrMapper.getAttrName(svgElementAttribute), myAttrs.get(svgElementAttribute));
  pathElement.setAttribute("android:pathData", SVGAttrParser.getPathData(child));

代码示例来源:origin: AlexanderBartash/hybris-integration-intellij-idea-plugin

@Override
  protected void run() throws Throwable {
    final XmlTag hybrisconfig = xmlFile.getRootTag();
    if (hybrisconfig == null) {
      return;
    }
    for (XmlTag extensions : hybrisconfig.getSubTags()) {
      if (!extensions.getName().equals("extensions")) {
        continue;
      }
      for (XmlTag extension : extensions.getSubTags()) {
        if (!extension.getName().equals("extension")) {
          continue;
        }
        if (result.getExtensionsToRemove().contains(extension.getAttributeValue("name"))) {
          extension.delete();
        }
      }
      for (String newExtension : result.getExtensionsToAdd()) {
        final XmlTag newTag = extensions.createChildTag("extension", null, null, false);
        final String name = newExtension.substring(newExtension.lastIndexOf("/") + 1);
        final String dir = "${HYBRIS_BIN_DIR}" + newExtension.substring(newExtension.indexOf("/custom"));
        newTag.setAttribute("dir", dir);
        newTag.setAttribute("name", name);
        extensions.addSubTag(newTag, false);
      }
    }
    FileDocumentManager.getInstance().saveAllDocuments();
  }
}.execute();

代码示例来源:origin: liias/monkey

private static void configureManifest(Manifest manifest, Module module, ManifestData manifestData) {
 requireNonNull(manifestData, "manifestData is null");
 requireNonNull(manifestData.appType, "appType is null");
 requireNonNull(manifestData.minSdkVersion, "minSdkVersion is null");
 requireNonNull(manifestData.targetDeviceId, "targetDeviceId is null");
 final PsiFile manifestFile = getValidatedPsiFile(manifest);
 if (manifestFile == null) {
  return;
 }
 String applicationId = MonkeyModuleUtil.generateProjectId();
 String entryClassName = WordUtils.capitalize(module.getName()) + "App";
 manifest.getApplication().getId().setValue(applicationId);
 manifest.getApplication().getType().setValue(manifestData.appType);
 manifest.getApplication().getName().setValue("@Strings.AppName");
 // entry is a class which extends Toybox.Application.AppBase
 manifest.getApplication().getEntry().setValue(entryClassName);
 manifest.getApplication().getLauncherIcon().setValue("@Drawables.LauncherIcon");
 JpsMonkeySdkType.SdkVersion sdkVersion = JpsMonkeySdkType.SdkVersion
  .fromVersionString(manifestData.sdk.getVersionString());
 if (hasMinSdkVersionSupport(sdkVersion)) {
  manifest.getApplication().getMinSdkVersion().setValue(manifestData.minSdkVersion);
 }
 Products products = manifest.getApplication().getProducts();
 XmlTag productsRootTag = products.getXmlTag();
 XmlTag productTag = productsRootTag.createChildTag("product", productsRootTag.getNamespace(), "", false);
 productTag = productsRootTag.addSubTag(productTag, true);
 productTag.setAttribute("id", null, manifestData.targetDeviceId);
 productTag.collapseIfEmpty();
 CodeStyleManager.getInstance(manifestFile.getProject()).reformat(manifestFile);
}

代码示例来源:origin: misakuo/svgtoandroid

rootTag.setAttribute("android:alpha", svgParser.getAlpha());

相关文章