Bug 54900 - [rulers] Java Editor does not show ruler on external Java files
Summary: [rulers] Java Editor does not show ruler on external Java files
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M5   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
: 81182 95254 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-03-15 16:15 EST by Wassim Melhem CLA
Modified: 2006-01-05 08:42 EST (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wassim Melhem CLA 2004-03-15 16:15:53 EST
We ran into this problem while investigating solutions for bug 54898.

If you open an external Java file using the Java editor, you don't get the 
ruler.  So if you set breakpoints in the file, you won't see the breakpoints 
in the editor.  They will only show up in the Breakpoints view, thus making 
the debugging experience much harder.
Comment 1 Wassim Melhem CLA 2004-04-30 02:06:54 EDT
Is this one going to be fixed in 3.0?
Comment 2 Dani Megert CLA 2004-04-30 05:05:45 EDT
We might fix this during the bug fixing phase (time permitting) but before we
need to agree with Debug how/where breakpoint information is stored for
non-resources.
Comment 3 Wassim Melhem CLA 2004-06-04 10:55:37 EDT
Although this bug was not marked as fixed, I was recently pleasantly suprised 
to see that I can set breakpoints on an external Java file without problems.  
Dani, did you fix this or was it divine intervention?
Comment 4 Dani Megert CLA 2004-06-04 11:03:58 EDT
no ruler yet. you probably selected a file that's already inside your workspace.
Comment 5 Wassim Melhem CLA 2004-06-04 11:16:26 EDT
This problem also used to occur in any of the libraries referenced by 
the "External Plug-ins Libraries" project that gets created by PDE when you 
add external plug-ins to the Java search.

This problem is now gone for some reason.  Since nothing was done at your end, 
I'm guessing that the new implementation of the "Add to Java Search" 
functionality by PDE that is now based on containers may have inadvertently 
alleviate the problem.
Comment 6 Kai-Uwe Maetzel CLA 2004-06-07 03:35:12 EDT
no action for 3.0
Comment 7 Spike CLA 2004-11-08 23:51:00 EST
I've run into this one recently working on the cfeclipse plugin.

We've got a view that allows you to open files that are in the local filesystem,
or on a remote FTP server.

The lack of a vertical ruler is a bit of a PITA because folding doesn't work
without it.

I've already created an ExternalFile class that implements IFile, but I'm not
totally sure what it is that kills the vertical ruler.

Any pointers on what custom stuff I might need to add would be appreciated.
Comment 8 Dani Megert CLA 2004-11-09 09:35:15 EST
>I've already created an ExternalFile class that implements IFile, but I'm not
>totally sure what it is that kills the vertical ruler.
Please note that IFile is not intended to be subclassed and hence you might into
trouble at several places.
Comment 9 Ed Burnette CLA 2004-11-09 10:09:54 EST
How did the ant editor get error and warning annotations to work in external 
files in 3.1M3? Isn't that a similar problem?
Comment 10 Dani Megert CLA 2004-11-09 10:16:29 EST
The Java model does not work on/with external files and hence no problem
reporting and no model operations e.g. to get the folding structure are
possible. The Ant plug-in (model) probably (I did not check) accepts non-IFiles
and can therefore generate problem annotations and structural info and hence it
makes sense to show the ruler(s).
Comment 11 Spike CLA 2004-11-09 12:15:16 EST
Thanks Daniel,

I'm aware that IFile isn't supposed to be subclassed. Right now I'm
investigating how the internals work to see if there's any way I can get the
vertical ruler to come up. Once I have a handle on that I can hopefully see what
it would take to do it 'properly' and decide if it's worth the effort.

I'm happy enough not to have full support for model operations, but folding and
line numbers would be pretty nice.
Comment 12 Spike CLA 2004-11-09 14:00:32 EST
I've got the ruler and folding stuff working now with external files.

The solution for anyone who wants to know was to create 3 new classes.
ExternalAnnotationModel, ExternalMarker and ExternalFile. The model extends
org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel and replicates most of
org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel. ExternalMarker
implements org.eclipse.core.resources.IMarker. It doesn't actually do anything
in any of the methods, but an instance is returned by
ExternalFile.createMarker(). ExternalFile extends
org.eclipse.core.internal.resources.File. You're not supposed to do that and it
may cause some bad things to happen, but other than that it works.

If I could find a way to do it without needing to use File or something else
you're not supposed to subclass, I'd be a happy man.
Comment 13 Darin Wright CLA 2004-12-17 12:07:59 EST
*** Bug 81182 has been marked as a duplicate of this bug. ***
Comment 14 Wassim Melhem CLA 2005-02-10 22:24:39 EST
Dani, what are the prospects of this issue being addressed for 3.1?

This one is vital to the success of the new source lookup for debugging 
Eclipse applications (bug 65164)
Comment 15 Dani Megert CLA 2005-02-11 02:11:25 EST
Wassim, there are really two cases here

1) open an external Java file which for us means it is a *.java file, a *.class
file or a *.jar which is not inside the workspace and not on the Java buildpath
of a project. That's what this bug report is about.

2) stuf which is on the Java build path of a project (e.g. rt.jar) where the
ruler is shown (if not it's different bug) and breakpoints can be set.

Wassim, are you talking about case 1 or 2? Can you provide a step by step
example/setup for the PDE problem?

Showing the ruler is not the problem - the problem is to know where we have to
get the annotations from. Darin, is Wassim's case supported and if so, where
does Debug attach the breakpoints?
Comment 16 Wassim Melhem CLA 2005-02-11 09:04:01 EST
I am certainly talking about case 1.

In Monday's build, we will release an SWT launcher which will clearly 
demonstrate the problem and will provide steps then.
Comment 17 Darin Wright CLA 2005-02-11 10:23:17 EST
The Java debugger supports breakpoints in files that are not contained in the 
workspace. In this case we assocaite the breakpoints with the Workspace Root 
resource.

However, I just found that our support for breakpoint creation in external 
files is broken which is a regression that will need to be fixed :-(
Comment 18 Wassim Melhem CLA 2005-02-19 13:12:39 EST
Dani, let me give you a scenario using M5 on Windows:

1. Fresh workspace.
2. Check out org.eclipse.swt.snippets from HEAD.
3. swt.snippets comes in the form of a plugin which uses a PDE container.  
That is not the case for regular SWT projects.  So go the Java Build 
Properties and remove the PDE container.  Now also manually add the swt.jar to 
the project's classpath.  It is located in the 
<eclipse_install>/plugins/org.eclipse.swt.win32_3.1.0/ws/win32/swt.jar.

4. DO NOT ATTACH SOURCE to swt.jar.  (I doubt that you can locate the source 
for it anyways, since it is deeply hidden in another location ;-)

5. In the org.eclipse.swt.snippets package, open the Snippet101 java file and 
set a breakpoint on the fourth line in Main (table.setSize(...))

6. Right-click on Snippet101.java and from the context menu: Debug > Debug As 
> SWT Application.

7. When you hit the breakpont from 5.  Try to step into Table.setSize()

8. you will see that even though swt.jar has no source attached to it in the 
workspace, the launcher was smart enough to locate the source on the fly, and 
the debugger knew where to stop etc.
I can do all the debug operations (step in/over, etc.) The only problem here 
is that there is no ruler.  I can't set breakpoints.

By extrapolation, we are planning on redoing the source lookup for debugging 
Eclipse applications in a similar way (bug 65164), so this ruler issue is a 
problem.
Comment 19 Darin Wright CLA 2005-05-14 11:25:53 EDT
*** Bug 95254 has been marked as a duplicate of this bug. ***
Comment 20 Dani Megert CLA 2006-01-05 08:17:16 EST
Fixed in HEAD.
Available in builds > N20060105-0010.

The rulers (vertical, diff, line number and folding) are now there but looks as if it is not be possible to add breakpoints: as far as I can see this is not supported by Debug (note: the instruction pointer appears). Darin, is this true? See also bug 122743.

NOTE:
In my opinion the correct way to solve this issue is to find the source and actually attach it to the JAR. Then open the file. Why isn't it done that why? I'd assume that if the user can attach the source manually and PDE can find the source (as comment 18 proves) this should be doable.
Comment 21 Darin Wright CLA 2006-01-05 08:42:40 EST
We do support breakpoints in external files, but it was recently broken by disallowing breakpoints in remote files. See bug 120170.