boolean (CompletionParameters parameters) { if (parameters.getInvocationCount() == 0) { return false; } if (Boolean.TRUE.equals(parameters.getOriginalFile().getUserData(BaseCompletionService.FORBID_WORD_COMPLETION))) { return false; } PsiElement insertedElement = parameters.getPosition(); PsiFile file = insertedElement.getContainingFile(); if (isWordCompletionDefinitelyEnabled(file)) { return true; } final CompletionData data = CompletionUtil.getCompletionDataByElement(insertedElement, file); if (data != null) { Set<CompletionVariant> toAdd = new HashSet<>(); data.addKeywordVariants(toAdd, insertedElement, file); for (CompletionVariant completionVariant : toAdd) { if (completionVariant.hasKeywordCompletions()) { return false; } } } final int startOffset = parameters.getOffset(); final PsiReference reference = file.findReferenceAt(startOffset); if (reference != null) { return false; } final PsiElement element = file.findElementAt(startOffset - 1); ASTNode textContainer = element != null ? element.getNode() : null; while (textContainer != null) { if (LanguageWordCompletion.INSTANCE.isEnabledIn(textContainer.getElementType())) { return true; } textContainer = textContainer.getTreeParent(); } return false; }