|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.cdt.internal.ui.editor.IndentUtil
public final class IndentUtil
Utility that indents a number of lines in a document.
Nested Class Summary | |
---|---|
static class |
IndentUtil.IndentResult
The result of an indentation operation. |
Method Summary | |
---|---|
static java.lang.String |
computeCommentIndent(org.eclipse.jface.text.IDocument document,
int line,
CHeuristicScanner scanner,
org.eclipse.jface.text.ITypedRegion partition)
Computes and returns the indentation for a block comment line. |
static java.lang.String |
computeIndent(org.eclipse.jface.text.IDocument document,
int line,
CIndenter indenter,
CHeuristicScanner scanner)
Computes and returns the indentation for a source line. |
static java.lang.String |
computePreprocessorIndent(org.eclipse.jface.text.IDocument document,
int line,
org.eclipse.jface.text.ITypedRegion partition)
Computes and returns the indentation for a preprocessor line. |
static java.lang.String |
getCurrentIndent(org.eclipse.jface.text.IDocument document,
int line,
boolean indentInsideLineComments)
Returns the indentation of the line line in document . |
static boolean |
indentInsideLineComments(org.eclipse.cdt.core.model.ICProject project)
Returns true if line comments at column 0 should be indented inside, false otherwise. |
static IndentUtil.IndentResult |
indentLines(org.eclipse.jface.text.IDocument document,
org.eclipse.jface.text.source.ILineRange lines,
org.eclipse.cdt.core.model.ICProject project,
IndentUtil.IndentResult result)
Indents the line range specified by lines in
document . |
static void |
indentLines(org.eclipse.jface.text.IDocument document,
org.eclipse.jface.text.source.LineRange lines,
java.lang.String indent)
Inserts indent string at the beginning of each line in lines . |
static IndentUtil.IndentResult |
shiftLines(org.eclipse.jface.text.IDocument document,
org.eclipse.jface.text.source.ILineRange lines,
org.eclipse.cdt.core.model.ICProject project,
IndentUtil.IndentResult result)
Shifts the line range specified by lines in
document . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static IndentUtil.IndentResult indentLines(org.eclipse.jface.text.IDocument document, org.eclipse.jface.text.source.ILineRange lines, org.eclipse.cdt.core.model.ICProject project, IndentUtil.IndentResult result) throws org.eclipse.jface.text.BadLocationException
lines
in
document
. The passed C project may be
null
, it is used solely to obtain formatter preferences.
document
- the document to be changedlines
- the line range to be indentedproject
- the C project to get the formatter preferences from, or
null
if global preferences should be usedresult
- the result from a previous call to indentLines
,
in order to maintain comment line properties, or null
.
Note that the passed result may be changed by the call.
org.eclipse.jface.text.BadLocationException
- if lines
is not a valid line
range on document
public static void indentLines(org.eclipse.jface.text.IDocument document, org.eclipse.jface.text.source.LineRange lines, java.lang.String indent) throws org.eclipse.jface.text.BadLocationException
indent
string at the beginning of each line in lines
.
document
- the document to be changed.lines
- the line range to be indented.indent
- the indent string to be inserted.
org.eclipse.jface.text.BadLocationException
- if lines
is not a valid line
range on document
public static boolean indentInsideLineComments(org.eclipse.cdt.core.model.ICProject project)
true
if line comments at column 0 should be indented inside, false
otherwise.
project
- the project to get project specific options from
true
if line comments at column 0 should be indented inside, false
otherwise.public static IndentUtil.IndentResult shiftLines(org.eclipse.jface.text.IDocument document, org.eclipse.jface.text.source.ILineRange lines, org.eclipse.cdt.core.model.ICProject project, IndentUtil.IndentResult result) throws org.eclipse.jface.text.BadLocationException
lines
in
document
. The amount that the lines get shifted
are determined by the first line in the range, all subsequent
lines are adjusted accordingly. The passed C project may be
null
, it is used solely to obtain formatter
preferences.
document
- the document to be changedlines
- the line range to be shiftedproject
- the C project to get the formatter preferences
from, or null
if global preferences should
be usedresult
- the result from a previous call to
shiftLines
, in order to maintain comment
line properties, or null
. Note that the
passed result may be changed by the call.
org.eclipse.jface.text.BadLocationException
- if lines
is not a
valid line range on document
public static java.lang.String getCurrentIndent(org.eclipse.jface.text.IDocument document, int line, boolean indentInsideLineComments) throws org.eclipse.jface.text.BadLocationException
line
in document
.
The returned string may contain pairs of leading slashes that are considered
part of the indentation.
document
- the documentline
- the lineindentInsideLineComments
- option whether to indent inside line comments starting at column 0
line
in document
org.eclipse.jface.text.BadLocationException
- if the document is changed concurrentlypublic static java.lang.String computeIndent(org.eclipse.jface.text.IDocument document, int line, CIndenter indenter, CHeuristicScanner scanner) throws org.eclipse.jface.text.BadLocationException
document
- the documentline
- the line in documentindenter
- the C indenterscanner
- the scanner
null
org.eclipse.jface.text.BadLocationException
public static java.lang.String computeCommentIndent(org.eclipse.jface.text.IDocument document, int line, CHeuristicScanner scanner, org.eclipse.jface.text.ITypedRegion partition) throws org.eclipse.jface.text.BadLocationException
document
- the documentline
- the line in documentscanner
- the scannerpartition
- the comment partition
null
if not computable
org.eclipse.jface.text.BadLocationException
public static java.lang.String computePreprocessorIndent(org.eclipse.jface.text.IDocument document, int line, org.eclipse.jface.text.ITypedRegion partition) throws org.eclipse.jface.text.BadLocationException
document
- the documentline
- the line in documentpartition
- the comment partition
null
if not computable
org.eclipse.jface.text.BadLocationException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |