Maven: How I get line number for maven file given the dependency? highlight dependency directly?


Currently I use MavenXpp3Reader to get the dependencies from maven file.

I wonder can I get the line num of the <groupId> for each dependency directly according to the dependency instance? My goal is to highlight the line of <groupId> so that is why I want to know the line number.

MavenXpp3Reader Xpp3Reader = new MavenXpp3Reader();

Model model = FileReader(path));

List<Dependency> dependencies = model.getDependencies();


Comment actions Permalink

Maven plugin uses DOM Model ( under the hood, see community/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom in IJ Community sources.

Your plugin can provide com.intellij.util.xml.highlighting.BasicDomElementsInspection to add additional highlighting for any element in the editor.

Comment actions Permalink

Thank you Yann. I use PSI structure now, because PsiNodes can easily be turned into line numbers using `Document.getLineNumber(ASTNode)` ( the project also want to highlight in java file. Is that a way I can do with PSI structure? look like XML DOM model is under PSI section


Please sign in to leave a comment.