本文整理汇总了Java中com.intellij.psi.xml.XmlAttributeValue.getTextLength方法的典型用法代码示例。如果您正苦于以下问题:Java XmlAttributeValue.getTextLength方法的具体用法?Java XmlAttributeValue.getTextLength怎么用?Java XmlAttributeValue.getTextLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.xml.XmlAttributeValue
的用法示例。
在下文中一共展示了XmlAttributeValue.getTextLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValue
import com.intellij.psi.xml.XmlAttributeValue; //导入方法依赖的package包/类
@Override
@Nullable
protected String getValue() {
if (myStub != null) {
return myStub.getValue();
}
final XmlAttribute attribute = (XmlAttribute)getXmlElement();
if (attribute != null) {
final XmlAttributeValue value = attribute.getValueElement();
if (value != null && value.getTextLength() >= 2) {
return attribute.getDisplayValue();
}
}
return null;
}
示例2: getTarget
import com.intellij.psi.xml.XmlAttributeValue; //导入方法依赖的package包/类
@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);
}
示例3: buildVisitor
import com.intellij.psi.xml.XmlAttributeValue; //导入方法依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder,
final boolean isOnTheFly,
@NotNull LocalInspectionToolSession session) {
return new XmlElementVisitor() {
@Override
public void visitXmlFile(XmlFile file) {
if (!JavaFxFileTypeFactory.isFxml(file)) return;
super.visitXmlFile(file);
}
@Override
public void visitXmlAttribute(XmlAttribute attribute) {
if (FxmlConstants.FX_ID.equals(attribute.getName())) {
final XmlAttributeValue valueElement = attribute.getValueElement();
if (valueElement != null && valueElement.getTextLength() > 0) {
final PsiClass controllerClass = JavaFxPsiUtil.getControllerClass(attribute.getContainingFile());
if (controllerClass != null) {
final PsiReference reference = valueElement.getReference();
if (reference instanceof JavaFxFieldIdReferenceProvider.JavaFxControllerFieldRef && ((JavaFxFieldIdReferenceProvider.JavaFxControllerFieldRef)reference).isUnresolved()) {
final PsiClass fieldClass =
checkContext(((JavaFxFieldIdReferenceProvider.JavaFxControllerFieldRef)reference).getXmlAttributeValue());
if (fieldClass != null) {
final String text = reference.getCanonicalText();
final NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(fieldClass.getLanguage());
boolean validName = namesValidator != null && namesValidator.isIdentifier(text, fieldClass.getProject());
holder.registerProblem(reference.getElement(), reference.getRangeInElement(), "Unresolved fx:id reference",
isOnTheFly && validName ? new LocalQuickFix[]{new CreateFieldFromUsageQuickFix(text)} : LocalQuickFix.EMPTY_ARRAY);
}
}
}
}
}
}
};
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:JavaFxUnresolvedFxIdReferenceInspection.java