Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 302854

Summary: API promotion for JavaEditor (internal -> public)
Product: [Eclipse Project] JDT Reporter: Gabriel BARBIER <barbier.gabriel>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: enhancement    
Priority: P3 CC: daniel_megert, remy.suen
Version: 3.6   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Gabriel BARBIER CLA 2010-02-15 08:52:21 EST
Hello,

In MoDisco project, we are using some methods from org.eclipse.jdt.internal.ui.javaeditor.JavaEditor to 
select a specific element of AST in an opened editor.

This class is considered as internal, so I would like
to ask for its promotion as public. It is mainly
to avoid use of @SuppressWarnings("restriction") as 
required to join the Helios train.


Example of usage:
((JavaEditor) result).setSelection(method);

Used by components:
- org.eclipse.gmt.modisco.java.discoverer
- org.eclipse.gmt.modisco.usecase.modelfilter.methodcalls

Best regards
Gabriel
Comment 1 Remy Suen CLA 2010-02-15 09:34:22 EST
Could you not instead analyze the IJavaElement and then ask the editor's selection provider to select the range of text in question?
Comment 2 Gabriel BARBIER CLA 2010-02-15 09:49:58 EST
(In reply to comment #1)
> Could you not instead analyze the IJavaElement and then ask the editor's
> selection provider to select the range of text in question?

Hello,
We are using a model of the java application (not the text) and we have not the information of location (line, range ...).
So if you have a tip to retrieve the range (and the length) from a jdt element, I guess I could use following method:

/**
 * Selects and reveals the specified range in this text editor.
 *
 * @param offset the offset of the selection
 * @param length the length of the selection
 */
void selectAndReveal(int offset, int length);
Comment 3 Remy Suen CLA 2010-02-15 09:58:49 EST
(In reply to comment #2)
> We are using a model of the java application (not the text) and we have not the
> information of location (line, range ...).

An IJavaElement may be an ISourceReference. You can query for location
information from there.

Looking at JavaEditor's setSelection(IJavaElement) implementation may provide
you with some hints.
Comment 4 Remy Suen CLA 2010-02-15 09:59:22 EST
Whoops, that conflict didn't work out well.
Comment 5 Dani Megert CLA 2010-02-15 10:00:36 EST
See methods in org.eclipse.jdt.ui.JavaUI.
Comment 6 Gabriel BARBIER CLA 2010-02-15 10:51:55 EST
Thanks for your help. JavaUI fit perfectly.

Gabriel