use of com.intellij.psi.xml.XmlTagValue in project intellij-community by JetBrains.
the class DomTarget method getTarget.
@Nullable
public static DomTarget getTarget(DomElement element, GenericDomValue nameElement) {
if (nameElement instanceof GenericAttributeValue) {
final GenericAttributeValue genericAttributeValue = (GenericAttributeValue) nameElement;
final XmlAttributeValue attributeValue = genericAttributeValue.getXmlAttributeValue();
if (attributeValue == null) {
return null;
}
final int length = attributeValue.getTextLength();
if (length >= 2) {
return new DomTarget(element, attributeValue, new TextRange(1, length - 1), nameElement);
}
}
final XmlTag tag = nameElement.getXmlTag();
if (tag == null) {
return null;
}
XmlTagValue tagValue = tag.getValue();
if (StringUtil.isEmpty(tagValue.getTrimmedText())) {
return null;
}
return new DomTarget(element, tag, XmlTagUtil.getTrimmedValueRange(tag), nameElement);
}
use of com.intellij.psi.xml.XmlTagValue in project intellij-community by JetBrains.
the class DomHardCoreTestCase method assertReference.
protected PsiReference assertReference(final GenericDomValue value, PsiElement resolveTo) {
final XmlTagValue tagValue = value.getXmlTag().getValue();
final TextRange textRange = tagValue.getTextRange();
final String s = value.getStringValue();
assertNotNull(s);
final int i = tagValue.getText().indexOf(s);
return assertReference(value, resolveTo, textRange.getStartOffset() + i + s.length());
}
use of com.intellij.psi.xml.XmlTagValue in project intellij-community by JetBrains.
the class DomReferencesTest method testPsiPrimitiveTypeArray.
public void testPsiPrimitiveTypeArray() throws Throwable {
final MyElement element = createElement("<a><psi-type>int[]</psi-type></a>");
final GenericDomValue value = element.getPsiType();
final XmlTagValue tagValue = value.getXmlTag().getValue();
final int i = tagValue.getText().indexOf(value.getStringValue());
assertReference(value, value.getXmlTag(), tagValue.getTextRange().getStartOffset() + i + "int".length());
}
use of com.intellij.psi.xml.XmlTagValue in project intellij-community by JetBrains.
the class XmlTagManipulator method getValueRanges.
public static TextRange[] getValueRanges(@NotNull final XmlTag tag) {
final XmlTagValue value = tag.getValue();
final XmlText[] texts = value.getTextElements();
if (texts.length == 0) {
return new TextRange[] { value.getTextRange().shiftRight(-tag.getTextOffset()) };
} else {
final TextRange[] ranges = new TextRange[texts.length];
for (int i = 0; i < texts.length; i++) {
ranges[i] = getValueRange(texts[i]);
}
return ranges;
}
}
use of com.intellij.psi.xml.XmlTagValue in project intellij-community by JetBrains.
the class XmlTagUtil method getTrimmedValueRange.
@NotNull
public static TextRange getTrimmedValueRange(@NotNull final XmlTag tag) {
XmlTagValue tagValue = tag.getValue();
final String text = tagValue.getText();
final String trimmed = text.trim();
final int index = text.indexOf(trimmed);
final int startOffset = tagValue.getTextRange().getStartOffset() - tag.getTextRange().getStartOffset() + index;
return new TextRange(startOffset, startOffset + trimmed.length());
}
Aggregations