void (CompletionResultSet result, CompletionParameters parameters, final Set<String> realExcludes, PsiElement position) { ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(position.getLanguage()); if (definition == null) { return; } final ElementPattern<PsiElement> pattern = psiElement().withElementType(definition.getStringLiteralElements()); final PsiElement localString = PsiTreeUtil.findFirstParent(position, false, element -> pattern.accepts(element)); if (localString == null) { return; } ElementManipulator<PsiElement> manipulator = ElementManipulators.getManipulator(localString); if (manipulator == null) { return; } int valueStart = manipulator.getRangeInElement(localString).getStartOffset() + localString.getTextRange().getStartOffset(); if (valueStart > parameters.getOffset()) { return; } PsiFile file = position.getContainingFile(); String prefix = file.getViewProvider().getContents().subSequence(valueStart, parameters.getOffset()).toString(); CompletionResultSet fullStringResult = result.withPrefixMatcher(new PlainPrefixMatcher(prefix)); file.accept(new PsiRecursiveElementWalkingVisitor() { @Override public void visitElement(@NotNull PsiElement element) { if (element == localString) { return; } if (pattern.accepts(element)) { element.accept(new PsiRecursiveElementWalkingVisitor() { @Override public void visitElement(@NotNull PsiElement each) { String valueText = ElementManipulators.getValueText(each); if (StringUtil.isNotEmpty(valueText) && !realExcludes.contains(valueText)) { final LookupElement item = createWordSuggestion(valueText); fullStringResult.addElement(item); } } }); return; } super.visitElement(element); } }); }