On Sat, Dec 03, 2005 at 08:41:34PM +0100, leif.bladt wrote:
> I found some spare time today, so I tried to get the new IndentEvent working...
>
> But I'm a bit confused, if it's enough to change the outputIndent() method in
> ViewPlugin.java and the sendEvent() method in View.java. How is indenting done
> 'til now? So Frank, could give me a short draft, how it works right now?
It depends on the semantic of your IndentEvent. As far as I can tell
there would be two possibilities:
1) an IndentEvent is sent when the indenting depth changes. This also
means that the actual whitespace used for indenting would still be a
WhitespaceEvent.
2) an IndentEvent is sent everytime the indenting whitespace should be
printed.
In the latter case modifying the outputIndent() method should be enough.
The sendEvent() method will always have to be changed to include a
default action for the new event anyways.
As for how it works now:
The ViewPlugin.java baseclass provides a protected int m_indent variable
which holds the current indenting depth (in logical units, which needs
to be multiplied by the number of spaces then - or replaced by an equal
number of tabs). When you take a look at the implementation of
handleElement(Block) you will see one of the occassions where this
indenting level is modified. After printing any modifiers and the '{'
there is a newline and the indenting for the contents of the block is
increased simply through m_indent++; Accordingly after the contents are
printed the indenting is reduced again. That's all there is to indenting
actually.
So if the IndentEvent is defined as in the second possibility above it
should be a very easy change. It gets more complicated when you want to
send events only once on logical indenting changes. The main problem
here lies in multiple decrements of the indent which should consequently
only cause one IndentEvent. This is not as much of a problem with java
really, but f.ex. python already has this problem in the parsing process
with constructs like this:
1: while True:
2: somemethod()
3: if something():
4: do_it()
5: this_is_the_problem()
With the first option from the above you'd get one Event at line 2 which
says the indent increased by 1. In line 4 there's another increase by 1,
but in line 5 we get a sudden decrease by 2 levels.
But as indenting is a rather unimportant concept for what the source
code actually does I don't think we really need the logical distinction
of this indents (as we basically can see those in the DOM tree anyways)
and the second option which simply creates a number of blanks should
suffice just fine.
PS: sorry if I sent this twice now, but I got a strange bounce from SF
the first time.
--
Raiser, Frank
Student @ University of Ulm (www.uni-ulm.de)
The most likely way for the world to be destroyed, most experts agree,
is by accident. That's where we come in; we're computer professionals.
We cause accidents. (Nathaniel Borenstein)
|