From 773f5f0bb9d71cf24a160a27bb954e0ecc137e16 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Fri, 8 Nov 2013 16:26:59 +0400 Subject: [PATCH] IDEA-102454 Parameter Info: TAB/Shift-TAB and editing does not work in language injected fragment --- .../actions/InjectionAwareEditorAction.java | 42 +++++++++++++++++++ .../hint/actions/NextParameterAction.java | 3 +- .../hint/actions/PrevParameterAction.java | 3 +- 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 platform/lang-impl/src/com/intellij/codeInsight/hint/actions/InjectionAwareEditorAction.java diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/InjectionAwareEditorAction.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/InjectionAwareEditorAction.java new file mode 100644 index 000000000000..45c7bf434098 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/InjectionAwareEditorAction.java @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2013 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.hint.actions; + +import com.intellij.codeInsight.actions.BaseCodeInsightAction; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.actionSystem.EditorAction; +import com.intellij.openapi.editor.actionSystem.EditorActionHandler; +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.Nullable; + +/** + * @author ignatov + */ +public class InjectionAwareEditorAction extends EditorAction { + protected InjectionAwareEditorAction(EditorActionHandler defaultHandler) { + super(defaultHandler); + } + + @Nullable + protected Editor getEditor(final DataContext dataContext) { + Editor editor = super.getEditor(dataContext); + Project project = CommonDataKeys.PROJECT.getData(dataContext); + Editor injected = project == null ? null : BaseCodeInsightAction.getInjectedEditor(project, editor); + return injected == null ? editor : injected; + } +} diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/NextParameterAction.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/NextParameterAction.java index 8bb50f9b47e6..407e169ed4b9 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/NextParameterAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/NextParameterAction.java @@ -17,12 +17,11 @@ package com.intellij.codeInsight.hint.actions; import com.intellij.codeInsight.hint.PrevNextParameterHandler; -import com.intellij.openapi.editor.actionSystem.EditorAction; /** * @author ven */ -public class NextParameterAction extends EditorAction { +public class NextParameterAction extends InjectionAwareEditorAction { public NextParameterAction() { super(new PrevNextParameterHandler(true)); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/PrevParameterAction.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/PrevParameterAction.java index 678de362eaf5..5c4647731609 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/PrevParameterAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/PrevParameterAction.java @@ -17,12 +17,11 @@ package com.intellij.codeInsight.hint.actions; import com.intellij.codeInsight.hint.PrevNextParameterHandler; -import com.intellij.openapi.editor.actionSystem.EditorAction; /** * @author ven */ -public class PrevParameterAction extends EditorAction { +public class PrevParameterAction extends InjectionAwareEditorAction { public PrevParameterAction() { super(new PrevNextParameterHandler(false)); }