|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.cdt.internal.ui.text.CIndenter
public final class CIndenter
Uses the CHeuristicScanner
to
get the indentation level for a certain position in a document.
An instance holds some internal position in the document and is therefore not threadsafe.
Constructor Summary | |
---|---|
CIndenter(org.eclipse.jface.text.IDocument document,
CHeuristicScanner scanner)
Creates a new instance. |
|
CIndenter(org.eclipse.jface.text.IDocument document,
CHeuristicScanner scanner,
org.eclipse.cdt.core.model.ICProject project)
Creates a new instance. |
Method Summary | |
---|---|
java.lang.StringBuffer |
computeContinuationLineIndentation(int offset)
Computes the indentation for a continuation line at offset . |
java.lang.StringBuffer |
computeIndentation(int offset)
Computes the indentation at offset . |
java.lang.StringBuffer |
computeIndentation(int offset,
boolean assumeOpeningBrace)
Computes the indentation at offset . |
java.lang.StringBuffer |
createReusingIndent(java.lang.StringBuffer buffer,
int additional)
Creates a string with a visual length of the given indentationSize . |
int |
findReferencePosition(int offset)
Returns the reference position regarding to indentation for offset ,
or NOT_FOUND . |
int |
findReferencePosition(int offset,
boolean danglingElse,
boolean matchBrace,
boolean matchParen,
boolean matchCase,
boolean matchAccessSpecifier)
Returns the reference position regarding to indentation for position ,
or NOT_FOUND . |
int |
findReferencePosition(int offset,
int nextToken)
Returns the reference position regarding to indentation for position ,
or NOT_FOUND . |
java.lang.StringBuffer |
getReferenceIndentation(int offset)
Computes the indentation at the reference point of position . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CIndenter(org.eclipse.jface.text.IDocument document, CHeuristicScanner scanner)
document
- the document to scanscanner
- the CHeuristicScanner
to be used for scanning
the document. It must be installed on the same IDocument
.public CIndenter(org.eclipse.jface.text.IDocument document, CHeuristicScanner scanner, org.eclipse.cdt.core.model.ICProject project)
document
- the document to scanscanner
- the CHeuristicScanner
to be used for scanning
the document. It must be installed on the same
IDocument
.project
- the C/C++ project to get the formatter preferences from, or
null
to use the workspace settingsMethod Detail |
---|
public java.lang.StringBuffer getReferenceIndentation(int offset)
position
.
offset
- the offset in the document
offset
resides, or null
if it cannot be determinedpublic java.lang.StringBuffer computeIndentation(int offset)
offset
.
offset
- the offset in the document
null
if it cannot be
determinedpublic java.lang.StringBuffer computeIndentation(int offset, boolean assumeOpeningBrace)
offset
.
offset
- the offset in the documentassumeOpeningBrace
- true
if an opening brace should be assumed
null
if it cannot be
determinedpublic java.lang.StringBuffer computeContinuationLineIndentation(int offset) throws org.eclipse.jface.text.BadLocationException
offset
.
offset
- the offset in the document
null
if it cannot be
determined.
org.eclipse.jface.text.BadLocationException
public java.lang.StringBuffer createReusingIndent(java.lang.StringBuffer buffer, int additional)
indentationSize
.
buffer
- the original indent to reuse if possibleadditional
- the additional indentation units to add or subtract to
reference
buffer
reflecting the indentation
adapted to additional
public int findReferencePosition(int offset)
offset
,
or NOT_FOUND
. This method calls
findReferencePosition(offset, nextChar)
where
nextChar
is the next character after offset
.
offset
- the offset for which the reference is computed
offset
should be indented, or CHeuristicScanner.NOT_FOUND
public int findReferencePosition(int offset, int nextToken)
position
,
or NOT_FOUND
.
If peekNextChar
is true
, the next token after
offset
is read and taken into account when computing the
indentation. Currently, if the next token is the first token on the line
(i.e. only preceded by whitespace), the following tokens are specially
handled:
switch
labels are indented relative to the switch blockelse
keyword is aligned with its if
, anything
else is aligned normally (i.e. with the base of any introducing statements).offset
, the indentation
is the same as for an else
keyword
offset
- the offset for which the reference is computednextToken
- the next token to assume in the document
offset
should be indented, or CHeuristicScanner.NOT_FOUND
public int findReferencePosition(int offset, boolean danglingElse, boolean matchBrace, boolean matchParen, boolean matchCase, boolean matchAccessSpecifier)
position
,
or NOT_FOUND
.fIndent
will contain the
relative indentation (in indentation units, not characters) after the
call. If there is a special alignment (e.g. for a method declaration
where parameters should be aligned), fAlign
will contain
the absolute position of the alignment reference in fDocument
,
otherwise fAlign
is set to CHeuristicScanner.NOT_FOUND
.
offset
- the offset for which the reference is computeddanglingElse
- whether a dangling else should be assumed at position
matchBrace
- whether the position of the matching brace should be
returned instead of doing code analysismatchParen
- whether the position of the matching parenthesis
should be returned instead of doing code analysismatchCase
- whether the position of a switch statement reference
should be returned (either an earlier case statement or the
switch block brace)matchAccessSpecifier
- whether the position of a class body reference
should be returned (either an earlier public/protected/private
or the class body brace)
position
should be indented, or CHeuristicScanner.NOT_FOUND
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |