types.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. /**
  2. * Core VSCode API type definitions
  3. *
  4. * This file contains TypeScript type definitions that match the VSCode Extension API.
  5. * These types allow VSCode extensions to run in Node.js without VSCode installed.
  6. */
  7. /**
  8. * Represents a thenable (Promise-like) value
  9. */
  10. export type Thenable<T> = Promise<T>
  11. /**
  12. * Represents a disposable resource that can be cleaned up
  13. */
  14. export interface Disposable {
  15. dispose(): void
  16. }
  17. /**
  18. * Represents a Uniform Resource Identifier (URI)
  19. */
  20. export interface IUri {
  21. scheme: string
  22. authority: string
  23. path: string
  24. query: string
  25. fragment: string
  26. fsPath: string
  27. toString(): string
  28. }
  29. /**
  30. * Represents a position in a text document (line and character)
  31. */
  32. export interface IPosition {
  33. line: number
  34. character: number
  35. isEqual(other: IPosition): boolean
  36. isBefore(other: IPosition): boolean
  37. isBeforeOrEqual(other: IPosition): boolean
  38. isAfter(other: IPosition): boolean
  39. isAfterOrEqual(other: IPosition): boolean
  40. compareTo(other: IPosition): number
  41. }
  42. /**
  43. * Represents a range in a text document (start and end positions)
  44. */
  45. export interface IRange {
  46. start: IPosition
  47. end: IPosition
  48. isEmpty: boolean
  49. isSingleLine: boolean
  50. contains(positionOrRange: IPosition | IRange): boolean
  51. isEqual(other: IRange): boolean
  52. intersection(other: IRange): IRange | undefined
  53. union(other: IRange): IRange
  54. }
  55. /**
  56. * Represents a selection in a text editor (extends Range with anchor and active positions)
  57. */
  58. export interface ISelection extends IRange {
  59. anchor: IPosition
  60. active: IPosition
  61. isReversed: boolean
  62. }
  63. /**
  64. * Represents a line of text in a document
  65. */
  66. export interface TextLine {
  67. text: string
  68. range: IRange
  69. rangeIncludingLineBreak: IRange
  70. firstNonWhitespaceCharacterIndex: number
  71. isEmptyOrWhitespace: boolean
  72. }
  73. /**
  74. * Represents a text document
  75. */
  76. export interface TextDocument {
  77. uri: IUri
  78. fileName: string
  79. languageId: string
  80. version: number
  81. isDirty: boolean
  82. isClosed: boolean
  83. lineCount: number
  84. getText(range?: IRange): string
  85. lineAt(line: number): TextLine
  86. offsetAt(position: IPosition): number
  87. positionAt(offset: number): IPosition
  88. save(): Thenable<boolean>
  89. validateRange(range: IRange): IRange
  90. validatePosition(position: IPosition): IPosition
  91. }
  92. /**
  93. * Configuration target for settings
  94. */
  95. export enum ConfigurationTarget {
  96. Global = 1,
  97. Workspace = 2,
  98. WorkspaceFolder = 3,
  99. }
  100. /**
  101. * Workspace folder representation
  102. */
  103. export interface WorkspaceFolder {
  104. uri: IUri
  105. name: string
  106. index: number
  107. }
  108. /**
  109. * Workspace configuration interface
  110. */
  111. export interface WorkspaceConfiguration {
  112. get<T>(section: string): T | undefined
  113. get<T>(section: string, defaultValue: T): T
  114. has(section: string): boolean
  115. inspect<T>(section: string): ConfigurationInspect<T> | undefined
  116. update(section: string, value: unknown, configurationTarget?: ConfigurationTarget): Thenable<void>
  117. }
  118. /**
  119. * Configuration inspection result
  120. */
  121. export interface ConfigurationInspect<T> {
  122. key: string
  123. defaultValue?: T
  124. globalValue?: T
  125. workspaceValue?: T
  126. workspaceFolderValue?: T
  127. }
  128. /**
  129. * Memento (state storage) interface
  130. */
  131. export interface Memento {
  132. get<T>(key: string): T | undefined
  133. get<T>(key: string, defaultValue: T): T
  134. update(key: string, value: unknown): Thenable<void>
  135. keys(): readonly string[]
  136. }
  137. /**
  138. * Secret storage interface for secure credential storage
  139. */
  140. export interface SecretStorage {
  141. get(key: string): Thenable<string | undefined>
  142. store(key: string, value: string): Thenable<void>
  143. delete(key: string): Thenable<void>
  144. onDidChange: Event<SecretStorageChangeEvent>
  145. }
  146. /**
  147. * Secret storage change event
  148. */
  149. export interface SecretStorageChangeEvent {
  150. key: string
  151. }
  152. /**
  153. * Represents an extension
  154. */
  155. export interface Extension<T> {
  156. id: string
  157. extensionUri: IUri
  158. extensionPath: string
  159. isActive: boolean
  160. packageJSON: Record<string, unknown>
  161. exports: T
  162. extensionKind: ExtensionKind
  163. activate(): Thenable<T>
  164. }
  165. /**
  166. * Extension kind enum
  167. */
  168. export enum ExtensionKind {
  169. UI = 1,
  170. Workspace = 2,
  171. }
  172. /**
  173. * Extension context provided to extension activation
  174. */
  175. export interface ExtensionContext {
  176. subscriptions: Disposable[]
  177. workspaceState: Memento
  178. globalState: Memento & { setKeysForSync(keys: readonly string[]): void }
  179. secrets: SecretStorage
  180. extensionUri: IUri
  181. extensionPath: string
  182. environmentVariableCollection: Record<string, unknown>
  183. storageUri: IUri | undefined
  184. storagePath: string | undefined
  185. globalStorageUri: IUri
  186. globalStoragePath: string
  187. logUri: IUri
  188. logPath: string
  189. extensionMode: ExtensionMode
  190. extension: Extension<unknown> | undefined
  191. }
  192. /**
  193. * Extension mode enum
  194. */
  195. export enum ExtensionMode {
  196. Production = 1,
  197. Development = 2,
  198. Test = 3,
  199. }
  200. /**
  201. * Event emitter event type
  202. */
  203. export type Event<T> = (listener: (e: T) => void, thisArgs?: unknown, disposables?: Disposable[]) => Disposable
  204. /**
  205. * Cancellation token for async operations
  206. */
  207. export interface CancellationToken {
  208. isCancellationRequested: boolean
  209. onCancellationRequested: Event<unknown>
  210. }
  211. /**
  212. * File system file type enum
  213. */
  214. export enum FileType {
  215. Unknown = 0,
  216. File = 1,
  217. Directory = 2,
  218. SymbolicLink = 64,
  219. }
  220. /**
  221. * File system stat information
  222. */
  223. export interface FileStat {
  224. type: FileType
  225. ctime: number
  226. mtime: number
  227. size: number
  228. }
  229. /**
  230. * Text editor options
  231. */
  232. export interface TextEditorOptions {
  233. tabSize?: number
  234. insertSpaces?: boolean
  235. cursorStyle?: number
  236. lineNumbers?: number
  237. }
  238. /**
  239. * View column enum for editor placement
  240. */
  241. export enum ViewColumn {
  242. Active = -1,
  243. Beside = -2,
  244. One = 1,
  245. Two = 2,
  246. Three = 3,
  247. }
  248. /**
  249. * UI Kind enum
  250. */
  251. export enum UIKind {
  252. Desktop = 1,
  253. Web = 2,
  254. }
  255. /**
  256. * End of line sequence enum
  257. */
  258. export enum EndOfLine {
  259. LF = 1,
  260. CRLF = 2,
  261. }
  262. /**
  263. * Status bar alignment
  264. */
  265. export enum StatusBarAlignment {
  266. Left = 1,
  267. Right = 2,
  268. }
  269. /**
  270. * Diagnostic severity levels
  271. */
  272. export enum DiagnosticSeverity {
  273. Error = 0,
  274. Warning = 1,
  275. Information = 2,
  276. Hint = 3,
  277. }
  278. /**
  279. * Diagnostic tags
  280. */
  281. export enum DiagnosticTag {
  282. Unnecessary = 1,
  283. Deprecated = 2,
  284. }
  285. /**
  286. * Overview ruler lane
  287. */
  288. export enum OverviewRulerLane {
  289. Left = 1,
  290. Center = 2,
  291. Right = 4,
  292. Full = 7,
  293. }
  294. /**
  295. * Decoration range behavior
  296. */
  297. export enum DecorationRangeBehavior {
  298. OpenOpen = 0,
  299. ClosedClosed = 1,
  300. OpenClosed = 2,
  301. ClosedOpen = 3,
  302. }
  303. /**
  304. * Text editor reveal type
  305. */
  306. export enum TextEditorRevealType {
  307. Default = 0,
  308. InCenter = 1,
  309. InCenterIfOutsideViewport = 2,
  310. AtTop = 3,
  311. }