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
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 |
OnLanguageChanged(SyntaxLanguageChangedEventArgs)
Raises the LanguageChanged
event.
protected virtual void OnLanguageChanged(SyntaxLanguageChangedEventArgs e)
Parameter | Type | Description |
---|---|---|
e | SyntaxLanguageChangedEventArgs | An |
OnParseDataChanged(ParseDataPropertyChangedEventArgs)
Raises the ParseDataChanged
event.
protected virtual void OnParseDataChanged(ParseDataPropertyChangedEventArgs e)
Parameter | Type | Description |
---|---|---|
e | ParseDataPropertyChangedEventArgs | An |
OnTextChanged(TextSnapshotChangedEventArgs)
Raises the TextChanged event.
protected override void OnTextChanged(TextSnapshotChangedEventArgs e)
Parameter | Type | Description |
---|---|---|
e | TextSnapshotChangedEventArgs | A |
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
ParseDataChanged
Occurs after the value of the ParseData property has changed.
public event EventHandler<ParseDataPropertyChangedEventArgs> ParseDataChanged
Event Type
Inherited Members
- TextDocumentBase.AddTextChangedEventHandler(EventHandler<TextSnapshotChangedEventArgs>, EventHandlerPriority)
- TextDocumentBase.AddTextChangingEventHandler(EventHandler<TextSnapshotChangingEventArgs>, EventHandlerPriority)
- TextDocumentBase.AppendText(ITextChangeType, string)
- TextDocumentBase.AppendText(ITextChangeType, string, ITextChangeOptions)
- TextDocumentBase.CreateTextChange(ITextChangeType)
- TextDocumentBase.CreateTextChange(ITextChangeType, ITextChangeOptions)
- TextDocumentBase.DeleteText(ITextChangeType, TextRange)
- TextDocumentBase.DeleteText(ITextChangeType, TextRange, ITextChangeOptions)
- TextDocumentBase.DeleteText(ITextChangeType, int, int)
- TextDocumentBase.DeleteText(ITextChangeType, int, int, ITextChangeOptions)
- TextDocumentBase.GetTextReplacementInsertText(ITextChangeOperation)
- TextDocumentBase.InsertText(ITextChangeType, int, string)
- TextDocumentBase.InsertText(ITextChangeType, int, string, ITextChangeOptions)
- TextDocumentBase.OnTextChanging(TextSnapshotChangingEventArgs)
- TextDocumentBase.RemoveTextChangedEventHandler(EventHandler<TextSnapshotChangedEventArgs>, EventHandlerPriority)
- TextDocumentBase.RemoveTextChangingEventHandler(EventHandler<TextSnapshotChangingEventArgs>, EventHandlerPriority)
- TextDocumentBase.ReplaceText(ITextChangeType, TextRange, string)
- TextDocumentBase.ReplaceText(ITextChangeType, TextRange, string, ITextChangeOptions)
- TextDocumentBase.ReplaceText(ITextChangeType, int, int, string)
- TextDocumentBase.ReplaceText(ITextChangeType, int, int, string, ITextChangeOptions)
- TextDocumentBase.SetHeaderAndFooterText(string, string)
- TextDocumentBase.SetText(string)
- TextDocumentBase.SetText(ITextChangeType, string)
- TextDocumentBase.SetText(ITextChangeType, string, ITextChangeOptions)
- TextDocumentBase.IsTextRangeReadOnly(TextRange)
- TextDocumentBase.NotifyPropertyChanged(string)
- 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.LoadFile(string)
- TextDocumentBase.LoadFile(string, Encoding)
- TextDocumentBase.LoadFile(Stream, Encoding)
- TextDocumentBase.SaveFile(string, LineTerminator)
- 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.CurrentSnapshot
- TextDocumentBase.AutoCharacterCasing
- TextDocumentBase.AutoConvertTabsToSpaces
- TextDocumentBase.IsModified
- TextDocumentBase.IsReadOnly
- TextDocumentBase.TabSize
- TextDocumentBase.UndoHistory
- TextDocumentBase.FileName
- TextDocumentBase.TextChanged
- TextDocumentBase.TextChanging
- TextDocumentBase.IsModifiedChanged
- TextDocumentBase.IsReadOnlyChanged
- TextDocumentBase.PropertyChanged
- TextDocumentBase.TabSizeChanged
- TextDocumentBase.FileNameChanged
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()