mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WEB-69468 Add support for configuring named scope to limit amount of files for global inspections run.
GitOrigin-RevId: f783f18ce7f40f215e3d2e446351034c88ae38b9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e5de686da6
commit
ac04b62c7d
+7
@@ -236,6 +236,13 @@ fun <T : CommandChain> T.inspectCodeEx(
|
||||
addCommand("${CMD_PREFIX}InspectCodeEx" + resultCommand)
|
||||
}
|
||||
|
||||
fun <T : CommandChain> T.configureNamedScope(
|
||||
scopeName: String,
|
||||
pattern: String,
|
||||
): T = apply {
|
||||
addCommand("${CMD_PREFIX}configureNamedScope -scopeName $scopeName -pattern $pattern")
|
||||
}
|
||||
|
||||
fun <T : CommandChain> T.checkOnRedCode(): T = apply {
|
||||
addCommand("${CMD_PREFIX}codeAnalysis ${CodeAnalysisType.CHECK_ON_RED_CODE}")
|
||||
}
|
||||
|
||||
+1
@@ -16,6 +16,7 @@ public final class BaseCommandProvider implements CommandProvider {
|
||||
Map.entry(StopProfileCommand.PREFIX, StopProfileCommand::new),
|
||||
Map.entry(InspectionCommand.PREFIX, InspectionCommand::new),
|
||||
Map.entry(InspectionCommandEx.PREFIX, InspectionCommandEx::new),
|
||||
Map.entry(ConfigureNamedScopeCommand.PREFIX, ConfigureNamedScopeCommand::new),
|
||||
Map.entry(ReformatCommand.PREFIX, ReformatCommand::new),
|
||||
Map.entry(GoToCommand.PREFIX, GoToCommand::new),
|
||||
Map.entry(ScrollEditorCommand.PREFIX, ScrollEditorCommand::new),
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package com.jetbrains.performancePlugin.commands;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.playback.PlaybackContext;
|
||||
import com.intellij.openapi.ui.playback.commands.AbstractCommand;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopeManager;
|
||||
import com.intellij.psi.search.scope.packageSet.PackageSetFactory;
|
||||
import com.intellij.psi.search.scope.packageSet.ParsingException;
|
||||
import com.sampullara.cli.Args;
|
||||
import com.sampullara.cli.Argument;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.concurrency.Promise;
|
||||
|
||||
import static org.jetbrains.concurrency.Promises.rejectedPromise;
|
||||
import static org.jetbrains.concurrency.Promises.resolvedPromise;
|
||||
|
||||
public class ConfigureNamedScopeCommand extends AbstractCommand {
|
||||
|
||||
public static final String PREFIX = CMD_PREFIX + "configureNamedScope";
|
||||
|
||||
private final Options myOptions = new Options();
|
||||
|
||||
public ConfigureNamedScopeCommand(String text, int line) {
|
||||
super(text, line);
|
||||
if (text.startsWith(PREFIX)) {
|
||||
Args.parse(myOptions, text.substring(PREFIX.length()).trim().split(" "), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull Promise<Object> _execute(@NotNull PlaybackContext context) {
|
||||
String scopeName = myOptions.scopeName;
|
||||
String pattern = myOptions.pattern;
|
||||
if (scopeName == null) {
|
||||
dumpError(context, "Missing scope name.");
|
||||
return rejectedPromise();
|
||||
}
|
||||
if (pattern == null) {
|
||||
dumpError(context, "Missing pattern.");
|
||||
return rejectedPromise();
|
||||
}
|
||||
Project project = context.getProject();
|
||||
if (NamedScopeManager.getInstance(project).getScope(scopeName) != null) {
|
||||
dumpError(context, "Scope " + scopeName + "already exists.");
|
||||
return rejectedPromise();
|
||||
}
|
||||
try {
|
||||
NamedScope newScope = NamedScopeManager.getInstance(project).createScope(scopeName, PackageSetFactory.getInstance().compile(pattern));
|
||||
NamedScopeManager.getInstance(project).addScope(newScope);
|
||||
}
|
||||
catch (ParsingException e) {
|
||||
dumpError(context, "Failed to parse scope pattern: " + pattern + "\n" + e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (NamedScopeManager.getInstance(project).getScope(scopeName) == null) {
|
||||
dumpError(context, "Failed to create scope " + scopeName);
|
||||
return rejectedPromise();
|
||||
}
|
||||
return resolvedPromise();
|
||||
}
|
||||
|
||||
static class Options {
|
||||
@Argument
|
||||
String scopeName;
|
||||
|
||||
@Argument
|
||||
String pattern;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user