Export (0) Print
Expand All

Source Class

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

This API is not CLS-compliant. 

System.Object
  Microsoft.VisualStudio.Package.Source

Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.12.0 (in Microsoft.VisualStudio.Package.LanguageService.12.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.11.0 (in Microsoft.VisualStudio.Package.LanguageService.11.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)

[CLSCompliantAttribute(false)]
public class Source : IDisposable, IVsTextLinesEvents, 
	IVsHiddenTextClient, IVsUserDataEvents

The Source type exposes the following members.

  NameDescription
Public methodSourceInitializes a new instance of the Source class.
Top

  NameDescription
Public propertyChangeCountGets the number of changes made to the source file since it was opened.
Public propertyColorStateGets or sets the IVsTextColorState object that is used in various parsing tasks.
Public propertyCompletedFirstParseGets whether the parser has completed at least once.
Public propertyCompletionSetGets the CompletionSet collection used for this instance of the Source class.
Public propertyDirtySpanGets a range that identifies the changed lines in the source.
Protected propertyHandlesSnapshots
Public propertyIsClosedGets the current state of the source file.
Public propertyIsCompletorActiveGets whether the IntelliSense member completion or method tip modes are active.
Public propertyIsDirtyGets or sets whether any of the lines of source have changed.
Public propertyLanguageServiceGets the language service associated with the source file.
Public propertyLastParseTimeGets the duration of the last parse operation.
Public propertyOutliningEnabledGets or sets whether outlining is currently enabled.
Top

  NameDescription
Public methodBeginParse()Begins a full parsing operation either in the foreground or the background.
Public methodBeginParse(Int32, Int32, TokenInfo, ParseReason, IVsTextView, ParseResultHandler)Begins a parsing operation with the given token, text view, and parse request handler.
Public methodCloseDetermines whether the source file can be closed.
Public methodColumnToVisiblePositionGets the screen column position corresponding to the specified character offset, taking into account tab size.
Public methodCommentBlockComments out a span of source using block comments.
Public methodCommentLinesComments out a span of source using line comments.
Public methodCommentSpanComments out the specified span of source.
Public methodCompletionStarts an IntelliSense member completion operation.
Public methodCreateAuthoringSinkCreates an instance of an AuthoringSink object for use in parsing operations.
Public methodCreateCompletionSetCreates a new instance of a CompletionSet class.
Public methodCreateErrorTaskItem(TextSpan, MARKERTYPE, String)Creates a new error task item for the Error List, for the supplied text, marker type, and file name.
Public methodCreateErrorTaskItem(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.
Public methodCreateMethodDataCreates a new instance of a MethodData object that handles the IntelliSense method tip mode.
Public methodDismissCompletorRemoves the IntelliSense method tip or completion list from view, whichever was active.
Public methodDisposeCalled in preparation of destroying this Source object.
Public methodEqualsDetermines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodExecMarkerCommandExecutes the specified command on the specified region.
Protected methodFinalizeThe class destructor, called just before the object is destroyed. (Overrides Object.Finalize().)
Public methodGetColorizerGets the colorizer associated with this Source object.
Public methodGetCommentFormatGets information on what defines a comment in the language.
Public methodGetDocumentSpanGets the span occupied by the entire source file.
Public methodGetExpansionProviderGets an expansion provider in support of code snippets.
Public methodGetFilePathGets the file name of the source file.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetHiddenTextSessionGets the hidden region manager if available.
Public methodGetLineGets the text on the specified line.
Public methodGetLineCountGets the number of lines in the source file.
Public methodGetLineIndexOfPositionGets the line and column for the specified position.
Public methodGetLineLengthGets the length of the specified line.
Public methodGetMarkerCommandInfoDetermines which marker commands can be shown on a context menu for the specified hidden region.
Public methodGetNewLineGets the newline character used at the end of the specified line.
Public methodGetPairExtents(IVsTextView, Int32, Int32, TextSpan)Gets the span between a matching pair of language elements.
Public methodGetPairExtents(IVsTextView, Int32, Int32, TextSpan, TextSpan)Gets the text spans for a matching pair (or triplet) of language elements.
Public methodGetPositionOfLineIndexGets the position corresponding to the given line and character offset location.
Public methodGetTaskProviderGets the task provider that manages the error tasks.
Public methodGetText()Gets all of the text of the source file.
Public methodGetText(TextSpan)Gets the text included in the text span.
Public methodGetText(Int32, Int32, Int32, Int32)Gets the text between the specified locations.
Public methodGetTextLinesGets the IVsTextLines object associated with this Source object.
Public methodGetTextUpToLineGets the text from the source up to and including the given line number.
Public methodGetTipTextGets the text in the given hidden region to be used in a tool tip.
Public methodGetTokenInfoGets information about the token at the specified position.
Public methodGetTokenInfoAtGets the index of the TokenInfo object that includes the supplied column number.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetUserDataGets the user data associated with the specified GUID.
Public methodGetWordExtentGets the span occupied by the word at the specified location.
Public methodMakeBaseSpanVisibleEnsures that the given span in the given hidden region is visible.
Public methodMatchBracesHighlights the spans of a pair of language elements, given the position of one of the elements.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodMethodTipDisplays an IntelliSense method tip showing a method's signature as it is entered.
Public methodNormalizeNewlinesConverts the newlines in the specified text to the specified newline.
Public methodOnBeforeSessionEndCalled just before a hidden region session is closed.
Public methodOnChangeLineAttributesCalled when one or more lines' attributes (font, color) have changed.
Public methodOnChangeLineTextCalled when a line's text has changed.
Public methodOnChangesCommittedCalled when a code snippet is committed to the source file.
Public methodOnCommandHandles IntelliSense-oriented commands.
Public methodOnHiddenRegionChangeCalled when a hidden region has changed.
Public methodOnIdleCalled when no other events are being handled.
Public methodOnUserDataChangeCalled when user data has been changed in a text buffer.
Public methodOpenMarks the Source object as being open.
Public methodProcessHiddenRegionsUpdates all hidden regions based on the given list of hidden regions.
Public methodRecolorizeUpdates the syntax highlighting on the specified range of lines.
Public methodReformatSpanFormat the specified span of source.
Public methodRegisterTextBufferEventHandlersRegisters event handlers for the given text.
Public methodRemoveHiddenRegionsRemoves all hidden regions from the current view.
Public methodRemoveTaskRemoves the specified error task from the error Task window.
Public methodScanToNonWhitespaceCharReturns the offset of the first non-whitespace character on the given line.
Public methodSetText(String)Replaces the source contents with the given text.
Public methodSetText(TextSpan, String)Replaces the specified span of source with the given text.
Public methodSetText(Int32, Int32, Int32, Int32, String)Replaces the specified section of source with the given text.
Public methodSetUserDataSets the given user data property to the given value.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodTrimSpanAdjusts the given span to skip leading and trailing whitespace.
Public methodUncommentBlockRemoves comment characters from around the specified span.
Public methodUncommentLinesRemoves line comment characters from the beginning of each line in the given span.
Public methodUncommentSpanRemoves any comment characters from the beginning and end of the given span.
Public methodVisiblePositionToColumnGets the character offset on the given line corresponding to the specified screen column position.
Top

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 Implementers

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.

Notes to Callers

This class is instantiated by a call to the CreateSource 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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft