|
13 | 13 | * See the License for the specific language governing permissions and |
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | | - |
17 | 16 | package com.jetbrains.python.impl.editor; |
18 | 17 |
|
| 18 | +import com.jetbrains.python.PythonLanguage; |
| 19 | +import consulo.annotation.access.RequiredReadAction; |
19 | 20 | import consulo.annotation.component.ExtensionImpl; |
20 | | -import consulo.ide.impl.idea.codeInsight.editorActions.enter.EnterBetweenBracesHandler; |
21 | | -import consulo.dataContext.DataContext; |
22 | 21 | import consulo.codeEditor.Editor; |
23 | 22 | import consulo.codeEditor.action.EditorActionHandler; |
24 | | -import consulo.util.lang.ref.Ref; |
| 23 | +import consulo.dataContext.DataContext; |
| 24 | +import consulo.ide.impl.idea.codeInsight.editorActions.enter.EnterBetweenBracesHandler; |
25 | 25 | import consulo.language.psi.PsiFile; |
26 | | -import com.jetbrains.python.PythonLanguage; |
| 26 | +import consulo.util.lang.ref.SimpleReference; |
27 | 27 | import jakarta.annotation.Nonnull; |
28 | 28 |
|
29 | 29 | /** |
30 | 30 | * @author yole |
31 | 31 | */ |
32 | 32 | @ExtensionImpl |
33 | 33 | public class PyEnterBetweenBracketsHandler extends EnterBetweenBracesHandler { |
34 | | - @Override |
35 | | - public Result preprocessEnter(@Nonnull PsiFile file, |
36 | | - @Nonnull Editor editor, |
37 | | - @Nonnull Ref<Integer> caretOffsetRef, |
38 | | - @Nonnull Ref<Integer> caretAdvance, |
39 | | - @Nonnull DataContext dataContext, |
40 | | - EditorActionHandler originalHandler) { |
41 | | - if (!file.getLanguage().is(PythonLanguage.getInstance())) { |
42 | | - return Result.Continue; |
| 34 | + @Override |
| 35 | + @RequiredReadAction |
| 36 | + public Result preprocessEnter( |
| 37 | + @Nonnull PsiFile file, |
| 38 | + @Nonnull Editor editor, |
| 39 | + @Nonnull SimpleReference<Integer> caretOffsetRef, |
| 40 | + @Nonnull SimpleReference<Integer> caretAdvance, |
| 41 | + @Nonnull DataContext dataContext, |
| 42 | + EditorActionHandler originalHandler |
| 43 | + ) { |
| 44 | + if (!file.getLanguage().is(PythonLanguage.getInstance())) { |
| 45 | + return Result.Continue; |
| 46 | + } |
| 47 | + return super.preprocessEnter(file, editor, caretOffsetRef, caretAdvance, dataContext, originalHandler); |
43 | 48 | } |
44 | | - return super.preprocessEnter(file, editor, caretOffsetRef, caretAdvance, dataContext, originalHandler); |
45 | | - } |
46 | 49 |
|
47 | | - @Override |
48 | | - protected boolean isBracePair(char c1, char c2) { |
49 | | - return c1 == '[' && c2 == ']'; |
50 | | - } |
| 50 | + @Override |
| 51 | + protected boolean isBracePair(char c1, char c2) { |
| 52 | + return c1 == '[' && c2 == ']'; |
| 53 | + } |
51 | 54 | } |
0 commit comments