Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » On ASTParser:May I parser only part of the file
On ASTParser:May I parser only part of the file [message #253030] Mon, 28 April 2008 08:19 Go to next message
Eclipse UserFriend
Originally posted by: reg.zhuce.163.com

May I set the Root of ASTNode to parser by location,say,offset and length?
I only want to parser a line of code.I think I can use ASTVisitor,but
ASTVisitor seems to start at the very beginning of the CompilationUnit
every time.
Any suggestions?
Re: On ASTParser:May I parser only part of the file [message #253066 is a reply to message #253030] Tue, 29 April 2008 08:25 Go to previous messageGo to next message
Eclipse UserFriend
dazh a écrit :
> May I set the Root of ASTNode to parser by location,say,offset and length?
> I only want to parser a line of code.I think I can use ASTVisitor,but
> ASTVisitor seems to start at the very beginning of the CompilationUnit
> every time.
> Any suggestions?
You can use ASTParser.setFocalPosition(..).
This will however scan all statements within a method.

If you want to use this method, you should take the upcoming 3.4M7
build. Two issues have been fixed with this method.
--
Olivier
Re: On ASTParser:May I parser only part of the file [message #253078 is a reply to message #253066] Tue, 29 April 2008 10:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: reg.zhuce.163.com

What does setSourceRange(..) mean?
Is it relative to this problem?
Olivier Thomann 写道:
> dazh a écrit :
>> May I set the Root of ASTNode to parser by location,say,offset and length?
>> I only want to parser a line of code.I think I can use ASTVisitor,but
>> ASTVisitor seems to start at the very beginning of the CompilationUnit
>> every time.
>> Any suggestions?
> You can use ASTParser.setFocalPosition(..).
> This will however scan all statements within a method.
>
> If you want to use this method, you should take the upcoming 3.4M7
> build. Two issues have been fixed with this method.
> --
> Olivier
Re: On ASTParser:May I parser only part of the file [message #253103 is a reply to message #253078] Tue, 29 April 2008 17:02 Go to previous message
Eclipse UserFriend
dazh a écrit :
> What does setSourceRange(..) mean?
> Is it relative to this problem?
No, setSourceRange(...) is called for you by the parser.
--
Olivier
Previous Topic:Hide/disable Package Explorer actions?
Next Topic:RunnableJar Feature in 3.4M4
Goto Forum:
  


Current Time: Tue Jul 22 16:16:33 EDT 2025

Powered by FUDForum. Page generated in 0.03183 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top