Bug 255275

Summary: API request: Need an efficient way to get the ISourceRange of IMethod's return type
Product: [Eclipse Project] JDT Reporter: Min Idzelis <min123>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED INVALID QA Contact:
Severity: enhancement    
Priority: P3 CC: amj87.iitr, Olivier_Thomann, philippe_mulet, srikanth_sankaran
Version: 3.5   
Target Milestone: 3.6 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Min Idzelis CLA 2008-11-13 15:43:02 EST
Build ID: Eclipse 3.4

I am doing several tricky things to get the source range of an IMethod's return type. I needed to retrieve the range source of the method, and create a tokenizer/parser to ignore comments until I found the return type of the method. This is not trivial, as c/c++ comments can appear anywhere and are tricky to match correctly. 

Short of creating an AST on top of the IMethod (which I don't want to do for performance reasons), I would like to get the offset/length of the return type for a method. 

Similar to:

IMethod.getSourceRange()
IMethod.getJavadocRange()
IMethod.getNameRange()

Proposed method name: 
IMethod.getReturnTypeRange()
Comment 1 Philipe Mulet CLA 2008-11-14 05:42:06 EST
Note that you can create a lightweight DOM AST (without statements), performance is not so bad then.
Comment 2 Min Idzelis CLA 2008-11-14 09:40:43 EST
(In reply to comment #1)
> Note that you can create a lightweight DOM AST (without statements),
> performance is not so bad then.
> 

Can this be done using public API?
Comment 3 Philipe Mulet CLA 2008-11-14 11:55:13 EST
DOM AST is public API.
Comment 5 Olivier Thomann CLA 2010-01-22 13:07:29 EST
Is this still required ?
Comment 6 Min Idzelis CLA 2010-01-22 13:42:24 EST
(In reply to comment #5)
> Is this still required ?

The technique mentioned in comment 4 seem adequate. This bug can be closed.
Comment 7 Olivier Thomann CLA 2010-01-22 13:45:12 EST
Thanks.
Can be done using existing APIs.
See comment 4.

Closing as INVALID.
Comment 8 Ayushman Jain CLA 2010-01-25 05:46:09 EST
verified for 3.6M5.
Comment 9 Srikanth Sankaran CLA 2010-01-25 05:58:57 EST
Verified.