Udostępnij za pośrednictwem


LanguageService.GetSource Method

Definition

Return a Source object.

Overloads

GetSource(String)

Returns an existing Source object given a file name.

GetSource(IVsTextLines)

Returns an existing Source object that contains the specified buffer of source.

GetSource(IVsTextView)

Returns an existing Source object that contains the source file shown in the specified text view.

Remarks

A Source object represents a source file. Source contains all the necessary elements to initiate and control a parse of the source file, asynchronously or synchronously. A Source object also controls various features that change the source such as commenting and uncommenting blocks of code, using the Task List to show errors, match braces (and other such language features), format parameter info ToolTips (for completion of methods), and outlining. All of these features are supported in the base class.

GetSource(String)

Returns an existing Source object given a file name.

public:
 Microsoft::VisualStudio::Package::Source ^ GetSource(System::String ^ fname);
public Microsoft.VisualStudio.Package.Source GetSource (string fname);
member this.GetSource : string -> Microsoft.VisualStudio.Package.Source
Public Function GetSource (fname As String) As Source

Parameters

fname
String

[in] The file name for which to find the Source object.

Returns

If successful, returns a Source object; otherwise, returns a null value (there is no Source object in this language service that represents the specified file name).

Remarks

Each Source object remembers the file name that it represents. The internal list of Source objects is searched for a matching name (which is a case-insensitive comparison).

Applies to

GetSource(IVsTextLines)

Returns an existing Source object that contains the specified buffer of source.

public:
 Microsoft::VisualStudio::Package::Source ^ GetSource(Microsoft::VisualStudio::TextManager::Interop::IVsTextLines ^ buffer);
public Microsoft.VisualStudio.Package.Source GetSource (Microsoft.VisualStudio.TextManager.Interop.IVsTextLines buffer);
member this.GetSource : Microsoft.VisualStudio.TextManager.Interop.IVsTextLines -> Microsoft.VisualStudio.Package.Source
Public Function GetSource (buffer As IVsTextLines) As Source

Parameters

buffer
IVsTextLines

[in] An IVsTextLines object containing the lines of source.

Returns

If successful, returns a Source object; otherwise, returns a null value (there is no Source object in this language service that controls that set of source lines).

Remarks

The language service maintains an internal list of all Source objects created. It is this list that is searched for a Source object that contains the specified IVsTextLines object.

Applies to

GetSource(IVsTextView)

Returns an existing Source object that contains the source file shown in the specified text view.

public:
 Microsoft::VisualStudio::Package::Source ^ GetSource(Microsoft::VisualStudio::TextManager::Interop::IVsTextView ^ view);
public Microsoft.VisualStudio.Package.Source GetSource (Microsoft.VisualStudio.TextManager.Interop.IVsTextView view);
member this.GetSource : Microsoft.VisualStudio.TextManager.Interop.IVsTextView -> Microsoft.VisualStudio.Package.Source
Public Function GetSource (view As IVsTextView) As Source

Parameters

view
IVsTextView

[in] An IVsTextView object that displays the source file for which to get the Source object.

Returns

If successful, returns a Source object; otherwise, returns a null value (there is no Source object in this language service that controls the set of source lines shown in the specified view).

Remarks

The IVsTextLines object is obtained from the IVsTextView with a call to Microsoft.VisualStudio.TextManager.Interop.IVsTextView.GetBuffer; it is that IVsTextLines object that is used to search for a Source object in the internal list of Source objects.

Applies to