Skip to content

Commit d62a448

Browse files
committed
jsdoc vscode.d.ts
1 parent cc9e65c commit d62a448

1 file changed

Lines changed: 79 additions & 75 deletions

File tree

src/vs/vscode.d.ts

Lines changed: 79 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
/*
77
- comments are marked like this '<<< comment >>>'
8-
- I've fixed typos directly without comments
98
109
some global comments:
1110
- I'm missing some structure/grouping in this file:
@@ -24,23 +23,8 @@
2423
"To get an instance of a {{FileSystemWatcher}} use {{workspace.createFileSystemWatcher}}."
2524
- lots of class or method comments are still missing. If we cannot create all of them in time, we should focus on comments for non-obvious cases.
2625
I have added a "non-obvious" comment.
27-
- unclear when we have functions in a namespace and when we have resolve function and a sub namespace / interface. Examples are:
28-
o workspace.openTextDocument() => return ITextDocument which opens a separate namespace
29-
o vscode.language.register* functions. Could have been workspace.getLanguage(selector) => ILangauge
30-
In general I think that having separate namespaces will help with scalibility. Results in smaller proposals in code complete.
31-
window.activeTextEditor.###, window.statusBar.###, window.quickPick.###
32-
33-
- async programming style, Promise return and method naming
34-
o we should make a statement how the async programming style works. What happens if I call a method and the actual operation can not be executed
35-
in the main thread since the editor / model changed.
36-
o would be good to have a naming theme that makes our model clear. We could for example use:
37-
setXXX/applyXXX => Thenable. The operation is either done or rejected. An example is applying edits which get rejected if the model version doesn't exist anymore.
38-
updateXXX => void. The operation is done but the result might never be observable. It could even be that the operation got dropped. Or we want to ensure the operation
39-
is not observable. Example updateSelection. Otherwise people might think updateSelection(xxx).then(() => selction is at position xxx which might not be the case).
26+
4027
- label, names, descriptions: would be great to indicate if they show up in the user interface and therefore must be human readable.
41-
- usage of option bags. Most functions flatten all parameters other only take an option bag. We should be consistent here. If option bags they must be optional
42-
- param: T | Thenable<T>: (e.g. showQuickPick). IMO we shouldn't pass Thenable as a param. It should be resolved outside> Otherwise we need to handle the error case
43-
inside and even need to communicate that back to the outside.
4428
*/
4529

4630

@@ -77,49 +61,44 @@ declare namespace vscode {
7761
}
7862

7963
/**
80-
* Represents a line of text such as a line of source code
81-
* <<< Is a textLine live. E.g. when updating the document will a text line update as well. If not
82-
* I would suggest to remove TextLine and add the methods to text document. Otherwise the object might
83-
* be misleading.
84-
* >>>
64+
* Represents a line of text such as a line of source code.
65+
*
66+
* TextLine objects are __immutable__. That means that when a [document](#TextDocument) changes
67+
* previsouly retrieved lines will not represent the latest state.
8568
*/
8669
export interface TextLine {
8770

8871
/**
89-
* The zero-offset line number <<<better: 'zero-based' see https://en.wikipedia.org/wiki/Zero-based_numbering >>>
72+
* The zero-base line number.
9073
*
9174
* @readonly
9275
*/
9376
lineNumber: number;
9477

9578
/**
96-
* The text of this line without the
97-
* newline character <<< what's about CR/LF on Windows? better: 'line separator characters' >>>
79+
* The text of this line without the line separator characters.
9880
*
9981
* @readonly
10082
*/
10183
text: string;
10284

10385
/**
104-
* The range this line covers without the
105-
* newline character <<< what's about CR/LF on Windows? better: 'line separator characters' >>>
86+
* The range this line covers without the line separator characters.
10687
*
10788
* @readonly
10889
*/
10990
range: Range;
11091

11192
/**
112-
* The range this line covers with the
113-
* newline character <<< dito >>>
93+
* The range this line covers with the line separator characters.
11494
*
11595
* @readonly
11696
*/
11797
rangeIncludingLineBreak: Range;
11898

11999
/**
120-
* The offset of the first character which
121-
* isn't a whitespace character as defined
122-
* by a `\s`-RegExp
100+
* The offset of the first character which is not a whitespace character as defined
101+
* by `/\s/`.
123102
*
124103
* @readonly
125104
*/
@@ -141,16 +120,17 @@ declare namespace vscode {
141120
export interface TextDocument {
142121

143122
/**
144-
* Get the associated URI for this document. Most documents have the file://-scheme, indicating that they represent files on disk.
145-
* However, some documents may have other schemes indicating that they are not available on disk.
123+
* The associated URI for this document. Most documents have the __file__-scheme, indicating that they
124+
* represent files on disk. However, some documents may have other schemes indicating that they are not
125+
* available on disk.
146126
*
147127
* @readonly
148128
*/
149129
uri: Uri;
150130

151131
/**
152-
* Returns the file system path of the file associated with this document. Shorthand
153-
* notation for `#uri.fsPath` <<< what if uri is not a file? >>>
132+
* The file system path of the associated resource. Shorthand
133+
* notation for `#uri.fsPath`. Independent of the uri scheme.
154134
*
155135
* @readonly
156136
*/
@@ -164,7 +144,7 @@ declare namespace vscode {
164144
isUntitled: boolean;
165145

166146
/**
167-
* The language identifier associated with this document.
147+
* The identifier of the language associated with this document.
168148
*
169149
* @readonly
170150
*/
@@ -232,25 +212,36 @@ declare namespace vscode {
232212
positionAt(offset: number): Position;
233213

234214
/**
235-
* Get the text in this document. If a range is provided the text contained
236-
* by the range is returned. <<< if the range is larger than the TextDocument only the intersection is ... >>>
215+
* Get the text of this document. A substring can be retrieved by providing
216+
* a range. The range will be [adjusted](#TextDocument.validateRange).
217+
*
218+
* @param range Include only the text included by the range.
237219
*/
238220
getText(range?: Range): string;
239221

240222
/**
241-
* Get the word under a certain position. May return null if position is at whitespace, on empty line, etc.
242-
* <<< what is a 'word'? >>>
223+
* Get a word-range at the given position. By default words are defined by
224+
* common separators, like space, -, _, etc. In addition, per languge custom
225+
* [word definitions](#LanguageConfiguration.wordPattern) can be defined.
226+
*
227+
* @param position A position.
228+
* @return A range spanning a word, or `undefined`.
243229
*/
244230
getWordRangeAtPosition(position: Position): Range;
245231

246232
/**
247-
* Ensure a range sticks to the text.
248-
* <<< 'sticks'? better: ensure a range is completely contained in the TextDocument. >>>
233+
* Ensure a range is completely contained in this document.
234+
*
235+
* @param range A range.
236+
* @return The given range or a new, adjusted range.
249237
*/
250238
validateRange(range: Range): Range;
251239

252240
/**
253-
* Ensure a position sticks to the text. // <<< dito >>>
241+
* Ensure a position is completely contained in this document.
242+
*
243+
* @param position A position.
244+
* @return The given position or a new, adjusted position.
254245
*/
255246
validatePosition(position: Position): Position;
256247
}
@@ -362,16 +353,21 @@ declare namespace vscode {
362353
* Create a new range from two position. If `start` is not
363354
* before or equal to `end` the values will be swapped.
364355
*
365-
* @param start
366-
* @param end
356+
* @param start A position.
357+
* @param end A position.
367358
*/
368359
constructor(start: Position, end: Position);
369360

370361
/**
371-
* Create a new range from two (line,character)-pairs. The parameters
362+
* Create a new range from four number. The parameters
372363
* might be swapped so that start is before or equal to end.
364+
*
365+
* @param startLine A positive number or zero.
366+
* @param startCharacter A positive number or zero.
367+
* @param endLine A positive number or zero.
368+
* @param endCharacter A positive number or zero.
373369
*/
374-
constructor(startLine: number, startColumn: number, endLine: number, endColumn: number); // <<< use 'character' instead of 'column' >>>
370+
constructor(startLine: number, startCharacter: number, endLine: number, endCharacter: number);
375371

376372
/**
377373
* `true` iff `start` and `end` are equal.
@@ -437,8 +433,13 @@ declare namespace vscode {
437433

438434
/**
439435
* Create a selection from four points.
436+
*
437+
* @param anchorLine A positive number or zero.
438+
* @param anchorCharacter A positive number or zero.
439+
* @param activeLine A positive number or zero.
440+
* @param activeCharacter A positive number or zero.
440441
*/
441-
constructor(anchorLine: number, anchorColumn: number, activeLine: number, activeColumn: number); // <<< 'column' -> 'character' >>>
442+
constructor(anchorLine: number, anchorCharacter: number, activeLine: number, activeCharacter: number);
442443
/**
443444
* A selection is reversed if the [anchor](#Selection.anchor)
444445
* is equal to [start](#Selection.start) and if [active](#Selection.active)
@@ -475,7 +476,7 @@ declare namespace vscode {
475476

476477
/**
477478
* A text editor decoration type is a handle to additional styles in
478-
* the editor.
479+
* the editor.
479480
*
480481
* To get an instance of a `TextEditorDecorationType` use
481482
* [createTextEditorDecorationType](#window.createTextEditorDecorationType).
@@ -619,15 +620,12 @@ declare namespace vscode {
619620
document: TextDocument;
620621

621622
/**
622-
* The primary selection on this text editor. In case the text editor has multiple selections this is the first selection as
623-
* in `TextEditor.selections[0]`. <<< and in the single selection case this is not true? This should always be true! >>>
624-
* @see [updateSelection](#updateSelection)
623+
* The primary selection on this text editor. Shorthand for `TextEditor.selections[0]`.
625624
*/
626625
selection: Selection;
627626

628627
/**
629-
* The selections in this text editor.
630-
* @see [updateSelection](#updateSelection)
628+
* The selections in this text editor. The primary selection is always at index 0.
631629
*/
632630
selections: Selection[];
633631

@@ -638,17 +636,24 @@ declare namespace vscode {
638636

639637
/**
640638
* Perform an edit on the document associated with this text editor.
641-
* The passed in {{editBuilder}} is available only for the duration of the callback.
642-
* <<< waht does 'available' mean? better: 'valid' >>>
639+
*
640+
* The given callback-function is invoked with an [edit-builder](#TextEditorEdit) which must
641+
* be used to make edits. Note that the the edit-builder is only valid while the
642+
* callback executes.
643+
*
644+
* @param callback A function which can make edits using an [edit-builder](#TextEditorEdit).
645+
* @return A promise that resolve when the edits could be applied.
643646
*/
644647
edit(callback: (editBuilder: TextEditorEdit) => void): Thenable<boolean>;
645648

646649
/**
647-
* Adds a set of decorations to the text editor.
648-
* You must first create a `TextEditorDecorationType`. <<< to create another object is probably true for 95% of all APIs; nuke this sentence! >>>
649-
* If a set of decorations already exists with the given type, they will be overwritten.
650+
* Adds a set of decorations to the text editor. If a set of decorations already exists with
651+
* the given [decoration type](#TextEditorDecorationType), they will be replaced.
652+
*
653+
* @param decorationType A decoration type.
654+
* @param rangesOrOptions Either [ranges](#Range) or more detailed [options](#DecorationOptions).
650655
*/
651-
setDecorations(decorationType: TextEditorDecorationType, ranges: Range[] | DecorationOptions[]): void;
656+
setDecorations(decorationType: TextEditorDecorationType, rangesOrOptions: Range[] | DecorationOptions[]): void;
652657

653658
/**
654659
* Scroll as necessary in order to reveal the given range.
@@ -676,17 +681,6 @@ declare namespace vscode {
676681
hide(): void;
677682
}
678683

679-
/**
680-
* Denotes a column in the VS Code window. Columns used to show editors
681-
* side by side.
682-
* <<< another reason not to use the term 'column' for 'character' within a line >>>
683-
* <<< this definition seems to be misplaced: it is not TextEditor related >>>
684-
*/
685-
export enum ViewColumn {
686-
One = 1,
687-
Two = 2,
688-
Three = 3
689-
}
690684

691685
/**
692686
* A complex edit that will be applied on a TextEditor.
@@ -910,12 +904,12 @@ declare namespace vscode {
910904
export interface QuickPickItem {
911905

912906
/**
913-
* The main label of this item <<< is there another 'non-main' label? >>>
907+
* A label. Will be rendered prominent.
914908
*/
915909
label: string;
916910

917911
/**
918-
* A description <<< for what is this used? >>>
912+
* A description. Will be rendered less prominent.
919913
*/
920914
description: string;
921915
}
@@ -936,7 +930,7 @@ declare namespace vscode {
936930
}
937931

938932
/**
939-
* Represents an actional item that is shown with an information, warning, or <<< what is an 'actional' item? >>>
933+
* Represents an action that is shown with an information, warning, or
940934
* error message
941935
*
942936
* @see #window.showInformationMessage
@@ -1524,6 +1518,16 @@ declare namespace vscode {
15241518
dispose(): void;
15251519
}
15261520

1521+
/**
1522+
* Denotes a column in the VS Code window. Columns used to show editors
1523+
* side by side.
1524+
*/
1525+
export enum ViewColumn {
1526+
One = 1,
1527+
Two = 2,
1528+
Three = 3
1529+
}
1530+
15271531
/**
15281532
* An output channel is a container for readonly textual information.
15291533
*

0 commit comments

Comments
 (0)