use of com.intellij.analysis.AnalysisUIOptions in project intellij-community by JetBrains.
the class SliceForwardHandler method askForParams.
@Override
public SliceAnalysisParams askForParams(PsiElement element, boolean dataFlowToThis, SliceManager.StoredSettingsBean storedSettingsBean, String dialogTitle) {
AnalysisScope analysisScope = new AnalysisScope(element.getContainingFile());
Module module = ModuleUtilCore.findModuleForPsiElement(element);
String name = module == null ? null : module.getName();
Project myProject = element.getProject();
final SliceForwardForm form = new SliceForwardForm();
form.init(storedSettingsBean.showDereferences);
AnalysisUIOptions analysisUIOptions = new AnalysisUIOptions();
analysisUIOptions.save(storedSettingsBean.analysisUIOptions);
BaseAnalysisActionDialog dialog = new BaseAnalysisActionDialog(dialogTitle, "Analyze scope", myProject, analysisScope, name, true, analysisUIOptions, element) {
@Override
protected JComponent getAdditionalActionSettings(Project project) {
return form.getComponent();
}
};
if (!dialog.showAndGet()) {
return null;
}
storedSettingsBean.analysisUIOptions.save(analysisUIOptions);
storedSettingsBean.showDereferences = form.isToShowDerefs();
AnalysisScope scope = dialog.getScope(analysisUIOptions, analysisScope, myProject, module);
SliceAnalysisParams params = new SliceAnalysisParams();
params.scope = scope;
params.dataFlowToThis = dataFlowToThis;
params.showInstanceDereferences = form.isToShowDerefs();
return params;
}
use of com.intellij.analysis.AnalysisUIOptions in project intellij-community by JetBrains.
the class SliceHandler method askForParams.
public SliceAnalysisParams askForParams(PsiElement element, boolean dataFlowToThis, SliceManager.StoredSettingsBean storedSettingsBean, String dialogTitle) {
AnalysisScope analysisScope = new AnalysisScope(element.getContainingFile());
Module module = ModuleUtilCore.findModuleForPsiElement(element);
String name = module == null ? null : module.getName();
Project myProject = element.getProject();
AnalysisUIOptions analysisUIOptions = new AnalysisUIOptions();
analysisUIOptions.save(storedSettingsBean.analysisUIOptions);
BaseAnalysisActionDialog dialog = new BaseAnalysisActionDialog(dialogTitle, "Analyze scope", myProject, analysisScope, name, true, analysisUIOptions, element);
if (!dialog.showAndGet()) {
return null;
}
AnalysisScope scope = dialog.getScope(analysisUIOptions, analysisScope, myProject, module);
storedSettingsBean.analysisUIOptions.save(analysisUIOptions);
SliceAnalysisParams params = new SliceAnalysisParams();
params.scope = scope;
params.dataFlowToThis = dataFlowToThis;
return params;
}
use of com.intellij.analysis.AnalysisUIOptions in project intellij-community by JetBrains.
the class RunInspectionAction method runInspection.
public static void runInspection(@NotNull final Project project, @NotNull String shortName, @Nullable VirtualFile virtualFile, PsiElement psiElement, PsiFile psiFile) {
final PsiElement element = psiFile == null ? psiElement : psiFile;
final InspectionProfile currentProfile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
final InspectionToolWrapper toolWrapper = element != null ? currentProfile.getInspectionTool(shortName, element) : currentProfile.getInspectionTool(shortName, project);
LOGGER.assertTrue(toolWrapper != null, "Missed inspection: " + shortName);
final InspectionManagerEx managerEx = (InspectionManagerEx) InspectionManager.getInstance(project);
final Module module = virtualFile != null ? ModuleUtilCore.findModuleForFile(virtualFile, project) : null;
AnalysisScope analysisScope = null;
if (psiFile != null) {
analysisScope = new AnalysisScope(psiFile);
} else {
if (virtualFile != null && virtualFile.isDirectory()) {
final PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(virtualFile);
if (psiDirectory != null) {
analysisScope = new AnalysisScope(psiDirectory);
}
}
if (analysisScope == null && virtualFile != null) {
analysisScope = new AnalysisScope(project, Arrays.asList(virtualFile));
}
if (analysisScope == null) {
analysisScope = new AnalysisScope(project);
}
}
final AnalysisUIOptions options = AnalysisUIOptions.getInstance(project);
final FileFilterPanel fileFilterPanel = new FileFilterPanel();
fileFilterPanel.init(options);
final AnalysisScope initialAnalysisScope = analysisScope;
final BaseAnalysisActionDialog dialog = new BaseAnalysisActionDialog("Run '" + toolWrapper.getDisplayName() + "'", AnalysisScopeBundle.message("analysis.scope.title", InspectionsBundle.message("inspection.action.noun")), project, analysisScope, module != null ? module.getName() : null, true, options, psiElement) {
private InspectionToolWrapper myUpdatedSettingsToolWrapper;
@Nullable
@Override
protected JComponent getAdditionalActionSettings(Project project) {
final JPanel fileFilter = fileFilterPanel.getPanel();
if (toolWrapper.getTool().createOptionsPanel() != null) {
JPanel additionPanel = new JPanel();
additionPanel.setLayout(new BoxLayout(additionPanel, BoxLayout.Y_AXIS));
additionPanel.add(fileFilter);
//new InheritOptionsForToolPanel(toolWrapper.getShortName(), project);
myUpdatedSettingsToolWrapper = copyToolWithSettings(toolWrapper);
additionPanel.add(new TitledSeparator(IdeBundle.message("goto.inspection.action.choose.inherit.settings.from")));
JComponent optionsPanel = myUpdatedSettingsToolWrapper.getTool().createOptionsPanel();
LOGGER.assertTrue(optionsPanel != null);
if (UIUtil.hasScrollPane(optionsPanel)) {
additionPanel.add(optionsPanel);
} else {
additionPanel.add(ScrollPaneFactory.createScrollPane(optionsPanel, SideBorder.NONE));
}
return additionPanel;
} else {
return fileFilter;
}
}
@NotNull
@Override
public AnalysisScope getScope(@NotNull AnalysisUIOptions uiOptions, @NotNull AnalysisScope defaultScope, @NotNull Project project, Module module) {
final AnalysisScope scope = super.getScope(uiOptions, defaultScope, project, module);
final GlobalSearchScope filterScope = fileFilterPanel.getSearchScope();
if (filterScope == null) {
return scope;
}
scope.setFilter(filterScope);
return scope;
}
private AnalysisScope getScope() {
return getScope(options, initialAnalysisScope, project, module);
}
private InspectionToolWrapper getToolWrapper() {
return myUpdatedSettingsToolWrapper == null ? toolWrapper : myUpdatedSettingsToolWrapper;
}
@NotNull
@Override
protected Action[] createActions() {
final List<Action> actions = new ArrayList<>();
final boolean hasFixAll = toolWrapper.getTool() instanceof CleanupLocalInspectionTool;
actions.add(new AbstractAction(hasFixAll ? AnalysisScopeBundle.message("action.analyze.verb") : CommonBundle.getOkButtonText()) {
{
putValue(DEFAULT_ACTION, Boolean.TRUE);
}
@Override
public void actionPerformed(ActionEvent e) {
RunInspectionIntention.rerunInspection(getToolWrapper(), managerEx, getScope(), null);
close(DialogWrapper.OK_EXIT_CODE);
}
});
if (hasFixAll) {
actions.add(new AbstractAction("Fix All") {
@Override
public void actionPerformed(ActionEvent e) {
InspectionToolWrapper wrapper = getToolWrapper();
InspectionProfileImpl cleanupToolProfile = RunInspectionIntention.createProfile(wrapper, managerEx, null);
managerEx.createNewGlobalContext(false).codeCleanup(getScope(), cleanupToolProfile, "Cleanup by " + wrapper.getDisplayName(), null, false);
close(DialogWrapper.OK_EXIT_CODE);
}
});
}
actions.add(getCancelAction());
if (SystemInfo.isMac) {
Collections.reverse(actions);
}
return actions.toArray(new Action[actions.size()]);
}
};
dialog.showAndGet();
}
use of com.intellij.analysis.AnalysisUIOptions in project intellij-community by JetBrains.
the class CleanupOnScopeIntention method getScope.
@Nullable
@Override
protected AnalysisScope getScope(final Project project, final PsiFile file) {
final Module module = ModuleUtilCore.findModuleForPsiElement(file);
AnalysisScope analysisScope = new AnalysisScope(file);
final VirtualFile virtualFile = file.getVirtualFile();
if (file.isPhysical() || virtualFile == null || !virtualFile.isInLocalFileSystem()) {
analysisScope = new AnalysisScope(project);
}
final BaseAnalysisActionDialog dlg = new BaseAnalysisActionDialog(AnalysisScopeBundle.message("specify.analysis.scope", InspectionsBundle.message("inspection.action.title")), AnalysisScopeBundle.message("analysis.scope.title", InspectionsBundle.message("inspection.action.noun")), project, analysisScope, module != null ? module.getName() : null, true, AnalysisUIOptions.getInstance(project), file);
if (!dlg.showAndGet()) {
return null;
}
final AnalysisUIOptions uiOptions = AnalysisUIOptions.getInstance(project);
return dlg.getScope(uiOptions, analysisScope, project, module);
}
use of com.intellij.analysis.AnalysisUIOptions in project intellij-community by JetBrains.
the class RunInspectionIntention method selectScopeAndRunInspection.
public static void selectScopeAndRunInspection(@NotNull String toolShortName, @NotNull AnalysisScope customScope, @Nullable Module module, @Nullable PsiElement context, @NotNull Project project) {
final BaseAnalysisActionDialog dlg = new BaseAnalysisActionDialog(AnalysisScopeBundle.message("specify.analysis.scope", InspectionsBundle.message("inspection.action.title")), AnalysisScopeBundle.message("analysis.scope.title", InspectionsBundle.message("inspection.action.noun")), project, customScope, module != null ? module.getName() : null, true, AnalysisUIOptions.getInstance(project), context);
if (!dlg.showAndGet()) {
return;
}
final AnalysisUIOptions uiOptions = AnalysisUIOptions.getInstance(project);
customScope = dlg.getScope(uiOptions, customScope, project, module);
final InspectionToolWrapper wrapper = LocalInspectionToolWrapper.findTool2RunInBatch(project, context, toolShortName);
LOG.assertTrue(wrapper != null, "Can't find tool with name = \"" + toolShortName + "\"");
rerunInspection(wrapper, (InspectionManagerEx) InspectionManager.getInstance(project), customScope, context);
}
Aggregations