From ce1f4e280d2c1fbdc7af5c0a449d66bdcfe979c0 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 24 May 2016 01:15:46 +0200 Subject: [PATCH] simplify getting project from AnActionEvent --- .../actions/GenerateCopyrightAction.java | 19 +++++++++---------- .../actions/UpdateCopyrightAction.java | 8 ++++---- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/actions/GenerateCopyrightAction.java b/plugins/copyright/src/com/maddyhome/idea/copyright/actions/GenerateCopyrightAction.java index c6d274f50f4c..2a1b9c9df186 100644 --- a/plugins/copyright/src/com/maddyhome/idea/copyright/actions/GenerateCopyrightAction.java +++ b/plugins/copyright/src/com/maddyhome/idea/copyright/actions/GenerateCopyrightAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,11 +31,11 @@ import org.jetbrains.annotations.Nullable; public class GenerateCopyrightAction extends AnAction { - public void update(AnActionEvent event) + public void update(AnActionEvent e) { - Presentation presentation = event.getPresentation(); - DataContext context = event.getDataContext(); - Project project = CommonDataKeys.PROJECT.getData(context); + Presentation presentation = e.getPresentation(); + DataContext context = e.getDataContext(); + Project project = e.getProject(); if (project == null) { presentation.setEnabled(false); @@ -60,12 +60,11 @@ public class GenerateCopyrightAction extends AnAction return file; } - public void actionPerformed(AnActionEvent event) - { - DataContext context = event.getDataContext(); - Project project = CommonDataKeys.PROJECT.getData(context); + public void actionPerformed(AnActionEvent e) { + DataContext context = e.getDataContext(); + Project project = e.getProject(); assert project != null; - Module module = LangDataKeys.MODULE.getData(context); + Module module = e.getData(LangDataKeys.MODULE); PsiDocumentManager.getInstance(project).commitAllDocuments(); diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/actions/UpdateCopyrightAction.java b/plugins/copyright/src/com/maddyhome/idea/copyright/actions/UpdateCopyrightAction.java index 4314c8953185..39b224f4f2f5 100644 --- a/plugins/copyright/src/com/maddyhome/idea/copyright/actions/UpdateCopyrightAction.java +++ b/plugins/copyright/src/com/maddyhome/idea/copyright/actions/UpdateCopyrightAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,9 +64,9 @@ public class UpdateCopyrightAction extends BaseAnalysisAction { } } - private static boolean isEnabled(AnActionEvent event) { - final DataContext context = event.getDataContext(); - final Project project = CommonDataKeys.PROJECT.getData(context); + private static boolean isEnabled(AnActionEvent e) { + final DataContext context = e.getDataContext(); + final Project project = e.getProject(); if (project == null) { return false; }