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
Remarks
The default value is a plain text language.
LanguageData
An object that specifies document-specific data for the Language that is loaded.
ParseData
The syntax/semantic parse data that has been assigned to this document as a result of a parsing operation.
Properties
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().
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
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
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:
trueif the property value has changed from its default; otherwise,false.
ShouldSerializeLanguageData()
Indicates whether the LanguageData property should be persisted.
public bool ShouldSerializeLanguageData()
Returns
- bool:
trueif the property value has changed from its default; otherwise,false.
ShouldSerializeParseData()
Indicates whether the ParseData property should be persisted.
public bool ShouldSerializeParseData()
Returns
- bool:
trueif 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
ParseDataChanged
Occurs after the value of the ParseData property has changed.
public event EventHandler<ParseDataPropertyChangedEventArgs>? ParseDataChanged
Event Type
Inherited Members
- TextDocumentBase.DefaultTabSize
- TextDocumentBase.IsTextRangeReadOnly(TextRange)
- TextDocumentBase.OnIsModifiedChanged(EventArgs)
- TextDocumentBase.OnIsReadOnlyChanged(EventArgs)
- TextDocumentBase.OnTabSizeChanged(EventArgs)
- TextDocumentBase.ReplaceAll(ISearchOptions)
- TextDocumentBase.ReplaceAll(ISearchOptions, params TextRange[])
- TextDocumentBase.ReplaceNext(ISearchOptions, int, bool)
- TextDocumentBase.ReplaceNext(ISearchOptions, int, bool, TextRange)
- TextDocumentBase.AddTextChangedEventHandler(EventHandler<TextSnapshotChangedEventArgs>, EventHandlerPriority)
- TextDocumentBase.AddTextChangingEventHandler(EventHandler<TextSnapshotChangingEventArgs>, EventHandlerPriority)
- TextDocumentBase.AppendText(ITextChangeType, string, ITextChangeOptions)
- TextDocumentBase.CreateTextChange(ITextChangeType, ITextChangeOptions)
- TextDocumentBase.DeleteText(ITextChangeType, TextRange, ITextChangeOptions)
- TextDocumentBase.DeleteText(ITextChangeType, int, int, ITextChangeOptions)
- TextDocumentBase.GetTextReplacementInsertText(ITextChangeOperation)
- TextDocumentBase.InsertText(ITextChangeType, int, string, ITextChangeOptions)
- TextDocumentBase.NormalizeLineTerminators(LineTerminator, ITextChangeOptions)
- TextDocumentBase.OnTextChanging(TextSnapshotChangingEventArgs)
- TextDocumentBase.RemoveTextChangedEventHandler(EventHandler<TextSnapshotChangedEventArgs>, EventHandlerPriority)
- TextDocumentBase.RemoveTextChangingEventHandler(EventHandler<TextSnapshotChangingEventArgs>, EventHandlerPriority)
- TextDocumentBase.ReplaceText(ITextChangeType, TextRange, string, ITextChangeOptions)
- TextDocumentBase.ReplaceText(ITextChangeType, int, int, string, ITextChangeOptions)
- TextDocumentBase.SetHeaderAndFooterText(string, string)
- TextDocumentBase.SetText(string)
- TextDocumentBase.SetText(ITextChangeType, string, ITextChangeOptions)
- TextDocumentBase.LoadFile(string, Encoding)
- TextDocumentBase.LoadFile(Stream, Encoding)
- TextDocumentBase.SaveFile(string, Encoding, LineTerminator?)
- TextDocumentBase.SaveFile(Stream, Encoding, LineTerminator?)
- TextDocumentBase.ResetAutoCharacterCasing()
- TextDocumentBase.ShouldSerializeAutoCharacterCasing()
- TextDocumentBase.ResetAutoConvertTabsToSpaces()
- TextDocumentBase.ShouldSerializeAutoConvertTabsToSpaces()
- TextDocumentBase.ResetFileName()
- TextDocumentBase.ShouldSerializeFileName()
- TextDocumentBase.ResetIsModified()
- TextDocumentBase.ShouldSerializeIsModified()
- TextDocumentBase.ResetIsReadOnly()
- TextDocumentBase.ShouldSerializeIsReadOnly()
- TextDocumentBase.ResetTabSize()
- TextDocumentBase.ShouldSerializeTabSize()
- TextDocumentBase.AutoCharacterCasing
- TextDocumentBase.AutoConvertTabsToSpaces
- TextDocumentBase.IsModified
- TextDocumentBase.IsReadOnly
- TextDocumentBase.TabSize
- TextDocumentBase.UndoHistory
- TextDocumentBase.CurrentSnapshot
- TextDocumentBase.FileName
- TextDocumentBase.IsModifiedChanged
- TextDocumentBase.IsReadOnlyChanged
- TextDocumentBase.TabSizeChanged
- TextDocumentBase.TextChanged
- TextDocumentBase.TextChanging
- TextDocumentBase.FileNameChanged
- ObservableObjectBase.OnPropertyChanged(string)
- ObservableObjectBase.OnPropertyChanged(PropertyChangedEventArgs)
- ObservableObjectBase.OnPropertyChanging(string)
- ObservableObjectBase.OnPropertyChanging(PropertyChangingEventArgs)
- ObservableObjectBase.SetProperty<T>(ref T, T, string)
- ObservableObjectBase.PropertyChanged
- ObservableObjectBase.PropertyChanging
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()