Server mode renames as per feedback
This commit is contained in:
parent
ff2ff98ee4
commit
d320625392
10 changed files with 35 additions and 35 deletions
|
@ -719,10 +719,10 @@ namespace ts.server {
|
|||
this.typesMapLocation = (opts.typesMapLocation === undefined) ? combinePaths(getDirectoryPath(this.getExecutingFilePath()), "typesMap.json") : opts.typesMapLocation;
|
||||
if (opts.serverMode !== undefined) {
|
||||
this.serverMode = opts.serverMode;
|
||||
this.syntaxOnly = this.serverMode === LanguageServiceMode.SyntaxOnly;
|
||||
this.syntaxOnly = this.serverMode === LanguageServiceMode.Syntactic;
|
||||
}
|
||||
else if (opts.syntaxOnly) {
|
||||
this.serverMode = LanguageServiceMode.SyntaxOnly;
|
||||
this.serverMode = LanguageServiceMode.Syntactic;
|
||||
this.syntaxOnly = true;
|
||||
}
|
||||
else {
|
||||
|
@ -3029,7 +3029,7 @@ namespace ts.server {
|
|||
let retainProjects: ConfiguredProject[] | ConfiguredProject | undefined;
|
||||
let projectForConfigFileDiag: ConfiguredProject | undefined;
|
||||
let defaultConfigProjectIsCreated = false;
|
||||
if (this.serverMode === LanguageServiceMode.ApproximateSemanticOnly) {
|
||||
if (this.serverMode === LanguageServiceMode.ApproximateSemantic) {
|
||||
// Invalidate resolutions in the file since this file is now open
|
||||
info.containingProjects.forEach(project => {
|
||||
if (project.resolutionCache.removeRelativeNoResolveResolutionsOfFile(info.path)) {
|
||||
|
@ -3124,7 +3124,7 @@ namespace ts.server {
|
|||
Debug.assert(this.openFiles.has(info.path));
|
||||
this.assignOrphanScriptInfoToInferredProject(info, this.openFiles.get(info.path));
|
||||
}
|
||||
else if (this.serverMode === LanguageServiceMode.ApproximateSemanticOnly && info.cacheSourceFile?.sourceFile.referencedFiles.length) {
|
||||
else if (this.serverMode === LanguageServiceMode.ApproximateSemantic && info.cacheSourceFile?.sourceFile.referencedFiles.length) {
|
||||
// This file was just opened and references in this file will previously not been resolved so schedule update
|
||||
info.containingProjects.forEach(project => project.markAsDirty());
|
||||
}
|
||||
|
|
|
@ -283,11 +283,11 @@ namespace ts.server {
|
|||
case LanguageServiceMode.Semantic:
|
||||
this.languageServiceEnabled = true;
|
||||
break;
|
||||
case LanguageServiceMode.ApproximateSemanticOnly:
|
||||
case LanguageServiceMode.ApproximateSemantic:
|
||||
this.languageServiceEnabled = true;
|
||||
this.compilerOptions.types = [];
|
||||
break;
|
||||
case LanguageServiceMode.SyntaxOnly:
|
||||
case LanguageServiceMode.Syntactic:
|
||||
this.languageServiceEnabled = false;
|
||||
this.compilerOptions.noResolve = true;
|
||||
this.compilerOptions.types = [];
|
||||
|
@ -471,9 +471,9 @@ namespace ts.server {
|
|||
switch (this.projectService.serverMode) {
|
||||
case LanguageServiceMode.Semantic:
|
||||
return true;
|
||||
case LanguageServiceMode.ApproximateSemanticOnly:
|
||||
case LanguageServiceMode.ApproximateSemantic:
|
||||
return this.fileIsOpen(this.toPath(containingFile));
|
||||
case LanguageServiceMode.SyntaxOnly:
|
||||
case LanguageServiceMode.Syntactic:
|
||||
return false;
|
||||
default:
|
||||
Debug.assertNever(this.projectService.serverMode);
|
||||
|
@ -677,7 +677,7 @@ namespace ts.server {
|
|||
}
|
||||
|
||||
enableLanguageService() {
|
||||
if (this.languageServiceEnabled || this.projectService.serverMode === LanguageServiceMode.SyntaxOnly) {
|
||||
if (this.languageServiceEnabled || this.projectService.serverMode === LanguageServiceMode.Syntactic) {
|
||||
return;
|
||||
}
|
||||
this.languageServiceEnabled = true;
|
||||
|
@ -689,7 +689,7 @@ namespace ts.server {
|
|||
if (!this.languageServiceEnabled) {
|
||||
return;
|
||||
}
|
||||
Debug.assert(this.projectService.serverMode !== LanguageServiceMode.SyntaxOnly);
|
||||
Debug.assert(this.projectService.serverMode !== LanguageServiceMode.Syntactic);
|
||||
this.languageService.cleanupSemanticCache();
|
||||
this.languageServiceEnabled = false;
|
||||
this.lastFileExceededProgramSize = lastFileExceededProgramSize;
|
||||
|
|
|
@ -751,17 +751,17 @@ namespace ts.server {
|
|||
switch (this.projectService.serverMode) {
|
||||
case LanguageServiceMode.Semantic:
|
||||
break;
|
||||
case LanguageServiceMode.ApproximateSemanticOnly:
|
||||
case LanguageServiceMode.ApproximateSemantic:
|
||||
invalidApproximateSemanticOnlyCommands.forEach(commandName =>
|
||||
this.handlers.set(commandName, request => {
|
||||
throw new Error(`Request: ${request.command} not allowed on approximate semantic only server`);
|
||||
throw new Error(`Request: ${request.command} not allowed in LanguageServiceMode.ApproximateSemantic`);
|
||||
})
|
||||
);
|
||||
break;
|
||||
case LanguageServiceMode.SyntaxOnly:
|
||||
case LanguageServiceMode.Syntactic:
|
||||
invalidSyntaxOnlyCommands.forEach(commandName =>
|
||||
this.handlers.set(commandName, request => {
|
||||
throw new Error(`Request: ${request.command} not allowed on syntax only server`);
|
||||
throw new Error(`Request: ${request.command} not allowed in LanguageServiceMode.Syntactic`);
|
||||
})
|
||||
);
|
||||
break;
|
||||
|
|
|
@ -1222,7 +1222,7 @@ namespace ts {
|
|||
}
|
||||
else if (typeof syntaxOnlyOrLanguageServiceMode === "boolean") {
|
||||
// languageServiceMode = SyntaxOnly
|
||||
languageServiceMode = syntaxOnlyOrLanguageServiceMode ? LanguageServiceMode.SyntaxOnly : LanguageServiceMode.Semantic;
|
||||
languageServiceMode = syntaxOnlyOrLanguageServiceMode ? LanguageServiceMode.Syntactic : LanguageServiceMode.Semantic;
|
||||
}
|
||||
else {
|
||||
languageServiceMode = syntaxOnlyOrLanguageServiceMode;
|
||||
|
@ -1276,7 +1276,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function synchronizeHostData(): void {
|
||||
Debug.assert(languageServiceMode !== LanguageServiceMode.SyntaxOnly);
|
||||
Debug.assert(languageServiceMode !== LanguageServiceMode.Syntactic);
|
||||
// perform fast check if host supports it
|
||||
if (host.getProjectVersion) {
|
||||
const hostProjectVersion = host.getProjectVersion();
|
||||
|
@ -1462,7 +1462,7 @@ namespace ts {
|
|||
|
||||
// TODO: GH#18217 frequently asserted as defined
|
||||
function getProgram(): Program | undefined {
|
||||
if (languageServiceMode === LanguageServiceMode.SyntaxOnly) {
|
||||
if (languageServiceMode === LanguageServiceMode.Syntactic) {
|
||||
Debug.assert(program === undefined);
|
||||
return undefined;
|
||||
}
|
||||
|
@ -2545,17 +2545,17 @@ namespace ts {
|
|||
switch (languageServiceMode) {
|
||||
case LanguageServiceMode.Semantic:
|
||||
break;
|
||||
case LanguageServiceMode.ApproximateSemanticOnly:
|
||||
case LanguageServiceMode.ApproximateSemantic:
|
||||
invalidOperationsOnApproximateSemanticOnly.forEach(key =>
|
||||
ls[key] = () => {
|
||||
throw new Error(`LanguageService Operation: ${key} not allowed on approximate semantic only server`);
|
||||
throw new Error(`LanguageService Operation: ${key} not allowed in LanguageServiceMode.ApproximateSemantic`);
|
||||
}
|
||||
);
|
||||
break;
|
||||
case LanguageServiceMode.SyntaxOnly:
|
||||
case LanguageServiceMode.Syntactic:
|
||||
invalidOperationsOnSyntaxOnly.forEach(key =>
|
||||
ls[key] = () => {
|
||||
throw new Error(`LanguageService Operation: ${key} not allowed on syntax only server`);
|
||||
throw new Error(`LanguageService Operation: ${key} not allowed in LanguageServiceMode.Syntactic`);
|
||||
}
|
||||
);
|
||||
break;
|
||||
|
|
|
@ -223,8 +223,8 @@ namespace ts {
|
|||
|
||||
export enum LanguageServiceMode {
|
||||
Semantic,
|
||||
ApproximateSemanticOnly,
|
||||
SyntaxOnly,
|
||||
ApproximateSemantic,
|
||||
Syntactic,
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -26,7 +26,7 @@ import { something } from "something";
|
|||
content: "{}"
|
||||
};
|
||||
const host = createServerHost([file1, file2, file3, something, libFile, configFile]);
|
||||
const session = createSession(host, { serverMode: LanguageServiceMode.ApproximateSemanticOnly, useSingleInferredProject: true });
|
||||
const session = createSession(host, { serverMode: LanguageServiceMode.ApproximateSemantic, useSingleInferredProject: true });
|
||||
return { host, session, file1, file2, file3, something, configFile };
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ import { something } from "something";
|
|||
session.executeCommand(request);
|
||||
}
|
||||
catch (e) {
|
||||
assert.equal(e.message, `Request: semanticDiagnosticsSync not allowed on approximate semantic only server`);
|
||||
assert.equal(e.message, `Request: semanticDiagnosticsSync not allowed in LanguageServiceMode.ApproximateSemantic`);
|
||||
hasException = true;
|
||||
}
|
||||
assert.isTrue(hasException);
|
||||
|
@ -149,7 +149,7 @@ import { something } from "something";
|
|||
project.getLanguageService().getSemanticDiagnostics(file1.path);
|
||||
}
|
||||
catch (e) {
|
||||
assert.equal(e.message, `LanguageService Operation: getSemanticDiagnostics not allowed on approximate semantic only server`);
|
||||
assert.equal(e.message, `LanguageService Operation: getSemanticDiagnostics not allowed in LanguageServiceMode.ApproximateSemantic`);
|
||||
hasException = true;
|
||||
}
|
||||
assert.isTrue(hasException);
|
||||
|
@ -195,7 +195,7 @@ function fooB() { }`
|
|||
content: "{}"
|
||||
};
|
||||
const host = createServerHost([file1, file2, file3, something, libFile, configFile]);
|
||||
const session = createSession(host, { serverMode: LanguageServiceMode.ApproximateSemanticOnly, useSingleInferredProject: true });
|
||||
const session = createSession(host, { serverMode: LanguageServiceMode.ApproximateSemantic, useSingleInferredProject: true });
|
||||
const service = session.getProjectService();
|
||||
openFilesForSession([file1], session);
|
||||
checkNumberOfProjects(service, { inferredProjects: 1 });
|
||||
|
|
|
@ -36,7 +36,7 @@ import { something } from "something";
|
|||
session.executeCommandSeq(request);
|
||||
}
|
||||
catch (e) {
|
||||
assert.equal(e.message, `Request: ${request.command} not allowed on syntax only server`);
|
||||
assert.equal(e.message, `Request: ${request.command} not allowed in LanguageServiceMode.Syntactic`);
|
||||
hasException = true;
|
||||
}
|
||||
assert.isTrue(hasException);
|
||||
|
@ -119,7 +119,7 @@ import { something } from "something";
|
|||
project.getLanguageService().getSemanticDiagnostics(file1.path);
|
||||
}
|
||||
catch (e) {
|
||||
assert.equal(e.message, `LanguageService Operation: getSemanticDiagnostics not allowed on syntax only server`);
|
||||
assert.equal(e.message, `LanguageService Operation: getSemanticDiagnostics not allowed in LanguageServiceMode.Syntactic`);
|
||||
hasException = true;
|
||||
}
|
||||
assert.isTrue(hasException);
|
||||
|
|
|
@ -960,9 +960,9 @@ namespace ts.server {
|
|||
case "semantic":
|
||||
return LanguageServiceMode.Semantic;
|
||||
case "approximatesemanticonly":
|
||||
return LanguageServiceMode.ApproximateSemanticOnly;
|
||||
return LanguageServiceMode.ApproximateSemantic;
|
||||
case "syntaxonly":
|
||||
return LanguageServiceMode.SyntaxOnly;
|
||||
return LanguageServiceMode.Syntactic;
|
||||
default:
|
||||
unknownServerMode = mode;
|
||||
return undefined;
|
||||
|
|
|
@ -5316,8 +5316,8 @@ declare namespace ts {
|
|||
}
|
||||
enum LanguageServiceMode {
|
||||
Semantic = 0,
|
||||
ApproximateSemanticOnly = 1,
|
||||
SyntaxOnly = 2
|
||||
ApproximateSemantic = 1,
|
||||
Syntactic = 2
|
||||
}
|
||||
interface LanguageServiceHost extends GetEffectiveTypeRootsHost {
|
||||
getCompilationSettings(): CompilerOptions;
|
||||
|
|
|
@ -5316,8 +5316,8 @@ declare namespace ts {
|
|||
}
|
||||
enum LanguageServiceMode {
|
||||
Semantic = 0,
|
||||
ApproximateSemanticOnly = 1,
|
||||
SyntaxOnly = 2
|
||||
ApproximateSemantic = 1,
|
||||
Syntactic = 2
|
||||
}
|
||||
interface LanguageServiceHost extends GetEffectiveTypeRootsHost {
|
||||
getCompilationSettings(): CompilerOptions;
|
||||
|
|
Loading…
Reference in a new issue