本文整理了Java中com.intellij.psi.xml.XmlTag
类的一些代码示例,展示了XmlTag
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlTag
类的具体详情如下:
包路径:com.intellij.psi.xml.XmlTag
类名称:XmlTag
暂无
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* <route controller="Foo"/>
* <route>
* <default key="_controller">Foo</default>
* </route>
*/
@Nullable
public static String getXmlController(@NotNull XmlTag serviceTag) {
for(XmlTag subTag :serviceTag.getSubTags()) {
if("default".equalsIgnoreCase(subTag.getName())) {
String keyValue = subTag.getAttributeValue("key");
if(keyValue != null && "_controller".equals(keyValue)) {
String actionName = subTag.getValue().getTrimmedText();
if(StringUtils.isNotBlank(actionName)) {
return actionName;
}
}
}
}
String controller = serviceTag.getAttributeValue("controller");
if(controller != null && StringUtils.isNotBlank(controller)) {
return controller;
}
return null;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
String indexAttr = argumentTag.getAttributeValue("index");
if(indexAttr != null) {
try {
String keyAttr = argumentTag.getAttributeValue("key");
if(keyAttr != null && keyAttr.length() > 1 && keyAttr.startsWith("$")) {
PsiElement parentTag = argumentTag.getParent();
if(parentTag instanceof XmlTag) {
String name = ((XmlTag) parentTag).getName();
PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(argumentTag.getProject(), aClass);
if(phpClass != null) {
int parameter = PhpElementsUtil.getConstructorArgumentByName(phpClass, StringUtils.stripStart(keyAttr, "$"));
if(serviceTag instanceof XmlTag && "service".equalsIgnoreCase(((XmlTag) serviceTag).getName())) {
String methodName = ((XmlTag) parentTag).getAttributeValue("method");
if(methodName != null && StringUtils.isNotBlank(methodName)) {
String aClass = XmlHelper.getClassFromServiceDefinition((XmlTag) serviceTag);
if(aClass != null) {
PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(argumentTag.getProject(), aClass);
if(phpClass != null) {
Method methodByName = phpClass.findMethodByName(methodName);
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
String version = rootTag.getAttributeValue("version");
if(version == null) {
return null;
XmlTag file = rootTag.findFirstSubTag("file");
if(file == null) {
return null;
source.getValue().setText(keyName);
target.getValue().setText(translation);
transUnit.setAttribute("id", String.valueOf(getIdForNewXlfUnit(body, "trans-unit")));
transUnit.addSubTag(source, false);
transUnit.addSubTag(target, false);
return body.addSubTag(transUnit, false);
};
XmlTag body = file.findFirstSubTag("body");
if(body != null) {
return func12.apply(body);
source.getValue().setText(keyName);
target.getValue().setText(translation);
transUnit.setAttribute("id", String.valueOf(String.valueOf(getIdForNewXlfUnit(body, "unit"))));
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Override
protected void run() {
XmlTag services = rootTag.findFirstSubTag("services");
XmlElementFactory instance = XmlElementFactory.getInstance(SymfonyCreateService.this.project);
if(services == null) {
services = rootTag.addSubTag(instance.createTagFromText("<services/>", rootTag.getLanguage()), false);
}
XmlTag tag = instance.createTagFromText(createServiceAsText(ServiceBuilder.OutputType.XML).replace("\r\n", "\n").replace("\n", " "), services.getLanguage());
textRange[0] = services.addSubTag(tag, false).getTextRange();
}
}.execute();
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
public static void addServices(List<String> items, XmlTag xmlTag) {
for (String item : items) {
if(StringUtils.isBlank(item)) {
item = "?";
}
XmlTag tag = XmlElementFactory.getInstance(xmlTag.getProject()).createTagFromText(String.format("<argument type=\"service\" id=\"%s\"/>", item), xmlTag.getLanguage());
xmlTag.addSubTag(tag, false);
}
}
代码示例来源: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: misakuo/svgtoandroid
Map<String, XmlTag> defsTags = svgParser.getAcceptedDefNodes();
for (XmlTag useTag : useTags) {
String href = useTag.getAttributeValue("xlink:href");
XmlTag def = defsTags.get(href.replace("#", ""));
if (def != null) {
XmlTag clonedTag = (XmlTag) def.copy();
for (XmlAttribute attribute : useTag.getAttributes()) {
if (!"xlink:href".equalsIgnoreCase(attribute.getName())) {
clonedTag.setAttribute(attribute.getName(), attribute.getValue());
XmlTag pathElement = distTag.createChildTag("path", distTag.getNamespace(), null, false);
Map<String, String> myAttrs = new HashMap<String, String>();
myAttrs.putAll(existedAttrs);
XmlAttribute id = child.getAttribute("class");
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")) {
pathElement.setAttribute("android:fillType", xmlValue);
} else {
pathElement.setAttribute(AttrMapper.getAttrName(svgElementAttribute), myAttrs.get(svgElementAttribute));
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
private void getOdmFields(@NotNull XmlTag xmlTag, @NotNull Collection<DoctrineModelField> fields) {
for (XmlTag tag : xmlTag.getSubTags()) {
String tagName = tag.getName();
if("field".equals(tagName)) {
String name = tag.getAttributeValue("name");
if(StringUtils.isNotBlank(name)) {
DoctrineModelField type = new DoctrineModelField(name, tag.getAttributeValue("type"));
type.setColumn(tag.getAttributeValue("fieldName"));
fields.add(type);
}
} else if(RELATIONS.contains(tagName)) {
String field = tag.getAttributeValue("field");
if(StringUtils.isNotBlank(field)) {
DoctrineModelField type = new DoctrineModelField(field);
type.setRelationType(tagName);
type.setRelation(tag.getAttributeValue("target-document"));
fields.add(type);
}
}
}
}
}
代码示例来源: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: Haehnchen/idea-php-symfony2-plugin
public static Set<String> getTags(XmlTag serviceTag) {
Set<String> tags = new HashSet<>();
for(XmlTag serviceSubTag: serviceTag.getSubTags()) {
if("tag".equals(serviceSubTag.getName())) {
XmlAttribute attribute = serviceSubTag.getAttribute("name");
if(attribute != null) {
String tagName = attribute.getValue();
if(tagName != null && StringUtils.isNotBlank(tagName)) {
tags.add(tagName);
}
}
}
}
return tags;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
if(psiElement instanceof XmlTag && "table".equals(((XmlTag) psiElement).getName()) && "search-results".equals(((XmlTag) psiElement).getAttributeValue("id"))) {
result[0] = (XmlTag) psiElement;
return false;
XmlTag thead = result[0].findFirstSubTag("thead");
if(thead == null) {
return Collections.emptyList();
XmlTag tr1 = thead.findFirstSubTag("tr");
if(tr1 == null) {
return Collections.emptyList();
for (XmlTag th : tr1.findSubTags("th")) {
header.add(StringUtils.trim(stripHtmlTags(th.getValue().getText())).toLowerCase());
XmlTag tbody = result[0].findFirstSubTag("tbody");
if(tbody == null) {
return Collections.emptyList();
for (XmlTag tr : tbody.findSubTags("tr")) {
XmlTag[] findSubTags = tr.findSubTags("td");
if(findSubTags.length < header.size()) {
continue;
row.put(header.get(i), Pair.create(
findSubTags[i],
StringUtils.trim(stripHtmlTags(findSubTags[i].getText().replaceAll("\\n", " "))).replace("\\s+", " ")
));
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@NotNull
public static Collection<XmlTag> getXmlContainerServiceDefinition(PsiFile psiFile) {
Collection<XmlTag> xmlTags = new ArrayList<>();
for(XmlTag xmlTag: PsiTreeUtil.getChildrenOfTypeAsList(psiFile.getFirstChild(), XmlTag.class)) {
if(xmlTag.getName().equals("container")) {
for(XmlTag servicesTag: xmlTag.getSubTags()) {
if(servicesTag.getName().equals("services")) {
for(XmlTag parameterTag: servicesTag.getSubTags()) {
if(parameterTag.getName().equals("service")) {
xmlTags.add(parameterTag);
}
}
}
}
}
}
return xmlTags;
}
代码示例来源: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: Haehnchen/idea-php-symfony2-plugin
if(!(psiElement instanceof XmlTag) || !"th".equals(((XmlTag) psiElement).getName())) {
return true;
XmlTagValue keyTag = ((XmlTag) psiElement).getValue();
String key = StringUtils.trim(keyTag.getText());
if(!ArrayUtils.contains(keys, key)) {
if(tdTag == null || !"td".equals(tdTag.getName())) {
return true;
XmlTagValue valueTag = tdTag.getValue();
String value = valueTag.getText();
if(StringUtils.isBlank(value)) {
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
if(xmlTag.getAttribute(s) != null) {
return false;
String autowire = xmlTag.getAttributeValue("autowire");
if("true".equalsIgnoreCase(autowire)) {
return false;
if(xmlTag.findSubTags("factory").length > 0) {
return false;
PsiElement servicesTag = xmlTag.getParent();
if(servicesTag instanceof XmlTag && "services".equals(((XmlTag) servicesTag).getName())) {
for (XmlTag defaults : ((XmlTag) servicesTag).findSubTags("defaults")) {
if("true".equalsIgnoreCase(defaults.getAttributeValue("autowire"))) {
return false;
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Nullable
public static XmlTag getServiceTagValid(@NotNull PsiElement psiElement) {
XmlTag xmlTag = PsiTreeUtil.getParentOfType(psiElement, XmlTag.class);
if(xmlTag == null) {
return null;
}
if("service".equals(xmlTag.getName())) {
return xmlTag;
}
xmlTag = PsiTreeUtil.getParentOfType(xmlTag, XmlTag.class);
if(xmlTag != null && "service".equals(xmlTag.getName())) {
return xmlTag;
}
return null;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
PsiElement xmlCallTag = xmlArgumentTag.getParent();
if(xmlCallTag instanceof XmlTag) {
String name = ((XmlTag) xmlCallTag).getName();
if (name.equals("call")) {
XmlAttribute methodAttribute = ((XmlTag) xmlCallTag).getAttribute("method");
if(methodAttribute != null) {
String methodName = methodAttribute.getValue();
if(methodName != null) {
XmlTag serviceTag = ((XmlTag) xmlCallTag).getParentTag();
if(serviceTag != null && "service".equals(serviceTag.getName())) {
String className = XmlHelper.getClassFromServiceDefinition(serviceTag);
if(className != null) {
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
if(!(psiElement instanceof XmlTag) || !"h2".equals(((XmlTag) psiElement).getName())) {
return true;
XmlTagValue keyTag = ((XmlTag) psiElement).getValue();
String contents = StringUtils.trim(keyTag.getText());
if(!"Rendered Templates".equalsIgnoreCase(contents)) {
if(tableTag == null || !"table".equals(tableTag.getName())) {
return Collections.emptyMap();
XmlTag tbody = tableTag.findFirstSubTag("tbody");
if(tbody == null) {
return Collections.emptyMap();
if(!"tr".equals(tag.getName())) {
continue;
XmlTag[] tds = tag.findSubTags("td");
if(tds.length < 2) {
continue;
String template = stripHtmlTags(StringUtils.trim(tds[0].getValue().getText()));
if(StringUtils.isBlank(template)) {
continue;
count = Integer.valueOf(stripHtmlTags(StringUtils.trim(tds[1].getValue().getText())));
} catch (NumberFormatException e) {
count = 0;
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Nullable
private Pair<String, Method> findMethodParameterHint(@NotNull XmlTag argumentTag) {
PsiElement serviceTag = argumentTag.getParent();
if("service".equalsIgnoreCase(((XmlTag) serviceTag).getName())) {
String aClass = XmlHelper.getClassFromServiceDefinition((XmlTag) serviceTag);
if(aClass != null && StringUtils.isNotBlank(aClass)) {
return getParamater(argumentTag.getProject(), aClass, aVoid -> XmlHelper.getArgumentIndex(argumentTag));
}
}
return null;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
public static void visitFile(@NotNull XmlFile psiFile, @NotNull Consumer<ServiceConsumer> consumer) {
if(!(psiFile.getFirstChild() instanceof XmlDocument)) {
return;
}
XmlTag xmlTags[] = PsiTreeUtil.getChildrenOfType(psiFile.getFirstChild(), XmlTag.class);
if(xmlTags == null) {
return;
}
for(XmlTag xmlTag: xmlTags) {
if(xmlTag.getName().equals("container")) {
for(XmlTag servicesTag: xmlTag.getSubTags()) {
if("services".equals(servicesTag.getName())) {
// default values:
// <defaults autowire="true" public="false" />
ServiceFileDefaults defaults = createDefaults(servicesTag);
for(XmlTag serviceTag: servicesTag.findSubTags("service")) {
String serviceId = serviceTag.getAttributeValue("id");
if(StringUtils.isBlank(serviceId)) {
continue;
}
consumer.consume(new ServiceConsumer(serviceTag, serviceId, new XmlTagAttributeValue(serviceTag), defaults));
}
}
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!