void (CompletionParameters parameters, GroovyCompletionConsumer consumer) { PsiElement position = parameters.getPosition(); PsiElement parent = position.getParent(); if (parent instanceof GrLiteral) { return; } if (STATEMENT_START.accepts(position)) { consumer.consume(LookupElementBuilder.create("if").bold().withInsertHandler(new InsertHandler<>() { @Override public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement item) { if (context.getCompletionChar() != ' ') { JavaTailTypes.IF_LPARENTH.processTail(context.getEditor(), context.getTailOffset()); } if (context.getCompletionChar() == '(') { context.setAddCompletionChar(false); } } })); } final String[] extendsImplements = addExtendsImplements(position); for (String keyword : extendsImplements) { consumer.consume(keyword(keyword, TailTypes.humbleSpaceBeforeWordType())); } if (extendsImplements.length > 0) { return; } if (parent instanceof GrExpression && parent.getParent() instanceof GrAnnotationNameValuePair) { addKeywords(consumer, false, PsiKeyword.TRUE, PsiKeyword.FALSE, PsiKeyword.NULL); return; } if (afterAtInType(position)) { consumer.consume(keyword(PsiKeyword.INTERFACE, TailTypes.humbleSpaceBeforeWordType())); } if (!psiElement().afterLeaf(".", ".&", "@", "*.", "?.").accepts(position)) { if (afterAbstractMethod(position, false, true)) { consumer.consume(keyword(PsiKeyword.THROWS, TailTypes.humbleSpaceBeforeWordType())); if (afterAbstractMethod(position, false, false)) return; } if (suggestPackage(position)) { consumer.consume(keyword(PsiKeyword.PACKAGE, TailTypes.humbleSpaceBeforeWordType())); } if (suggestImport(position)) { consumer.consume(keyword(PsiKeyword.IMPORT, TailTypes.humbleSpaceBeforeWordType())); } addTypeDefinitionKeywords(consumer, position); if (isAfterAnnotationMethodIdentifier(position)) { consumer.consume(keyword(PsiKeyword.DEFAULT, TailTypes.humbleSpaceBeforeWordType())); } addExtendsForTypeParams(position, consumer); registerControlCompletion(position, consumer); if (parent instanceof GrExpression || isInfixOperatorPosition(position)) { addKeywords(consumer, false, PsiKeyword.TRUE, PsiKeyword.FALSE, PsiKeyword.NULL, PsiKeyword.SUPER, PsiKeyword.THIS); consumer.consume(keyword(PsiKeyword.NEW, TailTypes.humbleSpaceBeforeWordType())); if (GroovyConfigUtils.isAtLeastGroovy40(position)) { consumer.consume(keyword(PsiKeyword.SWITCH, JavaTailTypes.SWITCH_LPARENTH)); } } if (isAfterForParameter(position)) { consumer.consume(keyword("in", TailTypes.humbleSpaceBeforeWordType())); } if (isInfixOperatorPosition(position)) { addKeywords(consumer, true, "as", "in", PsiKeyword.INSTANCEOF); } if (suggestPrimitiveTypes(position)) { final boolean addSpace = !IN_CAST_TYPE_ELEMENT.accepts(position) && !GroovySmartCompletionContributor.AFTER_NEW.accepts(position) && !isInExpression(position); addKeywords(consumer, addSpace, BUILT_IN_TYPES); } if (GroovyConfigUtils.isAtLeastGroovy40(position) && PsiJavaPatterns.psiElement(GrReferenceExpression.class).inside( PsiJavaPatterns.psiElement(GrCaseSection.class)).accepts(parent)) { addKeywords(consumer, true, PsiKeyword.YIELD); } if (PsiJavaPatterns.psiElement(GrReferenceExpression.class).inside( StandardPatterns.or(PsiJavaPatterns.psiElement(GrWhileStatement.class), PsiJavaPatterns.psiElement(GrForStatement.class))).accepts(parent)) { addKeywords(consumer, false, PsiKeyword.BREAK, PsiKeyword.CONTINUE); } else if (PsiJavaPatterns.psiElement(GrReferenceExpression.class).inside(GrCaseSection.class).accepts(parent)) { addKeywords(consumer, false, PsiKeyword.BREAK); } if (PsiJavaPatterns.psiElement().withSuperParent(2, GrImportStatement.class).accepts(position)) { if (PsiJavaPatterns.psiElement().afterLeaf(PsiKeyword.IMPORT).accepts(position)) { addKeywords(consumer, true, PsiKeyword.STATIC); } } else { if (suggestModifiers(position)) { addModifiers(position, consumer); } if (PsiJavaPatterns.psiElement().afterLeaf(MODIFIERS).accepts(position) || GroovyCompletionUtil.isInTypeDefinitionBody(position) && GroovyCompletionUtil.isNewStatement(position, true)) { addKeywords(consumer, true, PsiKeyword.SYNCHRONIZED); } if (suggestFinalDef(position) || PsiJavaPatterns .psiElement().afterLeaf(PsiJavaPatterns.psiElement().withText("(").withParent(GrForStatement.class)).accepts(position)) { addKeywords(consumer, true, PsiKeyword.FINAL, "def"); } } } }