@@ -20,10 +20,18 @@ declare namespace ts {
20
20
export import ClassificationType = ts.ClassificationType;
21
21
export import CompletionsTriggerCharacter = ts.CompletionsTriggerCharacter;
22
22
export import CompletionTriggerKind = ts.CompletionTriggerKind;
23
+ export import InlayHintKind = ts.InlayHintKind;
23
24
export import OrganizeImportsMode = ts.OrganizeImportsMode;
25
+ export import RefactorActionInfo = ts.RefactorActionInfo;
24
26
export import RefactorTriggerReason = ts.RefactorTriggerReason;
25
27
export import RenameInfoFailure = ts.RenameInfoFailure;
26
28
export import SemicolonPreference = ts.SemicolonPreference;
29
+ export import SignatureHelpCharacterTypedReason = ts.SignatureHelpCharacterTypedReason;
30
+ export import SignatureHelpInvokedReason = ts.SignatureHelpInvokedReason;
31
+ export import SignatureHelpParameter = ts.SignatureHelpParameter;
32
+ export import SignatureHelpRetriggerCharacter = ts.SignatureHelpRetriggerCharacter;
33
+ export import SignatureHelpRetriggeredReason = ts.SignatureHelpRetriggeredReason;
34
+ export import SignatureHelpTriggerCharacter = ts.SignatureHelpTriggerCharacter;
27
35
export import SignatureHelpTriggerReason = ts.SignatureHelpTriggerReason;
28
36
export import SymbolDisplayPart = ts.SymbolDisplayPart;
29
37
export import UserPreferences = ts.UserPreferences;
@@ -99,6 +107,7 @@ declare namespace ts {
99
107
GetApplicableRefactors = "getApplicableRefactors",
100
108
GetEditsForRefactor = "getEditsForRefactor",
101
109
GetMoveToRefactoringFileSuggestions = "getMoveToRefactoringFileSuggestions",
110
+ GetPasteEdits = "getPasteEdits",
102
111
OrganizeImports = "organizeImports",
103
112
GetEditsForFileRename = "getEditsForFileRename",
104
113
ConfigurePlugin = "configurePlugin",
@@ -112,6 +121,7 @@ declare namespace ts {
112
121
ProvideCallHierarchyOutgoingCalls = "provideCallHierarchyOutgoingCalls",
113
122
ProvideInlayHints = "provideInlayHints",
114
123
WatchChange = "watchChange",
124
+ MapCode = "mapCode",
115
125
}
116
126
/**
117
127
* A TypeScript Server message
@@ -469,6 +479,33 @@ declare namespace ts {
469
479
files: string[];
470
480
};
471
481
}
482
+ /**
483
+ * Request refactorings at a given position post pasting text from some other location.
484
+ */
485
+ export interface GetPasteEditsRequest extends Request {
486
+ command: CommandTypes.GetPasteEdits;
487
+ arguments: GetPasteEditsRequestArgs;
488
+ }
489
+ export interface GetPasteEditsRequestArgs extends FileRequestArgs {
490
+ /** The text that gets pasted in a file. */
491
+ pastedText: string[];
492
+ /** Locations of where the `pastedText` gets added in a file. If the length of the `pastedText` and `pastedLocations` are not the same,
493
+ * then the `pastedText` is combined into one and added at all the `pastedLocations`.
494
+ */
495
+ pasteLocations: TextSpan[];
496
+ /** The source location of each `pastedText`. If present, the length of `spans` must be equal to the length of `pastedText`. */
497
+ copiedFrom?: {
498
+ file: string;
499
+ spans: TextSpan[];
500
+ };
501
+ }
502
+ export interface GetPasteEditsResponse extends Response {
503
+ body: PasteEditsAction;
504
+ }
505
+ export interface PasteEditsAction {
506
+ edits: FileCodeEdits[];
507
+ fixId?: {};
508
+ }
472
509
export interface GetEditsForRefactorRequest extends Request {
473
510
command: CommandTypes.GetEditsForRefactor;
474
511
arguments: GetEditsForRefactorRequestArgs;
@@ -1733,6 +1770,33 @@ declare namespace ts {
1733
1770
export interface InlayHintsResponse extends Response {
1734
1771
body?: InlayHintItem[];
1735
1772
}
1773
+ export interface MapCodeRequestArgs extends FileRequestArgs {
1774
+ /**
1775
+ * The files and changes to try and apply/map.
1776
+ */
1777
+ mapping: MapCodeRequestDocumentMapping;
1778
+ }
1779
+ export interface MapCodeRequestDocumentMapping {
1780
+ /**
1781
+ * The specific code to map/insert/replace in the file.
1782
+ */
1783
+ contents: string[];
1784
+ /**
1785
+ * Areas of "focus" to inform the code mapper with. For example, cursor
1786
+ * location, current selection, viewport, etc. Nested arrays denote
1787
+ * priority: toplevel arrays are more important than inner arrays, and
1788
+ * inner array priorities are based on items within that array. Items
1789
+ * earlier in the arrays have higher priority.
1790
+ */
1791
+ focusLocations?: TextSpan[][];
1792
+ }
1793
+ export interface MapCodeRequest extends FileRequest {
1794
+ command: CommandTypes.MapCode;
1795
+ arguments: MapCodeRequestArgs;
1796
+ }
1797
+ export interface MapCodeResponse extends Response {
1798
+ body: readonly FileCodeEdits[];
1799
+ }
1736
1800
/**
1737
1801
* Synchronous request for semantic diagnostics of one file.
1738
1802
*/
@@ -2720,7 +2784,6 @@ declare namespace ts {
2720
2784
private compilerOptions;
2721
2785
compileOnSaveEnabled: boolean;
2722
2786
protected watchOptions: WatchOptions | undefined;
2723
- private rootFiles;
2724
2787
private rootFilesMap;
2725
2788
private program;
2726
2789
private externalFiles;
@@ -2801,7 +2864,7 @@ declare namespace ts {
2801
2864
private detachScriptInfoIfNotRoot;
2802
2865
isClosed(): boolean;
2803
2866
hasRoots(): boolean;
2804
- getRootFiles(): ts.server. NormalizedPath[];
2867
+ getRootFiles(): NormalizedPath[];
2805
2868
getRootScriptInfos(): ts.server.ScriptInfo[];
2806
2869
getScriptInfos(): ScriptInfo[];
2807
2870
getExcludedFiles(): readonly NormalizedPath[];
@@ -2872,8 +2935,6 @@ declare namespace ts {
2872
2935
*/
2873
2936
class ConfiguredProject extends Project {
2874
2937
readonly canonicalConfigFilePath: NormalizedPath;
2875
- /** Ref count to the project when opened from external project */
2876
- private externalProjectRefCount;
2877
2938
private projectReferences;
2878
2939
/**
2879
2940
* If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph
@@ -3117,6 +3178,10 @@ declare namespace ts {
3117
3178
* Open files: with value being project root path, and key being Path of the file that is open
3118
3179
*/
3119
3180
readonly openFiles: Map<Path, NormalizedPath | undefined>;
3181
+ /** Config files looked up and cached config files for open script info */
3182
+ private readonly configFileForOpenFiles;
3183
+ /** Set of open script infos that are root of inferred project */
3184
+ private rootOfInferredProjects;
3120
3185
/**
3121
3186
* Map of open files that are opened without complete path but have projectRoot as current directory
3122
3187
*/
@@ -3135,6 +3200,11 @@ declare namespace ts {
3135
3200
private safelist;
3136
3201
private readonly legacySafelist;
3137
3202
private pendingProjectUpdates;
3203
+ /**
3204
+ * All the open script info that needs recalculation of the default project,
3205
+ * this also caches config file info before config file change was detected to use it in case projects are not updated yet
3206
+ */
3207
+ private pendingOpenFileProjectUpdates?;
3138
3208
readonly currentDirectory: NormalizedPath;
3139
3209
readonly toCanonicalFileName: (f: string) => string;
3140
3210
readonly host: ServerHost;
@@ -3166,6 +3236,11 @@ declare namespace ts {
3166
3236
setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.InferredProjectCompilerOptions, projectRootPath?: string): void;
3167
3237
findProject(projectName: string): Project | undefined;
3168
3238
getDefaultProjectForFile(fileName: NormalizedPath, ensureProject: boolean): Project | undefined;
3239
+ /**
3240
+ * If there is default project calculation pending for this file,
3241
+ * then it completes that calculation so that correct default project is used for the project
3242
+ */
3243
+ private tryGetDefaultProjectForEnsuringConfiguredProjectForFile;
3169
3244
private doEnsureDefaultProjectForFile;
3170
3245
getScriptInfoEnsuringProjectsUptoDate(uncheckedFileName: string): ScriptInfo | undefined;
3171
3246
/**
@@ -3185,13 +3260,6 @@ declare namespace ts {
3185
3260
private delayUpdateSourceInfoProjects;
3186
3261
private delayUpdateProjectsOfScriptInfoPath;
3187
3262
private handleDeletedFile;
3188
- /**
3189
- * This function goes through all the openFiles and tries to file the config file for them.
3190
- * If the config file is found and it refers to existing project, it schedules the reload it for reload
3191
- * If there is no existing project it just opens the configured project for the config file
3192
- * shouldReloadProjectFor provides a way to filter out files to reload configured project for
3193
- */
3194
- private delayReloadConfiguredProjectsForFile;
3195
3263
private removeProject;
3196
3264
private assignOrphanScriptInfosToInferredProject;
3197
3265
/**
@@ -3201,14 +3269,6 @@ declare namespace ts {
3201
3269
private closeOpenFile;
3202
3270
private deleteScriptInfo;
3203
3271
private configFileExists;
3204
- /**
3205
- * Returns true if the configFileExistenceInfo is needed/impacted by open files that are root of inferred project
3206
- */
3207
- private configFileExistenceImpactsRootOfInferredProject;
3208
- /**
3209
- * This is called on file close, so that we stop watching the config file for this script info
3210
- */
3211
- private stopWatchingConfigFilesForClosedScriptInfo;
3212
3272
/**
3213
3273
* This function tries to search for a tsconfig.json for the given file.
3214
3274
* This is different from the method the compiler uses because
@@ -3218,17 +3278,10 @@ declare namespace ts {
3218
3278
* the newly opened file.
3219
3279
*/
3220
3280
private forEachConfigFileLocation;
3221
- /**
3222
- * This function tries to search for a tsconfig.json for the given file.
3223
- * This is different from the method the compiler uses because
3224
- * the compiler can assume it will always start searching in the
3225
- * current directory (the directory in which tsc was invoked).
3226
- * The server must start searching from the directory containing
3227
- * the newly opened file.
3228
- * If script info is passed in, it is asserted to be open script info
3229
- * otherwise just file name
3230
- */
3231
- private getConfigFileNameForFile;
3281
+ /** Get cached configFileName for scriptInfo or ancestor of open script info */
3282
+ private getConfigFileNameForFileFromCache;
3283
+ /** Caches the configFilename for script info or ancestor of open script info */
3284
+ private setConfigFileNameForFileInCache;
3232
3285
private printProjects;
3233
3286
private getConfiguredProjectByCanonicalConfigFilePath;
3234
3287
private findExternalProjectByProjectName;
@@ -3269,12 +3322,6 @@ declare namespace ts {
3269
3322
* This does not reload contents of open files from disk. But we could do that if needed
3270
3323
*/
3271
3324
reloadProjects(): void;
3272
- /**
3273
- * This function goes through all the openFiles and tries to file the config file for them.
3274
- * If the config file is found and it refers to existing project, it reloads it either immediately
3275
- * If there is no existing project it just opens the configured project for the config file
3276
- */
3277
- private reloadConfiguredProjectForFiles;
3278
3325
/**
3279
3326
* Remove the root of inferred project if script info is part of another project
3280
3327
*/
@@ -3296,11 +3343,21 @@ declare namespace ts {
3296
3343
private findExternalProjectContainingOpenScriptInfo;
3297
3344
private getOrCreateOpenScriptInfo;
3298
3345
private assignProjectToOpenedScriptInfo;
3299
- private createAncestorProjects;
3346
+ /**
3347
+ * Finds the default configured project for given info
3348
+ * For any tsconfig found, it looks into that project, if not then all its references,
3349
+ * The search happens for all tsconfigs till projectRootPath
3350
+ */
3351
+ private tryFindDefaultConfiguredProjectForOpenScriptInfo;
3352
+ /**
3353
+ * Finds the default configured project, if found, it creates the solution projects (does not load them right away)
3354
+ * with Find: finds the projects even if the project is deferredClosed
3355
+ */
3356
+ private tryFindDefaultConfiguredProjectAndLoadAncestorsForOpenScriptInfo;
3300
3357
private ensureProjectChildren;
3301
- private cleanupAfterOpeningFile;
3358
+ private cleanupConfiguredProjects;
3359
+ private cleanupProjectsAndScriptInfos;
3302
3360
openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult;
3303
- private removeOrphanConfiguredProjects;
3304
3361
private removeOrphanScriptInfos;
3305
3362
private telemetryOnOpenFile;
3306
3363
/**
@@ -3309,7 +3366,6 @@ declare namespace ts {
3309
3366
*/
3310
3367
closeClientFile(uncheckedFileName: string): void;
3311
3368
private collectChanges;
3312
- private closeConfiguredProjectReferencedFromExternalProject;
3313
3369
closeExternalProject(uncheckedFileName: string): void;
3314
3370
openExternalProjects(projects: protocol.ExternalProject[]): void;
3315
3371
/** Makes a filename safe to insert in a RegExp */
@@ -3440,6 +3496,7 @@ declare namespace ts {
3440
3496
private getLinkedEditingRange;
3441
3497
private getDocumentHighlights;
3442
3498
private provideInlayHints;
3499
+ private mapCode;
3443
3500
private setCompilerOptionsForInferredProjects;
3444
3501
private getProjectInfo;
3445
3502
private getProjectInfoWorker;
@@ -3499,6 +3556,7 @@ declare namespace ts {
3499
3556
private getApplicableRefactors;
3500
3557
private getEditsForRefactor;
3501
3558
private getMoveToRefactoringFileSuggestions;
3559
+ private getPasteEdits;
3502
3560
private organizeImports;
3503
3561
private getEditsForFileRename;
3504
3562
private getCodeFixes;
@@ -3507,6 +3565,7 @@ declare namespace ts {
3507
3565
private getStartAndEndPosition;
3508
3566
private mapCodeAction;
3509
3567
private mapCodeFixAction;
3568
+ private mapPasteEditsAction;
3510
3569
private mapTextChangesToCodeEdits;
3511
3570
private mapTextChangeToCodeEdit;
3512
3571
private convertTextChangeToCodeEdit;
@@ -9456,6 +9515,7 @@ declare namespace ts {
9456
9515
interface EmitOutput {
9457
9516
outputFiles: OutputFile[];
9458
9517
emitSkipped: boolean;
9518
+ diagnostics: readonly Diagnostic[];
9459
9519
}
9460
9520
interface OutputFile {
9461
9521
name: string;
@@ -10102,6 +10162,7 @@ declare namespace ts {
10102
10162
uncommentSelection(fileName: string, textRange: TextRange): TextChange[];
10103
10163
getSupportedCodeFixes(fileName?: string): readonly string[];
10104
10164
dispose(): void;
10165
+ getPasteEdits(args: PasteEditsArgs, formatOptions: FormatCodeSettings): PasteEdits;
10105
10166
}
10106
10167
interface JsxClosingTagInfo {
10107
10168
readonly newText: string;
@@ -10119,6 +10180,20 @@ declare namespace ts {
10119
10180
SortAndCombine = "SortAndCombine",
10120
10181
RemoveUnused = "RemoveUnused",
10121
10182
}
10183
+ interface PasteEdits {
10184
+ edits: readonly FileTextChanges[];
10185
+ fixId?: {};
10186
+ }
10187
+ interface PasteEditsArgs {
10188
+ targetFile: string;
10189
+ pastedText: string[];
10190
+ pasteLocations: TextRange[];
10191
+ copiedFrom: {
10192
+ file: string;
10193
+ range: TextRange[];
10194
+ } | undefined;
10195
+ preferences: UserPreferences;
10196
+ }
10122
10197
interface OrganizeImportsArgs extends CombinedCodeFixScope {
10123
10198
/** @deprecated Use `mode` instead */
10124
10199
skipDestructiveCodeActions?: boolean;
0 commit comments