ASTVisitor - geting line number of MethodDeclaration [message #758386] |
Wed, 23 November 2011 00:42 |
Eiji Adachi Messages: 8 Registered: November 2011 |
Junior Member |
|
|
I am implementing a parser with ASTVisitor and I want to store the initial and last line number (or offset from the initial line) of a method declaration.
i get the initial position:
final int startPosition = methodDeclaration.getStartPosition();
Then i get the offset:
final int offSet = methodDeclaration.getLength();
Then I try to retrieve this snippet by reading it directly from the source code:
final Reader in = new FileReader( "/workspace/Teste/src/Main.java" );
final BufferedReader reader = new BufferedReader( in );
reader.skip( startPosition );
final char[] buf = new char[3000];
reader.read( buf, 0, offSet );
The problem seems to be with my offset. Does anybody knows what am I doing wrong?
[Updated on: Wed, 23 November 2011 00:43] Report message to a moderator
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03939 seconds