use of ool.intellij.plugin.editor.inspection.fix.DeleteElementQuickFix in project oxy-template-support-plugin by mutant-industries.
the class RedundantIncludeInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new OxyTemplateElementVisitor() {
@Override
public void visitDirectiveParamFileReference(@NotNull DirectiveParamFileReference fileReference) {
final DirectiveStatement directiveStatement = PsiTreeUtil.getParentOfType(fileReference, DirectiveStatement.class);
assert directiveStatement != null;
if (!IncludeOnceDirective.NAME.equals(directiveStatement.getName()) || IncludeOptimizer.ignore(directiveStatement)) {
return;
}
PsiReference[] references = fileReference.getReferences();
PsiFile referencedFile = null;
for (PsiReference reference : references) {
if (reference instanceof FileReference && reference.resolve() instanceof PsiFile) {
referencedFile = (PsiFile) reference.resolve();
break;
}
}
if (referencedFile == null) {
return;
}
if (!directiveStatement.getContainingFile().getVirtualFile().getPath().equals(referencedFile.getVirtualFile().getPath())) {
for (Map.Entry<PsiElement, JSElement> entry : OxyTemplateHelper.getUsedJsMacros(fileReference.getContainingFile()).entrySet()) {
if (entry.getValue().getContainingFile().getVirtualFile().getPath().equals(referencedFile.getVirtualFile().getPath())) {
return;
}
}
}
holder.registerProblem(directiveStatement, getDisplayName(), ProblemHighlightType.LIKE_UNUSED_SYMBOL, new DeleteElementQuickFix());
}
};
}
Aggregations