org.eclipse.jdt.core.IField
IField field = IType.createField(contents, null, true, null);
How to get the line number of field?
Mark
8,47115 gold badges52 silver badges81 bronze badges
1 Answer 1
You can get the line number of an ASTNode using the below code
ASTNode node = compilationUnit.findDeclaringNode(field.getKey());
int lineNumber = compilationUnit.getLineNumber(node.getStartPosition()) - 1;
Note that this will work only if the bindings are resolved.
Refer the below links for more details:
answered Sep 26, 2013 at 9:41
Unni Kris
3,1034 gold badges39 silver badges58 bronze badges