use of com.intellij.execution.configurations.coverage.JavaCoverageEnabledConfiguration in project intellij-community by JetBrains.
the class CoverageJavaRunConfigurationExtension method updateJavaParameters.
public void updateJavaParameters(RunConfigurationBase configuration, JavaParameters params, RunnerSettings runnerSettings) {
if (!isApplicableFor(configuration)) {
return;
}
final JavaCoverageEnabledConfiguration coverageConfig = JavaCoverageEnabledConfiguration.getFrom(configuration);
//noinspection ConstantConditions
coverageConfig.setCurrentCoverageSuite(null);
final CoverageRunner coverageRunner = coverageConfig.getCoverageRunner();
if (runnerSettings instanceof CoverageRunnerData && coverageRunner != null) {
final CoverageDataManager coverageDataManager = CoverageDataManager.getInstance(configuration.getProject());
coverageConfig.setCurrentCoverageSuite(coverageDataManager.addCoverageSuite(coverageConfig));
coverageConfig.appendCoverageArgument(configuration, params);
final Sdk jdk = params.getJdk();
if (jdk != null && JavaSdk.getInstance().isOfVersionOrHigher(jdk, JavaSdkVersion.JDK_1_7) && coverageRunner instanceof JavaCoverageRunner && !((JavaCoverageRunner) coverageRunner).isJdk7Compatible()) {
Notifications.Bus.notify(new Notification("Coverage", "Coverage instrumentation is not fully compatible with JDK 7", coverageRunner.getPresentableName() + " coverage instrumentation can lead to java.lang.VerifyError errors with JDK 7. If so, please try IDEA coverage runner.", NotificationType.WARNING));
}
}
}
use of com.intellij.execution.configurations.coverage.JavaCoverageEnabledConfiguration in project intellij-community by JetBrains.
the class CoverageJavaRunConfigurationExtension method wrapElementListener.
@Override
public RefactoringElementListener wrapElementListener(PsiElement element, RunConfigurationBase configuration, RefactoringElementListener listener) {
if (!isApplicableFor(configuration)) {
return listener;
}
final JavaCoverageEnabledConfiguration coverageEnabledConfiguration = JavaCoverageEnabledConfiguration.getFrom(configuration);
if (coverageEnabledConfiguration != null) {
final Project project = configuration.getProject();
final ClassFilter[] patterns = coverageEnabledConfiguration.getCoveragePatterns();
final String[] filters = getFilters(coverageEnabledConfiguration);
if (patterns != null) {
assert filters != null;
if (element instanceof PsiClass) {
final String qualifiedName = ((PsiClass) element).getQualifiedName();
final int idx = ArrayUtil.find(filters, qualifiedName);
if (idx > -1) {
final RefactoringListeners.Accessor<PsiClass> accessor = new MyClassAccessor(project, patterns, idx, filters);
final RefactoringElementListener classListener = RefactoringListeners.getClassOrPackageListener(element, accessor);
if (classListener != null) {
listener = appendListener(listener, classListener);
}
} else if (qualifiedName != null) {
final String packageName = StringUtil.getPackageName(qualifiedName);
if (!StringUtil.isEmpty(packageName)) {
for (int i = 0; i < filters.length; i++) {
String filter = filters[i];
if (filter.equals(packageName + ".*")) {
listener = appendListener(listener, new RefactoringListeners.RefactorPackageByClass(new MyClassAccessor(project, patterns, i, filters)));
break;
}
}
}
}
} else if (element instanceof PsiPackage) {
final String qualifiedName = ((PsiPackage) element).getQualifiedName();
for (int i = 0, filtersLength = filters.length; i < filtersLength; i++) {
if (filters[i].startsWith(qualifiedName + ".")) {
final RefactoringElementListener packageListener;
if (filters[i].endsWith("*")) {
packageListener = RefactoringListeners.getListener((PsiPackage) element, new MyPackageAccessor(project, patterns, i, filters));
} else {
packageListener = RefactoringListeners.getClassOrPackageListener(element, new MyClassAccessor(project, patterns, i, filters));
}
if (packageListener != null) {
listener = appendListener(listener, packageListener);
}
}
}
}
}
}
return listener;
}
Aggregations