use of com.intellij.psi.xml.XmlTag in project intellij-community by JetBrains.
the class HtmlLocalInspectionTool method buildVisitor.
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
return new XmlElementVisitor() {
@Override
public void visitXmlToken(final XmlToken token) {
IElementType tokenType = token.getTokenType();
if (tokenType == XmlTokenType.XML_NAME || tokenType == XmlTokenType.XML_TAG_NAME) {
PsiElement element = token.getPrevSibling();
while (element instanceof PsiWhiteSpace) element = element.getPrevSibling();
if (element instanceof XmlToken && ((XmlToken) element).getTokenType() == XmlTokenType.XML_START_TAG_START) {
PsiElement parent = element.getParent();
if (parent instanceof XmlTag && !(token.getNextSibling() instanceof OuterLanguageElement)) {
XmlTag tag = (XmlTag) parent;
checkTag(tag, holder, isOnTheFly);
}
}
}
}
@Override
public void visitXmlAttribute(final XmlAttribute attribute) {
checkAttribute(attribute, holder, isOnTheFly);
}
};
}
use of com.intellij.psi.xml.XmlTag in project intellij-community by JetBrains.
the class IdRefReference method getIdValue.
@Nullable
protected String getIdValue(final PsiElement element) {
if (element instanceof XmlTag) {
final XmlTag tag = (XmlTag) element;
String s = tag.getAttributeValue(IdReferenceProvider.ID_ATTR_NAME);
if (!myIdAttrsOnly) {
if (s == null)
s = tag.getAttributeValue(IdReferenceProvider.NAME_ATTR_NAME);
if (s == null)
s = tag.getAttributeValue(IdReferenceProvider.STYLE_ID_ATTR_NAME);
}
return s != null ? s : getImplicitIdRefValue(tag);
} else if (element instanceof PsiComment) {
return getImplicitIdValue((PsiComment) element);
}
return null;
}
use of com.intellij.psi.xml.XmlTag in project intellij-community by JetBrains.
the class IdRefReference method getIdValueElement.
@Nullable
protected PsiElement getIdValueElement(PsiElement element) {
if (element instanceof XmlTag) {
final XmlTag tag = (XmlTag) element;
XmlAttribute attribute = tag.getAttribute(IdReferenceProvider.ID_ATTR_NAME, null);
if (!myIdAttrsOnly) {
if (attribute == null) {
attribute = tag.getAttribute(IdReferenceProvider.NAME_ATTR_NAME, null);
}
if (attribute == null) {
attribute = tag.getAttribute(IdReferenceProvider.STYLE_ID_ATTR_NAME, null);
}
}
return attribute != null ? attribute.getValueElement() : getImplicitIdRefValueElement(tag);
} else {
return element;
}
}
use of com.intellij.psi.xml.XmlTag in project intellij-community by JetBrains.
the class CheckEmptyTagInspection method buildVisitor.
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new XmlElementVisitor() {
@Override
public void visitXmlTag(final XmlTag tag) {
if (!isTagWithEmptyEndNotAllowed(tag)) {
return;
}
final ASTNode child = XmlChildRole.EMPTY_TAG_END_FINDER.findChild(tag.getNode());
if (child == null) {
return;
}
final LocalQuickFix fix = new MyLocalQuickFix();
holder.registerProblem(tag, XmlBundle.message("html.inspections.check.empty.script.message"), tag.getContainingFile().getContext() != null ? ProblemHighlightType.INFORMATION : ProblemHighlightType.GENERIC_ERROR_OR_WARNING, fix);
}
};
}
use of com.intellij.psi.xml.XmlTag in project intellij-community by JetBrains.
the class XmlConstraintsTest method configure.
private Map<String, XmlElementDescriptor> configure(String... files) {
myFixture.configureByFiles(files);
XmlTag tag = ((XmlFile) getFile()).getRootTag();
assertNotNull(tag);
XmlElementDescriptor descriptor = tag.getDescriptor();
assertNotNull(descriptor);
XmlElementDescriptor[] descriptors = descriptor.getElementsDescriptors(tag);
Map<String, XmlElementDescriptor> map = ContainerUtil.newMapFromValues(Arrays.asList(descriptors).iterator(), new Convertor<XmlElementDescriptor, String>() {
@Override
public String convert(XmlElementDescriptor o) {
return o.getName();
}
});
map.put(tag.getName(), tag.getDescriptor());
return map;
}
Aggregations