[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[platform-text-dev] Nested or layered partitions
|
Hi,
I've been playing around with the Eclipse syntax
highlighting a bit lately, trying to fix issues
in the FreeMarker (http://freemarker.sourceforge.net/)
plugin. FreeMarker is a template language that
embeds into text, normally HTML/XML.
The current (2.1) Eclipse model for text highlighting
seems to have certain problems with embedded languages
like PHP, JSP, ASP and similar. At least if one
attempts to colorize both the HTML code and the script
code. A simple demonstration of the difficulties could
be (with 'x' for XML, 'a' for XML attribute, and 'f'
for FreeMarker color):
Text: <p ${foo} a="text${bar}text">${baz}</p>
Color: xxxffffffxxxaaaaaffffffaaaaaxffffffxxxx
Now, I saw some mentioning of "introduce nested
partitions" in the 3.0 roadmap. Would that adress the
problems in the above example? How? Have any work
started on this yet or are there any ideas? (I couldn't
find any bug/RFE referencing this.)
While hacking on an XmlScanner for the example above,
I came up with my own idea for how to make this kind of
work really easy for the plugin writer. Basically, if
one concatenates the text in each partition type, the
scanners are usually very simple to write. For example,
by using two partitions (one FreeMarker and one XML) in
the above example:
FreeMarker: ${foo}${bar}${baz}
XML: <p a="texttext"></p>
Each of the scanners can now be written in a simple and
straightforward manner, ignoring the fact that some
characters that appear to be adjacent really aren't in
the buffer.
I haven't looked into the Eclipse internals much, so I
don't really know if something like this would even be
possible to accomplish efficiently. I realize that the
default implementation of ICharacterScanner would have
to do some internal bookkeeping to store the real
positions in the text buffer, but that seems workable.
Also, due to legacy code or possible parsing problems,
I understand that this behavior would have to be
optional.
But are there other, more complex or subtle issues?
Anyone care to comment?
Thanks for a really great developing environment!
Cheers,
/Per
--
Per Cederberg, Software Consultant
http://www.percederberg.net/software