use of com.intellij.codeInspection.ex.InspectionToolWrapper in project intellij-community by JetBrains.
the class DumpInspectionDescriptionsAction method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent event) {
final InspectionProfile profile = InspectionProfileManager.getInstance().getCurrentProfile();
final InspectionToolWrapper[] tools = profile.getInspectionTools(null);
final Collection<String> classes = ContainerUtil.newTreeSet();
final Map<String, Collection<String>> groups = ContainerUtil.newTreeMap();
final String tempDirectory = FileUtil.getTempDirectory();
final File descDirectory = new File(tempDirectory, "inspections");
if (!descDirectory.mkdirs() && !descDirectory.isDirectory()) {
LOG.error("Unable to create directory: " + descDirectory.getAbsolutePath());
return;
}
for (InspectionToolWrapper toolWrapper : tools) {
classes.add(getInspectionClass(toolWrapper).getName());
final String group = getGroupName(toolWrapper);
Collection<String> names = groups.get(group);
if (names == null)
groups.put(group, (names = ContainerUtil.newTreeSet()));
names.add(toolWrapper.getShortName());
final URL url = getDescriptionUrl(toolWrapper);
if (url != null) {
doDump(new File(descDirectory, toolWrapper.getShortName() + ".html"), new Processor() {
@Override
public void process(BufferedWriter writer) throws Exception {
writer.write(ResourceUtil.loadText(url));
}
});
}
}
doNotify("Inspection descriptions dumped to\n" + descDirectory.getAbsolutePath());
final File fqnListFile = new File(tempDirectory, "inspection_fqn_list.txt");
final boolean fqnOk = doDump(fqnListFile, new Processor() {
@Override
public void process(BufferedWriter writer) throws Exception {
for (String name : classes) {
writer.write(name);
writer.newLine();
}
}
});
if (fqnOk) {
doNotify("Inspection class names dumped to\n" + fqnListFile.getAbsolutePath());
}
final File groupsFile = new File(tempDirectory, "inspection_groups.txt");
final boolean groupsOk = doDump(groupsFile, new Processor() {
@Override
public void process(BufferedWriter writer) throws Exception {
for (Map.Entry<String, Collection<String>> entry : groups.entrySet()) {
writer.write(entry.getKey());
writer.write(':');
writer.newLine();
for (String name : entry.getValue()) {
writer.write(" ");
writer.write(name);
writer.newLine();
}
}
}
});
if (groupsOk) {
doNotify("Inspection groups dumped to\n" + fqnListFile.getAbsolutePath());
}
}
use of com.intellij.codeInspection.ex.InspectionToolWrapper in project intellij-community by JetBrains.
the class JavaAwareInspectionProfileCoverter method fillErrorLevels.
@Override
protected void fillErrorLevels(InspectionProfileImpl profile) {
super.fillErrorLevels(profile);
//javadoc attributes
InspectionToolWrapper toolWrapper = profile.getInspectionTool(JavaDocLocalInspectionBase.SHORT_NAME, (PsiElement) null);
JavaDocLocalInspectionBase inspection = (JavaDocLocalInspectionBase) toolWrapper.getTool();
inspection.myAdditionalJavadocTags = myAdditionalJavadocTags;
}
use of com.intellij.codeInspection.ex.InspectionToolWrapper in project intellij-community by JetBrains.
the class HTMLExportFrameMaker method done.
@SuppressWarnings({ "HardCodedStringLiteral" })
public void done() {
StringBuffer buf = new StringBuffer();
if (myInspectionToolWrappers.isEmpty()) {
buf.append("Everything is fine. Nothing is ruined.");
} else {
for (InspectionToolWrapper toolWrapper : myInspectionToolWrappers) {
buf.append("<A HREF=\"");
buf.append(toolWrapper.getFolderName());
buf.append("-index.html\">");
buf.append(toolWrapper.getDisplayName());
buf.append("</A><BR>");
}
}
HTMLExportUtil.writeFile(myRootFolder, "index.html", buf, myProject);
}
use of com.intellij.codeInspection.ex.InspectionToolWrapper in project intellij-community by JetBrains.
the class RemoveRedundantUncheckedSuppressionTest method configureLocalInspectionTools.
@NotNull
@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
final PossibleHeapPollutionVarargsInspection varargsInspection = new PossibleHeapPollutionVarargsInspection();
final UncheckedWarningLocalInspection warningLocalInspection = new UncheckedWarningLocalInspection();
final RedundantSuppressInspection inspection = new RedundantSuppressInspection() {
@NotNull
@Override
protected InspectionToolWrapper[] getInspectionTools(PsiElement psiElement, @NotNull InspectionManager manager) {
return new InspectionToolWrapper[] { new LocalInspectionToolWrapper(varargsInspection), new LocalInspectionToolWrapper(warningLocalInspection) };
}
};
return new LocalInspectionTool[] { new LocalInspectionTool() {
@Nls
@NotNull
@Override
public String getGroupDisplayName() {
return inspection.getGroupDisplayName();
}
@Nls
@NotNull
@Override
public String getDisplayName() {
return inspection.getDisplayName();
}
@NotNull
@Override
public String getShortName() {
return inspection.getShortName();
}
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly, @NotNull LocalInspectionToolSession session) {
return new JavaElementVisitor() {
@Override
public void visitClass(PsiClass aClass) {
checkMember(aClass, inspection, holder);
}
@Override
public void visitMethod(PsiMethod method) {
checkMember(method, inspection, holder);
}
};
}
private void checkMember(PsiMember member, RedundantSuppressInspection inspection, ProblemsHolder holder) {
final ProblemDescriptor[] problemDescriptors = inspection.checkElement(member, InspectionManager.getInstance(getProject()));
if (problemDescriptors != null) {
for (ProblemDescriptor problemDescriptor : problemDescriptors) {
holder.registerProblem(problemDescriptor);
}
}
}
}, varargsInspection, warningLocalInspection };
}
use of com.intellij.codeInspection.ex.InspectionToolWrapper 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() };
}
Aggregations