C# Класс Microsoft.R.Editor.Tree.EditorTree

Document tree for the editor. It does not derive from AST and rather aggregates it. The reason is that editor tree can be read and updated from different threads and hence we need to control access to the tree elements using appropriate locks. Typically there are three threads: main application thread which should be creating editor tree, incremental parse thread and validation (syntx check) thread.
Наследование: IEditorTree, IDisposable
Показать файл Открыть проект Примеры использования класса

Private Properties

Свойство Тип Описание
ApplyChangesFromQueue List
Dispose void
FireOnNodesRemoved void
FireOnPositionsOnlyChanged void
FireOnUpdateBegin void
FireOnUpdateCompleted void
FireOnUpdatesPending void
FirePostUpdateEvents void
GetAstRootUnsafe Microsoft.R.Core.AST.AstRoot
InvalidateInRange bool
NotifyTextChange void
OnTextBufferChanged void
ProcessChanges void
TakeThreadOwnerShip void
ToString string

Открытые методы

Метод Описание
AcquireReadLock ( System.Guid treeUserId ) : AstRoot
AcquireWriteLock ( ) : bool
Build ( ) : void

Builds initial AST. Subsequent updates should be coming from a background thread.

Dispose ( ) : void
EditorTree ( ITextBuffer textBuffer, ICoreShell shell, IExpressionTermFilter filter = null ) : System

Creates document tree on a given text buffer.

EnsureTreeReady ( ) : void

Ensures tree is up to date, matches current text buffer snapshot and all changes since the last update were processed. Blocks until all changes have been processed. Does not pump messages.

GetCommentBlockContainingRange ( ITextRange range ) : ITextRange

Determines if a given range is inside a comment and returns range of the comment block.

GetCommentBlockFromPosition ( int position ) : ITextRange

Determines if a given position is inside a comment and returns range of the comment block.

GetPositionElement ( int position, IAstNode &node ) : PositionType

Determines position type and enclosing element node for a given position in the document text.

Invalidate ( ) : void

Removes all elements from the tree

InvokeWhenReady ( Action action, object p, Type type, bool processNow = false ) : void

Provides a way to automatically invoke particular action once when tree becomes ready again. Typically used in asynchronous completion and signature help scenarios.

IsRangeInComment ( ITextRange range ) : bool

Determines if a given range is inside a comment.

IsRangeInComment ( int position ) : bool

Determines if a given position is inside a comment of any kind. Comment may be plain HTML comment or artifact type comment like <%--...--%> in ASP.NET or @* ... *@ in Razor.

ReleaseReadLock ( System.Guid treeUserId ) : bool
ReleaseWriteLock ( ) : bool

Приватные методы

Метод Описание
ApplyChangesFromQueue ( Queue queue ) : List
Dispose ( bool disposing ) : void
FireOnNodesRemoved ( IReadOnlyCollection nodes ) : void

Fires 'nodes removed' event on the main thread context

FireOnPositionsOnlyChanged ( ) : void

Fires 'positions changed starting inside this element' event on the main thread context

FireOnUpdateBegin ( ) : void

Fires 'update begin' event on the main thread context

FireOnUpdateCompleted ( TreeUpdateType updateType ) : void

Fires 'update end' event on the main thread context

FireOnUpdatesPending ( IReadOnlyCollection textChanges ) : void

Fires 'tree updates pending' event on the main thread context

FirePostUpdateEvents ( List changes, bool fullParse ) : void
GetAstRootUnsafe ( ) : AstRoot
InvalidateInRange ( ITextRange range ) : bool

Removes nodes from the tree collection if node range is partially or entirely within the deleted region. This is needed since parsing is asynchronous and without node removal intellisense and syntax checker may end up processing nodes that are out of date. Where possible stops at the nearest scope level so scope nodes may still be used in smart indenter.

NotifyTextChange ( int start, int oldLength, int newLength ) : void
OnTextBufferChanged ( object sender, TextContentChangedEventArgs e ) : void
ProcessChanges ( ) : void

Initiates processing of pending changes synchronously.

TakeThreadOwnerShip ( ) : void

Makes current thread owner of the tree. Normally only one thread can access the tree.

ToString ( ) : string

Описание методов

AcquireReadLock() публичный Метод

public AcquireReadLock ( System.Guid treeUserId ) : AstRoot
treeUserId System.Guid
Результат Microsoft.R.Core.AST.AstRoot

AcquireWriteLock() публичный Метод

public AcquireWriteLock ( ) : bool
Результат bool

Build() публичный Метод

Builds initial AST. Subsequent updates should be coming from a background thread.
public Build ( ) : void
Результат void

Dispose() публичный Метод

public Dispose ( ) : void
Результат void

EditorTree() публичный Метод

Creates document tree on a given text buffer.
public EditorTree ( ITextBuffer textBuffer, ICoreShell shell, IExpressionTermFilter filter = null ) : System
textBuffer ITextBuffer Text buffer
shell ICoreShell
filter IExpressionTermFilter
Результат System

EnsureTreeReady() публичный Метод

Ensures tree is up to date, matches current text buffer snapshot and all changes since the last update were processed. Blocks until all changes have been processed. Does not pump messages.
public EnsureTreeReady ( ) : void
Результат void

GetCommentBlockContainingRange() публичный Метод

Determines if a given range is inside a comment and returns range of the comment block.
public GetCommentBlockContainingRange ( ITextRange range ) : ITextRange
range ITextRange Text range to check
Результат ITextRange

GetCommentBlockFromPosition() публичный Метод

Determines if a given position is inside a comment and returns range of the comment block.
public GetCommentBlockFromPosition ( int position ) : ITextRange
position int Position to check
Результат ITextRange

GetPositionElement() публичный Метод

Determines position type and enclosing element node for a given position in the document text.
public GetPositionElement ( int position, IAstNode &node ) : PositionType
position int Position in the document text
node IAstNode Node that contains position
Результат PositionType

Invalidate() публичный Метод

Removes all elements from the tree
public Invalidate ( ) : void
Результат void

InvokeWhenReady() публичный Метод

Provides a way to automatically invoke particular action once when tree becomes ready again. Typically used in asynchronous completion and signature help scenarios.
public InvokeWhenReady ( Action action, object p, Type type, bool processNow = false ) : void
action Action Action to invoke
p object Parameter to pass to the action
type System.Type Action identifier
processNow bool /// If true, change processing begins now. /// If false, next regular parsing pass with process pending changes. ///
Результат void

IsRangeInComment() публичный Метод

Determines if a given range is inside a comment.
public IsRangeInComment ( ITextRange range ) : bool
range ITextRange Text range
Результат bool

IsRangeInComment() публичный Метод

Determines if a given position is inside a comment of any kind. Comment may be plain HTML comment or artifact type comment like <%--...--%> in ASP.NET or @* ... *@ in Razor.
public IsRangeInComment ( int position ) : bool
position int Position in the document
Результат bool

ReleaseReadLock() публичный Метод

public ReleaseReadLock ( System.Guid treeUserId ) : bool
treeUserId System.Guid
Результат bool

ReleaseWriteLock() публичный Метод

public ReleaseWriteLock ( ) : bool
Результат bool