I am trying to write an eclipse plugin which highlights some text in java editor after user save the text (ResourceChangeListener). I am implementing ILightweightLabelDecorator and extending BaseLabelProvider, The method
public void decorate(Object arg0, IDecoration arg1)
getting called but I am getting Objects of type org.eclipse.jdt.internal.core.* e.g org.eclipse.jdt.internal.core.PackageDeclaration. I need line numbers from that object so I can highlight that text. ASTNode object has a property to get the position (line numbers) but I am not getting that one. How can I get ASTNode from org.eclipse.jdt.internal.core.* objects?
Thanks in advance.
PackageDeclaration
is part of the JDT Java Model which is a lighter weight version of the AST used by a lot of the Java code. As such it isn't related to ASTNode
.
Many Java Model objects (including PackageDeclaration
) implement ISourceReference
which tells you about the source code. This includes getSource
and getSourceRange
methods.