Minor maven action optimization: check MavenDataKeys.MAVEN_GOALS firstly

This commit is contained in:
Sergey Evdokimov
2013-05-08 17:49:28 +04:00
parent d3e35fb2e6
commit 14febaa995
4 changed files with 12 additions and 11 deletions
@@ -38,12 +38,12 @@ public class RunBuildAction extends MavenAction {
}
private static boolean checkOrPerform(DataContext context, boolean perform) {
final MavenProject project = MavenActionUtil.getMavenProject(context);
if (project == null) return false;
final List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
if (goals == null || goals.isEmpty()) return false;
final MavenProject project = MavenActionUtil.getMavenProject(context);
if (project == null) return false;
if (!perform) return true;
final MavenRunnerParameters params = new MavenRunnerParameters(true,
@@ -50,14 +50,14 @@ public class AssignShortcutAction extends MavenAction {
@Nullable
private static String getGoalActionId(DataContext context) {
MavenProject project = MavenActionUtil.getMavenProject(context);
if (project == null) return null;
final List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
if (goals == null || goals.size() != 1) {
return null;
}
MavenProject project = MavenActionUtil.getMavenProject(context);
if (project == null) return null;
String goal = goals.get(0);
return getShortcutsManager(context).getActionId(project.getPath(), goal);
@@ -58,11 +58,12 @@ public class ToggleBeforeRunTaskAction extends MavenToggleAction {
@Nullable
protected static Pair<MavenProject, String> getTaskDesc(DataContext context) {
List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
if (goals == null || goals.size() != 1) return null;
MavenProject mavenProject = MavenActionUtil.getMavenProject(context);
if (mavenProject == null) return null;
List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
if (goals == null || goals.size() != 1) return null;
return Pair.create(mavenProject, goals.get(0));
}
@@ -53,12 +53,12 @@ public abstract class ToggleCompilerTasksAction extends MavenToggleAction {
}
protected static List<MavenCompilerTask> getTasks(DataContext context) {
MavenProject project = MavenActionUtil.getMavenProject(context);
if (project == null) return Collections.emptyList();
final List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
if (goals == null || goals.isEmpty()) return Collections.emptyList();
MavenProject project = MavenActionUtil.getMavenProject(context);
if (project == null) return Collections.emptyList();
List<MavenCompilerTask> result = new ArrayList<MavenCompilerTask>();
for (String each : goals) {
result.add(new MavenCompilerTask(project.getPath(), each));