In This Article

CodeDocument Class

Represents a text document with some advanced features that relate to syntax highlighting and code parsing.

public class CodeDocument : TextDocumentBase, ICodeDocument, IParseTarget, ITextDocument
Inheritance:
object TextDocumentBase object
Derived:
EditorDocument
Implements:
ICodeDocument IParseTarget ITextDocument

Constructors

CodeDocument()

Initializes a new instance of the CodeDocument class.

public CodeDocument()

Properties

Language

Gets or sets the ISyntaxLanguage that is currently loaded.

public ISyntaxLanguage Language { get; set; }

Property Value

ISyntaxLanguage:

The ISyntaxLanguage that is currently loaded.

Remarks

The default value is a plain text language.

LanguageData

Gets or sets an object that specifies document-specific data for the Language that is loaded.

public object LanguageData { get; set; }

Property Value

object:

An object that specifies document-specific data for the Language that is loaded.

ParseData

Gets or sets the syntax/semantic parse data that has been assigned to this document as a result of a parsing operation.

public IParseData ParseData { get; set; }

Property Value

IParseData:

The syntax/semantic parse data that has been assigned to this document as a result of a parsing operation.

Properties

Gets the dictionary containing custom properties for this object.

public PropertyDictionary Properties { get; }

Property Value

PropertyDictionary:

The dictionary containing custom properties for this object.

Methods

AddLanguageChangedEventHandler(EventHandler<SyntaxLanguageChangedEventArgs>, EventHandlerPriority)

Adds an event handler for the LanguageChanged event using the specified priority level.

public void AddLanguageChangedEventHandler(EventHandler<SyntaxLanguageChangedEventArgs> handler, EventHandlerPriority priority)
Parameter Type Description
handler EventHandler<SyntaxLanguageChangedEventArgs>

The delegate handler.

priority EventHandlerPriority

A EventHandlerPriority specifying the priority level.

CreateParseRequest()

Creates an IParseRequest that will be used by calls to QueueParseRequest().

protected virtual IParseRequest CreateParseRequest()

Returns

IParseRequest:

The IParseRequest that was created.

CreateTagAggregator<T>()

Creates a new ITagAggregator<T> that collects the tag results from all ITagger<T> instances associated with this document.

public ITagAggregator<T> CreateTagAggregator<T>() where T : ITag
Type Parameters:
T -

The type of ITag associated with this aggregator.

Returns

ITagAggregator<T>:

The ITagAggregator<T> that was created.

GetReadOnlyRegions(TextRange)

Returns the collection of read-only region tag snapshot ranges.

protected override IEnumerable<TagSnapshotRange<IReadOnlyRegionTag>> GetReadOnlyRegions(TextRange textRange)
Parameter Type Description
textRange TextRange

The text range relative to the current snapshot for which to locate read-only regions.

Returns

IEnumerable<TagSnapshotRange<IReadOnlyRegionTag>>:

The collection of read-only region tag snapshot ranges.

GetServices<TService>()

Returns a list of available services of the specified type.

public IList<TService> GetServices<TService>() where TService : class
Type Parameters:
TService -

The type of service.

Returns

IList<TService>:

The list of available services of the specified type.

NotifyParseComplete(IParseRequest, IParseData)

Called when a parsing operation has completed for this document, and passes the original request along with the result.

protected virtual void NotifyParseComplete(IParseRequest request, IParseData result)
Parameter Type Description
request IParseRequest

An IParseRequest that contains information about the parsing operation that was requested.

result IParseData

An IParseData that is the result of the parsing operation.

Remarks

The default implementation of this method assigns result to the ParseData property.

OnFileNameChanged(StringPropertyChangedEventArgs)

Raises the FileNameChanged event.

protected override void OnFileNameChanged(StringPropertyChangedEventArgs e)
Parameter Type Description
e StringPropertyChangedEventArgs

An StringPropertyChangedEventArgs that contains the event data.

OnLanguageChanged(SyntaxLanguageChangedEventArgs)

Raises the LanguageChanged event.

protected virtual void OnLanguageChanged(SyntaxLanguageChangedEventArgs e)
Parameter Type Description
e SyntaxLanguageChangedEventArgs

An SyntaxLanguageChangedEventArgs that contains the event data.

OnParseDataChanged(ParseDataPropertyChangedEventArgs)

Raises the ParseDataChanged event.

protected virtual void OnParseDataChanged(ParseDataPropertyChangedEventArgs e)
Parameter Type Description
e ParseDataPropertyChangedEventArgs

An ParseDataPropertyChangedEventArgs that contains the event data.

OnTextChanged(TextSnapshotChangedEventArgs)

Raises the TextChanged event.

protected override void OnTextChanged(TextSnapshotChangedEventArgs e)
Parameter Type Description
e TextSnapshotChangedEventArgs

A TextSnapshotChangedEventArgs that contains the event data.

QueueParseRequest()

Queues up a parse request for the document with the ambient dispatcher.

public void QueueParseRequest()

Remarks

If AmbientParseRequestDispatcherProvider does not provide a dispatcher, the parsing operation is completed immediately in the calling thread.

RemoveLanguageChangedEventHandler(EventHandler<SyntaxLanguageChangedEventArgs>, EventHandlerPriority)

Removes an event handler for the LanguageChanged event using the specified priority level.

public void RemoveLanguageChangedEventHandler(EventHandler<SyntaxLanguageChangedEventArgs> handler, EventHandlerPriority priority)
Parameter Type Description
handler EventHandler<SyntaxLanguageChangedEventArgs>

The delegate handler.

priority EventHandlerPriority

A EventHandlerPriority specifying the priority level.

Events

LanguageChanged

Occurs after the value of the Language property has changed.

public event EventHandler<SyntaxLanguageChangedEventArgs> LanguageChanged

Event Type

EventHandler<SyntaxLanguageChangedEventArgs>

ParseDataChanged

Occurs after the value of the ParseData property has changed.

public event EventHandler<ParseDataPropertyChangedEventArgs> ParseDataChanged

Event Type

EventHandler<ParseDataPropertyChangedEventArgs>

Inherited Members