int caretOffset = parameters.getOffset();
if (file.findElementAt(caretOffset) instanceof PsiComment) return;
LeafPsiElement leafBeforeCaret = PsiUtil.lookupLeafBeforeOffset(file, caretOffset);
int invocationCount = parameters.getInvocationCount();
if (invocationCount > 1) context.setExtended(true);
if (leafBeforeCaret == null) {
ElementTypeBundle elementTypeBundle = file.getElementTypeBundle();
Set<LeafElementType> firstPossibleLeafs = elementTypeBundle.getRootElementType().getLookupCache().getFirstPossibleLeafs();
for (LeafElementType firstPossibleLeaf : firstPossibleLeafs) {
if (firstPossibleLeaf instanceof TokenElementType) {
TokenElementType tokenElementType = (TokenElementType) firstPossibleLeaf;
if (context.getCodeCompletionFilterSettings().acceptReservedWord(tokenElementType.getTokenTypeCategory())) {
LookupItemFactory lookupItemFactory = tokenElementType.getLookupItemFactory(language);
lookupItemFactory.createLookupItem(tokenElementType, consumer);
}
}
}
} else {
leafBeforeCaret = (LeafPsiElement) leafBeforeCaret.getOriginalElement();
try {
buildElementRelativeVariants(leafBeforeCaret, consumer);
} catch (ConsumerStoppedException e) {
}