|
Eclipse Platform Release 3.1 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jface.text.AbstractLineTracker
Abstract implementation of ILineTracker
. It lets the
definition of line delimiters to subclasses. Assuming that '\n' is
the only line delimiter, this abstract implementation defines the
following line scheme:
Nested Class Summary | |
---|---|
protected static class |
AbstractLineTracker.DelimiterInfo
Combines the information of the occurrence of a line delimiter. |
protected static class |
AbstractLineTracker.Request
Representation of replace and set requests. |
Constructor Summary | |
---|---|
protected |
AbstractLineTracker()
Creates a new line tracker. |
Method Summary | |
---|---|
protected void |
checkRewriteSession()
Checks the presence of a rewrite session and flushes it. |
int |
computeNumberOfLines(String text)
Computes the number of lines in the given text. |
protected void |
flushRewriteSession()
Flushes the active rewrite session. |
String |
getLineDelimiter(int line)
Returns the line delimiter of the specified line. |
IRegion |
getLineInformation(int line)
Returns a line description of the given line. |
IRegion |
getLineInformationOfOffset(int position)
Returns a line description of the line at the given offset. |
int |
getLineLength(int line)
Returns length of the specified line including the line's delimiter. |
int |
getLineNumberOfOffset(int position)
Returns the line number the character at the given offset belongs to. |
int |
getLineOffset(int line)
Returns the position of the first character of the specified line. |
int |
getNumberOfLines()
Returns the number of lines. |
int |
getNumberOfLines(int position,
int length)
Returns the number of lines which are occupied by a given text range. |
protected boolean |
hasActiveRewriteSession()
Tells whether there's an active rewrite session. |
protected abstract AbstractLineTracker.DelimiterInfo |
nextDelimiterInfo(String text,
int offset)
Returns the information about the first delimiter found in the given text starting at the given offset. |
void |
replace(int position,
int length,
String text)
Informs the line tracker about the specified change in the tracked text. |
void |
set(String text)
Sets the tracked text to the specified text. |
void |
startRewriteSession(DocumentRewriteSession session)
Tells the line tracker that a rewrite session started. |
void |
stopRewriteSession(DocumentRewriteSession session,
String text)
Tells the line tracker that the rewrite session has finished. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.eclipse.jface.text.ILineTracker |
---|
getLegalLineDelimiters |
Constructor Detail |
protected AbstractLineTracker()
Method Detail |
public int getLineLength(int line) throws BadLocationException
ILineTracker
getLineLength
in interface ILineTracker
line
- the line of interest
BadLocationException
- if line is unknown to this trackerpublic int getLineNumberOfOffset(int position) throws BadLocationException
ILineTracker
getLineNumberOfOffset
in interface ILineTracker
position
- the offset whose line number to be determined
BadLocationException
- if the offset is invalid in this trackerpublic IRegion getLineInformationOfOffset(int position) throws BadLocationException
ILineTracker
getLineInformationOfOffset
in interface ILineTracker
position
- the offset whose line should be described
BadLocationException
- if offset is invalid in this trackerpublic IRegion getLineInformation(int line) throws BadLocationException
ILineTracker
getLineInformation
in interface ILineTracker
line
- the line that should be described
BadLocationException
- if line is unknown to this trackerpublic int getLineOffset(int line) throws BadLocationException
ILineTracker
getLineOffset
in interface ILineTracker
line
- the line of interest
BadLocationException
- if the line is unknown to this trackerpublic int getNumberOfLines()
ILineTracker
getNumberOfLines
in interface ILineTracker
public int getNumberOfLines(int position, int length) throws BadLocationException
ILineTracker
getNumberOfLines
in interface ILineTracker
position
- the offset of the specified text rangelength
- the length of the specified text range
BadLocationException
- if specified range is unknown to this trackerpublic int computeNumberOfLines(String text)
ILineTracker
computeNumberOfLines
in interface ILineTracker
text
- the text whose number of lines should be computed
public String getLineDelimiter(int line) throws BadLocationException
ILineTracker
null
if the
line is not closed with a line delimiter.
getLineDelimiter
in interface ILineTracker
line
- the line whose line delimiter is queried
null
if line does not have a delimiter
BadLocationException
- if the line number is invalid in this tracker's line structureprotected abstract AbstractLineTracker.DelimiterInfo nextDelimiterInfo(String text, int offset)
text
- the text to be searchedoffset
- the offset in the given text
null
public void replace(int position, int length, String text) throws BadLocationException
ILineTracker
replace
in interface ILineTracker
position
- the offset of the replaced textlength
- the length of the replaced texttext
- the substitution text
BadLocationException
- if specified range is unknown to this trackerpublic void set(String text)
ILineTracker
set
in interface ILineTracker
text
- the new tracked textpublic final void startRewriteSession(DocumentRewriteSession session)
ILineTrackerExtension
startRewriteSession
in interface ILineTrackerExtension
session
- the rewrite sessionpublic final void stopRewriteSession(DocumentRewriteSession session, String text)
ILineTrackerExtension
startRewriteSession
has been called
before. The text resulting from the rewrite session is passed to the line
tracker.
stopRewriteSession
in interface ILineTrackerExtension
session
- the rewrite sessiontext
- the text with which to re-initialize the line trackerprotected final boolean hasActiveRewriteSession()
true
if there is an active rewrite session,
false
otherwiseprotected final void flushRewriteSession() throws BadLocationException
BadLocationException
- in case the recorded requests cannot be
processed correctlyprotected final void checkRewriteSession() throws BadLocationException
BadLocationException
- in case flushing does not succeed
|
Eclipse Platform Release 3.1 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.