Convenient method for register inspections in tests

This commit is contained in:
Roman Shevchenko
2012-08-20 18:17:43 +04:00
parent 750a96c2c9
commit db0c5fa0b2
2 changed files with 11 additions and 4 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -99,6 +99,8 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
void enableInspections(Class<? extends LocalInspectionTool>... inspections);
void enableInspections(@NotNull Collection<Class<? extends LocalInspectionTool>> inspections);
void disableInspections(InspectionProfileEntry... inspections);
/**
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -252,10 +252,15 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
@Override
public void enableInspections(final Class<? extends LocalInspectionTool>... inspections) {
enableInspections(Arrays.asList(inspections));
}
@Override
public void enableInspections(@NotNull final Collection<Class<? extends LocalInspectionTool>> inspections) {
final ArrayList<LocalInspectionTool> tools = new ArrayList<LocalInspectionTool>();
for (Class clazz : inspections) {
for (Class<? extends LocalInspectionTool> clazz : inspections) {
try {
LocalInspectionTool inspection = (LocalInspectionTool)clazz.getConstructor().newInstance();
LocalInspectionTool inspection = clazz.getConstructor().newInstance();
tools.add(inspection);
}
catch (Exception e) {