use of com.intellij.codeInspection.InspectionProfileEntry 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.InspectionProfileEntry in project intellij-community by JetBrains.
the class RefJavaManagerImpl method getDeadCodeTool.
private UnusedDeclarationInspectionBase getDeadCodeTool(PsiFile file) {
Tools tools = ((GlobalInspectionContextBase) myRefManager.getContext()).getTools().get(UnusedDeclarationInspectionBase.SHORT_NAME);
InspectionToolWrapper toolWrapper = tools == null ? null : tools.getEnabledTool(file);
InspectionProfileEntry tool = toolWrapper == null ? null : toolWrapper.getTool();
return tool instanceof UnusedDeclarationInspectionBase ? (UnusedDeclarationInspectionBase) tool : null;
}
use of com.intellij.codeInspection.InspectionProfileEntry in project intellij-community by JetBrains.
the class LightInspectionTestCase method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
for (String environmentClass : getEnvironmentClasses()) {
myFixture.addClass(environmentClass);
}
final InspectionProfileEntry inspection = getInspection();
if (inspection != null) {
myFixture.enableInspections(inspection);
final Project project = myFixture.getProject();
final HighlightDisplayKey displayKey = HighlightDisplayKey.find(inspection.getShortName());
final InspectionProfileImpl currentProfile = ProjectInspectionProfileManager.getInstance(project).getCurrentProfile();
final HighlightDisplayLevel errorLevel = currentProfile.getErrorLevel(displayKey, null);
if (errorLevel == HighlightDisplayLevel.DO_NOT_SHOW) {
currentProfile.setErrorLevel(displayKey, HighlightDisplayLevel.WARNING, project);
}
}
Sdk sdk = ModuleRootManager.getInstance(ModuleManager.getInstance(getProject()).getModules()[0]).getSdk();
if (JAVA_1_7.getSdk().getName().equals(sdk == null ? null : sdk.getName())) {
PsiClass object = JavaPsiFacade.getInstance(getProject()).findClass("java.lang.Object", GlobalSearchScope.allScope(getProject()));
assertNotNull(object);
PsiClass component = JavaPsiFacade.getInstance(getProject()).findClass("java.awt.Component", GlobalSearchScope.allScope(getProject()));
assertNotNull(component);
}
}
use of com.intellij.codeInspection.InspectionProfileEntry in project intellij-community by JetBrains.
the class InspectionProfileImpl method modifyToolSettings.
@Override
public <T extends InspectionProfileEntry> void modifyToolSettings(@NotNull final Key<T> shortNameKey, @NotNull final PsiElement psiElement, @NotNull final Consumer<T> toolConsumer) {
modifyProfile(model -> {
InspectionProfileEntry tool = model.getUnwrappedTool(shortNameKey.toString(), psiElement);
toolConsumer.consume((T) tool);
});
}
use of com.intellij.codeInspection.InspectionProfileEntry in project intellij-community by JetBrains.
the class LightInspectionTestCase method getBasePath.
@Override
protected String getBasePath() {
final InspectionProfileEntry inspection = getInspection();
assertNotNull("File-based tests should either return an inspection or override this method", inspection);
final String className = inspection.getClass().getName();
final String[] words = className.split("\\.");
final StringBuilder basePath = new StringBuilder("/plugins/InspectionGadgets/test/");
final int lastWordIndex = words.length - 1;
for (int i = 0; i < lastWordIndex; i++) {
String word = words[i];
if (word.equals("ig")) {
//noinspection SpellCheckingInspection
word = "igtest";
}
basePath.append(word).append('/');
}
String lastWord = words[lastWordIndex];
lastWord = StringUtil.trimEnd(lastWord, "Inspection");
final int length = lastWord.length();
boolean upperCase = false;
for (int i = 0; i < length; i++) {
final char ch = lastWord.charAt(i);
if (Character.isUpperCase(ch)) {
if (!upperCase) {
upperCase = true;
if (i != 0) {
basePath.append('_');
}
}
basePath.append(Character.toLowerCase(ch));
} else {
upperCase = false;
basePath.append(ch);
}
}
return basePath.toString();
}
Aggregations