From cb2596942932edc24f557a1e19234fc3d013eef7 Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Tue, 20 Nov 2012 15:31:24 +0400 Subject: [PATCH] [by: alexander.doroshko] IDEA-95143 Code Style | Arrangement: 'Rearrange code' action should not be shown in 'Code' menu if it is not available in current context --- .../codeStyle/arrangement/action/RearrangeCodeAction.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/RearrangeCodeAction.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/RearrangeCodeAction.java index e0085ba12e77..1906a47aa724 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/RearrangeCodeAction.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/RearrangeCodeAction.java @@ -15,7 +15,6 @@ */ package com.intellij.application.options.codeStyle.arrangement.action; -import com.intellij.lang.Language; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.LangDataKeys; @@ -45,11 +44,8 @@ public class RearrangeCodeAction extends AnAction { @Override public void update(AnActionEvent e) { - Language language = LangDataKeys.LANGUAGE.getData(e.getDataContext()); - boolean enabled = false; - if (language != null) { - enabled = Rearranger.EXTENSION.forLanguage(language) != null; - } + PsiFile file = LangDataKeys.PSI_FILE.getData(e.getDataContext()); + boolean enabled = file != null && Rearranger.EXTENSION.forLanguage(file.getLanguage()) != null; e.getPresentation().setEnabled(enabled); }