mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
More user-friendly API for retrieving intention actions
This commit is contained in:
+2
-17
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.java.codeInsight.daemon;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
@@ -44,8 +30,7 @@ public class GutterIntentionsTest extends LightCodeInsightFixtureTestCase {
|
||||
"}");
|
||||
assertSize(1, myFixture.findGuttersAtCaret());
|
||||
|
||||
ShowIntentionsPass.IntentionsInfo intentions = new ShowIntentionsPass.IntentionsInfo();
|
||||
ShowIntentionsPass.getActionsToShow(getEditor(), getFile(), intentions, -1);
|
||||
ShowIntentionsPass.IntentionsInfo intentions = ShowIntentionsPass.getActionsToShow(getEditor(), getFile());
|
||||
final HighlightInfo.IntentionActionDescriptor intentionActionDescriptor = assertOneElement(intentions.guttersToShow);
|
||||
List<IntentionAction> options = intentionActionDescriptor.getOptions(myFixture.getElementAtCaret(), getEditor());
|
||||
assertNotNull(options);
|
||||
|
||||
+11
-15
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.codeInsight.daemon.impl;
|
||||
|
||||
@@ -302,6 +288,16 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of actions to show in the Alt-Enter popup at the caret offset in the given editor.
|
||||
*/
|
||||
@NotNull
|
||||
public static IntentionsInfo getActionsToShow(@NotNull Editor hostEditor, @NotNull PsiFile hostFile) {
|
||||
IntentionsInfo result = new IntentionsInfo();
|
||||
getActionsToShow(hostEditor, hostFile, result, -1);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void getActionsToShow(@NotNull final Editor hostEditor,
|
||||
@NotNull final PsiFile hostFile,
|
||||
@NotNull final IntentionsInfo intentions,
|
||||
|
||||
+2
-5
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.codeInsight.intention.impl;
|
||||
|
||||
@@ -65,8 +63,7 @@ public class ShowIntentionActionsHandler implements CodeInsightActionHandler {
|
||||
final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project);
|
||||
letAutoImportComplete(editor, file, codeAnalyzer);
|
||||
|
||||
ShowIntentionsPass.IntentionsInfo intentions = new ShowIntentionsPass.IntentionsInfo();
|
||||
ShowIntentionsPass.getActionsToShow(editor, file, intentions, -1);
|
||||
ShowIntentionsPass.IntentionsInfo intentions = ShowIntentionsPass.getActionsToShow(editor, file);
|
||||
IntentionHintComponent hintComponent = codeAnalyzer.getLastIntentionHint();
|
||||
if (hintComponent != null) {
|
||||
IntentionHintComponent.PopupUpdateResult result = hintComponent.isForEditor(editor)
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ide.actions;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
@@ -61,8 +47,7 @@ public class ApplyIntentionAction extends AnAction {
|
||||
|
||||
@Nullable
|
||||
public static ApplyIntentionAction[] getAvailableIntentions(@NotNull Editor editor, @NotNull PsiFile file) {
|
||||
ShowIntentionsPass.IntentionsInfo info = new ShowIntentionsPass.IntentionsInfo();
|
||||
ShowIntentionsPass.getActionsToShow(editor, file, info, -1);
|
||||
ShowIntentionsPass.IntentionsInfo info = ShowIntentionsPass.getActionsToShow(editor, file);
|
||||
if (info.isEmpty()) return null;
|
||||
|
||||
final List<HighlightInfo.IntentionActionDescriptor> actions = new ArrayList<>();
|
||||
|
||||
+1
-2
@@ -249,8 +249,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
|
||||
@NotNull
|
||||
private static List<IntentionAction> doGetAvailableIntentions(@NotNull Editor editor, @NotNull PsiFile file) {
|
||||
ShowIntentionsPass.IntentionsInfo intentions = new ShowIntentionsPass.IntentionsInfo();
|
||||
ShowIntentionsPass.getActionsToShow(editor, file, intentions, -1);
|
||||
ShowIntentionsPass.IntentionsInfo intentions = ShowIntentionsPass.getActionsToShow(editor, file);
|
||||
|
||||
List<IntentionAction> result = new ArrayList<>();
|
||||
IntentionListStep intentionListStep = new IntentionListStep(null, intentions, editor, file, file.getProject());
|
||||
|
||||
Reference in New Issue
Block a user