Result (char c, int prefixLength, Lookup lookup) { final PsiFile psiFile = lookup.getPsiFile(); if (psiFile != null && !psiFile.getViewProvider().getLanguages().contains(GroovyLanguage.INSTANCE)) return null; LookupElement item = lookup.getCurrentItem(); if (item == null) return null; if (Character.isJavaIdentifierPart(c) || c == '\'') { return Result.ADD_TO_PREFIX; } int caret = lookup.getEditor().getCaretModel().getOffset(); if (c == '.' && prefixLength == 0 && !lookup.isSelectionTouched() && caret > 0 && lookup.getEditor().getDocument().getCharsSequence().charAt(caret - 1) == '.') { return Result.HIDE_LOOKUP; } if (c == ':') { PsiFile file = lookup.getPsiFile(); PsiDocumentManager.getInstance(file.getProject()).commitDocument(lookup.getEditor().getDocument()); PsiElement element = file.findElementAt(Math.max(caret - 1, 0)); if (PsiJavaPatterns.psiElement().withParent( PsiJavaPatterns.psiElement(GrReferenceExpression.class).withParent( PsiJavaPatterns.psiElement(GrConditionalExpression.class))).accepts(element)) { return Result.SELECT_ITEM_AND_FINISH_LOOKUP; } if (item.getObject() instanceof NamedArgumentDescriptor && (MapArgumentCompletionProvider.IN_ARGUMENT_LIST_OF_CALL.accepts(element) || MapArgumentCompletionProvider.IN_LABEL.accepts(element))) { return Result.SELECT_ITEM_AND_FINISH_LOOKUP; } return Result.HIDE_LOOKUP; } if (c == '[' || c == ']' || c == ')' || c == '>') return CharFilter.Result.SELECT_ITEM_AND_FINISH_LOOKUP; if (c == '<' && item.getObject() instanceof PsiClass) return Result.SELECT_ITEM_AND_FINISH_LOOKUP; if (c == '(' && PsiKeyword.RETURN.equals(item.getLookupString())) { return Result.HIDE_LOOKUP; } return null; }