Skip to content

Commit 03bb5d1

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

File tree

4 files changed

+20
-25
lines changed

4 files changed

+20
-25
lines changed

src/server/editorServices.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
namespace ts {
2-
export interface UserPreferences {
3-
readonly lazyConfiguredProjectsFromExternalProject?: boolean;
4-
}
5-
}
6-
71
namespace ts.server {
82
export const maxProgramSizeForNonTsFiles = 20 * 1024 * 1024;
93
/*@internal*/
@@ -224,9 +218,15 @@ namespace ts.server {
224218
}
225219
}
226220

221+
/*@internal*/
222+
export function convertUserPreferences(preferences: protocol.UserPreferences): UserPreferences {
223+
const { lazyConfiguredProjectsFromExternalProject, ...userPreferences } = preferences;
224+
return userPreferences;
225+
}
226+
227227
export interface HostConfiguration {
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
return info && info.getFormatCodeSettings() || this.hostConfiguration.formatCodeOptions;
809809
}
810810

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

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

src/server/scriptInfo.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ namespace ts.server {
234234
*/
235235
readonly containingProjects: Project[] = [];
236236
private formatSettings: FormatCodeSettings | undefined;
237-
private preferences: UserPreferences | undefined;
237+
private preferences: protocol.UserPreferences | undefined;
238238

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

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

338338
attachToProject(project: Project): boolean {
339339
const isNew = !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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ namespace ts.server {
14231423
const position = this.getPosition(args, scriptInfo);
14241424

14251425
const completions = 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
return this.projectService.getFormatCodeOptions(file);
23532353
}
23542354

2355-
private getPreferences(file: NormalizedPath): UserPreferences {
2355+
private getPreferences(file: NormalizedPath): protocol.UserPreferences {
23562356
return this.projectService.getPreferences(file);
23572357
}
23582358

23592359
private getHostFormatOptions(): FormatCodeSettings {
23602360
return this.projectService.getHostFormatCodeOptions();
23612361
}
23622362

2363-
private getHostPreferences(): UserPreferences {
2363+
private getHostPreferences(): protocol.UserPreferences {
23642364
return this.projectService.getHostPreferences();
23652365
}
23662366
}

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

+5-10
Original file line numberDiff line numberDiff line change
@@ -7929,14 +7929,14 @@ declare namespace ts.server {
79297929
getSnapshot(): IScriptSnapshot;
79307930
private ensureRealPath;
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-
declare namespace ts {
8205-
interface UserPreferences {
8206-
readonly lazyConfiguredProjectsFromExternalProject?: boolean;
8207-
}
8208-
}
82098204
declare namespace ts.server {
82108205
const maxProgramSizeForNonTsFiles: number;
82118206
const ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground";
@@ -8319,7 +8314,7 @@ declare namespace ts.server {
83198314
function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind.Unknown | ScriptKind.JS | ScriptKind.JSX | ScriptKind.TS | ScriptKind.TSX;
83208315
interface HostConfiguration {
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
private ensureProjectStructuresUptoDate;
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
private onSourceFileChanged;
84458440
private handleDeletedFile;
84468441
private onConfigChangedForConfiguredProject;

0 commit comments

Comments
 (0)