PsiElement (PsiFile file, int caretOffset) { PsiElement stringElement = file.findElementAt(caretOffset - 1); if (stringElement == null) return null; ASTNode node = stringElement.getNode(); if (node == null) return null; // For expression injection in GString like "abc ${}<caret> abc" if (!INNER_STRING_TOKENS.contains(node.getElementType()) && checkGStringInjection(stringElement)) { stringElement = stringElement.getParent().getParent().getNextSibling(); if (stringElement == null) return null; } return stringElement; }