Source Source Source Source Class

Definition

Important

This API is not CLS-compliant.

Represents a source file in the language service and controls parsing operations on that source.

public ref class Source : IDisposable, Microsoft::VisualStudio::TextManager::Interop::IVsHiddenTextClient, Microsoft::VisualStudio::TextManager::Interop::IVsTextLinesEvents, Microsoft::VisualStudio::TextManager::Interop::IVsUserDataEvents
[System.CLSCompliant(false)]
public class Source : IDisposable, Microsoft.VisualStudio.TextManager.Interop.IVsHiddenTextClient, Microsoft.VisualStudio.TextManager.Interop.IVsTextLinesEvents, Microsoft.VisualStudio.TextManager.Interop.IVsUserDataEvents
type Source = class
    interface IDisposable
    interface IVsTextLinesEvents
    interface IVsHiddenTextClient
    interface IVsUserDataEvents
Public Class Source
Implements IDisposable, IVsHiddenTextClient, IVsTextLinesEvents, IVsUserDataEvents
Inheritance
SourceSourceSourceSource
Attributes
Implements

Remarks

A Source object represents the entire source file associated with a particular view. Information about the source file can be obtained from this class. However, the primary functionality of this class is to handle parsing operations on the source in support for IntelliSense operations and source file-specific editing operations such as adding comments to and removing comments from blocks of code and reporting parsing errors.

Notes to Inheritors

The base class supports all of the IntelliSense operations in coordination with methods on the LanguageService class (these are detailed in the Source class's method descriptions). If you:

  • support different comment delimiters other than the standard C#/C++ delimiters,

  • reformat code,

    and/or

  • support advanced functionality for hidden regions (monitoring change of state, ensuring a span is visible, and marker-oriented context menu commands),

    you must derive a class from the Source class and instantiate your class in CreateSource(IVsTextLines).

Notes to Callers

This class is instantiated by a call to the CreateSource(IVsTextLines) method. This is done when the CodeWindowManager object is instantiated (the Source object is passed to the CodeWindowManager constructor). A Colorizer object can be instantiated and passed to the Source class's constructor.

Constructors

Source(LanguageService, IVsTextLines, Colorizer) Source(LanguageService, IVsTextLines, Colorizer) Source(LanguageService, IVsTextLines, Colorizer) Source(LanguageService, IVsTextLines, Colorizer)

Initializes a new instance of the Source class.

Properties

ChangeCount ChangeCount ChangeCount ChangeCount

Gets the number of changes made to the source file since it was opened.

ColorState ColorState ColorState ColorState

Gets or sets the IVsTextColorState object that is used in various parsing tasks.

CompletedFirstParse CompletedFirstParse CompletedFirstParse CompletedFirstParse

Gets whether the parser has completed at least once.

CompletionSet CompletionSet CompletionSet CompletionSet

Gets the CompletionSet collection used for this instance of the Source class.

DirtySpan DirtySpan DirtySpan DirtySpan

Gets a range that identifies the changed lines in the source.

HandlesSnapshots HandlesSnapshots HandlesSnapshots HandlesSnapshots
IsClosed IsClosed IsClosed IsClosed

Gets the current state of the source file.

IsCompletorActive IsCompletorActive IsCompletorActive IsCompletorActive

Gets whether the IntelliSense member completion or method tip modes are active.

IsDirty IsDirty IsDirty IsDirty

Gets or sets whether any of the lines of source have changed.

LanguageService LanguageService LanguageService LanguageService

Gets the language service associated with the source file.

LastParseTime LastParseTime LastParseTime LastParseTime

Gets the duration of the last parse operation.

OutliningEnabled OutliningEnabled OutliningEnabled OutliningEnabled

Gets or sets whether outlining is currently enabled.

Methods

BeginParse() BeginParse() BeginParse() BeginParse()

Begins a full parsing operation either in the foreground or the background.

BeginParse(Int32, Int32, TokenInfo, ParseReason, IVsTextView, ParseResultHandler) BeginParse(Int32, Int32, TokenInfo, ParseReason, IVsTextView, ParseResultHandler) BeginParse(Int32, Int32, TokenInfo, ParseReason, IVsTextView, ParseResultHandler) BeginParse(Int32, Int32, TokenInfo, ParseReason, IVsTextView, ParseResultHandler)

Begins a parsing operation with the given token, text view, and parse request handler.

Close() Close() Close() Close()

Determines whether the source file can be closed.

ColumnToVisiblePosition(Int32, Int32) ColumnToVisiblePosition(Int32, Int32) ColumnToVisiblePosition(Int32, Int32) ColumnToVisiblePosition(Int32, Int32)

Gets the screen column position corresponding to the specified character offset, taking into account tab size.

CommentBlock(TextSpan, String, String) CommentBlock(TextSpan, String, String) CommentBlock(TextSpan, String, String) CommentBlock(TextSpan, String, String)

Comments out a span of source using block comments.

CommentLines(TextSpan, String) CommentLines(TextSpan, String) CommentLines(TextSpan, String) CommentLines(TextSpan, String)

Comments out a span of source using line comments.

CommentSpan(TextSpan) CommentSpan(TextSpan) CommentSpan(TextSpan) CommentSpan(TextSpan)

Comments out the specified span of source.

Completion(IVsTextView, TokenInfo, ParseReason) Completion(IVsTextView, TokenInfo, ParseReason) Completion(IVsTextView, TokenInfo, ParseReason) Completion(IVsTextView, TokenInfo, ParseReason)

Starts an IntelliSense member completion operation.

CreateAuthoringSink(ParseReason, Int32, Int32) CreateAuthoringSink(ParseReason, Int32, Int32) CreateAuthoringSink(ParseReason, Int32, Int32) CreateAuthoringSink(ParseReason, Int32, Int32)

Creates an instance of an AuthoringSink object for use in parsing operations.

CreateCompletionSet() CreateCompletionSet() CreateCompletionSet() CreateCompletionSet()

Creates a new instance of a CompletionSet class.

CreateErrorTaskItem(TextSpan, MARKERTYPE, String) CreateErrorTaskItem(TextSpan, MARKERTYPE, String) CreateErrorTaskItem(TextSpan, MARKERTYPE, String) CreateErrorTaskItem(TextSpan, MARKERTYPE, String)

Creates a new error task item for the Error List, for the supplied text, marker type, and file name.

CreateErrorTaskItem(TextSpan, String, String, TaskPriority, TaskCategory, MARKERTYPE, TaskErrorCategory) CreateErrorTaskItem(TextSpan, String, String, TaskPriority, TaskCategory, MARKERTYPE, TaskErrorCategory) CreateErrorTaskItem(TextSpan, String, String, TaskPriority, TaskCategory, MARKERTYPE, TaskErrorCategory) CreateErrorTaskItem(TextSpan, String, String, TaskPriority, TaskCategory, MARKERTYPE, TaskErrorCategory)

Creates a new error task item for the Error List, for the supplied text, file name, message, priority, category, marker type, and error type.

CreateMethodData() CreateMethodData() CreateMethodData() CreateMethodData()

Creates a new instance of a MethodData object that handles the IntelliSense method tip mode.

DismissCompletor() DismissCompletor() DismissCompletor() DismissCompletor()

Removes the IntelliSense method tip or completion list from view, whichever was active.

Dispose() Dispose() Dispose() Dispose()

Called in preparation of destroying this Source object.

ExecMarkerCommand(IVsHiddenRegion, Int32) ExecMarkerCommand(IVsHiddenRegion, Int32) ExecMarkerCommand(IVsHiddenRegion, Int32) ExecMarkerCommand(IVsHiddenRegion, Int32)

Executes the specified command on the specified region.

Finalize() Finalize() Finalize() Finalize()

The class destructor, called just before the object is destroyed.

GetColorizer() GetColorizer() GetColorizer() GetColorizer()

Gets the colorizer associated with this Source object.

GetCommentFormat() GetCommentFormat() GetCommentFormat() GetCommentFormat()

Gets information on what defines a comment in the language.

GetDocumentSpan() GetDocumentSpan() GetDocumentSpan() GetDocumentSpan()

Gets the span occupied by the entire source file.

GetExpansionProvider() GetExpansionProvider() GetExpansionProvider() GetExpansionProvider()

Gets an expansion provider in support of code snippets.

GetFilePath() GetFilePath() GetFilePath() GetFilePath()

Gets the file name of the source file.

GetHiddenTextSession() GetHiddenTextSession() GetHiddenTextSession() GetHiddenTextSession()

Gets the hidden region manager if available.

GetLine(Int32) GetLine(Int32) GetLine(Int32) GetLine(Int32)

Gets the text on the specified line.

GetLineCount() GetLineCount() GetLineCount() GetLineCount()

Gets the number of lines in the source file.

GetLineIndexOfPosition(Int32, Int32, Int32) GetLineIndexOfPosition(Int32, Int32, Int32) GetLineIndexOfPosition(Int32, Int32, Int32) GetLineIndexOfPosition(Int32, Int32, Int32)

Gets the line and column for the specified position.

GetLineLength(Int32) GetLineLength(Int32) GetLineLength(Int32) GetLineLength(Int32)

Gets the length of the specified line.

GetMarkerCommandInfo(IVsHiddenRegion, Int32, String[], UInt32[]) GetMarkerCommandInfo(IVsHiddenRegion, Int32, String[], UInt32[]) GetMarkerCommandInfo(IVsHiddenRegion, Int32, String[], UInt32[]) GetMarkerCommandInfo(IVsHiddenRegion, Int32, String[], UInt32[])

Determines which marker commands can be shown on a context menu for the specified hidden region.

GetNewLine(Int32) GetNewLine(Int32) GetNewLine(Int32) GetNewLine(Int32)

Gets the newline character used at the end of the specified line.

GetPairExtents(IVsTextView, Int32, Int32, TextSpan) GetPairExtents(IVsTextView, Int32, Int32, TextSpan) GetPairExtents(IVsTextView, Int32, Int32, TextSpan) GetPairExtents(IVsTextView, Int32, Int32, TextSpan)

Gets the span between a matching pair of language elements.

GetPairExtents(IVsTextView, Int32, Int32, TextSpan, TextSpan) GetPairExtents(IVsTextView, Int32, Int32, TextSpan, TextSpan) GetPairExtents(IVsTextView, Int32, Int32, TextSpan, TextSpan) GetPairExtents(IVsTextView, Int32, Int32, TextSpan, TextSpan)

Gets the text spans for a matching pair (or triplet) of language elements.

GetPositionOfLineIndex(Int32, Int32) GetPositionOfLineIndex(Int32, Int32) GetPositionOfLineIndex(Int32, Int32) GetPositionOfLineIndex(Int32, Int32)

Gets the position corresponding to the given line and character offset location.

GetTaskProvider() GetTaskProvider() GetTaskProvider() GetTaskProvider()

Gets the task provider that manages the error tasks.

GetText(TextSpan) GetText(TextSpan) GetText(TextSpan) GetText(TextSpan)

Gets the text included in the text span.

GetText(Int32, Int32, Int32, Int32) GetText(Int32, Int32, Int32, Int32) GetText(Int32, Int32, Int32, Int32) GetText(Int32, Int32, Int32, Int32)

Gets the text between the specified locations.

GetText() GetText() GetText() GetText()

Gets all of the text of the source file.

GetTextLines() GetTextLines() GetTextLines() GetTextLines()

Gets the IVsTextLines object associated with this Source object.

GetTextUpToLine(Int32) GetTextUpToLine(Int32) GetTextUpToLine(Int32) GetTextUpToLine(Int32)

Gets the text from the source up to and including the given line number.

GetTipText(IVsHiddenRegion, String[]) GetTipText(IVsHiddenRegion, String[]) GetTipText(IVsHiddenRegion, String[]) GetTipText(IVsHiddenRegion, String[])

Gets the text in the given hidden region to be used in a tool tip.

GetTokenInfo(Int32, Int32) GetTokenInfo(Int32, Int32) GetTokenInfo(Int32, Int32) GetTokenInfo(Int32, Int32)

Gets information about the token at the specified position.

GetTokenInfoAt(TokenInfo[], Int32, TokenInfo) GetTokenInfoAt(TokenInfo[], Int32, TokenInfo) GetTokenInfoAt(TokenInfo[], Int32, TokenInfo) GetTokenInfoAt(TokenInfo[], Int32, TokenInfo)

Gets the index of the TokenInfo object that includes the supplied column number.

GetUserData(Guid) GetUserData(Guid) GetUserData(Guid) GetUserData(Guid)

Gets the user data associated with the specified GUID.

GetWordExtent(Int32, Int32, WORDEXTFLAGS, Int32, Int32) GetWordExtent(Int32, Int32, WORDEXTFLAGS, Int32, Int32) GetWordExtent(Int32, Int32, WORDEXTFLAGS, Int32, Int32) GetWordExtent(Int32, Int32, WORDEXTFLAGS, Int32, Int32)

Gets the span occupied by the word at the specified location.

MakeBaseSpanVisible(IVsHiddenRegion, TextSpan[]) MakeBaseSpanVisible(IVsHiddenRegion, TextSpan[]) MakeBaseSpanVisible(IVsHiddenRegion, TextSpan[]) MakeBaseSpanVisible(IVsHiddenRegion, TextSpan[])

Ensures that the given span in the given hidden region is visible.

MatchBraces(IVsTextView, Int32, Int32, TokenInfo) MatchBraces(IVsTextView, Int32, Int32, TokenInfo) MatchBraces(IVsTextView, Int32, Int32, TokenInfo) MatchBraces(IVsTextView, Int32, Int32, TokenInfo)

Highlights the spans of a pair of language elements, given the position of one of the elements.

MethodTip(IVsTextView, Int32, Int32, TokenInfo) MethodTip(IVsTextView, Int32, Int32, TokenInfo) MethodTip(IVsTextView, Int32, Int32, TokenInfo) MethodTip(IVsTextView, Int32, Int32, TokenInfo)

Displays an IntelliSense method tip showing a method's signature as it is entered.

NormalizeNewlines(String, String) NormalizeNewlines(String, String) NormalizeNewlines(String, String) NormalizeNewlines(String, String)

Converts the newlines in the specified text to the specified newline.

OnBeforeSessionEnd() OnBeforeSessionEnd() OnBeforeSessionEnd() OnBeforeSessionEnd()

Called just before a hidden region session is closed.

OnChangeLineAttributes(Int32, Int32) OnChangeLineAttributes(Int32, Int32) OnChangeLineAttributes(Int32, Int32) OnChangeLineAttributes(Int32, Int32)

Called when one or more lines' attributes (font, color) have changed.

OnChangeLineText(TextLineChange[], Int32) OnChangeLineText(TextLineChange[], Int32) OnChangeLineText(TextLineChange[], Int32) OnChangeLineText(TextLineChange[], Int32)

Called when a line's text has changed.

OnCommand(IVsTextView, VSConstants+VSStd2KCmdID, Char) OnCommand(IVsTextView, VSConstants+VSStd2KCmdID, Char) OnCommand(IVsTextView, VSConstants+VSStd2KCmdID, Char) OnCommand(IVsTextView, VSConstants+VSStd2KCmdID, Char)

Handles IntelliSense-oriented commands.

OnHiddenRegionChange(IVsHiddenRegion, HIDDEN_REGION_EVENT, Int32) OnHiddenRegionChange(IVsHiddenRegion, HIDDEN_REGION_EVENT, Int32) OnHiddenRegionChange(IVsHiddenRegion, HIDDEN_REGION_EVENT, Int32) OnHiddenRegionChange(IVsHiddenRegion, HIDDEN_REGION_EVENT, Int32)

Called when a hidden region has changed.

OnIdle(Boolean) OnIdle(Boolean) OnIdle(Boolean) OnIdle(Boolean)

Called when no other events are being handled.

OnUserDataChange(Guid, Object) OnUserDataChange(Guid, Object) OnUserDataChange(Guid, Object) OnUserDataChange(Guid, Object)

Called when user data has been changed in a text buffer.

Open() Open() Open() Open()

Marks the Source object as being open.

ProcessHiddenRegions(ArrayList) ProcessHiddenRegions(ArrayList) ProcessHiddenRegions(ArrayList) ProcessHiddenRegions(ArrayList)

Updates all hidden regions based on the given list of hidden regions.

Recolorize(Int32, Int32) Recolorize(Int32, Int32) Recolorize(Int32, Int32) Recolorize(Int32, Int32)

Updates the syntax highlighting on the specified range of lines.

ReformatSpan(EditArray, TextSpan) ReformatSpan(EditArray, TextSpan) ReformatSpan(EditArray, TextSpan) ReformatSpan(EditArray, TextSpan)

Format the specified span of source.

RegisterTextBufferEventHandlers(IVsTextLines) RegisterTextBufferEventHandlers(IVsTextLines) RegisterTextBufferEventHandlers(IVsTextLines) RegisterTextBufferEventHandlers(IVsTextLines)

Registers event handlers for the given text.

RemoveHiddenRegions() RemoveHiddenRegions() RemoveHiddenRegions() RemoveHiddenRegions()

Removes all hidden regions from the current view.

RemoveTask(DocumentTask) RemoveTask(DocumentTask) RemoveTask(DocumentTask) RemoveTask(DocumentTask)

Removes the specified error task from the error Task window.

ScanToNonWhitespaceChar(Int32) ScanToNonWhitespaceChar(Int32) ScanToNonWhitespaceChar(Int32) ScanToNonWhitespaceChar(Int32)

Returns the offset of the first non-whitespace character on the given line.

SetText(String) SetText(String) SetText(String) SetText(String)

Replaces the source contents with the given text.

SetText(TextSpan, String) SetText(TextSpan, String) SetText(TextSpan, String) SetText(TextSpan, String)

Replaces the specified span of source with the given text.

SetText(Int32, Int32, Int32, Int32, String) SetText(Int32, Int32, Int32, Int32, String) SetText(Int32, Int32, Int32, Int32, String) SetText(Int32, Int32, Int32, Int32, String)

Replaces the specified section of source with the given text.

SetUserData(Guid, Object) SetUserData(Guid, Object) SetUserData(Guid, Object) SetUserData(Guid, Object)

Sets the given user data property to the given value.

TrimSpan(TextSpan) TrimSpan(TextSpan) TrimSpan(TextSpan) TrimSpan(TextSpan)

Adjusts the given span to skip leading and trailing whitespace.

UncommentBlock(TextSpan, String, String) UncommentBlock(TextSpan, String, String) UncommentBlock(TextSpan, String, String) UncommentBlock(TextSpan, String, String)

Removes comment characters from around the specified span.

UncommentLines(TextSpan, String) UncommentLines(TextSpan, String) UncommentLines(TextSpan, String) UncommentLines(TextSpan, String)

Removes line comment characters from the beginning of each line in the given span.

UncommentSpan(TextSpan) UncommentSpan(TextSpan) UncommentSpan(TextSpan) UncommentSpan(TextSpan)

Removes any comment characters from the beginning and end of the given span.

VisiblePositionToColumn(Int32, Int32) VisiblePositionToColumn(Int32, Int32) VisiblePositionToColumn(Int32, Int32) VisiblePositionToColumn(Int32, Int32)

Gets the character offset on the given line corresponding to the specified screen column position.

Extension Methods

FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>)
FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>)

Microsoft internal use only.

FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>)
FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>)
IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>) IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>) IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>) IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>)

Microsoft internal use only.

Applies to