NetBeans Screenshot of the Week #38: E4X Support


As part of the JavaScript 1.7 work,
I also beefed up the E4X support. E4X allows you to embed XML objects
directly in your JavaScript source. Here's some simple E4X JavaScript:







We've had E4X support in NetBeans in both NetBeans 6.1 and 6.5. But now, in NetBeans 7.0, semantic highlighting is E4X aware, such that the source code looks like this instead:







The whole XML document declaration has a faint purple background, element names are blue and document content is bolded.
(The green here, as for all JavaScript code in NetBeans, indicates variables in global scope.)


Another new E4X feature is formatting/pretty printing. If you press Alt-Shift-F to format the above source, the E4X is
reformatted and indented:







In addition, the navigator window shows the logical structure of the XML document as well. Clicking in the source
will expand and select the corresponding item in the navigator, and conversely double clicking in the navigator
warps the source to the corresponding location in the XML declaration:







Finally, there's some primitive support in code completion for the XML document:




Comments:

That's pretty cool.

Each time I type e4x expressions, I always wonder if something could be done for auto-completion when putting together an xpath expression. Any plans on supporting this in netbeans?

I am not sure if it can be done, or if so, how. Maybe using schemas and annotations, like:

[Schema("blah.xsd") var doc : XML = ...;

The editor could be able to do some completion, could it not?

Posted by Tech Per on November 30, 2008 at 06:13 PM PST #

Thanks Per. Yes, if we had a standard way of annotating the expected Schema or DTD of the XML documents, then not only could we do a better job with code completion, but we could run semantic checks with quickfixes/warnings for errors in your XML!

So many things to do, so little time....

Posted by Tor Norbye on December 01, 2008 at 12:55 AM PST #

Post a Comment:
Comments are closed for this entry.
About

Tor Norbye

Search

Archives
« April 2014
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