use of com.intellij.codeInspection.LocalInspectionTool in project intellij-community by JetBrains.
the class StreamApiMigrationInspectionTest method configureLocalInspectionTools.
@NotNull
@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
StreamApiMigrationInspection inspection = new StreamApiMigrationInspection();
inspection.SUGGEST_FOREACH = true;
return new LocalInspectionTool[] { inspection };
}
use of com.intellij.codeInspection.LocalInspectionTool in project intellij-community by JetBrains.
the class StreamToLoopInspectionTest method configureLocalInspectionTools.
@NotNull
@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
StreamToLoopInspection inspection = new StreamToLoopInspection();
inspection.SUPPORT_UNKNOWN_SOURCES = true;
return new LocalInspectionTool[] { inspection };
}
use of com.intellij.codeInspection.LocalInspectionTool in project intellij-community by JetBrains.
the class DaemonRespondToChangesTest method configureLocalInspectionTools.
@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
if (isStressTest() && !getTestName(false).equals("TypingCurliesClearsEndOfFileErrorsInPhp_ItIsPerformanceTestBecauseItRunsTooLong")) {
// all possible inspections
List<InspectionToolWrapper> all = InspectionToolRegistrar.getInstance().createTools();
List<LocalInspectionTool> locals = new ArrayList<>();
all.stream().filter(tool -> tool instanceof LocalInspectionToolWrapper).forEach(tool -> {
LocalInspectionTool e = ((LocalInspectionToolWrapper) tool).getTool();
locals.add(e);
});
return locals.toArray(new LocalInspectionTool[locals.size()]);
}
return new LocalInspectionTool[] { new FieldCanBeLocalInspection(), new RequiredAttributesInspectionBase(), new CheckDtdReferencesInspection(), new AccessStaticViaInstance() };
}
use of com.intellij.codeInspection.LocalInspectionTool in project intellij-community by JetBrains.
the class DaemonRespondToChangesTest method testLIPGetAllParentsAfterCodeBlockModification.
public void testLIPGetAllParentsAfterCodeBlockModification() throws Throwable {
@Language("JAVA") String text = "class LQF {\n" + " int f;\n" + " public void me() {\n" + " //<caret>\n" + " }\n" + "}";
configureByText(StdFileTypes.JAVA, text);
final List<PsiElement> visitedElements = Collections.synchronizedList(new ArrayList<>());
class MyVisitor extends PsiElementVisitor {
@Override
public void visitElement(PsiElement element) {
visitedElements.add(element);
}
}
final LocalInspectionTool tool = new LocalInspectionTool() {
@Nls
@NotNull
@Override
public String getGroupDisplayName() {
return "fegna";
}
@Nls
@NotNull
@Override
public String getDisplayName() {
return getGroupDisplayName();
}
@NotNull
@Override
public String getShortName() {
return getGroupDisplayName();
}
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
return new MyVisitor();
}
};
disposeOnTearDown(() -> disableInspectionTool(tool.getShortName()));
enableInspectionTool(tool);
List<HighlightInfo> infos = highlightErrors();
assertEmpty(infos);
List<PsiElement> allPsi = CollectHighlightsUtil.getElementsInRange(myFile, 0, myFile.getTextLength());
assertEquals(new HashSet<>(allPsi), new HashSet<>(visitedElements));
// inside code block modification
visitedElements.clear();
backspace();
backspace();
infos = highlightErrors();
assertEmpty(infos);
PsiMethod method = ((PsiJavaFile) myFile).getClasses()[0].getMethods()[0];
List<PsiElement> methodAndParents = CollectHighlightsUtil.getElementsInRange(myFile, method.getTextRange().getStartOffset(), method.getTextRange().getEndOffset(), true);
assertEquals(new HashSet<>(methodAndParents), new HashSet<>(visitedElements));
}
use of com.intellij.codeInspection.LocalInspectionTool in project intellij-community by JetBrains.
the class HighlightSeverityTest method testErrorLikeUnusedSymbol.
public void testErrorLikeUnusedSymbol() throws Exception {
enableInspectionTool(new LocalInspectionTool() {
@NotNull
@Override
public String getShortName() {
return getDisplayName();
}
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly, @NotNull LocalInspectionToolSession session) {
return new JavaElementVisitor() {
@Override
public void visitIdentifier(PsiIdentifier identifier) {
if (identifier.getText().equals("k")) {
holder.registerProblem(identifier, "Variable 'k' is never used");
}
}
};
}
@NotNull
@Override
public HighlightDisplayLevel getDefaultLevel() {
return HighlightDisplayLevel.ERROR;
}
@Nls
@NotNull
@Override
public String getDisplayName() {
return "x";
}
@Nls
@NotNull
@Override
public String getGroupDisplayName() {
return getDisplayName();
}
});
doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false);
}
Aggregations