See: Description
Package | Description |
---|---|
org.netbeans.modules.editor.indent.api | |
org.netbeans.modules.editor.indent.spi |
Editor Indentation module defines
EditorIndentationAPI
providing indentation and reformatting services to the clients.
It also contains SPI allowing the modules to register language-specific
indenters and formatters into
MimeLookup
through XML layers.
Added method org.netbeans.modules.editor.indent.spi.Context.modifyIndent(int, int, String), which allows to set indent by specifying particular indent string.
Implementation of indentation which depends on typing hooks moved to a separate module, see its javadoc for more info.
Method IndentUtils.createIndentString(int indent, boolean expandTabs, int tabSize) added.
Adding CodeStylePreferences.Provider
interface in order to allow
isolating the project-dependent code style preferences storage from the rest
of the editor infrastructure.
Let IndentTask and/or ReformatTask implement Lookup.Provider and before executing indentation/reformat call these providers and provide merged result via getLookup() method in Context. Individual formatters check lookup for presence of other formatters and communicate with them via domain specific APIs.
Altghough there are formatting actions already there may be clients wishing to explicitly fix indentation of e.g. a newly inserted code into a Swing document.
The same code is used after inserting a newline into a document.
The Indent is an entry point for performing reindentation. The following code should be used by clients:Indent indent = Indent.get(doc); indent.lock(); try { doc.atomicLock(); try { indent.reindent(startOffset, endOffset); } finally { doc.atomicUnlock(); } } finally { indent.unlock(); }
Code beautification should not only fix line indentation but it may also perform extra changes to code according to formatting rules. For example add newlines or additional whitespace or add/remove extra braces etc.
The Reformat class should be used:Reformat reformat = Reformat.get(doc); reformat.lock(); try { doc.atomicLock(); try { reformat.reformat(startOffset, endOffset); } finally { doc.atomicUnlock(); } } finally { reformat.unlock(); }
|
The sources for the module are in the Apache Git repositories or in the GitHub repositories.
Nothing.
Read more about the implementation in the answers to architecture questions.