use of com.intellij.psi.xml.XmlAttribute in project intellij-community by JetBrains.
the class FormReferenceProvider method processButtonGroupReference.
private static void processButtonGroupReference(final XmlTag tag, final PsiReferenceProcessor processor, final PsiPlainTextFile file, final PsiReference classReference) {
final XmlAttribute boundAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_BOUND, null);
final XmlAttribute nameAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_NAME, null);
if (boundAttribute != null && Boolean.parseBoolean(boundAttribute.getValue()) && nameAttribute != null) {
processor.execute(new FieldFormReference(file, classReference, getValueRange(nameAttribute), null, null, false));
}
}
use of com.intellij.psi.xml.XmlAttribute in project intellij-community by JetBrains.
the class MavenPluginConfigurationParameterDomExtender method registerExtensions.
@Override
public void registerExtensions(@NotNull MavenDomConfigurationParameter param, @NotNull DomExtensionsRegistrar r) {
for (XmlAttribute each : param.getXmlTag().getAttributes()) {
String name = each.getName();
if (CompletionUtil.DUMMY_IDENTIFIER_TRIMMED.equals(name))
continue;
r.registerGenericAttributeValueChildExtension(new XmlName(name), String.class);
}
}
use of com.intellij.psi.xml.XmlAttribute in project intellij-community by JetBrains.
the class XsltValidator method checkUnusedVariable.
public static void checkUnusedVariable(XsltVariable variable, ProblemsHolder holder) {
if (variable instanceof XsltParameter) {
if (((XsltParameter) variable).isAbstract()) {
return;
}
} else {
if (variable.isVoid()) {
return;
}
}
final XmlTag tag = variable.getTag();
final XmlTag templateTag = XsltCodeInsightUtil.getTemplateTag(tag, false);
if (templateTag == null) {
return;
}
final XmlAttribute attribute = tag.getAttribute("name");
if (attribute == null) {
return;
}
final PsiElement token = XsltSupport.getAttValueToken(attribute);
if (token == null) {
return;
}
final SearchScope scope = new LocalSearchScope(templateTag);
final Query<PsiReference> refs = ReferencesSearch.search(variable, scope, false);
if (isUnused(variable, refs)) {
final String name = variable.getName();
assert name != null;
final LocalQuickFix[] fixes;
if (variable instanceof XsltParameter) {
fixes = new LocalQuickFix[] { new DeleteUnusedParameterFix(name, (XsltParameter) variable) };
} else {
fixes = new LocalQuickFix[] { new DeleteUnusedVariableFix(name, variable) };
}
holder.registerProblem(token, ((DeleteUnusedElementBase) fixes[0]).getType() + " '" + name + "' is never used", ProblemHighlightType.LIKE_UNUSED_SYMBOL, fixes);
}
}
use of com.intellij.psi.xml.XmlAttribute in project intellij-community by JetBrains.
the class XsltValidator method isUnused.
private static boolean isUnused(PsiElement obj, Query<PsiReference> query) {
if (obj instanceof XsltParameter) {
final Collection<PsiReference> references = query.findAll();
int n = references.size();
for (PsiReference reference : references) {
final PsiElement element = reference.getElement();
if (element instanceof XmlAttributeValue) {
final XmlAttribute parent = (XmlAttribute) element.getParent();
if ("name".equals(parent.getName())) {
final XmlTag tag = parent.getParent();
if (tag != null && "with-param".equals(tag.getLocalName())) {
n--;
}
}
}
}
return n == 0;
} else {
return query.findFirst() == null;
}
}
use of com.intellij.psi.xml.XmlAttribute in project intellij-community by JetBrains.
the class XsltDeclarationInspection method buildVisitor.
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
if (!(holder.getFile() instanceof XmlFile))
return PsiElementVisitor.EMPTY_VISITOR;
return new XmlElementVisitor() {
@Override
public void visitXmlTag(final XmlTag tag) {
final XmlAttribute nameAttr = tag.getAttribute("name", null);
if (nameAttr == null || PsiTreeUtil.hasErrorElements(nameAttr))
return;
if (XsltSupport.isVariableOrParam(tag)) {
final XsltNamedElement instance = getXsltElementFactory().wrapElement(tag, XsltNamedElement.class);
checkDeclaration(instance, nameAttr.getValue(), holder);
} else if (XsltSupport.isTemplate(tag)) {
final XsltTemplate tmpl = getXsltElementFactory().wrapElement(tag, XsltTemplate.class);
checkDeclaration(tmpl, nameAttr.getValue(), holder);
}
}
private void checkDeclaration(final XsltNamedElement element, final String name, ProblemsHolder holder) {
final XmlTag tag = element.getTag();
final PsiElement token = element.getNameIdentifier();
if (name == null || name.length() == 0) {
if (token != null) {
holder.registerProblem(token, "Empty name not permitted");
} else {
final XmlAttribute attribute = element.getNameAttribute();
if (attribute != null) {
final XmlAttributeValue e = attribute.getValueElement();
if (e != null) {
holder.registerProblem(e, "Empty name not permitted");
}
}
}
} else if (!isLegalName(name, holder.getManager().getProject())) {
assert token != null;
holder.registerProblem(token, "Illegal name");
} else {
assert token != null;
final XmlFile file = (XmlFile) tag.getContainingFile();
final XmlTag duplicatedSymbol = DeclarationChecker.getInstance(file).getDuplicatedSymbol(tag);
if (duplicatedSymbol != null) {
if (duplicatedSymbol.getContainingFile() == file) {
holder.registerProblem(token, "Duplicate declaration");
} else {
holder.registerProblem(token, "Duplicates declaration from '" + duplicatedSymbol.getContainingFile().getName() + "'");
}
}
}
}
private boolean isLegalName(String value, Project project) {
return getNamesValidator().isIdentifier(value, project);
}
};
}
Aggregations