sandip chitale's blog    Sandip Chitale's blog (scblog)
NOTE: I have moved many of my modules to NetBeans Plugin Portal . Please check there for latest versions of modules described on this blog.
20061029 Sunday October 29, 2006

Getting started with the new Java language support inrastructure in NetBeans 6.0

There is going be a complete overhaul of Java editor in NetBeans 6.0. There are going to be a lot of cool, new features. Jan Lahoda has already blogged about some of those features. All those new features are supported by a javac based Java language support infrastructure. The Jackpot technology is also part of it. If you want to learn more about the new infrastucture go here.

WhichElement Module

I have developed a simple module - WhichElement - based on the new Java language support infrastructure APIs ( we need a good name for this ;) ). This blog may help/inspire you to get started with the new APIs.

The WhichElement module shows information about the Element under the caret in a read-only text field (40 column) in the IDE status bar. The tool tip shows the full text so that it can be seen when is wider than 40 columns. The text field contents can be copied using standard keybinding (e.g. on windows - Ctrl+A Ctrl+C).

This module demonstrates/makes use of:

  • CaretAwareJavaSourceTaskFactory - a factory for creating a task which is run every time the caret position in the Java editor changes. This factory is registered using the: META-INF/services/org.netbeans.api.java.source.JavaSourceTaskFactory file.
  • CancellableTask<CompilationInfo> - a caret sensitive task which finds the Element under the caret and displays information about it in the status bar.

I have uploaded the WhichElements Module to my Netbeans update center described here.

You will need a NetBeans IDE dev build dated after 10/25/2006. As pointed out by Jesse Glick you can get the latest dev build here. You can also build the NetBeans IDE using the sources checked out after 10/25/2006 from the NetBeans CVS repository. (How to get NetBeans CVS Access?).

Sources

If you want to hack the above project you will need to check out the NetBeans sources from the NetBeans CVS repository.

DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.


Posted by sandipchitale ( Oct 29 2006, 04:07:03 PM PST ) Permalink Comments [8]


Trackback URL: http://blogs.sun.com/scblog/entry/getting_started_with_new_java
Comments:

There is no need to build the IDE from sources if you don't want to:
latest dev build

Posted by Jesse Glick on October 30, 2006 at 04:53 AM PST #

Thanks for the information, Jesse. I did not know that the dev builds had started working.

Posted by Sandip on October 30, 2006 at 08:54 AM PST #

Hi, I got some problem with latest Nb6 (daily) and WhichElement :-( java.lang.NoSuchMethodError: org.netbeans.api.java.source.support.CaretAwareJavaSourceTaskFactory: method <init>()V not found at org.netbeans.modules.whichelement.WhichElementJavaSourceTaskFactory.<init>(WhichElementJavaSourceTaskFactory.java:34) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at java.lang.Class.newInstance0(Class.java:355) at java.lang.Class.newInstance(Class.java:308) at org.openide.util.lookup.MetaInfServicesLookup$P.getInstance(MetaInfServicesLookup.java:410) at org.openide.util.lookup.AbstractLookup$R.allInstances(AbstractLookup.java:897) at org.openide.util.lookup.ProxyLookup$R.computeResult(ProxyLookup.java:457) at org.openide.util.lookup.ProxyLookup$R.allInstances(ProxyLookup.java:400) at org.netbeans.modules.java.source.JavaSourceTaskFactoryManager.update(JavaSourceTaskFactoryManager.java:53) at org.netbeans.modules.java.source.JavaSourceTaskFactoryManager.<init>(JavaSourceTaskFactoryManager.java:49) at org.netbeans.modules.java.source.JavaSourceTaskFactoryManager.register(JavaSourceTaskFactoryManager.java:35) at org.netbeans.modules.java.source.JBrowseModule.restored(JBrowseModule.java:73) at org.netbeans.core.startup.NbInstaller.loadCode(NbInstaller.java:355) at org.netbeans.core.startup.NbInstaller.load(NbInstaller.java:274) at org.netbeans.ModuleManager.enable(ModuleManager.java:901) at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:380) at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:316) at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:260) at org.netbeans.core.startup.Main.getModuleSystem(Main.java:154) at org.netbeans.core.startup.Main.start(Main.java:308) at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:89) [catch] at java.lang.Thread.run(Thread.java:619)

Posted by Sven Reimers on November 15, 2006 at 03:41 AM PST #

Looks like some APIs changed. I will look into it.

Posted by Sandip on November 15, 2006 at 05:18 AM PST #

Sven Reimers, do you have version WhichElement(Spec Version 1.5)?

Posted by Sandip on November 15, 2006 at 05:43 AM PST #

No, it is 1.3 (as I can see in ModuleManager). No updates are shown for your UpdateCenter. But I will verify again... (Contact me via e-mail ig you like)

Posted by Sven Reimers on November 15, 2006 at 10:47 AM PST #

I just checked again your updatecenter - it shows 1.3 as module version being served.

Posted by Sven Reimers on November 15, 2006 at 10:52 AM PST #

enhancement request. Could you please make whichelement info to appear as popup when CTRL + MouseOver used for a fast look. When you stop holding CTRL the popup disappears

Posted by krishs on December 01, 2006 at 01:26 PM PST #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed








« November 2009
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
     
       
Today

Get NetBeans 5.5

Locations of visitors to this page

Today's Page Hits: 146


XML
All
/Creator
/General
/Hobby
/Java
/JavaScript
/Mozilla
/NetBeans
/Ubuntu
/VisualWeb
/VisualWebPack
/Web 2.0

XML
All
/Creator
/General
/Hobby
/Java
/JavaScript
/Mozilla
/NetBeans
/Ubuntu
/VisualWeb
/VisualWebPack
/Web 2.0

scblog
scblog