Bug 91718 - Language embedding-aware formatting
Language embedding-aware formatting
Product: editor
Classification: Unclassified
Component: Formatting & Indentation
All All
: P2 (vote)
: 6.x
Assigned To: Miloslav Metelka
Depends on:
Blocks: 89283
  Show dependency treegraph
Reported: 2007-01-03 10:01 UTC by Tomasz Slota
Modified: 2007-11-05 13:39 UTC (History)
3 users (show)

See Also:
Issue Type: TASK

Diff of the added editor/indent module and related changes (166.48 KB, patch)
2007-06-14 14:33 UTC, Miloslav Metelka
Details | Diff
Javadoc of the editor/indent module (119.50 KB, application/x-compressed)
2007-06-14 14:35 UTC, Miloslav Metelka
Commit log of trunk integration (7.43 KB, text/plain)
2007-06-18 11:06 UTC, Miloslav Metelka

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Slota 2007-01-03 10:01:45 UTC
Provide infrastructure for formatting code consisting of embedded languages like JSP, which may embed 
HTML, Java, JavaScript, etc.
Comment 1 Miloslav Metelka 2007-01-04 22:18:31 UTC
I understand that this is critical and I would like to work on this ASAP. It's
necessary to agree on the appropriate SPI first and provide the corresponding
Comment 2 Miloslav Metelka 2007-06-05 11:19:43 UTC
I've created a branch indent_91718 for the new indentation infra.
cvs co editor/indent editor/lib editor/libsrc
are currently branched (I will inform about possible additions).
Comment 3 Miloslav Metelka 2007-06-07 15:54:36 UTC
In addition NbEditorDocument.java is branched so the following may be used:
cvs co -r indent_91718 -f editor/src
I've added FormatterImpl so the original actions should now delegate to the new
API where the new indent/reformat factories impls are registered.
Comment 4 Miloslav Metelka 2007-06-13 10:37:57 UTC
Summary of the things that the new API/SPI attempts to solve:
1) Allow language-embedding specific operation i.e. reuse the formatters for a particular language in an embedded
context. Handle the automatic delegation in the infrastructure. If necessary provide a data transfer between upper-level
and embedded formatters.

2) Separation of providers of
  a) fixing of line(s) indents (e.g. pressing Tab in emacs)
  b) full code beautification (may change spaces inside the lines; add e.g. extra braces etc.).
  If b) is not available it defaults to a)

2) Always operate on document and prefer incremental changes. This should eliminate the problem of moving breakpoints
and bookmarks to the begining of the reformatted area and support lexer.
 Reformatting of a newly generated code without its final insertion into the document (aka IndentEngine.createWriter())
can be handled by performing of the insertion and reformatting it in a transaction; storing the reformatted code in a
string; doing of rollback (undo) of all these changes; output the string.
 If the reformatters themselves prefer String => reformatted-String processing provide a support for making a diff
between the two and perform the incremental changes in the document.

3) Provide extra pre-(document-write-lock)-locking possibility (currently a usecase for the new java infrastructure that
needs to lock itself before acquiring any document locks).

4) The new API/SPI should coexist with the existing model of org.openide.text.IndentEngine and
org.netbeans.editor.Formatter. If the new SPI providers will be registered they will be preferred but if not the
original infrastructure should continue to work.
Comment 5 Miloslav Metelka 2007-06-14 14:33:08 UTC
Created attachment 43694 [details]
Diff of the added editor/indent module and related changes
Comment 6 Miloslav Metelka 2007-06-14 14:35:51 UTC
Created attachment 43695 [details]
Javadoc of the editor/indent module
Comment 7 Miloslav Metelka 2007-06-14 14:48:54 UTC
I would like to ask for review. IMHO the fasttrack should suffice as the API and SPI is fairly small and simple.
There is a new editor/indent module that covers the usecases mentioned in this issue. The module implements
FormatterOverride for callback from editor/lib formatting legacy infrastructure.
Comment 8 Miloslav Metelka 2007-06-18 11:06:26 UTC
Created attachment 43871 [details]
Commit log of trunk integration
Comment 9 Miloslav Metelka 2007-06-18 11:08:08 UTC
Integrated in trunk.

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