本文整理汇总了Java中com.intellij.psi.xml.XmlAttributeValue类的典型用法代码示例。如果您正苦于以下问题:Java XmlAttributeValue类的具体用法?Java XmlAttributeValue怎么用?Java XmlAttributeValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XmlAttributeValue类属于com.intellij.psi.xml包,在下文中一共展示了XmlAttributeValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIdentifier
import com.intellij.psi.xml.XmlAttributeValue; //导入依赖的package包/类
@NotNull
@Override
public DictionaryIdentifier getIdentifier() {
DictionaryIdentifier myIdentifier = null;
XmlAttribute nameAttr = myXmlElement.getAttribute("name");
if (nameAttr != null) {
XmlAttributeValue attrValue = nameAttr.getValueElement();
if (attrValue != null) {
myIdentifier = new DictionaryIdentifierImpl(this, getName(), attrValue);
}
} else {
for (XmlAttribute anyAttr : myXmlElement.getAttributes()) {
myIdentifier = new DictionaryIdentifierImpl(this, getName(), anyAttr);
}
}
return myIdentifier != null ? myIdentifier : new DictionaryIdentifierImpl(this, getName(), myXmlElement.getAttributes()[0]);
}
示例2: getResolvedProperty
import com.intellij.psi.xml.XmlAttributeValue; //导入依赖的package包/类
@Nullable
private static IProperty getResolvedProperty(@NotNull final XmlAttributeValue codeValue) {
return CachedValuesManager.getCachedValue(codeValue, KEY, () -> {
List<IProperty> allProperties = new SmartList<>();
for (PsiReference nextRef : codeValue.getReferences()) {
if (nextRef instanceof PsiPolyVariantReference) {
Arrays.stream(((PsiPolyVariantReference) nextRef).multiResolve(false))
.filter(ResolveResult::isValidResult)
.map(ResolveResult::getElement)
.map(o -> ObjectUtils.tryCast(o, IProperty.class))
.filter(Objects::nonNull)
.forEach(allProperties::add);
} else {
Optional.ofNullable(nextRef.resolve())
.map(o -> ObjectUtils.tryCast(o, IProperty.class))
.ifPresent(allProperties::add);
}
}
IProperty theChosenOne = chooseForLocale(allProperties);
return new CachedValueProvider.Result<>(theChosenOne, PsiModificationTracker.MODIFICATION_COUNT);
});
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:24,代码来源:JspPropertyFoldingBuilder.java
示例3: findAlternativeDoms
import com.intellij.psi.xml.XmlAttributeValue; //导入依赖的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
示例4: buildTemplate
import com.intellij.psi.xml.XmlAttributeValue; //导入依赖的package包/类
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();
}
示例5: isReferenceTo
import com.intellij.psi.xml.XmlAttributeValue; //导入依赖的package包/类
public boolean isReferenceTo(PsiElement element) {
if (element == null)
return false;
PsiElement parent = PsiTreeUtil.getParentOfType(element, XmlTag.class);
if (parent != null && parent instanceof XmlTag &&
(MuleConfigConstants.FLOW_TAG_NAME.equals(((XmlTag)parent).getName()) ||
MuleConfigConstants.SUB_FLOW_TAG_NAME.equals(((XmlTag)parent).getName()))) { //It's a <flow> tag or <sub-flow> tag
if (element instanceof XmlAttributeValue && ((XmlAttributeValue)element).getValue().equals(getFlowName())) {
return true;
}
}
return false;
}
示例6: findDeclaration
import com.intellij.psi.xml.XmlAttributeValue; //导入依赖的package包/类
private PsiElement findDeclaration(PsiElement element, String type) {
if (!(element instanceof XmlAttributeValue)) {
return null;
}
JSObjectLiteralExpression exports = WeexFileUtil.getExportsStatement(element);
if (exports == null) {
return null;
} else {
String valueName = CodeUtil.getVarNameFromMustache(((XmlAttributeValue) element).getValue());
if ("function".equals(type)) {
return WeexFileUtil.getFunctionDeclaration(value, valueName);
} else {
return WeexFileUtil.getVarDeclaration(value, valueName);
}
}
}
示例7: inject
import com.intellij.psi.xml.XmlAttributeValue; //导入依赖的package包/类
@NotNull
public PsiReference[] inject(@Nullable String unresolvedText, @NotNull PsiElement element, @NotNull ConvertContext context) {
if (element instanceof XmlAttributeValue) {
final XmlAttributeValue xmlAttributeValue = (XmlAttributeValue)element;
final List<PsiReference> refs = PsiReferenceListSpinAllocator.alloc();
try {
addPropertyReferences(context, xmlAttributeValue, refs);
addMacrodefParameterRefs(xmlAttributeValue, refs);
return refs.size() == 0? PsiReference.EMPTY_ARRAY : ContainerUtil.toArray(refs, new PsiReference[refs.size()]);
}
finally {
PsiReferenceListSpinAllocator.dispose(refs);
}
}
return PsiReference.EMPTY_ARRAY;
}
示例8: extractTextFromElement
import com.intellij.psi.xml.XmlAttributeValue; //导入依赖的package包/类
@Override
public Optional<String> extractTextFromElement(PsiElement element, boolean concatString, boolean stripWhitespace) {
// maybe its xml then try that
if (element instanceof XmlAttributeValue) {
return Optional.ofNullable(((XmlAttributeValue) element).getValue());
} else if (element instanceof XmlText) {
return Optional.ofNullable(((XmlText) element).getValue());
} else if (element instanceof XmlToken) {
// it may be a token which is a part of an combined attribute
if (concatString) {
XmlAttributeValue xml = PsiTreeUtil.getParentOfType(element, XmlAttributeValue.class);
if (xml != null) {
return Optional.ofNullable(getInnerText(xml.getValue()));
}
} else {
String returnText = element.getText();
final PsiElement prevSibling = element.getPrevSibling();
if (prevSibling != null && prevSibling.getText().equalsIgnoreCase("&")) {
returnText = prevSibling.getText() + returnText;
}
return Optional.ofNullable(getInnerText(returnText));
}
}
return Optional.empty();
}
示例9: findIdFields
import com.intellij.psi.xml.XmlAttributeValue; //导入依赖的package包/类
@NotNull
public static PsiField[] findIdFields(@NotNull XmlAttribute attribute) {
final XmlAttributeValue value = attribute.getValueElement();
if (value != null && isIdDeclaration(value)) {
final String id = getResourceNameByReferenceText(attribute.getValue());
if (id != null) {
final AndroidFacet facet = AndroidFacet.getInstance(attribute);
if (facet != null) {
return findResourceFields(facet, ResourceType.ID.getName(), id, false);
}
}
}
return PsiField.EMPTY_ARRAY;
}
示例10: buildVisitor
import com.intellij.psi.xml.XmlAttributeValue; //导入依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder,
boolean isOnTheFly,
@NotNull LocalInspectionToolSession session) {
return new XmlElementVisitor() {
@Override
public void visitXmlTag(XmlTag tag) {
if (tag.getValue().getTextElements().length > 0) {
checkReferences(tag, holder);
}
}
@Override
public void visitXmlAttributeValue(XmlAttributeValue value) {
checkReferences(value, holder);
}
};
}
示例11: computeProblemRange
import com.intellij.psi.xml.XmlAttributeValue; //导入依赖的package包/类
@Override
@NotNull
protected Pair<TextRange, PsiElement> computeProblemRange() {
final PsiReference reference = myReference;
PsiElement element = reference.getElement();
if (element instanceof XmlAttributeValue && element.getTextLength() == 0) return NO_PROBLEM;
final TextRange referenceRange = reference.getRangeInElement();
if (referenceRange.isEmpty()) {
int startOffset = referenceRange.getStartOffset();
return element instanceof XmlAttributeValue
? Pair.create((TextRange)new UnfairTextRange(startOffset - 1, startOffset + 1), element)
: Pair.create(TextRange.from(startOffset, 1), element);
}
return Pair.create(referenceRange, element);
}
示例12: getPsiElement
import com.intellij.psi.xml.XmlAttributeValue; //导入依赖的package包/类
@Nullable
private PsiElement getPsiElement() {
if (myDomElement instanceof DomFileElement) {
return ((DomFileElement)myDomElement).getFile();
}
if (myDomElement instanceof GenericAttributeValue) {
final GenericAttributeValue attributeValue = (GenericAttributeValue)myDomElement;
final XmlAttributeValue value = attributeValue.getXmlAttributeValue();
return value != null && StringUtil.isNotEmpty(value.getText()) ? value : attributeValue.getXmlElement();
}
final XmlTag tag = myDomElement.getXmlTag();
if (myDomElement instanceof GenericValue && tag != null) {
final XmlText[] textElements = tag.getValue().getTextElements();
if (textElements.length > 0) {
return textElements[0];
}
}
return tag;
}
示例13: domKnowsBetter
import com.intellij.psi.xml.XmlAttributeValue; //导入依赖的package包/类
private boolean domKnowsBetter(final CompletionParameters parameters, final CompletionResultSet result) {
final XmlAttributeValue element = PsiTreeUtil.getParentOfType(parameters.getPosition(), XmlAttributeValue.class);
if (element == null) {
return false;
}
if (isSchemaEnumerated(element)) {
return false;
}
final PsiElement parent = element.getParent();
if (parent instanceof XmlAttribute) {
XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor();
if (descriptor != null && descriptor.getDefaultValue() != null) {
final PsiReference[] references = myProvider.getReferencesByElement(element, new ProcessingContext());
if (references.length > 0) {
return LegacyCompletionContributor.completeReference(parameters, result);
}
}
}
return false;
}
示例14: isSchemaEnumerated
import com.intellij.psi.xml.XmlAttributeValue; //导入依赖的package包/类
public static boolean isSchemaEnumerated(final PsiElement element) {
if (element instanceof XmlTag) {
final XmlTag simpleContent = XmlUtil.getSchemaSimpleContent((XmlTag)element);
if (simpleContent != null && XmlUtil.collectEnumerationValues(simpleContent, new HashSet<String>())) {
return true;
}
}
if (element instanceof XmlAttributeValue) {
final PsiElement parent = element.getParent();
if (parent instanceof XmlAttribute) {
final XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor();
if (descriptor != null && descriptor.isEnumerated()) {
return true;
}
String[] enumeratedValues = XmlAttributeValueGetter.getEnumeratedValues((XmlAttribute)parent);
if (enumeratedValues != null && enumeratedValues.length > 0) {
String value = descriptor == null ? null : descriptor.getDefaultValue();
if (value == null || enumeratedValues.length != 1 || !value.equals(enumeratedValues[0])) {
return true;
}
}
}
}
return false;
}
示例15: doFix
import com.intellij.psi.xml.XmlAttributeValue; //导入依赖的package包/类
@Nullable
public SmartPsiElementPointer<XmlTag> doFix(Project project, ProblemDescriptor descriptor, boolean reformat) {
PsiElement element = descriptor.getPsiElement();
if (element instanceof XmlAttributeValue) {
element = element.getParent();
}
else if (!(element instanceof XmlAttribute)) {
return null;
}
XmlAttribute attribute = (XmlAttribute)element;
XmlTag parent = attribute.getParent();
if (!FileModificationService.getInstance().prepareFileForWrite(parent.getContainingFile())) return null;
SmartPsiElementPointer<XmlTag> pointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(parent);
doRemove(project, attribute, parent);
if (reformat) {
reformatStartTag(project, pointer);
}
return pointer;
}