Asper Header  1.0.14
The header injector extension
Loading...
Searching...
No Matches
MockTextDocument Class Reference

Mock implementation of VS Code TextDocument for testing purposes. More...

Inheritance diagram for MockTextDocument:
Inheritance graph
Collaboration diagram for MockTextDocument:
Collaboration graph

Public Member Functions

 constructor (filePath:string, content:string='', languageId:string='typescript', eol:vscode.EndOfLine=vscode.EndOfLine.LF, isClosed:boolean=false)
 Creates a new mock text document with specified configuration.
 

Data Fields

lines : MockDocumentLine[] = []
 Array of document lines with metadata.
 
uri : vscode.Uri
 File URI for the mock document.
 
languageId : string
 Language identifier for syntax highlighting.
 
eol : vscode.EndOfLine
 End-of-line character sequence type.
 
version : number
 Document version number for change tracking.
 
isClosed : boolean
 Whether the document is closed.
 
lineCount : number = 0
 Total number of lines in the document.
 
fileName : string = ''
 Base filename without path.
 
isUntitled : boolean = false
 Whether this is an untitled document.
 
encoding : string = 'utf8'
 Document encoding format.
 
isDirty : boolean = false
 Whether the document has unsaved changes.
 

Detailed Description

Mock implementation of VS Code TextDocument for testing purposes.

Provides a comprehensive mock of the VS Code TextDocument interface, enabling isolated testing of document manipulation operations without requiring actual VS Code environment. Supports all essential TextDocument operations including line access, text retrieval, and position calculations.

Key Features:

  • Line Management: Dynamic line collection with proper indexing
  • Position Mapping: Accurate offset/position conversion utilities
  • Range Operations: Support for text extraction within ranges
  • Language Detection: Configurable language ID for syntax testing
  • EOL Handling: Support for both LF and CRLF line endings
  • File Metadata: URI, encoding, and file state simulation

Definition at line 69 of file commentGenerator.test.ts.

Member Function Documentation

◆ constructor()

MockTextDocument::constructor ( filePath:string,
content:string = '',
languageId:string = 'typescript',
eol:vscode. EndOfLine = vscode.EndOfLine.LF,
isClosed:boolean = false )
inline

Creates a new mock text document with specified configuration.

Parameters
filePathAbsolute file path for the document URI
contentInitial text content (defaults to empty string)
languageIdLanguage identifier (defaults to 'typescript')
eolEnd-of-line character type (defaults to LF)
isClosedWhether document starts in closed state

Initializes a fully functional mock document that can be used for testing text operations, header injection, and file manipulation without requiring actual VS Code document instances.

Definition at line 105 of file commentGenerator.test.ts.

Field Documentation

◆ __pad0__

lines MockTextDocument::__pad0__

Array of document lines with metadata.

Definition at line 71 of file commentGenerator.test.ts.

◆ __pad10__

isDirty MockTextDocument::__pad10__

Whether the document has unsaved changes.

Definition at line 91 of file commentGenerator.test.ts.

◆ __pad1__

uri MockTextDocument::__pad1__

File URI for the mock document.

Definition at line 73 of file commentGenerator.test.ts.

◆ __pad2__

languageId MockTextDocument::__pad2__

Language identifier for syntax highlighting.

Definition at line 75 of file commentGenerator.test.ts.

◆ __pad3__

eol MockTextDocument::__pad3__

End-of-line character sequence type.

Definition at line 77 of file commentGenerator.test.ts.

◆ __pad4__

version MockTextDocument::__pad4__

Document version number for change tracking.

Definition at line 79 of file commentGenerator.test.ts.

◆ __pad5__

isClosed MockTextDocument::__pad5__

Whether the document is closed.

Definition at line 81 of file commentGenerator.test.ts.

◆ __pad6__

lineCount MockTextDocument::__pad6__

Total number of lines in the document.

Definition at line 83 of file commentGenerator.test.ts.

◆ __pad7__

fileName MockTextDocument::__pad7__

Base filename without path.

Definition at line 85 of file commentGenerator.test.ts.

◆ __pad8__

isUntitled MockTextDocument::__pad8__

Whether this is an untitled document.

Definition at line 87 of file commentGenerator.test.ts.

◆ __pad9__

encoding MockTextDocument::__pad9__

Document encoding format.

Definition at line 89 of file commentGenerator.test.ts.


The documentation for this class was generated from the following file: