public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement lookupElement) { PhpInsertHandlerUtil.insertStringAtCaret(context.getEditor(), "()"); context.getEditor().getCaretModel().moveCaretRelatively(-1, 0, false, false, true); String lookupString = lookupElement.getLookupString(); if(AnnotationIndex.getControllerAnnotations().containsKey(lookupString)) { String useStatement = AnnotationIndex.getControllerAnnotations().get(lookupString).getUse(); if(null != useStatement) { AnnotationUseImporter.insertUse(context, useStatement); } } }
public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement lookupElement) { // check this: // {{ form_javasc|() }} // {{ form_javasc| }} if(PhpInsertHandlerUtil.isStringAtCaret(context.getEditor(), "(")) { return; } String addText = "()"; PhpInsertHandlerUtil.insertStringAtCaret(context.getEditor(), addText); context.getEditor().getCaretModel().moveCaretRelatively(-1, 0, false, false, true); }
public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement lookupElement) { PsiElement psiElement = lookupElement.getPsiElement(); if(psiElement instanceof Method && needParameter((Method) psiElement)) { // check this: // {{ form_javasc|() }} // {{ form_javasc| }} if(PhpInsertHandlerUtil.isStringAtCaret(context.getEditor(), "(")) { return; } String addText = "()"; PhpInsertHandlerUtil.insertStringAtCaret(context.getEditor(), addText); context.getEditor().getCaretModel().moveCaretRelatively(-1, 0, false, false, true); } }
public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement lookupElement) { if(lookupElement.getObject() instanceof AnnotationValue) { String addText = "=\"\""; if(((AnnotationValue) lookupElement.getObject()).getType() == AnnotationValue.Type.Array) { addText = "={}"; } PhpInsertHandlerUtil.insertStringAtCaret(context.getEditor(), addText); } else { PhpInsertHandlerUtil.insertStringAtCaret(context.getEditor(), "=\"\""); } context.getEditor().getCaretModel().moveCaretRelatively(-1, 0, false, false, true); }
public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement lookupElement) { String insertText = null; if((lookupElement.getObject() instanceof PsiElement)) { return; } if((lookupElement.getObject() instanceof String)) { insertText = (String) lookupElement.getObject(); } if(insertText == null) { return; } // "<caret>", '<caret>' insertText = PsiElementUtils.trimQuote(insertText); if(!insertText.startsWith("%")) { context.getDocument().insertString(context.getStartOffset(), "%"); } // %| is also fired if(!insertText.endsWith("%") || insertText.length() == 1) { context.getDocument().insertString(context.getTailOffset(), "%"); context.getEditor().getCaretModel().moveCaretRelatively(1, 0, false, false, true); } }
@Override public void handleInsert(InsertionContext context, LookupElement lookupElement) { if(ResourceFileInsertHandler.isStringBeforeCaret(context.getEditor(), context, "'") || ResourceFileInsertHandler.isStringBeforeCaret(context.getEditor(), context, "\"")) { return; } int startOffset = context.getStartOffset(); context.getDocument().insertString(startOffset, "\""); context.getDocument().insertString(startOffset + lookupElement.getLookupString().length() + 1, "\""); // move to end context.getEditor().getCaretModel().moveCaretRelatively(1, 0, false, false, true); } }
context.getEditor().getCaretModel().moveCaretRelatively(-1, 0, false, false, true);
@Override public void handleInsert(@NotNull final InsertionContext context, @NotNull LookupElement item) { final Editor editor = context.getEditor(); int caretOffset = editor.getCaretModel().getOffset(); PsiElement targetElement = context.getFile().findElementAt(caretOffset); if (targetElement != null && targetElement.getNode().getElementType() == LEFT_PAREN) { return; } PsiElement subDefitnition = item.getPsiElement(); EditorModificationUtil.insertStringAtCaret(editor, "()"); // todo we need hint with prototype here, but prototypes handling NYI if (!(subDefitnition instanceof PerlSubDefinitionElement && ((PerlSubDefinitionElement)subDefitnition).getSubArgumentsList().isEmpty())) { editor.getCaretModel().moveCaretRelatively(-1, 0, false, false, true); } } }