Home > Services > DXCore Services – Documents

DXCore Services – Documents

November 22nd, 2011

The Documents DXCore service provides an API to control opening and closing documents inside the Visual Studio IDE. You can insert, remove and change any text at the specified coordinates of the given documents.

Method name

Description

Activate(Document) Activates (gives focus to) the specified document. Preference is given to the source code view. If a source code view is unavailable but an alternate view is available (e.g., a form designer for this document), it will be activated. See also: CodeRush.Designer.Activate and CodeRush.Editor.Activate.
Activate(Document, Boolean) Activates (gives focus to) the specified document. See also: CodeRush.Designer.Activate and CodeRush.Editor.Activate.
Activate(Document, DocumentView) Activates (gives focus to) or opens the specified view of the specified document.
Activate(Document, DocumentView, Boolean) Activates (gives focus to) or opens the specified view of the specified document.
AttachObject(Document, String, Object) Attaches a named object to the specified document.
AttachObject(String, Object) Attaches a named object to the active document.
BelongsToValidProject(Document) Checks if the specified document belongs to a valid project.
DeleteCharsLeft(EditPoint, Int32) Deletes the specified number of characters to the left of the specified edit point in the active document.
DeleteCharsRight(EditPoint, Int32) Deletes the specified number of characters to the right of the specified edit point in the active document.
Find(String) Returns the document by the specified path.
Find(EndDTE.TextDocument) Returns the document by the EnvDTE.TextDocument instance.
Format Formats the active document.
Format(Int32, Int32, Int32, Int32) Formats the specified range of the active document.
Format(SourceRange) Formats the specified range of the active document.
GdiPaintOnTextViews( EditorPaintEventHandler) Paints on all text views corresponding to the active document.
Get(String) Returns the document specified by the given file name.
GetAllOpenedDocuments Returns the designer document for the active file.
GetDesigner Returns the designer document for the active file.
GetDesigner(String) Returns the designer document specified by the given file name.
GetDocuments(GetDocumentFlags) Returns a collection of all documents based on the specified criteria. For example, you can use this method to get a collection of all text documents in the current project.
GetEnumerator Returns an enumerator for iterating documents.
GetIndentSize(String) Returns the indent size for the specified document.
GetLeadingWhiteSpace(Int32) Returns the leading white space (tabs and spaces) for the specified line.
GetLineAt(Int32) Returns the code line at the specified line number for the active document.
GetLineAt(TextDocument, Int32) Returns the code line at the specified line number for the specified document.
GetObject(Document, String) Gets the object attached to the given document.
GetObject(String) Gets the object attached to the active document.
GetProjectName(Document) Returns the name of the project for the specified document.
GetText(String) Retrieves the current text of the specified file. If the file is opened in Visual Studio in a document window or in-memory, the current contents of the buffer will be returned. If the file is not open, the contents of the file on disk will be returned.
GetText(String, Boolean) Retrieves the current text of the specified file. If the file is open in Visual Studio in a document window or in-memory, the current contents of the buffer will be returned. If the file is not open, the contents of the file on disk will be returned.
GetTextDocument Returns the non-designer source document for the active file.
GetTextDocument(String) Returns the non-designer source document specified by the given file name.
InsertText(String) Inserts the specified text at the editor caret in the active document.
LineStartsWith(Int32, String) Returns true if the given line number in the current file starts with the specified prefix. Leading white space is ignored.
Parse(TextDocument) Parses the specified text document and returns the language element representing it.
ParseActive Parses the active text document and returns the language element representing it.
RefreshTextViews Refreshes text views of the active document.
RemoveObject(Document, String) Removes an attached object from the specified document.
RemoveObject(String) Removes an attached object from the active document.
ShowCode Opens the specified file and scrolls it to the specified source range.

Properties:

Property name

Description

Active Returns the active document.
ActiveFileExt Returns the file extension (e.g., “.cs”, “.cpp”, “.h”, “.vb”, etc.) of the active document.
ActiveFileName Returns the file name of the active or last active document.
ActiveLanguage Returns the programming language used in the active document.
ActiveLine Returns the line of source code at the cursor in the active document.
ActiveTextDocument Returns the active text document or null if the active document is not a text document (e.g., a designer).
ActiveTextView Gets the active text view for the active text document. Returns null if not available.
AllDocuments Returns a collection of all documents.
AllProjectDocuments Returns a collection of all documents in the current project.
AllProjectTextDocuments Returns a collection of all text documents in the current project.
AllSolutionDocuments Returns a collection of all documents in the current solution.
AllSolutionTextDocuments Returns a collection of all text documents in the current solution.
AllTextDocuments Returns a collection of all text documents.
CollapsibleRegionsProvider Returns a collapsible regions implementer that allows you to iterate via collapsed or expanded regions of outlined text.
Count Gets the number of documents available.
Formatting Returns true if code in the active document is being formatted, through a call to CodeRush.Document.Format or TextDocument.Format.
Item Return the document by the specified document path.
LastActive Returns the last active document.
—–
Products: DXCore
Versions: 12.1 and up
VS IDEs: any
Updated: Jun/09/2012
ID: D129

Similar Posts: