How to find string line where cursor is
已回答
I have offset PlatformDataKeys.EDITOR.getData(e.dataContext).caretModel.offset that gives me offset from the beginning of the file.
I have val xmlFile = PsiManager.getInstance(project).findFile(file!!) as XmlFile.
How to use both of them to get the word or element where the cursor is and element?
请先登录再写评论。
xmlFile.findElementAt(offset) see also https://plugins.jetbrains.com/docs/intellij/psi-elements.html