mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-54916 exception in PhpStorm commandLineTool plugin
This commit is contained in:
@@ -24,7 +24,11 @@ public abstract class BaseEnterHandler extends EditorWriteActionHandler {
|
||||
private static final String GROUP_ID = "EnterHandler.GROUP_ID";
|
||||
|
||||
protected BaseEnterHandler() {
|
||||
super(true);
|
||||
super(false);
|
||||
}
|
||||
|
||||
protected BaseEnterHandler(boolean runForEachCaret) {
|
||||
super(runForEachCaret);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -56,6 +56,7 @@ public class EnterHandler extends BaseEnterHandler {
|
||||
private final EditorActionHandler myOriginalHandler;
|
||||
|
||||
public EnterHandler(EditorActionHandler originalHandler) {
|
||||
super(true);
|
||||
myOriginalHandler = originalHandler;
|
||||
}
|
||||
|
||||
@@ -65,32 +66,32 @@ public class EnterHandler extends BaseEnterHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeWriteAction(final Editor editor, final DataContext dataContext) {
|
||||
public void executeWriteAction(final Editor editor, final Caret caret, final DataContext dataContext) {
|
||||
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
|
||||
if (project != null && !project.isDefault()) {
|
||||
PostprocessReformattingAspect.getInstance(project).disablePostprocessFormattingInside(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
executeWriteActionInner(editor, dataContext, project);
|
||||
executeWriteActionInner(editor, caret, dataContext, project);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
executeWriteActionInner(editor, dataContext, project);
|
||||
executeWriteActionInner(editor, caret, dataContext, project);
|
||||
}
|
||||
}
|
||||
|
||||
private void executeWriteActionInner(Editor editor, DataContext dataContext, Project project) {
|
||||
private void executeWriteActionInner(Editor editor, Caret caret, DataContext dataContext, Project project) {
|
||||
CodeInsightSettings settings = CodeInsightSettings.getInstance();
|
||||
if (project == null) {
|
||||
myOriginalHandler.execute(editor, dataContext);
|
||||
myOriginalHandler.execute(editor, caret, dataContext);
|
||||
return;
|
||||
}
|
||||
final Document document = editor.getDocument();
|
||||
final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);
|
||||
|
||||
if (file == null) {
|
||||
myOriginalHandler.execute(editor, dataContext);
|
||||
myOriginalHandler.execute(editor, caret, dataContext);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -107,7 +108,7 @@ public class EnterHandler extends BaseEnterHandler {
|
||||
int offset2 = CharArrayUtil.shiftForward(text, offset1 + 1, " \t");
|
||||
boolean isEmptyLine = offset2 >= length || text.charAt(offset2) == '\n';
|
||||
if (!isEmptyLine) { // we are in leading spaces of a non-empty line
|
||||
myOriginalHandler.execute(editor, dataContext);
|
||||
myOriginalHandler.execute(editor, caret, dataContext);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -148,7 +149,7 @@ public class EnterHandler extends BaseEnterHandler {
|
||||
final boolean insertSpace =
|
||||
!isFirstColumn && !(caretOffset >= text.length() || text.charAt(caretOffset) == ' ' || text.charAt(caretOffset) == '\t');
|
||||
editor.getCaretModel().moveToOffset(caretOffset);
|
||||
myOriginalHandler.execute(editor, dataContext);
|
||||
myOriginalHandler.execute(editor, caret, dataContext);
|
||||
if (!editor.isInsertMode() || forceSkipIndent) {
|
||||
return;
|
||||
}
|
||||
|
||||
+4
-2
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateSettings;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -30,6 +31,7 @@ public class EnterHandler extends BaseEnterHandler {
|
||||
private final EditorActionHandler myOriginalHandler;
|
||||
|
||||
public EnterHandler(EditorActionHandler originalHandler) {
|
||||
super(true);
|
||||
myOriginalHandler = originalHandler;
|
||||
}
|
||||
|
||||
@@ -39,7 +41,7 @@ public class EnterHandler extends BaseEnterHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeWriteAction(Editor editor, DataContext dataContext) {
|
||||
public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) {
|
||||
Project project = CommonDataKeys.PROJECT.getData(dataContext);
|
||||
if (project != null) {
|
||||
PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
|
||||
@@ -49,6 +51,6 @@ public class EnterHandler extends BaseEnterHandler {
|
||||
}
|
||||
}
|
||||
|
||||
myOriginalHandler.execute(editor, dataContext);
|
||||
myOriginalHandler.execute(editor, caret, dataContext);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user