| edu.rice.cs.drjava.model.AbstractDJDocument edu.rice.cs.drjava.model.definitions.DefinitionsDocument
DefinitionsDocument | public class DefinitionsDocument extends AbstractDJDocument implements Finalizable<DefinitionsDocument>(Code) | | The document model for the definitions pane.
This implementation of Document contains a "reduced model". The reduced model is automatically kept
in sync when this document is updated. Also, that synchronization is maintained even across undo/redo -- this is
done by making the undo/redo commands know how to restore the reduced model state.
The reduced model is not thread-safe, so it is essential that ONLY this DefinitionsDocument call methods on it.
Any information from the reduced model should be obtained through helper methods on DefinitionsDocument, and ALL
methods in DefinitionsDocument which reference the reduced model (via the _reduced field) MUST be synchronized.
This prevents any thread from seeing an inconsistent state in the middle of another thread's changes.
See Also: BraceReduction See Also: ReducedModelControl See Also: ReducedModelComment See Also: ReducedModelBrace |
Inner Class :public static class WrappedPosition implements Position | |
Field Summary | |
final public static Log | _log |
Method Summary | |
int | _getAnonymousInnerClassIndex(int pos) Return the index of the anonymous inner class being instantiated at the specified position. | protected String | _getPackageQualifier() Gets an appropriate prefix to fully qualify a class name. | static String | _removeTabs(String source) Given a String, return a new String will all tabs converted to spaces. | protected void | _styleChanged() | public void | addDocumentClosedListener(DocumentClosedListener l) | public void | addFinalizationListener(FinalizationListener<DefinitionsDocument> fl) Registers a finalization listener with the specific instance of the ddoc
NOTE:This should only be used by test cases. | protected void | addUndoRedo(AbstractDocument.DefaultDocumentEvent chng, Runnable undoCommand, Runnable doCommand) | public void | close() Called when this is kicked out of the document cache so that the references made to it may
be released so that this can be GC'd. | public int | commentLines(int selStart, int selEnd) Comments out all lines between selStart and selEnd, inclusive. | public Position | createPosition(int offs) Factory method for created WrappedPositions. | public void | documentSaved() Informs this document's undo manager that the document has been saved. | protected void | endCompoundEdit(int key) | protected void | endLastCompoundEdit() | protected void | finalize() This is called when this method is GC'd. | public int | getCurrentCol() Return the current column of the cursor position. | public int | getCurrentLine() Return the current line of the cursor position. | public String | getEnclosingClassName(int pos, boolean qual) Searching backwards finds the name of the enclosing named class or interface. | public String | getEnclosingTopLevelClassName(int pos) Returns the name of the class or interface enclosing the caret position at the top level. | public List<FinalizationListener<DefinitionsDocument>> | getFinalizationListeners() | public String | getFirstTopLevelClassName() Gets the name of the top level class in this source file. | public String | getMainClassName() Gets the name of the document's main class: the document's only public class/interface or
first top level class if document contains no public classes or interfaces. | public UndoableEdit | getNextRedo() Public accessor for the next undo action. | public String | getNextTopLevelClassName(int startPos, int endPos) | public UndoableEdit | getNextUndo() Public accessor for the next undo action. | public int | getOffset(int lineNum) Returns the offset corresponding to the first character of the given line number,
or -1 if the lineNum is not found. | public OpenDefinitionsDocument | getOpenDefDoc() the OpenDefinitonsDocument that is associated with this DefinitionsDocument. | public String | getPackageName() Gets the package name embedded in the text of this document by minimally parsing the document to find the
package statement. | public String | getQualifiedClassName() | public String | getQualifiedClassName(int pos) Gets fully qualified class name of the top level class enclosing the given position. | public CompoundUndoManager | getUndoManager() | public WeakHashMap<WrappedPosition, Integer> | getWrappedPositionOffsets() Remove all positions that have been garbage-collected from the list of positions, then return a weakly-linked
hashmap with positions and their current offsets. | public void | gotoLine(int line) Goes to a particular line in the document. | public void | insertString(int offset, String str, AttributeSet a) Inserts a string of text into the document. | public boolean | isModifiedSinceSave() Determines if the document has been modified since the last save. | protected Indenter | makeNewIndenter(int indentLevel) Returns a new indenter. | public void | remove(int offset, int len) Removes a block of text from the specified location. | public void | removeDocumentClosedListener(DocumentClosedListener l) | public void | resetModification() Resets the modification state of this document. | public void | resetUndoManager() Resets the undo manager. | public void | setOpenDefDoc(OpenDefinitionsDocument odd) Sets the OpenDefinitionsDocument that holds this DefinitionsDocument (the odd can only be set once). | public void | setWrappedPositionOffsets(WeakHashMap<WrappedPosition, Integer> whm) Re-create the wrapped positions in the hashmap, update the wrapped position, and add them to the list. | protected int | startCompoundEdit() | public boolean | tabsRemoved() Returns true iff tabs are to removed on text insertion. | public String | toString() | public int | uncommentLines(int selStart, int selEnd) Uncomments all lines between selStart and selEnd, inclusive. | public void | updateModifiedSinceSave() Resets the modification state of this document to be consistent with state of _undoManager. |
DefinitionsDocument | public DefinitionsDocument(Indenter indenter, GlobalEventNotifier notifier)(Code) | | Convenience constructor for using a custom indenter.
Parameters: indenter - custom indenter class Parameters: notifier - used by CompoundUndoManager to announce undoable edits |
DefinitionsDocument | public DefinitionsDocument(GlobalEventNotifier notifier)(Code) | | Main constructor. This has an obnoxious dependency on GlobalEventNotifier, which is passed through here only
for a single usage in CompoundUndoManager. TODO: find a better way.
Parameters: notifier - used by CompoundUndoManager to announce undoable edits |
DefinitionsDocument | public DefinitionsDocument(GlobalEventNotifier notifier, CompoundUndoManager undoManager)(Code) | | Main constructor. This has an obnoxious dependency on GlobalEventNotifier, which is passed through here only
for a single usage in CompoundUndoManager. TODO: find a better way.
Parameters: notifier - used by CompoundUndoManager to announce undoable edits |
_getAnonymousInnerClassIndex | int _getAnonymousInnerClassIndex(int pos) throws BadLocationException, ClassNameNotFoundException(Code) | | Return the index of the anonymous inner class being instantiated at the specified position.
Parameters: position - of the opening curly brace of the anonymous inner class anonymous class index |
_getPackageQualifier | protected String _getPackageQualifier()(Code) | | Gets an appropriate prefix to fully qualify a class name. Returns this class's package followed by a dot, or the
empty string if no package name is found.
|
_removeTabs | static String _removeTabs(String source)(Code) | | Given a String, return a new String will all tabs converted to spaces. Each tab is converted
to one space, since changing the number of characters within insertString screws things up.
Parameters: source - the String to be converted. a String will all the tabs converted to spaces |
_styleChanged | protected void _styleChanged()(Code) | | |
addFinalizationListener | public void addFinalizationListener(FinalizationListener<DefinitionsDocument> fl)(Code) | | Registers a finalization listener with the specific instance of the ddoc
NOTE:This should only be used by test cases. This is to ensure that
we don't spring memory leaks by allowing our unit tests to keep track of
whether objects are being finalized (garbage collected)
Parameters: fl - the listener to register |
close | public void close()(Code) | | Called when this is kicked out of the document cache so that the references made to it may
be released so that this can be GC'd.
|
commentLines | public int commentLines(int selStart, int selEnd)(Code) | | Comments out all lines between selStart and selEnd, inclusive. The current cursor position is maintained
after the operation.
Parameters: selStart - the document offset for the start of the selection Parameters: selEnd - the document offset for the end of the selection |
createPosition | public Position createPosition(int offs) throws BadLocationException(Code) | | Factory method for created WrappedPositions. Stores the created Position instance
so it can be linked to a different DefinitionsDocument later.
|
documentSaved | public void documentSaved()(Code) | | Informs this document's undo manager that the document has been saved.
|
endCompoundEdit | protected void endCompoundEdit(int key)(Code) | | |
endLastCompoundEdit | protected void endLastCompoundEdit()(Code) | | |
finalize | protected void finalize()(Code) | | This is called when this method is GC'd. Since this class implements
edu.rice.cs.drjava.model.Finalizable, it must notify its listeners
|
getCurrentCol | public int getCurrentCol()(Code) | | Return the current column of the cursor position. Uses a 0 based index.
|
getCurrentLine | public int getCurrentLine()(Code) | | Return the current line of the cursor position. Uses a 1-based index.
|
getEnclosingClassName | public String getEnclosingClassName(int pos, boolean qual) throws BadLocationException, ClassNameNotFoundException(Code) | | Searching backwards finds the name of the enclosing named class or interface. NB: ignores comments.
WARNING: In long source files and when contained in anonymous inner classes, this function might take a LONG time.
Parameters: pos - Position to start from Parameters: qual - true to find the fully qualified class name name of the enclosing named class or interface |
getFirstTopLevelClassName | public String getFirstTopLevelClassName() throws ClassNameNotFoundException(Code) | | Gets the name of the top level class in this source file. This attempts to find the first declaration
of a class or interface.
The name of first class in the file throws: ClassNameNotFoundException - if no top level class found |
getMainClassName | public String getMainClassName() throws ClassNameNotFoundException(Code) | | Gets the name of the document's main class: the document's only public class/interface or
first top level class if document contains no public classes or interfaces.
|
getNextRedo | public UndoableEdit getNextRedo()(Code) | | Public accessor for the next undo action.
|
getNextUndo | public UndoableEdit getNextUndo()(Code) | | Public accessor for the next undo action.
|
getOffset | public int getOffset(int lineNum)(Code) | | Returns the offset corresponding to the first character of the given line number,
or -1 if the lineNum is not found. Avoid locking the document by copying its text.
Parameters: lineNum - the line number for which to calculate the offset. the offset of the first character in the given line number |
getPackageName | public String getPackageName()(Code) | | Gets the package name embedded in the text of this document by minimally parsing the document to find the
package statement. If package statement is not found or is ill-formed, returns "" as the package name.
The name of package embedded in this document. If there is no well-formed package statement, returns "" as the package name. |
getQualifiedClassName | public String getQualifiedClassName() throws ClassNameNotFoundException(Code) | | Gets the package and main class/interface name of this OpenDefinitionsDocument
the qualified main class/interface name |
getQualifiedClassName | public String getQualifiedClassName(int pos) throws ClassNameNotFoundException(Code) | | Gets fully qualified class name of the top level class enclosing the given position.
|
getWrappedPositionOffsets | public WeakHashMap<WrappedPosition, Integer> getWrappedPositionOffsets()(Code) | | Remove all positions that have been garbage-collected from the list of positions, then return a weakly-linked
hashmap with positions and their current offsets.
list of weak references to all positions that have been created and that have not been garbage-collected yet. |
gotoLine | public void gotoLine(int line)(Code) | | Goes to a particular line in the document.
|
isModifiedSinceSave | public boolean isModifiedSinceSave()(Code) | | Determines if the document has been modified since the last save.
true if the document has been modified |
makeNewIndenter | protected Indenter makeNewIndenter(int indentLevel)(Code) | | Returns a new indenter.
|
resetModification | public void resetModification()(Code) | | Resets the modification state of this document. Used after a document has been saved or reverted.
|
resetUndoManager | public void resetUndoManager()(Code) | | Resets the undo manager.
|
setOpenDefDoc | public void setOpenDefDoc(OpenDefinitionsDocument odd)(Code) | | Sets the OpenDefinitionsDocument that holds this DefinitionsDocument (the odd can only be set once).
Parameters: odd - the OpenDefinitionsDocument to set as this DD's holder |
setWrappedPositionOffsets | public void setWrappedPositionOffsets(WeakHashMap<WrappedPosition, Integer> whm) throws BadLocationException(Code) | | Re-create the wrapped positions in the hashmap, update the wrapped position, and add them to the list.
Parameters: whm - weakly-linked hashmap of wrapped positions and their offsets |
startCompoundEdit | protected int startCompoundEdit()(Code) | | |
tabsRemoved | public boolean tabsRemoved()(Code) | | Returns true iff tabs are to removed on text insertion.
|
uncommentLines | public int uncommentLines(int selStart, int selEnd)(Code) | | Uncomments all lines between selStart and selEnd, inclusive.
The current cursor position is maintained after the operation.
Parameters: selStart - the document offset for the start of the selection Parameters: selEnd - the document offset for the end of the selection |
updateModifiedSinceSave | public void updateModifiedSinceSave()(Code) | | Resets the modification state of this document to be consistent with state of _undoManager. Called whenever
an undo or redo is performed.
|
Methods inherited from edu.rice.cs.drjava.model.AbstractDJDocument | protected Object _checkCache(String key)(Code)(Java Doc) public boolean _indentLine(Indenter.IndentReason reason)(Code)(Java Doc) protected static boolean _isReversteStartOfComment(String text, int pos)(Code)(Java Doc) protected static boolean _isStartOfComment(String text, int pos)(Code)(Java Doc) protected static HashSet<String> _makeKeywords()(Code)(Java Doc) protected static HashSet<String> _makeNormEndings()(Code)(Java Doc) protected static HashSet<String> _makePrimTypes()(Code)(Java Doc) protected void _removeIndenter()(Code)(Java Doc) protected void _storeInCache(String key, Object result)(Code)(Java Doc) abstract protected void _styleChanged()(Code)(Java Doc) abstract protected void addUndoRedo(AbstractDocument.DefaultDocumentEvent chng, Runnable undoCommand, Runnable doCommand)(Code)(Java Doc) public int balanceBackward()(Code)(Java Doc) public int balanceForward()(Code)(Java Doc) public void clear()(Code)(Java Doc) protected void clearCache()(Code)(Java Doc) abstract protected void endCompoundEdit(int i)(Code)(Java Doc) abstract protected void endLastCompoundEdit()(Code)(Java Doc) public boolean findCharInStmtBeforePos(char findChar, int position)(Code)(Java Doc) public int findCharOnLine(int pos, char findChar)(Code)(Java Doc) public int findNextEnclosingBrace(int pos, char opening, char closing) throws BadLocationException(Code)(Java Doc) public int findPrevCharPos(int pos, char[] whitespace) throws BadLocationException(Code)(Java Doc) public int findPrevDelimiter(int pos, char[] delims) throws BadLocationException(Code)(Java Doc) public int findPrevDelimiter(int pos, char[] delims, boolean skipParenPhrases) throws BadLocationException(Code)(Java Doc) public int findPrevEnclosingBrace(int pos, char opening, char closing) throws BadLocationException(Code)(Java Doc) public int findPrevNonWSCharPos(int pos) throws BadLocationException(Code)(Java Doc) public byte[] getBytes()(Code)(Java Doc) public int getCurrentLocation()(Code)(Java Doc) public int getFirstNonWSCharPos(int pos) throws BadLocationException(Code)(Java Doc) public int getFirstNonWSCharPos(int pos, boolean acceptComments) throws BadLocationException(Code)(Java Doc) public int getFirstNonWSCharPos(int pos, char[] whitespace, boolean acceptComments) throws BadLocationException(Code)(Java Doc) public Vector<HighlightStatus> getHighlightStatus(int start, int end)(Code)(Java Doc) public int getIndent()(Code)(Java Doc) public IndentInfo getIndentInformation()(Code)(Java Doc) public String getIndentOfCurrStmt(int pos) throws BadLocationException(Code)(Java Doc) public String getIndentOfCurrStmt(int pos, char[] delims) throws BadLocationException(Code)(Java Doc) public String getIndentOfCurrStmt(int pos, char[] delims, char[] whitespace) throws BadLocationException(Code)(Java Doc) public int getIntelligentBeginLinePos(int currPos) throws BadLocationException(Code)(Java Doc) public int getLineEndPos(int pos)(Code)(Java Doc) public int getLineFirstCharPos(int pos) throws BadLocationException(Code)(Java Doc) public int getLineStartPos(int pos)(Code)(Java Doc) public BraceReduction getReduced()(Code)(Java Doc) public ReducedModelState getStateAtCurrent()(Code)(Java Doc) public String getText()(Code)(Java Doc) public int getWhiteSpace()(Code)(Java Doc) public void indentLines(int selStart, int selEnd)(Code)(Java Doc) public void indentLines(int selStart, int selEnd, Indenter.IndentReason reason, ProgressMonitor pm) throws OperationCanceledException(Code)(Java Doc) public void insertString(int offset, String str, AttributeSet a) throws BadLocationException(Code)(Java Doc) protected void insertUpdate(AbstractDocument.DefaultDocumentEvent chng, AttributeSet attr)(Code)(Java Doc) abstract protected Indenter makeNewIndenter(int indentLevel)(Code)(Java Doc) public void move(int dist)(Code)(Java Doc) public boolean posInParenPhrase(int pos)(Code)(Java Doc) public boolean posInParenPhrase()(Code)(Java Doc) protected boolean posNotInBlock(int pos)(Code)(Java Doc) public void remove(int offset, int len) throws BadLocationException(Code)(Java Doc) protected void removeUpdate(AbstractDocument.DefaultDocumentEvent chng)(Code)(Java Doc) public void resetReducedModelLocation()(Code)(Java Doc) public void setCurrentLocation(int loc)(Code)(Java Doc) public void setIndent(int indent)(Code)(Java Doc) public void setTab(String tab, int pos)(Code)(Java Doc) abstract protected int startCompoundEdit()(Code)(Java Doc) public ReducedModelState stateAtRelLocation(int dist)(Code)(Java Doc)
|
|
|