Use protocol.UserPreferences in server to store UserPreferences
This commit is contained in:
parent
52fef42baa
commit
03bb5d170e
|
@ -1,9 +1,3 @@
|
|||
namespace ts {
|
||||
export interface UserPreferences {
|
||||
readonly lazyConfiguredProjectsFromExternalProject?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
namespace ts.server {
|
||||
export const maxProgramSizeForNonTsFiles = 20 * 1024 * 1024;
|
||||
/*@internal*/
|
||||
|
@ -224,9 +218,15 @@ namespace ts.server {
|
|||
}
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function convertUserPreferences(preferences: protocol.UserPreferences): UserPreferences {
|
||||
const { lazyConfiguredProjectsFromExternalProject, ...userPreferences } = preferences;
|
||||
return userPreferences;
|
||||
}
|
||||
|
||||
export interface HostConfiguration {
|
||||
formatCodeOptions: FormatCodeSettings;
|
||||
preferences: UserPreferences;
|
||||
preferences: protocol.UserPreferences;
|
||||
hostInfo: string;
|
||||
extraFileExtensions?: FileExtensionInfo[];
|
||||
}
|
||||
|
@ -808,7 +808,7 @@ namespace ts.server {
|
|||
return info && info.getFormatCodeSettings() || this.hostConfiguration.formatCodeOptions;
|
||||
}
|
||||
|
||||
getPreferences(file: NormalizedPath): UserPreferences {
|
||||
getPreferences(file: NormalizedPath): protocol.UserPreferences {
|
||||
const info = this.getScriptInfoForNormalizedPath(file);
|
||||
return info && info.getPreferences() || this.hostConfiguration.preferences;
|
||||
}
|
||||
|
@ -817,7 +817,7 @@ namespace ts.server {
|
|||
return this.hostConfiguration.formatCodeOptions;
|
||||
}
|
||||
|
||||
getHostPreferences(): UserPreferences {
|
||||
getHostPreferences(): protocol.UserPreferences {
|
||||
return this.hostConfiguration.preferences;
|
||||
}
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ namespace ts.server {
|
|||
*/
|
||||
readonly containingProjects: Project[] = [];
|
||||
private formatSettings: FormatCodeSettings | undefined;
|
||||
private preferences: UserPreferences | undefined;
|
||||
private preferences: protocol.UserPreferences | undefined;
|
||||
|
||||
/* @internal */
|
||||
fileWatcher: FileWatcher | undefined;
|
||||
|
@ -333,7 +333,7 @@ namespace ts.server {
|
|||
}
|
||||
|
||||
getFormatCodeSettings(): FormatCodeSettings | undefined { return this.formatSettings; }
|
||||
getPreferences(): UserPreferences | undefined { return this.preferences; }
|
||||
getPreferences(): protocol.UserPreferences | undefined { return this.preferences; }
|
||||
|
||||
attachToProject(project: Project): boolean {
|
||||
const isNew = !this.isAttached(project);
|
||||
|
@ -432,7 +432,7 @@ namespace ts.server {
|
|||
}
|
||||
}
|
||||
|
||||
setOptions(formatSettings: FormatCodeSettings, preferences: UserPreferences | undefined): void {
|
||||
setOptions(formatSettings: FormatCodeSettings, preferences: protocol.UserPreferences | undefined): void {
|
||||
if (formatSettings) {
|
||||
if (!this.formatSettings) {
|
||||
this.formatSettings = getDefaultFormatCodeSettings(this.host);
|
||||
|
|
|
@ -1423,7 +1423,7 @@ namespace ts.server {
|
|||
const position = this.getPosition(args, scriptInfo);
|
||||
|
||||
const completions = project.getLanguageService().getCompletionsAtPosition(file, position, {
|
||||
...this.getPreferences(file),
|
||||
...convertUserPreferences(this.getPreferences(file)),
|
||||
triggerCharacter: args.triggerCharacter,
|
||||
includeExternalModuleExports: args.includeExternalModuleExports,
|
||||
includeInsertTextCompletions: args.includeInsertTextCompletions
|
||||
|
@ -2352,7 +2352,7 @@ namespace ts.server {
|
|||
return this.projectService.getFormatCodeOptions(file);
|
||||
}
|
||||
|
||||
private getPreferences(file: NormalizedPath): UserPreferences {
|
||||
private getPreferences(file: NormalizedPath): protocol.UserPreferences {
|
||||
return this.projectService.getPreferences(file);
|
||||
}
|
||||
|
||||
|
@ -2360,7 +2360,7 @@ namespace ts.server {
|
|||
return this.projectService.getHostFormatCodeOptions();
|
||||
}
|
||||
|
||||
private getHostPreferences(): UserPreferences {
|
||||
private getHostPreferences(): protocol.UserPreferences {
|
||||
return this.projectService.getHostPreferences();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7929,14 +7929,14 @@ declare namespace ts.server {
|
|||
getSnapshot(): IScriptSnapshot;
|
||||
private ensureRealPath;
|
||||
getFormatCodeSettings(): FormatCodeSettings | undefined;
|
||||
getPreferences(): UserPreferences | undefined;
|
||||
getPreferences(): protocol.UserPreferences | undefined;
|
||||
attachToProject(project: Project): boolean;
|
||||
isAttached(project: Project): boolean;
|
||||
detachFromProject(project: Project): void;
|
||||
detachAllProjects(): void;
|
||||
getDefaultProject(): Project;
|
||||
registerFileUpdate(): void;
|
||||
setOptions(formatSettings: FormatCodeSettings, preferences: UserPreferences | undefined): void;
|
||||
setOptions(formatSettings: FormatCodeSettings, preferences: protocol.UserPreferences | undefined): void;
|
||||
getLatestVersion(): string;
|
||||
saveTo(fileName: string): void;
|
||||
reloadFromFile(tempFileName?: NormalizedPath): boolean;
|
||||
|
@ -8201,11 +8201,6 @@ declare namespace ts.server {
|
|||
setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void;
|
||||
}
|
||||
}
|
||||
declare namespace ts {
|
||||
interface UserPreferences {
|
||||
readonly lazyConfiguredProjectsFromExternalProject?: boolean;
|
||||
}
|
||||
}
|
||||
declare namespace ts.server {
|
||||
const maxProgramSizeForNonTsFiles: number;
|
||||
const ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground";
|
||||
|
@ -8319,7 +8314,7 @@ declare namespace ts.server {
|
|||
function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind.Unknown | ScriptKind.JS | ScriptKind.JSX | ScriptKind.TS | ScriptKind.TSX;
|
||||
interface HostConfiguration {
|
||||
formatCodeOptions: FormatCodeSettings;
|
||||
preferences: UserPreferences;
|
||||
preferences: protocol.UserPreferences;
|
||||
hostInfo: string;
|
||||
extraFileExtensions?: FileExtensionInfo[];
|
||||
}
|
||||
|
@ -8438,9 +8433,9 @@ declare namespace ts.server {
|
|||
*/
|
||||
private ensureProjectStructuresUptoDate;
|
||||
getFormatCodeOptions(file: NormalizedPath): FormatCodeSettings;
|
||||
getPreferences(file: NormalizedPath): UserPreferences;
|
||||
getPreferences(file: NormalizedPath): protocol.UserPreferences;
|
||||
getHostFormatCodeOptions(): FormatCodeSettings;
|
||||
getHostPreferences(): UserPreferences;
|
||||
getHostPreferences(): protocol.UserPreferences;
|
||||
private onSourceFileChanged;
|
||||
private handleDeletedFile;
|
||||
private onConfigChangedForConfiguredProject;
|
||||
|
|
Loading…
Reference in a new issue