use of com.intellij.codeInspection.InspectionEP in project kotlin by JetBrains.
the class AbstractQuickFixMultiFileTest method enableInspectionTools.
private void enableInspectionTools(@NotNull Class<?> klass) {
List<InspectionEP> eps = ContainerUtil.newArrayList();
ContainerUtil.addAll(eps, Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION));
ContainerUtil.addAll(eps, Extensions.getExtensions(InspectionEP.GLOBAL_INSPECTION));
InspectionProfileEntry tool = null;
for (InspectionEP ep : eps) {
if (klass.getName().equals(ep.implementationClass)) {
tool = ep.instantiateTool();
}
}
assert tool != null : "Could not find inspection tool for class: " + klass;
enableInspectionTools(tool);
}
use of com.intellij.codeInspection.InspectionEP in project intellij-community by JetBrains.
the class InspectionProfileImpl method addTool.
public void addTool(@Nullable Project project, @NotNull InspectionToolWrapper toolWrapper, @NotNull Map<String, List<String>> dependencies) {
final String shortName = toolWrapper.getShortName();
HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
if (key == null) {
final InspectionEP extension = toolWrapper.getExtension();
Computable<String> computable = extension == null ? new Computable.PredefinedValueComputable<>(toolWrapper.getDisplayName()) : extension::getDisplayName;
if (toolWrapper instanceof LocalInspectionToolWrapper) {
key = HighlightDisplayKey.register(shortName, computable, toolWrapper.getID(), ((LocalInspectionToolWrapper) toolWrapper).getAlternativeID());
} else {
key = HighlightDisplayKey.register(shortName, computable);
}
}
if (key == null) {
LOG.error(shortName + " ; number of initialized tools: " + myTools.size());
return;
}
HighlightDisplayLevel baseLevel = myBaseProfile != null && myBaseProfile.getToolsOrNull(shortName, project) != null ? myBaseProfile.getErrorLevel(key, project) : HighlightDisplayLevel.DO_NOT_SHOW;
HighlightDisplayLevel defaultLevel = toolWrapper.getDefaultLevel();
HighlightDisplayLevel level = baseLevel.getSeverity().compareTo(defaultLevel.getSeverity()) > 0 ? baseLevel : defaultLevel;
boolean enabled = myBaseProfile != null ? myBaseProfile.isToolEnabled(key) : toolWrapper.isEnabledByDefault();
final ToolsImpl toolsList = new ToolsImpl(toolWrapper, level, !myLockedProfile && enabled, enabled);
final Element element = myUninitializedSettings.remove(shortName);
try {
if (element != null) {
getPathMacroManager().expandPaths(element);
toolsList.readExternal(element, getProfileManager(), dependencies);
} else if (!myUninitializedSettings.containsKey(InspectionElementsMergerBase.getMergedMarkerName(shortName))) {
final InspectionElementsMergerBase merger = getMerger(shortName);
Element merged = merger == null ? null : merger.merge(myUninitializedSettings);
if (merged != null) {
getPathMacroManager().expandPaths(merged);
toolsList.readExternal(merged, getProfileManager(), dependencies);
} else if (isProfileLocked()) {
// https://youtrack.jetbrains.com/issue/IDEA-158936
toolsList.setEnabled(false);
if (toolsList.getNonDefaultTools() == null) {
toolsList.getDefaultState().setEnabled(false);
}
}
}
} catch (InvalidDataException e) {
LOG.error("Can't read settings for " + toolWrapper, e);
}
myTools.put(shortName, toolsList);
}
use of com.intellij.codeInspection.InspectionEP in project intellij-community by JetBrains.
the class InspectionTestCase method getUnusedDeclarationWrapper.
protected static GlobalInspectionToolWrapper getUnusedDeclarationWrapper() {
InspectionEP ep = new InspectionEP();
ep.presentation = UnusedDeclarationPresentation.class.getName();
ep.implementationClass = UnusedDeclarationInspection.class.getName();
ep.shortName = UnusedDeclarationInspectionBase.SHORT_NAME;
ep.displayName = UnusedDeclarationInspectionBase.DISPLAY_NAME;
return new GlobalInspectionToolWrapper(ep);
}
use of com.intellij.codeInspection.InspectionEP in project android by JetBrains.
the class AndroidInspectionsTest method getUnusedDeclarationWrapper.
private static GlobalInspectionToolWrapper getUnusedDeclarationWrapper() {
final InspectionEP ep = new InspectionEP();
ep.presentation = UnusedDeclarationPresentation.class.getName();
ep.implementationClass = UnusedDeclarationInspection.class.getName();
ep.shortName = UnusedDeclarationInspectionBase.SHORT_NAME;
UnusedDeclarationInspection tool = new UnusedDeclarationInspection(true);
return new GlobalInspectionToolWrapper(tool, ep);
}
Aggregations