Skip to content

Commit 03bb5d1

Browse files
committed
Use protocol.UserPreferences in server to store UserPreferences
1 parent 52fef42 commit 03bb5d1

4 files changed

Lines changed: 20 additions & 25 deletions

File tree

‎src/server/editorServices.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
namespacets{
2-
exportinterfaceUserPreferences{
3-
readonlylazyConfiguredProjectsFromExternalProject?: boolean;
4-
}
5-
}
6-
71
namespacets.server{
82
exportconstmaxProgramSizeForNonTsFiles=20*1024*1024;
93
/*@internal*/
@@ -224,9 +218,15 @@ namespace ts.server {
224218
}
225219
}
226220

221+
/*@internal*/
222+
exportfunctionconvertUserPreferences(preferences: protocol.UserPreferences): UserPreferences{
223+
const{ lazyConfiguredProjectsFromExternalProject, ...userPreferences}=preferences;
224+
returnuserPreferences;
225+
}
226+
227227
exportinterfaceHostConfiguration{
228228
formatCodeOptions: FormatCodeSettings;
229-
preferences: UserPreferences;
229+
preferences: protocol.UserPreferences;
230230
hostInfo: string;
231231
extraFileExtensions?: FileExtensionInfo[];
232232
}
@@ -808,7 +808,7 @@ namespace ts.server {
808808
returninfo&&info.getFormatCodeSettings()||this.hostConfiguration.formatCodeOptions;
809809
}
810810

811-
getPreferences(file: NormalizedPath): UserPreferences{
811+
getPreferences(file: NormalizedPath): protocol.UserPreferences{
812812
constinfo=this.getScriptInfoForNormalizedPath(file);
813813
returninfo&&info.getPreferences()||this.hostConfiguration.preferences;
814814
}
@@ -817,7 +817,7 @@ namespace ts.server {
817817
returnthis.hostConfiguration.formatCodeOptions;
818818
}
819819

820-
getHostPreferences(): UserPreferences{
820+
getHostPreferences(): protocol.UserPreferences{
821821
returnthis.hostConfiguration.preferences;
822822
}
823823

‎src/server/scriptInfo.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ namespace ts.server {
234234
*/
235235
readonlycontainingProjects: Project[]=[];
236236
privateformatSettings: FormatCodeSettings|undefined;
237-
privatepreferences: UserPreferences|undefined;
237+
privatepreferences: protocol.UserPreferences|undefined;
238238

239239
/* @internal */
240240
fileWatcher: FileWatcher|undefined;
@@ -333,7 +333,7 @@ namespace ts.server {
333333
}
334334

335335
getFormatCodeSettings(): FormatCodeSettings|undefined{returnthis.formatSettings;}
336-
getPreferences(): UserPreferences|undefined{returnthis.preferences;}
336+
getPreferences(): protocol.UserPreferences|undefined{returnthis.preferences;}
337337

338338
attachToProject(project: Project): boolean{
339339
constisNew=!this.isAttached(project);
@@ -432,7 +432,7 @@ namespace ts.server {
432432
}
433433
}
434434

435-
setOptions(formatSettings: FormatCodeSettings,preferences: UserPreferences|undefined): void{
435+
setOptions(formatSettings: FormatCodeSettings,preferences: protocol.UserPreferences|undefined): void{
436436
if(formatSettings){
437437
if(!this.formatSettings){
438438
this.formatSettings=getDefaultFormatCodeSettings(this.host);

‎src/server/session.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ namespace ts.server {
14231423
constposition=this.getPosition(args,scriptInfo);
14241424

14251425
constcompletions=project.getLanguageService().getCompletionsAtPosition(file,position,{
1426-
...this.getPreferences(file),
1426+
...convertUserPreferences(this.getPreferences(file)),
14271427
triggerCharacter: args.triggerCharacter,
14281428
includeExternalModuleExports: args.includeExternalModuleExports,
14291429
includeInsertTextCompletions: args.includeInsertTextCompletions
@@ -2352,15 +2352,15 @@ namespace ts.server {
23522352
returnthis.projectService.getFormatCodeOptions(file);
23532353
}
23542354

2355-
privategetPreferences(file: NormalizedPath): UserPreferences{
2355+
privategetPreferences(file: NormalizedPath): protocol.UserPreferences{
23562356
returnthis.projectService.getPreferences(file);
23572357
}
23582358

23592359
privategetHostFormatOptions(): FormatCodeSettings{
23602360
returnthis.projectService.getHostFormatCodeOptions();
23612361
}
23622362

2363-
privategetHostPreferences(): UserPreferences{
2363+
privategetHostPreferences(): protocol.UserPreferences{
23642364
returnthis.projectService.getHostPreferences();
23652365
}
23662366
}

‎tests/baselines/reference/api/tsserverlibrary.d.ts‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7929,14 +7929,14 @@ declare namespace ts.server {
79297929
getSnapshot(): IScriptSnapshot;
79307930
privateensureRealPath;
79317931
getFormatCodeSettings(): FormatCodeSettings|undefined;
7932-
getPreferences(): UserPreferences|undefined;
7932+
getPreferences(): protocol.UserPreferences|undefined;
79337933
attachToProject(project: Project): boolean;
79347934
isAttached(project: Project): boolean;
79357935
detachFromProject(project: Project): void;
79367936
detachAllProjects(): void;
79377937
getDefaultProject(): Project;
79387938
registerFileUpdate(): void;
7939-
setOptions(formatSettings: FormatCodeSettings,preferences: UserPreferences|undefined): void;
7939+
setOptions(formatSettings: FormatCodeSettings,preferences: protocol.UserPreferences|undefined): void;
79407940
getLatestVersion(): string;
79417941
saveTo(fileName: string): void;
79427942
reloadFromFile(tempFileName?: NormalizedPath): boolean;
@@ -8201,11 +8201,6 @@ declare namespace ts.server {
82018201
setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void;
82028202
}
82038203
}
8204-
declarenamespacets{
8205-
interfaceUserPreferences{
8206-
readonlylazyConfiguredProjectsFromExternalProject?: boolean;
8207-
}
8208-
}
82098204
declarenamespacets.server{
82108205
constmaxProgramSizeForNonTsFiles: number;
82118206
constProjectsUpdatedInBackgroundEvent="projectsUpdatedInBackground";
@@ -8319,7 +8314,7 @@ declare namespace ts.server {
83198314
functionconvertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind.Unknown|ScriptKind.JS|ScriptKind.JSX|ScriptKind.TS|ScriptKind.TSX;
83208315
interfaceHostConfiguration{
83218316
formatCodeOptions: FormatCodeSettings;
8322-
preferences: UserPreferences;
8317+
preferences: protocol.UserPreferences;
83238318
hostInfo: string;
83248319
extraFileExtensions?: FileExtensionInfo[];
83258320
}
@@ -8438,9 +8433,9 @@ declare namespace ts.server {
84388433
*/
84398434
privateensureProjectStructuresUptoDate;
84408435
getFormatCodeOptions(file: NormalizedPath): FormatCodeSettings;
8441-
getPreferences(file: NormalizedPath): UserPreferences;
8436+
getPreferences(file: NormalizedPath): protocol.UserPreferences;
84428437
getHostFormatCodeOptions(): FormatCodeSettings;
8443-
getHostPreferences(): UserPreferences;
8438+
getHostPreferences(): protocol.UserPreferences;
84448439
privateonSourceFileChanged;
84458440
privatehandleDeletedFile;
84468441
privateonConfigChangedForConfiguredProject;

0 commit comments

Comments
 (0)