private static void addCompletionChar( Project project, CompletionAssertions.WatchingInsertionContext context, LookupElement item, Editor editor, CompletionProgressIndicator indicator, char completionChar) { int tailOffset = context.getTailOffset(); if (tailOffset < 0) { LOG.info( "tailOffset<0 after inserting " + item + " of " + item.getClass() + "; invalidated at: " + context.invalidateTrace + "\n--------"); } else { editor.getCaretModel().moveToOffset(tailOffset); } if (context.getCompletionChar() == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) { final Language language = PsiUtilBase.getLanguageInEditor(editor, project); if (language != null) { for (SmartEnterProcessor processor : SmartEnterProcessors.INSTANCE.forKey(language)) { if (processor.processAfterCompletion(editor, indicator.getParameters().getOriginalFile())) break; } } } else if (!editor .getCaretModel() .supportsMultipleCarets()) { // this will be done outside of runForEach caret context DataContext dataContext = DataManager.getInstance().getDataContext(editor.getContentComponent()); EditorActionManager.getInstance() .getTypedAction() .getHandler() .execute(editor, completionChar, dataContext); } }
@Override protected void reformat(PsiElement atCaret) throws IncorrectOperationException { PsiElement parent = atCaret.getParent(); if (parent instanceof GrCodeBlock) { final GrCodeBlock block = (GrCodeBlock) parent; if (block.getStatements().length > 0 && block.getStatements()[0] == atCaret) { atCaret = block; } } else if (parent instanceof GrForStatement) { atCaret = parent; } super.reformat(atCaret); }
@Override public void commit(@NotNull Editor editor) { // pull up super.commit(editor); }