mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Removed commit before EnterHandlerDelegate.postProcessEnter() (implementors must take care of commits if needed)
This commit is contained in:
@@ -137,6 +137,7 @@ public class JavadocHelper {
|
||||
@NotNull
|
||||
public Pair<JavadocParameterInfo, List<JavadocParameterInfo>> parse(@NotNull PsiFile psiFile, @NotNull Editor editor, int offset) {
|
||||
List<JavadocParameterInfo> result = new ArrayList<JavadocParameterInfo>();
|
||||
PsiDocumentManager.getInstance(psiFile.getProject()).commitDocument(editor.getDocument());
|
||||
final PsiElement elementAtCaret = psiFile.findElementAt(offset);
|
||||
if (elementAtCaret == null) {
|
||||
return EMPTY;
|
||||
|
||||
@@ -170,7 +170,6 @@ public class EnterHandler extends BaseEnterHandler {
|
||||
);
|
||||
action.setForceIndent(forceIndent);
|
||||
action.run();
|
||||
documentManager.commitDocument(document);
|
||||
for (EnterHandlerDelegate delegate : delegates) {
|
||||
if (delegate.postProcessEnter(file, editor, dataContext) == EnterHandlerDelegate.Result.Stop) {
|
||||
break;
|
||||
|
||||
+20
-3
@@ -16,10 +16,10 @@
|
||||
|
||||
package com.intellij.codeInsight.editorActions.enter;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -39,5 +39,22 @@ public interface EnterHandlerDelegate {
|
||||
@NotNull final Ref<Integer> caretAdvance, @NotNull final DataContext dataContext,
|
||||
@Nullable final EditorActionHandler originalHandler);
|
||||
|
||||
/**
|
||||
* Called at the end of Enter handling after line feed insertion and indentation adjustment.
|
||||
* <p>
|
||||
* <b>Important Note: A document associated with the editor has modifications which are not reflected yet in the PSI file. If any
|
||||
* operations with PSI are needed including a search for PSI elements, the document must be committed first to update the PSI.
|
||||
* For example:</b>
|
||||
* <code><pre>
|
||||
* PsiDocumentManager.getInstance(file.getProject()).commitDocument(editor.getDocument);
|
||||
* </pre></code>
|
||||
*
|
||||
* @param file The PSI file associated with the document.
|
||||
* @param editor The document.
|
||||
* @param dataContext The data context passed to the Enter handler.
|
||||
* @return One of <code>{@link Result} values.</code>
|
||||
* @see DataContext
|
||||
* @see com.intellij.psi.PsiDocumentManager
|
||||
*/
|
||||
Result postProcessEnter(@NotNull PsiFile file, @NotNull Editor editor, @NotNull DataContext dataContext);
|
||||
}
|
||||
|
||||
@@ -369,6 +369,7 @@ public class PythonEnterHandler extends EnterHandlerDelegateAdapter {
|
||||
|
||||
private static void addGoogleDocStringSectionIndent(@NotNull PsiFile file, @NotNull Editor editor, int offset) {
|
||||
final Document document = editor.getDocument();
|
||||
PsiDocumentManager.getInstance(file.getProject()).commitDocument(document);
|
||||
final PsiElement element = file.findElementAt(offset);
|
||||
if (element != null) {
|
||||
// Insert additional indentation after section header in Google code style docstrings
|
||||
|
||||
Reference in New Issue
Block a user