use of com.intellij.codeInspection.ProblemDescriptor in project intellij-community by JetBrains.
the class DomHighlightingLiteTest method testHighlightStatus_OtherInspections2.
public void testHighlightStatus_OtherInspections2() throws Throwable {
myElement.setFileDescription(new DomFileDescription<>(DomElement.class, "a"));
final MyDomElementsInspection inspection = new MyDomElementsInspection() {
@Override
public ProblemDescriptor[] checkFile(@NotNull final PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) {
myAnnotationsManager.appendProblems(myElement, createHolder(), this.getClass());
return ProblemDescriptor.EMPTY_ARRAY;
}
@Override
public void checkFileElement(final DomFileElement fileElement, final DomElementAnnotationHolder holder) {
}
};
registerInspectionKey(inspection);
LocalInspectionToolWrapper toolWrapper = new LocalInspectionToolWrapper(inspection);
myInspectionProfile.setInspectionTools(toolWrapper);
myInspectionProfile.setEnabled(toolWrapper, false);
myAnnotationsManager.appendProblems(myElement, createHolder(), MockAnnotatingDomInspection.class);
assertEquals(DomHighlightStatus.INSPECTIONS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement));
}
use of com.intellij.codeInspection.ProblemDescriptor in project intellij-community by JetBrains.
the class DomHighlightingLiteTest method testHighlightStatus_OtherInspections.
public void testHighlightStatus_OtherInspections() throws Throwable {
myElement.setFileDescription(new DomFileDescription<>(DomElement.class, "a"));
final MyDomElementsInspection inspection = new MyDomElementsInspection() {
@Override
public ProblemDescriptor[] checkFile(@NotNull final PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) {
myAnnotationsManager.appendProblems(myElement, createHolder(), this.getClass());
return ProblemDescriptor.EMPTY_ARRAY;
}
@Override
public void checkFileElement(final DomFileElement fileElement, final DomElementAnnotationHolder holder) {
}
};
registerInspectionKey(inspection);
myInspectionProfile.setInspectionTools(new LocalInspectionToolWrapper(inspection));
myAnnotationsManager.appendProblems(myElement, createHolder(), MockAnnotatingDomInspection.class);
assertEquals(DomHighlightStatus.ANNOTATORS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement));
myAnnotationsManager.appendProblems(myElement, createHolder(), inspection.getClass());
assertEquals(DomHighlightStatus.INSPECTIONS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement));
}
use of com.intellij.codeInspection.ProblemDescriptor in project intellij-community by JetBrains.
the class HardwiredNamespacePrefix method createVisitor.
protected Visitor createVisitor(final InspectionManager manager, final boolean isOnTheFly) {
return new Visitor(manager, isOnTheFly) {
protected void checkExpression(XPathExpression expression) {
if (!(expression instanceof XPathBinaryExpression)) {
return;
}
final XPathBinaryExpression expr = (XPathBinaryExpression) expression;
if (expr.getOperator() == XPathTokenTypes.EQ) {
final XPathExpression lop = expr.getLOperand();
final XPathExpression rop = expr.getROperand();
if (isNameComparison(lop, rop)) {
assert rop != null;
final ProblemDescriptor p = manager.createProblemDescriptor(rop, "Hardwired namespace prefix", isOnTheFly, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
addProblem(p);
} else if (isNameComparison(rop, lop)) {
assert lop != null;
final ProblemDescriptor p = manager.createProblemDescriptor(lop, "Hardwired namespace prefix", isOnTheFly, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
addProblem(p);
} else if (isNameFunctionCall(lop)) {
// TODO
} else if (isNameFunctionCall(rop)) {
// TODO
}
}
}
};
}
use of com.intellij.codeInspection.ProblemDescriptor in project intellij-community by JetBrains.
the class AbstractFix method createQuickFix.
@Nullable
public LocalQuickFix createQuickFix(boolean isOnTheFly) {
final boolean requiresEditor = requiresEditor();
if (requiresEditor && !isOnTheFly)
return null;
return new LocalQuickFix() {
@NotNull
public String getName() {
return AbstractFix.this.getText();
}
@NotNull
public String getFamilyName() {
return AbstractFix.this.getFamilyName();
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
Editor editor;
if (requiresEditor) {
final DataContext dataContext = DataManager.getInstance().getDataContext();
editor = CommonDataKeys.EDITOR.getData(dataContext);
if (editor == null) {
if ((editor = FileEditorManager.getInstance(project).getSelectedTextEditor()) == null) {
return;
}
}
} else {
editor = null;
}
final PsiFile psiFile = descriptor.getPsiElement().getContainingFile();
if (!isAvailable(project, editor, psiFile)) {
return;
}
invoke(project, editor, psiFile);
}
};
}
use of com.intellij.codeInspection.ProblemDescriptor in project intellij-community by JetBrains.
the class BuildoutUnresolvedPartInspection method checkFile.
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
List<ProblemDescriptor> problems = Lists.newArrayList();
if (file.getFileType().equals(BuildoutCfgFileType.INSTANCE)) {
Visitor visitor = new Visitor();
file.accept(visitor);
for (BuildoutPartReference ref : visitor.getUnresolvedParts()) {
ProblemDescriptor d = manager.createProblemDescriptor(ref.getElement(), ref.getRangeInElement(), PyBundle.message("buildout.unresolved.part.inspection.msg"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
problems.add(d);
}
}
return problems.toArray(new ProblemDescriptor[problems.size()]);
}
Aggregations