Java Code Examples for com.intellij.psi.xml.XmlAttribute#getValueElement()
The following examples show how to use
com.intellij.psi.xml.XmlAttribute#getValueElement() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FluidTypeResolver.java From idea-php-typo3-plugin with MIT License | 6 votes |
/** * Get the "for IN" variable identifier as separated string * <p> * {% for car in "cars" %} * {% for car in "cars"|length %} * {% for car in "cars.test" %} */ @NotNull public static Collection<String> getForTagIdentifierAsString(XmlTag forTag) { XmlAttribute each = forTag.getAttribute("each"); if (each == null || each.getValueElement() == null) { return ContainerUtil.emptyList(); } PsiElement fluidElement = FluidUtil.retrieveFluidElementAtPosition(each.getValueElement()); if (fluidElement == null) { return Collections.emptyList(); } PsiElement deepestFirst = PsiTreeUtil.getDeepestFirst(fluidElement); return FluidTypeResolver.formatPsiTypeName(deepestFirst); }
Example 2
Source File: FlowInPlaceRenamer.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
private static Template buildTemplate(@NotNull XmlAttribute attr, List<XmlTag> refs) { //XmlFile containingFile = (XmlFile)attr.getContainingFile(); PsiElement commonParent = PsiTreeUtil.findCommonParent(refs); TemplateBuilderImpl builder = new TemplateBuilderImpl(attr); XmlAttributeValue attrValue = attr.getValueElement(); PsiElement valuePsi = attrValue.getFirstChild().getNextSibling(); String flowNameValue = new String(attrValue.getValue()); builder.replaceElement(valuePsi,"PrimaryVariable", new TextExpression(flowNameValue), true); /* for (XmlTag ref : refs) { if (ref.getContainingFile().equals(attr.getContainingFile())) { XmlAttribute nextAttr = ref.getAttribute(MuleConfigConstants.NAME_ATTRIBUTE); XmlAttributeValue nextValue = nextAttr.getValueElement(); PsiElement nextValuePsi = nextValue.getFirstChild().getNextSibling(); builder.replaceElement(nextValuePsi, "OtherVariable", "PrimaryVariable",false); } } */ return builder.buildInlineTemplate(); }
Example 3
Source File: InTemplateDeclarationVariableProvider.java From idea-php-typo3-plugin with MIT License | 5 votes |
@Override public void visitXmlTag(XmlTag tag) { if (tag.getName().equals("f:alias")) { XmlAttribute map = tag.getAttribute("map"); if (map != null) { XmlAttributeValue valueElement = map.getValueElement(); if (valueElement != null) { TextRange valueTextRange = valueElement.getValueTextRange(); PsiElement fluidElement = extractLanguagePsiElementForElementAtPosition(FluidLanguage.INSTANCE, tag, valueTextRange.getStartOffset() + 1); FluidArrayCreationExpr fluidArray = (FluidArrayCreationExpr) PsiTreeUtil.findFirstParent(fluidElement, x -> x instanceof FluidArrayCreationExpr); if (fluidArray != null) { fluidArray.getArrayKeyList().forEach(fluidArrayKey -> { if (fluidArrayKey.getFirstChild() instanceof FluidStringLiteral) { String key = ((FluidStringLiteral) fluidArrayKey.getFirstChild()).getContents(); variables.put(key, new FluidVariable(key)); return; } variables.put(fluidArrayKey.getText(), new FluidVariable(fluidArrayKey.getText())); }); } } } } super.visitXmlTag(tag); }
Example 4
Source File: StringLiteralPsiReference.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@Nullable @Override public PsiElement resolve() { final String flowName = getFlowName(); final XmlTag flow = MuleConfigUtils.findFlow(myElement.getProject(), flowName); if (flow != null) { final XmlAttribute name = flow.getAttribute(MuleConfigConstants.NAME_ATTRIBUTE); return name != null ? name.getValueElement() : null; } return null; }
Example 5
Source File: FlowRefPsiReference.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@Nullable @Override public PsiElement resolve() { final String flowName = getFlowName(); final XmlTag flow = MuleConfigUtils.findFlow(myElement, flowName); if (flow != null) { final XmlAttribute name = flow.getAttribute(MuleConfigConstants.NAME_ATTRIBUTE); return name != null ? name.getValueElement() : null; } return null; }
Example 6
Source File: ConfigRefPsiReference.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@Nullable @Override public PsiElement resolve() { final String elementName = getElementName(); final XmlTag globalElement = MuleConfigUtils.findGlobalElement(myElement, elementName); if (globalElement != null) { final XmlAttribute name = globalElement.getAttribute(MuleConfigConstants.NAME_ATTRIBUTE); return name != null ? name.getValueElement() : null; } return null; }
Example 7
Source File: MuleSchemaUtils.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@Nullable public static PsiReference getSchemaReference(XmlAttribute base) { if (base != null && base.getValueElement() != null) { final String text = base.getValue(); if (text != null && text.indexOf(":") > 0) { final String prefix = text.substring(0, text.indexOf(":")); return SchemaReferencesProvider.createTypeOrElementOrAttributeReference(base.getValueElement(), prefix); } else { return SchemaReferencesProvider.createTypeOrElementOrAttributeReference(base.getValueElement()); } } return null; }
Example 8
Source File: BlueprintAttributeValueReferenceProvider.java From camel-idea-plugin with Apache License 2.0 | 5 votes |
@Override protected PsiReference[] getCamelReferencesByElement(PsiElement element, ProcessingContext context) { if (element instanceof XmlAttributeValue) { XmlAttribute attribute = PsiTreeUtil.getParentOfType(element, XmlAttribute.class); if (attribute != null) { XmlTag tag = attribute.getParent(); XmlAttributeValue value = attribute.getValueElement(); if (tag != null && value != null && BeanUtils.getService().isPartOfBeanContainer(tag)) { return getAttributeReferences(attribute, value, context); } } } return PsiReference.EMPTY_ARRAY; }