Bug 90974 - Better support for .properties files
Better support for .properties files
Status: NEW
Product: utilities
Classification: Unclassified
Component: Properties
5.x
All All
: P2 (vote)
: TBD
Assigned To: Jan Peska
issues@utilities
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-12-12 17:30 UTC by Jan Jancura
Modified: 2013-05-01 16:38 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments
Emacs el file (6.92 KB, text/plain)
2006-12-12 17:31 UTC, Jan Jancura
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Jancura 2006-12-12 17:30:14 UTC
I came across this blog entry:

http://squirrelsewer.blogspot.com/2006/11/resource-bundle-syntax-gotchas.html

There are some interesting things there. It's easy to end up with single quotes
in your strings, and if your strings are being formatted by MessageFormat (which
I suspect is the case for most people), it can have unintended consequences.

I looked up MessageFormat, and lo and behold, it's a whole "language"!  (Look at
the grammar listed right in its javadoc: 
http://java.sun.com/j2se/1.5.0/docs/api/java/text/MessageFormat.html )

I see that there is a Schliemann .nbs file for properties files, but it's only
doing key=value recognition at this point. (And needs to handle : as a separator
as well.)

Would it make sense to actually tokenize .properties files as if they are
MessageFormat language files??  I think that would help 95% of .properties file
users.

-- Tor 

Craig:

FWIW, I think this would be a great idea ... but with a potential caveat.  What
happens if the developer is specifying resources that are *not* MessageFormat
strings, and the coloring confuses things, or creates "false positive" error
reports for invalid syntax?  Ideally, we could implement this so you could turn
it on or off on a per-properties-file basis, perhaps defaulting with convention
over configuration (Bundle.properties==yes, Messages.properties=yes,
Foo.properties=no) or some per-file setting that persists with the project.

Jesse:
That is why I have used the attached in Emacs for about ten years. I wrote it
from scratch in an afternoon, I guess, but it still provides better coloring
than NB ever did, mainly because duplicating it in old NB would have taken me
days. With the advent of Schliemann it should be easy to correct that. Note that
there is some special treatment in there for ATG Dynamo (an old app server) and
Ant, and the MessageFormat handling is minimal. The basic format features are
handling of

1. Continued lines such as

prop=\
    val1:\
    val2

~

prop=val1:val2

2. Extra spaces at the ends of lines, which are otherwise invisible parts of the
value.

3. \uXXXX, \n, and other escapes.

To Craig's question - I have never been bothered by the possibility of the
attached major mode coloring something that wasn't actually special. It's rare
and mostly harmless. We can assume that most .properties files edited by NB
developers are

1. Resource bundle strings, sometimes using MessageFormat.

2. Ant property definitions, sometimes using ${property} substs.

3. Relatively short and straightforward config files for other systems - Maven,
Tomcat, whatever.
Comment 1 Jan Jancura 2006-12-12 17:31:18 UTC
Created attachment 36619 [details]
Emacs el file
Comment 2 Jiri Prox 2007-09-17 20:48:11 UTC
Obsolete milestone, please reevaluate
Comment 3 Jan Jancura 2007-09-18 17:20:37 UTC
reevaluted


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo