Monday, April 25, 2011

Evaluating expressions in JDT Debugger


You can use the Display View to type in an expression and evaluate it in the context of the current stack frame. (The name Display is not great - see bug 342144).

- Use content assist to type expressions

- Select the expression and use Ctrl+Shift+I (Inspect) to show the result in a pop-up. You can also invoke the Inspect command from the context menu.

- Press Ctrl+Shift+I again to persist the result in the Expressions view.

See also Eclipse help.

Tuesday, March 8, 2011

JDT at EclipseCon 2011


Raksha Vasisht and I will be speaking at EclipseCon 2011 in Santa Clara. We have the following 2 talks

What's new in JDT
Monday, March 21 14:00 - 14:20, Stevens Creek

JDT - Tips and Tricks
Tuesday, March 22 14:00 - 14:20, Stevens Creek

We are also organizing a Bof
Eclipse - Tips and Tricks
Wednesday, March 23 19:30, Sonoma

See you soon at EclipseCon !

Sunday, February 6, 2011

JDT 3.7 M5 - New and Noteworthy

This time there are a bunch of interesting items in the debug area

There is now a history for recently used breakpoint conditions:

The global history shows the saved conditions across all conditional breakpoints, while the local history shows the history of one particular breakpoint.

In the Java editor, if you delete a breakpoint that has a condition set on it, you will now be prompted before the breakpoint gets deleted:

You can specify that you would not like to be notified again when trying to remove a conditional breakpoint. This can later be changed again via Prompt for confirmation when deleting a conditional breakpoint from editor on the Java > Debug preference page.


If you accidentally removed a breakpoint from the editor's vertical ruler or the Breakpoints view, you can now get it back using the standard undo functionality - Edit > Undo Delete Breakpoint (Ctrl+Z) - in the Breakpoints view or any other view that works against the global undo history.


The Add missing case statements quick assist is now available in the body of the switch statement:


The Quick Outline shows inherited members of top-level types when Ctrl+O is pressed twice. Now, it also shows inherited members of the type that contains the current editor selection:


The focus types that can show inherited members are marked with a triangle.


Two new compiler options have been added that mark methods which can be made static because they only refer to static members.


The first option marks private and final methods than can always be made static. The second option also marks other methods. Note that methods can be overridden in a subclass, so if you make a "potentially static" method static, this may break existing clients. These options are disabled by default.

Another interesting feature in the SDK is detached editors. This can be really useful in a dual monitor setup.

 Though while trying this out I 'lost' a couple of editors before filing Bug 336391

Monday, December 13, 2010

JDT 3.7 M4 - New and Noteworthy

This time there are a bunch of interesting items in the quick assist (Ctrl+1) area

The Introduce new local with cast type quick assist is now not only available on the instanceof keyword, but also in the body of the conditional statement (before the first body statement).


The Join variable declaration quick assist is now also available for variables initialized to null.


The Exchange left and right operands for infix expression quick assist is now also available for the !=, <, <=, >, and >= operators.


The properties file editor now offers two new quick assists to escape or unescape backslashes.


The Escape backslashes quick assist is also offered automatically on paste if the pasted text contains backslashes that should be escaped.  The next step is to provide a similar feature in the Java Editor, see Bug 332205.

Couple of irritating bugs that got fixed
  • Bug 327079 [JUnit] Can't run single test with JUnit 4 launcher if there's a suite() method
  • Bug 329677 [type hierarchy] view must honor package name abbreviation setting

Sunday, October 31, 2010

e4 - Eclipse 4.x - Second Impression

I have been using the latest builds of Eclipse 4.x SDK for my daily work for the last 6 weeks. The overall stability has improved gradually, and the NPEs are quite rare now. Some of the bugs I filed were also fixed  quite quickly during M3 - Bug 325834 , Bug 327154. But there are still a few things which must work but don't.
  • Ability to customize a perspective (Bug 320478)
  • Ability to set or change key bindings (Bug 317299)
  • Plus I am a bit confused about the 'Editor Area' introduced in 4.1 M3. Does this mean I should not create multiple editor stacks? Should I create multiple editor stacks only in the editor area? Will this editor area continue to take extra space as it does in M3? In 3.x we had a editor only area, are we going back towards that? M4 is supposed to have a more polished implementation of the 'Editor area', I will wait for that.
I am also hoping that Editor tab rendering could be improved significantly in Eclipse 4.x (Bug 325422).

    Saturday, September 18, 2010

    e4 - Eclipse 4.0 : First Impression

    Looks a bit funny

    Off is On and On is Off - I saw that Build Automatically was Off so I switched it On, and then my code changes had no effect... few minutes later I realized that if something is turned Off in the UI, it may mean that it is actually turned On! e.g.Mark Occurrences, Build Automatically.  Or in the case of 'Edit > Smart Insert Mode' I cannot even toggle it.

    Layout and minimized Views - I like the overall layout and the fact that I can put views in the editor area. I also like the way when minimized views are selected they open in a pop-up sort of a way. Overall the UI/layout feels nice.

    Custom Key Bindings - mmh...


    Order of menu and toolbar items - The ordering of items in menus and toolbars can be a bit different from 3.x versions. e.g. navigate menu, run/debug toolbar
    I can use it for my daily work, except for some minor glitches and some funny behavior I have been able to use it for last few days. And I do like the layout, mixing of editors and views, and the overall feel of the UI to not go back to 3.x (at least for now).

    Monday, September 6, 2010

    New Command in JDT : Open from Clipboard

    This is what I used to end up doing very frequently
    - copy something like String#getBytes from a bug comment
    - press Ctrl+Shift+T in Eclipse
    - paste the copied text Open Type dialog
    - argh... no matches
    - delete the method name
    - open the type in an editor
    - press Ctrl+O
    - argh.. what was that method again?
    - go back to bugzilla and read/copy the method name
    - come back to Quick Outline and filter the method
    - and finally reach the method

    The new command opens a Java element or a Java stack trace from clipboard. If the clipboard content spans multiple lines then the it is pasted to the Java Stack Trace Console. If the clipboard content is a single line the command tries to open the matching Java element in an editor. Some examples
    • java.lang.String
    • String#getBytes
    • java.lang.String.getBytes(String, int[], int)
    • String.java:123
    • at java.lang.String.matches(String.java:1550)
    • java.lang.String.valueOf(char) line: 1456  
    I use this command with a key binding of Ctrl+Shift+V. After doing a Ctrl+C the most natural thing to do is Ctrl+V so the key binding for this command should be similar. Plus Ctrl+Shift+V is also similar to Ctrl+Shift+T and Ctrl+Shift+R, making it a bit easier for me to remember it.

    This command (Bug 48880) is already in nightly builds and will be in the today's I-build.

    As a final note I should also mention 2 'nasty' Platform bugs that I faced while implementing this command
    • Bug 324160: [Commands] Platform should support to use the action IDs from the action set contribution in menuContribution
    • Bug 324161: menu contributions added using 'endof' should appear before contributions added using 'after'
    I say nasty because in its current form the whole menu contribution, command, actionSet, action story can be very confusing...