String (@NotNull CustomTemplateCallback callback) { CharSequence result = ""; Editor editor = callback.getEditor(); CharSequence sequence = editor.getDocument().getImmutableCharSequence(); Collection<TextMateSnippet> availableSnippets = getAvailableSnippets(editor); for (TextMateSnippet snippet : availableSnippets) { CharSequence prefix = getPrefixForSnippet(sequence, editor.getCaretModel().getOffset(), snippet); if (prefix != null && prefix.length() > result.length()) { result = prefix; } } return !availableSnippets.isEmpty() ? result.toString() : null; }