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 ObservableObjectBase TextDocumentBase object
Derived:
EditorDocument
Implements:
ICodeDocument IParseTarget ITextDocument

Constructors

CodeDocument()

Initializes an instance of the class.

public CodeDocument()

Properties

Language

The ISyntaxLanguage that is currently loaded.

public ISyntaxLanguage Language { get; set; }

Property Value

ISyntaxLanguage

Remarks

The default value is a plain text language.

LanguageData

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

public object? LanguageData { get; set; }

Property Value

object

ParseData

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

Properties

The dictionary containing custom properties for this object.

public PropertyDictionary Properties { get; }

Property Value

PropertyDictionary

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

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>

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>>

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>

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

The event data.

OnLanguageChanged(SyntaxLanguageChangedEventArgs)

Raises the LanguageChanged event.

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

The event data.

OnParseDataChanged(ParseDataPropertyChangedEventArgs)

Raises the ParseDataChanged event.

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

The event data.

OnTextChanged(TextSnapshotChangedEventArgs)

Raises the TextChanged event.

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

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.

ResetLanguage()

Resets the Language property to its default value.

public void ResetLanguage()

ResetLanguageData()

Resets the LanguageData property to its default value.

public void ResetLanguageData()

ResetParseData()

Resets the ParseData property to its default value.

public void ResetParseData()

ShouldSerializeLanguage()

Indicates whether the Language property should be persisted.

public bool ShouldSerializeLanguage()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

ShouldSerializeLanguageData()

Indicates whether the LanguageData property should be persisted.

public bool ShouldSerializeLanguageData()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

ShouldSerializeParseData()

Indicates whether the ParseData property should be persisted.

public bool ShouldSerializeParseData()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

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

Extension Methods