use of org.infernus.idea.checkstyle.model.ScanScope in project checkstyle-idea by jshiell.
the class CheckStyleConfigPanel method getPluginConfiguration.
public PluginConfiguration getPluginConfiguration() {
final String checkstyleVersion = (String) csVersionDropdown.getSelectedItem();
ScanScope scanScope = (ScanScope) scopeDropdown.getSelectedItem();
if (scanScope == null) {
scanScope = ScanScope.getDefaultValue();
}
// we don't know the scanBeforeCheckin flag at this point
return PluginConfigurationBuilder.defaultConfiguration(project).withCheckstyleVersion(checkstyleVersion).withScanScope(scanScope).withSuppressErrors(suppressErrorsCheckbox.isSelected()).withCopyLibraries(copyLibsCheckbox.isSelected()).withLocations(new TreeSet<>(locationModel.getLocations())).withThirdPartyClassPath(getThirdPartyClasspath()).withActiveLocation(locationModel.getActiveLocation()).build();
}
use of org.infernus.idea.checkstyle.model.ScanScope in project checkstyle-idea by jshiell.
the class ScanCurrentFile method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent event) {
final Project project = DataKeys.PROJECT.getData(event.getDataContext());
if (project == null) {
return;
}
try {
final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
if (checkStylePlugin == null) {
throw new IllegalStateException("Couldn't get checkstyle plugin");
}
final ScanScope scope = checkStylePlugin.configurationManager().getCurrent().getScanScope();
final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
toolWindow.activate(() -> {
try {
setProgressText(toolWindow, "plugin.status.in-progress.current");
final VirtualFile selectedFile = getSelectedFile(project, scope);
if (selectedFile != null) {
project.getComponent(CheckStylePlugin.class).asyncScanFiles(Arrays.asList(selectedFile), getSelectedOverride(toolWindow));
}
} catch (Throwable e) {
CheckStylePlugin.processErrorAndLog("Current File scan", e);
}
});
} catch (Throwable e) {
CheckStylePlugin.processErrorAndLog("Current File scan", e);
}
}
use of org.infernus.idea.checkstyle.model.ScanScope in project checkstyle-idea by jshiell.
the class ScanModule method actionPerformed.
@Override
public final void actionPerformed(final AnActionEvent event) {
try {
final Project project = DataKeys.PROJECT.getData(event.getDataContext());
if (project == null) {
return;
}
final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
final VirtualFile[] selectedFiles = FileEditorManager.getInstance(project).getSelectedFiles();
if (selectedFiles.length == 0) {
setProgressText(toolWindow, "plugin.status.in-progress.no-file");
return;
}
final Module module = ModuleUtil.findModuleForFile(selectedFiles[0], project);
if (module == null) {
setProgressText(toolWindow, "plugin.status.in-progress.no-module");
return;
}
final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
if (checkStylePlugin == null) {
throw new IllegalStateException("Couldn't get checkstyle plugin");
}
final ScanScope scope = checkStylePlugin.configurationManager().getCurrent().getScanScope();
toolWindow.activate(() -> {
try {
setProgressText(toolWindow, "plugin.status.in-progress.module");
Runnable scanAction = null;
if (scope == ScanScope.Everything) {
scanAction = new ScanEverythingAction(module, getSelectedOverride(toolWindow));
} else {
final VirtualFile[] moduleSourceRoots = ModuleRootManager.getInstance(module).getSourceRoots(scope.includeTestClasses());
if (moduleSourceRoots.length > 0) {
scanAction = new ScanSourceRootsAction(project, moduleSourceRoots, getSelectedOverride(toolWindow));
}
}
if (scanAction != null) {
ApplicationManager.getApplication().runReadAction(scanAction);
}
} catch (Throwable e) {
CheckStylePlugin.processErrorAndLog("Current Module scan", e);
}
});
} catch (Throwable e) {
CheckStylePlugin.processErrorAndLog("Current Module scan", e);
}
}
use of org.infernus.idea.checkstyle.model.ScanScope in project checkstyle-idea by jshiell.
the class ScanModule method update.
@Override
public final void update(final AnActionEvent event) {
super.update(event);
try {
final Presentation presentation = event.getPresentation();
final Project project = DataKeys.PROJECT.getData(event.getDataContext());
if (project == null) {
// check if we're loading...
presentation.setEnabled(false);
return;
}
final VirtualFile[] selectedFiles = FileEditorManager.getInstance(project).getSelectedFiles();
if (selectedFiles.length == 0) {
return;
}
final Module module = ModuleUtil.findModuleForFile(selectedFiles[0], project);
if (module == null) {
return;
}
final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
if (checkStylePlugin == null) {
throw new IllegalStateException("Couldn't get checkstyle plugin");
}
final ScanScope scope = checkStylePlugin.configurationManager().getCurrent().getScanScope();
VirtualFile[] moduleFiles = null;
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
if (scope == ScanScope.Everything) {
moduleFiles = moduleRootManager.getContentRoots();
} else {
moduleFiles = moduleRootManager.getSourceRoots(scope.includeTestClasses());
}
// disable if no files are selected or scan in progress
if (containsAtLeastOneFile(moduleFiles)) {
presentation.setEnabled(!checkStylePlugin.isScanInProgress());
} else {
presentation.setEnabled(false);
}
} catch (Throwable e) {
CheckStylePlugin.processErrorAndLog("Current Module button update", e);
}
}
use of org.infernus.idea.checkstyle.model.ScanScope in project checkstyle-idea by jshiell.
the class ScanProject method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent event) {
try {
final Project project = DataKeys.PROJECT.getData(event.getDataContext());
if (project == null) {
return;
}
final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
if (checkStylePlugin == null) {
throw new IllegalStateException("Couldn't get checkstyle plugin");
}
final ScanScope scope = checkStylePlugin.configurationManager().getCurrent().getScanScope();
final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
toolWindow.activate(() -> {
try {
setProgressText(toolWindow, "plugin.status.in-progress.project");
Runnable scanAction = null;
if (scope == ScanScope.Everything) {
scanAction = new ScanEverythingAction(project, getSelectedOverride(toolWindow));
} else {
final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(project);
final VirtualFile[] sourceRoots = projectRootManager.getContentSourceRoots();
if (sourceRoots.length > 0) {
scanAction = new ScanSourceRootsAction(project, sourceRoots, getSelectedOverride(toolWindow));
}
}
if (scanAction != null) {
ApplicationManager.getApplication().runReadAction(scanAction);
}
} catch (Throwable e) {
CheckStylePlugin.processErrorAndLog("Project scan", e);
}
});
} catch (Throwable e) {
CheckStylePlugin.processErrorAndLog("Project scan", e);
}
}
Aggregations