use of org.intellij.lang.xpath.xslt.quickfix.DeleteUnusedParameterFix 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);
}
}
Aggregations