private void doInsert(InsertionContext context, @NotNull LookupElement item, @Nullable GoSignature signature) { int paramsCount = signature != null ? signature.getParameters().getParameterDeclarationList().size() : 0; InsertHandler<LookupElement> handler = paramsCount == 0 ? ParenthesesInsertHandler.NO_PARAMETERS : ParenthesesInsertHandler.WITH_PARAMETERS; handler.handleInsert(context, item); if (signature != null) { AutoPopupController.getInstance(context.getProject()).autoPopupParameterInfo(context.getEditor(), null); } } };
@Override public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { if (!(file instanceof GoFile)) { return; } String testingQualifier = null; if (myType.getParamType() != null) { testingQualifier = importTestingPackageIfNeeded((GoFile)file); PsiDocumentManager.getInstance(file.getProject()).doPostponedOperationsAndUnblockDocument(editor.getDocument()); } String functionText = "func " + myType.getPrefix(); int offset = functionText.length(); functionText += "(" + myType.getSignature(testingQualifier) + ") {\n\t\n}"; EditorModificationUtil.insertStringAtCaret(editor, functionText, false, offset); AutoPopupController.getInstance(project).scheduleAutoPopup(editor); }
@Override public void handleInsert(@NotNull InsertionContext context, LookupElement item) { Editor editor = context.getEditor(); int tailOffset = context.getTailOffset(); Document document = editor.getDocument(); context.commitDocument(); boolean staysAtChar = document.getTextLength() > tailOffset && document.getCharsSequence().charAt(tailOffset) == myChar; context.setAddCompletionChar(false); if (!staysAtChar) { document.insertString(tailOffset, String.valueOf(myChar)); } editor.getCaretModel().moveToOffset(tailOffset + 1); AutoPopupController.getInstance(context.getProject()).scheduleAutoPopup(editor); } }
@Override public void handleInsert(@NotNull InsertionContext context, LookupElement item) { Editor editor = context.getEditor(); int tailOffset = context.getTailOffset(); Document document = editor.getDocument(); context.commitDocument(); boolean staysAtChar = (document.getTextLength() > tailOffset) && (document.getCharsSequence().charAt(tailOffset) == myCharacter); context.setAddCompletionChar(false); if (!staysAtChar) { document.insertString(tailOffset, String.valueOf(myCharacter)); } editor.getCaretModel().moveToOffset(tailOffset + 1); AutoPopupController.getInstance(context.getProject()).scheduleAutoPopup(editor); } }
public void handleInsert(InsertionContext context, LookupElement item) { Editor editor = context.getEditor(); char completionChar = context.getCompletionChar(); if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) { return; } Project project = editor.getProject(); if (project != null) { int completionCharOffset = getCompletionCharOffset(editor); if (completionCharOffset == -1) { EditorModificationUtil.insertStringAtCaret(editor, ";", false, 1); PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); } else { editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1); } if (myTriggerAutoPopup) { AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null); } } }
public void handleInsert(InsertionContext context, LookupElement item) { Editor editor = context.getEditor(); char completionChar = context.getCompletionChar(); if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) { return; } Project project = editor.getProject(); if (project != null) { int completionCharOffset = getCompletionCharOffset(editor); if (completionCharOffset == -1) { EditorModificationUtil.insertStringAtCaret(editor, " {}", false, 2); PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); } else { editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1); } if (myTriggerAutoPopup) { AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null); } } }
public void handleInsert(InsertionContext context, LookupElement item) { Editor editor = context.getEditor(); char completionChar = context.getCompletionChar(); if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) { return; } Project project = editor.getProject(); if (project != null) { int completionCharOffset = getCompletionCharOffset(editor); if (completionCharOffset == -1) { EditorModificationUtil.insertStringAtCaret(editor, "()", false, 1); PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); } else { editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1); } if (myTriggerAutoPopup) { AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null); } } }
public void handleInsert(InsertionContext context, LookupElement item) { Editor editor = context.getEditor(); char completionChar = context.getCompletionChar(); if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) { return; } Project project = editor.getProject(); if (project != null) { int completionCharOffset = getCompletionCharOffset(editor); if (completionCharOffset == -1) { EditorModificationUtil.insertStringAtCaret(editor, "();", false, 1); PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); } else { editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1); } if (myTriggerAutoPopup) { AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null); } } }
public void handleInsert(InsertionContext context, LookupElement item) { Editor editor = context.getEditor(); char completionChar = context.getCompletionChar(); if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) { return; } Project project = editor.getProject(); if (project != null) { int completionCharOffset = getCompletionCharOffset(editor); if (completionCharOffset == -1) { EditorModificationUtil.insertStringAtCaret(editor, ":", false, 1); if (myWithSpace) { EditorModificationUtil.insertStringAtCaret(editor, " ", false, 1); } PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); } else { editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1); } if (myTriggerAutoPopup) { AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null); } } }
() -> AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null) );
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
@NotNull @Override public Result checkAutoPopup(char typedChar, @NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { int currentOffset = editor.getCaretModel().getOffset(); if (currentOffset > 0) { currentOffset--; } PsiElement element = file.findElementAt(currentOffset); if (element == null) { return super.checkAutoPopup(typedChar, project, editor, file); } IElementType elementType = PsiUtilCore.getElementType(element); if (typedChar == '>' && elementType == OPERATOR_MINUS || typedChar == ':' && elementType == COLON || typedChar == ' ' && (AUTO_OPENED_TOKENS.contains(elementType) || element.getParent() instanceof PsiPerlStringList) || typedChar == '{' && SIGILS.contains(elementType) || StringUtil.containsChar("$@%#", typedChar)) { AutoPopupController.getInstance(project).scheduleAutoPopup(editor); return Result.STOP; } return super.checkAutoPopup(typedChar, project, editor, file); } }
document.insertString(currentOffset, "::"); caretModel.moveToOffset(currentOffset + 2); AutoPopupController.getInstance(project).scheduleAutoPopup(editor); return Result.STOP;
AutoPopupController.getInstance(project).scheduleAutoPopup(editor); AutoPopupController.getInstance(project).scheduleAutoPopup(editor, CompletionType.BASIC, psiFile -> { PsiElement newElement = psiFile.findElementAt(offset); return PsiUtilCore.getElementType(newElement) == elementTokenType &&
PsiDocumentManager.getInstance(project).commitDocument(document); CodeStyleManager.getInstance(project).reformatText(file, reformatFrom, offset + 2); AutoPopupController.getInstance(project).scheduleAutoPopup(editor);