diff --git a/Jakefile.js b/Jakefile.js
index 64a8553ef39dc..b548a0d3dd86d 100644
--- a/Jakefile.js
+++ b/Jakefile.js
@@ -174,7 +174,7 @@ var serverCoreSources = [
"lsHost.ts",
"project.ts",
"editorServices.ts",
- "protocol.d.ts",
+ "protocol.ts",
"session.ts",
"server.ts"
].map(function (f) {
@@ -198,14 +198,13 @@ var typingsInstallerSources = [
var serverSources = serverCoreSources.concat(servicesSources);
var languageServiceLibrarySources = [
- "protocol.d.ts",
+ "protocol.ts",
"utilities.ts",
"scriptVersionCache.ts",
"scriptInfo.ts",
"lsHost.ts",
"project.ts",
"editorServices.ts",
- "protocol.d.ts",
"session.ts",
].map(function (f) {
@@ -259,7 +258,7 @@ var harnessSources = harnessCoreSources.concat([
].map(function (f) {
return path.join(unittestsDirectory, f);
})).concat([
- "protocol.d.ts",
+ "protocol.ts",
"utilities.ts",
"scriptVersionCache.ts",
"scriptInfo.ts",
@@ -267,7 +266,6 @@ var harnessSources = harnessCoreSources.concat([
"project.ts",
"typingsCache.ts",
"editorServices.ts",
- "protocol.d.ts",
"session.ts",
].map(function (f) {
return path.join(serverDirectory, f);
@@ -518,6 +516,40 @@ compileFile(processDiagnosticMessagesJs,
[],
/*useBuiltCompiler*/ false);
+var buildProtocolTs = path.join(scriptsDirectory, "buildProtocol.ts");
+var buildProtocolJs = path.join(scriptsDirectory, "buildProtocol.js");
+var buildProtocolDts = path.join(builtLocalDirectory, "protocol.d.ts");
+var typescriptServicesDts = path.join(builtLocalDirectory, "typescriptServices.d.ts");
+
+file(buildProtocolTs);
+
+compileFile(buildProtocolJs,
+ [buildProtocolTs],
+ [buildProtocolTs],
+ [],
+ /*useBuiltCompiler*/ false,
+ {noOutFile: true});
+
+file(buildProtocolDts, [buildProtocolTs, buildProtocolJs, typescriptServicesDts], function() {
+
+ var protocolTs = path.join(serverDirectory, "protocol.ts");
+
+ var cmd = host + " " + buildProtocolJs + " "+ protocolTs + " " + typescriptServicesDts + " " + buildProtocolDts;
+ console.log(cmd);
+ var ex = jake.createExec([cmd]);
+ // Add listeners for output and error
+ ex.addListener("stdout", function (output) {
+ process.stdout.write(output);
+ });
+ ex.addListener("stderr", function (error) {
+ process.stderr.write(error);
+ });
+ ex.addListener("cmdEnd", function () {
+ complete();
+ });
+ ex.run();
+}, { async: true })
+
// The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task
file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], function () {
var cmd = host + " " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson;
@@ -655,6 +687,8 @@ compileFile(
inlineSourceMap: true
});
+file(typescriptServicesDts, [servicesFile]);
+
var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js");
compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: true });
@@ -689,7 +723,7 @@ task("build-fold-end", [], function () {
// Local target to build the compiler and services
desc("Builds the full compiler and services");
-task("local", ["build-fold-start", "generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON, "lssl", "build-fold-end"]);
+task("local", ["build-fold-start", "generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, buildProtocolDts, builtGeneratedDiagnosticMessagesJSON, "lssl", "build-fold-end"]);
// Local target to build only tsc.js
desc("Builds only the compiler");
@@ -745,7 +779,7 @@ task("generate-spec", [specMd]);
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
desc("Makes a new LKG out of the built js files");
task("LKG", ["clean", "release", "local"].concat(libraryTargets), function () {
- var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile, cancellationTokenFile, typingsInstallerFile].concat(libraryTargets);
+ var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile, cancellationTokenFile, typingsInstallerFile, buildProtocolDts].concat(libraryTargets);
var missingFiles = expectedFiles.filter(function (f) {
return !fs.existsSync(f);
});
diff --git a/scripts/buildProtocol.ts b/scripts/buildProtocol.ts
new file mode 100644
index 0000000000000..8d49262a470de
--- /dev/null
+++ b/scripts/buildProtocol.ts
@@ -0,0 +1,143 @@
+///
+
+import * as ts from "../lib/typescript";
+import * as path from "path";
+
+function endsWith(s: string, suffix: string) {
+ return s.lastIndexOf(suffix, s.length - suffix.length) !== -1;
+}
+
+class DeclarationsWalker {
+ private visitedTypes: ts.Type[] = [];
+ private text = "";
+ private constructor(private typeChecker: ts.TypeChecker, private protocolFile: ts.SourceFile) {
+ }
+
+ static getExtraDeclarations(typeChecker: ts.TypeChecker, protocolFile: ts.SourceFile): string {
+ let text = "declare namespace ts.server.protocol {\n";
+ var walker = new DeclarationsWalker(typeChecker, protocolFile);
+ walker.visitTypeNodes(protocolFile);
+ return walker.text
+ ? `declare namespace ts.server.protocol {\n${walker.text}}`
+ : "";
+ }
+
+ private processType(type: ts.Type): void {
+ if (this.visitedTypes.indexOf(type) >= 0) {
+ return;
+ }
+ this.visitedTypes.push(type);
+ let s = type.aliasSymbol || type.getSymbol();
+ if (!s) {
+ return;
+ }
+ if (s.name === "Array") {
+ // we should process type argument instead
+ return this.processType((type).typeArguments[0]);
+ }
+ else {
+ for (const decl of s.getDeclarations()) {
+ const sourceFile = decl.getSourceFile();
+ if (sourceFile === this.protocolFile || path.basename(sourceFile.fileName) === "lib.d.ts") {
+ return;
+ }
+ // splice declaration in final d.ts file
+ const text = decl.getFullText();
+ this.text += `${text}\n`;
+
+ // recursively pull all dependencies into result dts file
+ this.visitTypeNodes(decl);
+ }
+ }
+ }
+
+ private visitTypeNodes(node: ts.Node) {
+ if (node.parent) {
+ switch (node.parent.kind) {
+ case ts.SyntaxKind.VariableDeclaration:
+ case ts.SyntaxKind.MethodDeclaration:
+ case ts.SyntaxKind.MethodSignature:
+ case ts.SyntaxKind.PropertyDeclaration:
+ case ts.SyntaxKind.PropertySignature:
+ case ts.SyntaxKind.Parameter:
+ case ts.SyntaxKind.IndexSignature:
+ if (((node.parent).type) === node) {
+ const type = this.typeChecker.getTypeAtLocation(node);
+ if (type && !(type.flags & ts.TypeFlags.TypeParameter)) {
+ this.processType(type);
+ }
+ }
+ break;
+ }
+ }
+ ts.forEachChild(node, n => this.visitTypeNodes(n));
+ }
+}
+
+function generateProtocolFile(protocolTs: string, typeScriptServicesDts: string): string {
+ const options = { target: ts.ScriptTarget.ES5, declaration: true, noResolve: true, types: [], stripInternal: true };
+
+ /**
+ * 1st pass - generate a program from protocol.ts and typescriptservices.d.ts and emit core version of protocol.d.ts with all internal members stripped
+ * @return text of protocol.d.t.s
+ */
+ function getInitialDtsFileForProtocol() {
+ const program = ts.createProgram([protocolTs, typeScriptServicesDts], options);
+
+ let protocolDts: string;
+ program.emit(program.getSourceFile(protocolTs), (file, content) => {
+ if (endsWith(file, ".d.ts")) {
+ protocolDts = content;
+ }
+ });
+ if (protocolDts === undefined) {
+ throw new Error(`Declaration file for protocol.ts is not generated`)
+ }
+ return protocolDts;
+ }
+
+ const protocolFileName = "protocol.d.ts";
+ /**
+ * Second pass - generate a program from protocol.d.ts and typescriptservices.d.ts, then augment core protocol.d.ts with extra types from typescriptservices.d.ts
+ */
+ function getProgramWithProtocolText(protocolDts: string, includeTypeScriptServices: boolean) {
+ const host = ts.createCompilerHost(options);
+ const originalGetSourceFile = host.getSourceFile;
+ host.getSourceFile = (fileName) => {
+ if (fileName === protocolFileName) {
+ return ts.createSourceFile(fileName, protocolDts, options.target);
+ }
+ return originalGetSourceFile.apply(host, [fileName]);
+ }
+ const rootFiles = includeTypeScriptServices ? [protocolFileName, typeScriptServicesDts] : [protocolFileName];
+ return ts.createProgram(rootFiles, options, host);
+ }
+
+ let protocolDts = getInitialDtsFileForProtocol();
+ const program = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ true);
+
+ const protocolFile = program.getSourceFile("protocol.d.ts");
+ const extraDeclarations = DeclarationsWalker.getExtraDeclarations(program.getTypeChecker(), protocolFile);
+ if (extraDeclarations) {
+ protocolDts += extraDeclarations;
+ }
+ // do sanity check and try to compile generated text as standalone program
+ const sanityCheckProgram = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ false);
+ const diagnostics = [...program.getSyntacticDiagnostics(), ...program.getSemanticDiagnostics(), ...program.getGlobalDiagnostics()];
+ if (diagnostics.length) {
+ const flattenedDiagnostics = diagnostics.map(d => ts.flattenDiagnosticMessageText(d.messageText, "\n")).join("\n");
+ throw new Error(`Unexpected errors during sanity check: ${flattenedDiagnostics}`);
+ }
+ return protocolDts;
+}
+
+if (process.argv.length < 5) {
+ console.log(`Expected 3 arguments: path to 'protocol.ts', path to 'typescriptservices.d.ts' and path to output file`);
+ process.exit(1);
+}
+
+const protocolTs = process.argv[2];
+const typeScriptServicesDts = process.argv[3];
+const outputFile = process.argv[4];
+const generatedProtocolDts = generateProtocolFile(protocolTs, typeScriptServicesDts);
+ts.sys.writeFile(outputFile, generatedProtocolDts);
diff --git a/src/compiler/types.ts b/src/compiler/types.ts
index 638504e613f11..e751f32b3da57 100644
--- a/src/compiler/types.ts
+++ b/src/compiler/types.ts
@@ -2917,11 +2917,7 @@ namespace ts {
NodeJs = 2
}
- export type RootPaths = string[];
- export type PathSubstitutions = MapLike;
- export type TsConfigOnlyOptions = RootPaths | PathSubstitutions;
-
- export type CompilerOptionsValue = string | number | boolean | (string | number)[] | TsConfigOnlyOptions;
+ export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike;
export interface CompilerOptions {
allowJs?: boolean;
@@ -2973,14 +2969,14 @@ namespace ts {
out?: string;
outDir?: string;
outFile?: string;
- paths?: PathSubstitutions;
+ paths?: MapLike;
preserveConstEnums?: boolean;
project?: string;
/* @internal */ pretty?: DiagnosticStyle;
reactNamespace?: string;
removeComments?: boolean;
rootDir?: string;
- rootDirs?: RootPaths;
+ rootDirs?: string[];
skipLibCheck?: boolean;
skipDefaultLibCheck?: boolean;
sourceMap?: boolean;
diff --git a/src/harness/unittests/compileOnSave.ts b/src/harness/unittests/compileOnSave.ts
index 24fd47ee0cbb5..797268000eb48 100644
--- a/src/harness/unittests/compileOnSave.ts
+++ b/src/harness/unittests/compileOnSave.ts
@@ -3,6 +3,8 @@
///
namespace ts.projectSystem {
+ import CommandNames = server.CommandNames;
+
function createTestTypingsInstaller(host: server.ServerHost) {
return new TestTypingsInstaller("/a/data/", /*throttleLimit*/5, host);
}
@@ -75,7 +77,7 @@ namespace ts.projectSystem {
};
// Change the content of file1 to `export var T: number;export function Foo() { };`
- changeModuleFile1ShapeRequest1 = makeSessionRequest(server.CommandNames.Change, {
+ changeModuleFile1ShapeRequest1 = makeSessionRequest(CommandNames.Change, {
file: moduleFile1.path,
line: 1,
offset: 1,
@@ -85,7 +87,7 @@ namespace ts.projectSystem {
});
// Change the content of file1 to `export var T: number;export function Foo() { };`
- changeModuleFile1InternalRequest1 = makeSessionRequest(server.CommandNames.Change, {
+ changeModuleFile1InternalRequest1 = makeSessionRequest(CommandNames.Change, {
file: moduleFile1.path,
line: 1,
offset: 1,
@@ -95,7 +97,7 @@ namespace ts.projectSystem {
});
// Change the content of file1 to `export var T: number;export function Foo() { };`
- changeModuleFile1ShapeRequest2 = makeSessionRequest(server.CommandNames.Change, {
+ changeModuleFile1ShapeRequest2 = makeSessionRequest(CommandNames.Change, {
file: moduleFile1.path,
line: 1,
offset: 1,
@@ -104,7 +106,7 @@ namespace ts.projectSystem {
insertString: `export var T2: number;`
});
- moduleFile1FileListRequest = makeSessionRequest(server.CommandNames.CompileOnSaveAffectedFileList, { file: moduleFile1.path, projectFileName: configFile.path });
+ moduleFile1FileListRequest = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: moduleFile1.path, projectFileName: configFile.path });
});
it("should contains only itself if a module file's shape didn't change, and all files referencing it if its shape changed", () => {
@@ -120,7 +122,7 @@ namespace ts.projectSystem {
sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer1, file1Consumer2] }]);
// Change the content of file1 to `export var T: number;export function Foo() { console.log('hi'); };`
- const changeFile1InternalRequest = makeSessionRequest(server.CommandNames.Change, {
+ const changeFile1InternalRequest = makeSessionRequest(CommandNames.Change, {
file: moduleFile1.path,
line: 1,
offset: 46,
@@ -143,7 +145,7 @@ namespace ts.projectSystem {
sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer1, file1Consumer2] }]);
// Change file2 content to `let y = Foo();`
- const removeFile1Consumer1ImportRequest = makeSessionRequest(server.CommandNames.Change, {
+ const removeFile1Consumer1ImportRequest = makeSessionRequest(CommandNames.Change, {
file: file1Consumer1.path,
line: 1,
offset: 1,
@@ -156,7 +158,7 @@ namespace ts.projectSystem {
sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer2] }]);
// Add the import statements back to file2
- const addFile2ImportRequest = makeSessionRequest(server.CommandNames.Change, {
+ const addFile2ImportRequest = makeSessionRequest(CommandNames.Change, {
file: file1Consumer1.path,
line: 1,
offset: 1,
@@ -167,7 +169,7 @@ namespace ts.projectSystem {
session.executeCommand(addFile2ImportRequest);
// Change the content of file1 to `export var T2: string;export var T: number;export function Foo() { };`
- const changeModuleFile1ShapeRequest2 = makeSessionRequest(server.CommandNames.Change, {
+ const changeModuleFile1ShapeRequest2 = makeSessionRequest(CommandNames.Change, {
file: moduleFile1.path,
line: 1,
offset: 1,
@@ -272,7 +274,7 @@ namespace ts.projectSystem {
const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false);
openFilesForSession([globalFile3], session);
- const changeGlobalFile3ShapeRequest = makeSessionRequest(server.CommandNames.Change, {
+ const changeGlobalFile3ShapeRequest = makeSessionRequest(CommandNames.Change, {
file: globalFile3.path,
line: 1,
offset: 1,
@@ -283,7 +285,7 @@ namespace ts.projectSystem {
// check after file1 shape changes
session.executeCommand(changeGlobalFile3ShapeRequest);
- const globalFile3FileListRequest = makeSessionRequest(server.CommandNames.CompileOnSaveAffectedFileList, { file: globalFile3.path });
+ const globalFile3FileListRequest = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: globalFile3.path });
sendAffectedFileRequestAndCheckResult(session, globalFile3FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer1, file1Consumer2, globalFile3, moduleFile2] }]);
});
@@ -316,7 +318,7 @@ namespace ts.projectSystem {
const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false);
openFilesForSession([moduleFile1], session);
- const file1ChangeShapeRequest = makeSessionRequest(server.CommandNames.Change, {
+ const file1ChangeShapeRequest = makeSessionRequest(CommandNames.Change, {
file: moduleFile1.path,
line: 1,
offset: 27,
@@ -345,7 +347,7 @@ namespace ts.projectSystem {
const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false);
openFilesForSession([moduleFile1], session);
- const file1ChangeShapeRequest = makeSessionRequest(server.CommandNames.Change, {
+ const file1ChangeShapeRequest = makeSessionRequest(CommandNames.Change, {
file: moduleFile1.path,
line: 1,
offset: 27,
@@ -369,7 +371,7 @@ namespace ts.projectSystem {
openFilesForSession([moduleFile1, file1Consumer1], session);
sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer1, file1Consumer1Consumer1] }]);
- const changeFile1Consumer1ShapeRequest = makeSessionRequest(server.CommandNames.Change, {
+ const changeFile1Consumer1ShapeRequest = makeSessionRequest(CommandNames.Change, {
file: file1Consumer1.path,
line: 2,
offset: 1,
@@ -400,7 +402,7 @@ namespace ts.projectSystem {
const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false);
openFilesForSession([file1, file2], session);
- const file1AffectedListRequest = makeSessionRequest(server.CommandNames.CompileOnSaveAffectedFileList, { file: file1.path });
+ const file1AffectedListRequest = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: file1.path });
sendAffectedFileRequestAndCheckResult(session, file1AffectedListRequest, [{ projectFileName: configFile.path, files: [file1, file2] }]);
});
@@ -415,7 +417,7 @@ namespace ts.projectSystem {
const session = createSession(host);
openFilesForSession([file1, file2, file3], session);
- const file1AffectedListRequest = makeSessionRequest(server.CommandNames.CompileOnSaveAffectedFileList, { file: file1.path });
+ const file1AffectedListRequest = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: file1.path });
sendAffectedFileRequestAndCheckResult(session, file1AffectedListRequest, [
{ projectFileName: configFile1.path, files: [file1, file2] },
@@ -437,11 +439,11 @@ namespace ts.projectSystem {
host.reloadFS([referenceFile1, configFile]);
host.triggerFileWatcherCallback(moduleFile1.path, /*removed*/ true);
- const request = makeSessionRequest(server.CommandNames.CompileOnSaveAffectedFileList, { file: referenceFile1.path });
+ const request = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: referenceFile1.path });
sendAffectedFileRequestAndCheckResult(session, request, [
{ projectFileName: configFile.path, files: [referenceFile1] }
]);
- const requestForMissingFile = makeSessionRequest(server.CommandNames.CompileOnSaveAffectedFileList, { file: moduleFile1.path });
+ const requestForMissingFile = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: moduleFile1.path });
sendAffectedFileRequestAndCheckResult(session, requestForMissingFile, []);
});
@@ -456,7 +458,7 @@ namespace ts.projectSystem {
const session = createSession(host);
openFilesForSession([referenceFile1], session);
- const request = makeSessionRequest(server.CommandNames.CompileOnSaveAffectedFileList, { file: referenceFile1.path });
+ const request = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: referenceFile1.path });
sendAffectedFileRequestAndCheckResult(session, request, [
{ projectFileName: configFile.path, files: [referenceFile1] }
]);
@@ -483,7 +485,7 @@ namespace ts.projectSystem {
const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false);
openFilesForSession([file1, file2], session);
- const compileFileRequest = makeSessionRequest(server.CommandNames.CompileOnSaveEmitFile, { file: file1.path, projectFileName: configFile.path });
+ const compileFileRequest = makeSessionRequest(CommandNames.CompileOnSaveEmitFile, { file: file1.path, projectFileName: configFile.path });
session.executeCommand(compileFileRequest);
const expectedEmittedFileName = "/a/b/f1.js";
diff --git a/src/server/builder.ts b/src/server/builder.ts
index 639c41d2b63e5..475202a0aabae 100644
--- a/src/server/builder.ts
+++ b/src/server/builder.ts
@@ -1,6 +1,5 @@
///
///
-///
///
///
diff --git a/src/server/client.ts b/src/server/client.ts
index 058abdff41dd1..b0bc2c5dac052 100644
--- a/src/server/client.ts
+++ b/src/server/client.ts
@@ -1,7 +1,6 @@
///
namespace ts.server {
-
export interface SessionClientHost extends LanguageServiceHost {
writeMessage(message: string): void;
}
diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts
index dc2c45156cd89..1a331c093207a 100644
--- a/src/server/editorServices.ts
+++ b/src/server/editorServices.ts
@@ -1,6 +1,5 @@
///
///
-///
///
///
///
diff --git a/src/server/protocol.d.ts b/src/server/protocol.ts
similarity index 80%
rename from src/server/protocol.d.ts
rename to src/server/protocol.ts
index 2f447934040b3..80623f05aec3a 100644
--- a/src/server/protocol.d.ts
+++ b/src/server/protocol.ts
@@ -1,7 +1,102 @@
/**
* Declaration module describing the TypeScript Server protocol
*/
-declare namespace ts.server.protocol {
+namespace ts.server.protocol {
+ export namespace CommandTypes {
+ export type Brace = "brace";
+ /* @internal */
+ export type BraceFull = "brace-full";
+ export type BraceCompletion = "braceCompletion";
+ export type Change = "change";
+ export type Close = "close";
+ export type Completions = "completions";
+ /* @internal */
+ export type CompletionsFull = "completions-full";
+ export type CompletionDetails = "completionEntryDetails";
+ export type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList";
+ export type CompileOnSaveEmitFile = "compileOnSaveEmitFile";
+ export type Configure = "configure";
+ export type Definition = "definition";
+ /* @internal */
+ export type DefinitionFull = "definition-full";
+ export type Implementation = "implementation";
+ /* @internal */
+ export type ImplementationFull = "implementation-full";
+ export type Exit = "exit";
+ export type Format = "format";
+ export type Formatonkey = "formatonkey";
+ /* @internal */
+ export type FormatFull = "format-full";
+ /* @internal */
+ export type FormatonkeyFull = "formatonkey-full";
+ /* @internal */
+ export type FormatRangeFull = "formatRange-full";
+ export type Geterr = "geterr";
+ export type GeterrForProject = "geterrForProject";
+ export type SemanticDiagnosticsSync = "semanticDiagnosticsSync";
+ export type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync";
+ export type NavBar = "navbar";
+ /* @internal */
+ export type NavBarFull = "navbar-full";
+ export type Navto = "navto";
+ /* @internal */
+ export type NavtoFull = "navto-full";
+ export type NavTree = "navtree";
+ export type NavTreeFull = "navtree-full";
+ export type Occurrences = "occurrences";
+ export type DocumentHighlights = "documentHighlights";
+ /* @internal */
+ export type DocumentHighlightsFull = "documentHighlights-full";
+ export type Open = "open";
+ export type Quickinfo = "quickinfo";
+ /* @internal */
+ export type QuickinfoFull = "quickinfo-full";
+ export type References = "references";
+ /* @internal */
+ export type ReferencesFull = "references-full";
+ export type Reload = "reload";
+ export type Rename = "rename";
+ /* @internal */
+ export type RenameInfoFull = "rename-full";
+ /* @internal */
+ export type RenameLocationsFull = "renameLocations-full";
+ export type Saveto = "saveto";
+ export type SignatureHelp = "signatureHelp";
+ /* @internal */
+ export type SignatureHelpFull = "signatureHelp-full";
+ export type TypeDefinition = "typeDefinition";
+ export type ProjectInfo = "projectInfo";
+ export type ReloadProjects = "reloadProjects";
+ export type Unknown = "unknown";
+ export type OpenExternalProject = "openExternalProject";
+ export type OpenExternalProjects = "openExternalProjects";
+ export type CloseExternalProject = "closeExternalProject";
+ /* @internal */
+ export type SynchronizeProjectList = "synchronizeProjectList";
+ /* @internal */
+ export type ApplyChangedToOpenFiles = "applyChangedToOpenFiles";
+ /* @internal */
+ export type EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full";
+ /* @internal */
+ export type Cleanup = "cleanup";
+ /* @internal */
+ export type OutliningSpans = "outliningSpans";
+ export type TodoComments = "todoComments";
+ export type Indentation = "indentation";
+ export type DocCommentTemplate = "docCommentTemplate";
+ /* @internal */
+ export type CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full";
+ /* @internal */
+ export type NameOrDottedNameSpan = "nameOrDottedNameSpan";
+ /* @internal */
+ export type BreakpointStatement = "breakpointStatement";
+ export type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects";
+ export type GetCodeFixes = "getCodeFixes";
+ /* @internal */
+ export type GetCodeFixesFull = "getCodeFixes-full";
+ export type GetSupportedCodeFixes = "getSupportedCodeFixes";
+ }
+
/**
* A TypeScript Server message
*/
@@ -36,6 +131,7 @@ declare namespace ts.server.protocol {
* Request to reload the project structure for all the opened files
*/
export interface ReloadProjectsRequest extends Message {
+ command: CommandTypes.ReloadProjects;
}
/**
@@ -98,10 +194,25 @@ declare namespace ts.server.protocol {
projectFileName?: string;
}
+ /**
+ * Requests a JS Doc comment template for a given position
+ */
+ export interface DocCommentTemplateRequest extends FileLocationRequest {
+ command: CommandTypes.DocCommentTemplate;
+ }
+
+ /**
+ * Response to DocCommentTemplateRequest
+ */
+ export interface DocCommandTemplateResponse extends Response {
+ body?: TextInsertion;
+ }
+
/**
* A request to get TODO comments from the file
*/
export interface TodoCommentRequest extends FileRequest {
+ command: CommandTypes.TodoComments;
arguments: TodoCommentRequestArgs;
}
@@ -115,13 +226,58 @@ declare namespace ts.server.protocol {
descriptors: TodoCommentDescriptor[];
}
+ /**
+ * Response for TodoCommentRequest request.
+ */
+ export interface TodoCommentsResponse extends Response {
+ body?: TodoComment[];
+ }
+
+ /**
+ * Request to obtain outlining spans in file.
+ */
+ /* @internal */
+ export interface OutliningSpansRequest extends FileRequest {
+ command: CommandTypes.OutliningSpans;
+ }
+
+ /**
+ * Response to OutliningSpansRequest request.
+ */
+ /* @internal */
+ export interface OutliningSpansResponse extends Response {
+ body?: OutliningSpan[];
+ }
+
/**
* A request to get indentation for a location in file
*/
export interface IndentationRequest extends FileLocationRequest {
+ command: CommandTypes.Indentation;
arguments: IndentationRequestArgs;
}
+ /**
+ * Response for IndentationRequest request.
+ */
+ export interface IndentationResponse extends Response {
+ body?: IndentationResult;
+ }
+
+ /**
+ * Indentation result representing where indentation should be placed
+ */
+ export interface IndentationResult {
+ /**
+ * The base position in the document that the indent should be relative to
+ */
+ position: number;
+ /**
+ * The number of columns the indent should be at relative to the position's column.
+ */
+ indentation: number;
+ }
+
/**
* Arguments for IndentationRequest request.
*/
@@ -147,6 +303,7 @@ declare namespace ts.server.protocol {
* A request to get the project information of the current file.
*/
export interface ProjectInfoRequest extends Request {
+ command: CommandTypes.ProjectInfo;
arguments: ProjectInfoRequestArgs;
}
@@ -223,16 +380,17 @@ declare namespace ts.server.protocol {
/**
* The line number for the request (1-based).
*/
- line?: number;
+ line: number;
/**
* The character offset (on the line) for the request (1-based).
*/
- offset?: number;
+ offset: number;
/**
* Position (can be specified instead of line/offset pair)
*/
+ /* @internal */
position?: number;
}
@@ -240,6 +398,7 @@ declare namespace ts.server.protocol {
* Request for the available codefixes at a specific position.
*/
export interface CodeFixRequest extends Request {
+ command: CommandTypes.GetCodeFixes;
arguments: CodeFixRequestArgs;
}
@@ -250,31 +409,33 @@ declare namespace ts.server.protocol {
/**
* The line number for the request (1-based).
*/
- startLine?: number;
+ startLine: number;
/**
* The character offset (on the line) for the request (1-based).
*/
- startOffset?: number;
+ startOffset: number;
/**
* Position (can be specified instead of line/offset pair)
*/
+ /* @internal */
startPosition?: number;
/**
* The line number for the request (1-based).
*/
- endLine?: number;
+ endLine: number;
/**
* The character offset (on the line) for the request (1-based).
*/
- endOffset?: number;
+ endOffset: number;
/**
* Position (can be specified instead of line/offset pair)
*/
+ /* @internal */
endPosition?: number;
/**
@@ -283,6 +444,13 @@ declare namespace ts.server.protocol {
errorCodes?: number[];
}
+ /**
+ * Response for GetCodeFixes request.
+ */
+ export interface GetCodeFixesResponse extends Response {
+ body?: CodeAction[];
+ }
+
/**
* A request whose arguments specify a file location (file, line, col).
*/
@@ -291,16 +459,34 @@ declare namespace ts.server.protocol {
}
/**
- * A request to get semantic diagnostics for a span in the file
+ * A request to get codes of supported code fixes.
*/
- export interface SemanticDiagnosticsRequest extends FileRequest {
- arguments: SemanticDiagnosticsRequestArgs;
+ export interface GetSupportedCodeFixesRequest extends Request {
+ command: CommandTypes.GetSupportedCodeFixes;
}
/**
- * Arguments for SemanticDiagnosticsRequest request.
+ * A response for GetSupportedCodeFixesRequest request.
*/
- export interface SemanticDiagnosticsRequestArgs extends FileRequestArgs {
+ export interface GetSupportedCodeFixesResponse extends Response {
+ /**
+ * List of error codes supported by the server.
+ */
+ body?: string[];
+ }
+
+ /**
+ * A request to get encoded semantic classifications for a span in the file
+ */
+ /** @internal */
+ export interface EncodedSemanticClassificationsRequest extends FileRequest {
+ arguments: EncodedSemanticClassificationsRequestArgs;
+ }
+
+ /**
+ * Arguments for EncodedSemanticClassificationsRequest request.
+ */
+ export interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs {
/**
* Start position of the span.
*/
@@ -328,6 +514,7 @@ declare namespace ts.server.protocol {
* define the symbol found in file at location line, col.
*/
export interface DefinitionRequest extends FileLocationRequest {
+ command: CommandTypes.Definition;
}
/**
@@ -336,6 +523,7 @@ declare namespace ts.server.protocol {
* define the type for the symbol found in file at location line, col.
*/
export interface TypeDefinitionRequest extends FileLocationRequest {
+ command: CommandTypes.TypeDefinition;
}
/**
@@ -344,6 +532,7 @@ declare namespace ts.server.protocol {
* implement the symbol found in file at location line, col.
*/
export interface ImplementationRequest extends FileLocationRequest {
+ command: CommandTypes.Implementation;
}
/**
@@ -404,6 +593,7 @@ declare namespace ts.server.protocol {
* Request to get brace completion for a location in the file.
*/
export interface BraceCompletionRequest extends FileLocationRequest {
+ command: CommandTypes.BraceCompletion;
arguments: BraceCompletionRequestArgs;
}
@@ -423,6 +613,7 @@ declare namespace ts.server.protocol {
* in the file at a given line and column.
*/
export interface OccurrencesRequest extends FileLocationRequest {
+ command: CommandTypes.Occurrences;
}
export interface OccurrencesResponseItem extends FileSpan {
@@ -442,6 +633,7 @@ declare namespace ts.server.protocol {
* in the file at a given line and column.
*/
export interface DocumentHighlightsRequest extends FileLocationRequest {
+ command: CommandTypes.DocumentHighlights;
arguments: DocumentHighlightsRequestArgs;
}
@@ -481,6 +673,7 @@ declare namespace ts.server.protocol {
* reference the symbol found in file at location line, col.
*/
export interface ReferencesRequest extends FileLocationRequest {
+ command: CommandTypes.References;
}
export interface ReferencesResponseItem extends FileSpan {
@@ -555,6 +748,7 @@ declare namespace ts.server.protocol {
* name of the symbol so that client can print it unambiguously.
*/
export interface RenameRequest extends FileLocationRequest {
+ command: CommandTypes.Rename;
arguments: RenameRequestArgs;
}
@@ -754,6 +948,7 @@ declare namespace ts.server.protocol {
/**
* Represents set of changes in open file
*/
+ /* @internal */
export interface ChangedOpenFile {
/**
* Name of file
@@ -765,65 +960,6 @@ declare namespace ts.server.protocol {
changes: ts.TextChange[];
}
- /**
- * Editor options
- */
- export interface EditorOptions {
-
- /** Number of spaces for each tab. Default value is 4. */
- tabSize?: number;
-
- /** Number of spaces to indent during formatting. Default value is 4. */
- indentSize?: number;
-
- /** Number of additional spaces to indent during formatting to preserve base indentation (ex. script block indentation). Default value is 0. */
- baseIndentSize?: number;
-
- /** The new line character to be used. Default value is the OS line delimiter. */
- newLineCharacter?: string;
-
- /** Whether tabs should be converted to spaces. Default value is true. */
- convertTabsToSpaces?: boolean;
- }
-
- /**
- * Format options
- */
- export interface FormatOptions extends EditorOptions {
-
- /** Defines space handling after a comma delimiter. Default value is true. */
- insertSpaceAfterCommaDelimiter?: boolean;
-
- /** Defines space handling after a semicolon in a for statement. Default value is true */
- insertSpaceAfterSemicolonInForStatements?: boolean;
-
- /** Defines space handling after a binary operator. Default value is true. */
- insertSpaceBeforeAndAfterBinaryOperators?: boolean;
-
- /** Defines space handling after keywords in control flow statement. Default value is true. */
- insertSpaceAfterKeywordsInControlFlowStatements?: boolean;
-
- /** Defines space handling after function keyword for anonymous functions. Default value is false. */
- insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean;
-
- /** Defines space handling after opening and before closing non empty parenthesis. Default value is false. */
- insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean;
-
- /** Defines space handling after opening and before closing non empty brackets. Default value is false. */
- insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean;
-
- /** Defines space handling before and after template string braces. Default value is false. */
- insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean;
-
- /** Defines space handling before and after JSX expression braces. Default value is false. */
- insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
-
- /** Defines whether an open brace is put onto a new line for functions or not. Default value is false. */
- placeOpenBraceOnNewLineForFunctions?: boolean;
-
- /** Defines whether an open brace is put onto a new line for control blocks or not. Default value is false. */
- placeOpenBraceOnNewLineForControlBlocks?: boolean;
- }
/**
* Information found in a configure request.
@@ -844,12 +980,7 @@ declare namespace ts.server.protocol {
/**
* The format options to use during formatting and other code editing features.
*/
- formatOptions?: FormatOptions;
-
- /**
- * If set to true - then all loose files will land into one inferred project
- */
- useOneInferredProject?: boolean;
+ formatOptions?: FormatCodeSettings;
}
/**
@@ -857,6 +988,7 @@ declare namespace ts.server.protocol {
* host information, such as host type, tab size, and indent size.
*/
export interface ConfigureRequest extends Request {
+ command: CommandTypes.Configure;
arguments: ConfigureRequestArguments;
}
@@ -892,6 +1024,7 @@ declare namespace ts.server.protocol {
* send a response to an open request.
*/
export interface OpenRequest extends Request {
+ command: CommandTypes.Open;
arguments: OpenRequestArgs;
}
@@ -899,18 +1032,20 @@ declare namespace ts.server.protocol {
* Request to open or update external project
*/
export interface OpenExternalProjectRequest extends Request {
+ command: CommandTypes.OpenExternalProject;
arguments: OpenExternalProjectArgs;
}
/**
* Arguments to OpenExternalProjectRequest request
*/
- type OpenExternalProjectArgs = ExternalProject;
+ export type OpenExternalProjectArgs = ExternalProject;
/**
* Request to open multiple external projects
*/
export interface OpenExternalProjectsRequest extends Request {
+ command: CommandTypes.OpenExternalProjects;
arguments: OpenExternalProjectsArgs;
}
@@ -924,10 +1059,25 @@ declare namespace ts.server.protocol {
projects: ExternalProject[];
}
+ /**
+ * Response to OpenExternalProjectRequest request. This is just an acknowledgement, so
+ * no body field is required.
+ */
+ export interface OpenExternalProjectResponse extends Response {
+ }
+
+ /**
+ * Response to OpenExternalProjectsRequest request. This is just an acknowledgement, so
+ * no body field is required.
+ */
+ export interface OpenExternalProjectsResponse extends Response {
+ }
+
/**
* Request to close external project.
*/
export interface CloseExternalProjectRequest extends Request {
+ command: CommandTypes.CloseExternalProject;
arguments: CloseExternalProjectRequestArgs;
}
@@ -941,9 +1091,17 @@ declare namespace ts.server.protocol {
projectFileName: string;
}
+ /**
+ * Response to CloseExternalProjectRequest request. This is just an acknowledgement, so
+ * no body field is required.
+ */
+ export interface CloseExternalProjectResponse extends Response {
+ }
+
/**
* Request to check if given list of projects is up-to-date and synchronize them if necessary
*/
+ /* @internal */
export interface SynchronizeProjectListRequest extends Request {
arguments: SynchronizeProjectListRequestArgs;
}
@@ -961,6 +1119,7 @@ declare namespace ts.server.protocol {
/**
* Request to synchronize list of open files with the client
*/
+ /* @internal */
export interface ApplyChangedToOpenFilesRequest extends Request {
arguments: ApplyChangedToOpenFilesRequestArgs;
}
@@ -968,6 +1127,7 @@ declare namespace ts.server.protocol {
/**
* Arguments to ApplyChangedToOpenFilesRequest
*/
+ /* @internal */
export interface ApplyChangedToOpenFilesRequestArgs {
/**
* List of newly open files
@@ -993,6 +1153,7 @@ declare namespace ts.server.protocol {
* or all open loose files and its transitive closure of referenced files if 'useOneInferredProject' is true.
*/
export interface SetCompilerOptionsForInferredProjectsRequest extends Request {
+ command: CommandTypes.CompilerOptionsForInferredProjects;
arguments: SetCompilerOptionsForInferredProjectsArgs;
}
@@ -1006,11 +1167,19 @@ declare namespace ts.server.protocol {
options: ExternalProjectCompilerOptions;
}
+ /**
+ * Response to SetCompilerOptionsForInferredProjectsResponse request. This is just an acknowledgement, so
+ * no body field is required.
+ */
+ export interface SetCompilerOptionsForInferredProjectsResponse extends Response {
+ }
+
/**
* Exit request; value of command field is "exit". Ask the server process
* to exit.
*/
export interface ExitRequest extends Request {
+ command: CommandTypes.Exit;
}
/**
@@ -1021,6 +1190,7 @@ declare namespace ts.server.protocol {
* currently send a response to a close request.
*/
export interface CloseRequest extends FileRequest {
+ command: CommandTypes.Close;
}
/**
@@ -1028,6 +1198,7 @@ declare namespace ts.server.protocol {
* NOTE: this us query-only operation and does not generate any output on disk.
*/
export interface CompileOnSaveAffectedFileListRequest extends FileRequest {
+ command: CommandTypes.CompileOnSaveAffectedFileList;
}
/**
@@ -1055,7 +1226,8 @@ declare namespace ts.server.protocol {
* Request to recompile the file. All generated outputs (.js, .d.ts or .js.map files) is written on disk.
*/
export interface CompileOnSaveEmitFileRequest extends FileRequest {
- args: CompileOnSaveEmitFileRequestArgs;
+ command: CommandTypes.CompileOnSaveEmitFile;
+ arguments: CompileOnSaveEmitFileRequestArgs;
}
/**
@@ -1075,6 +1247,7 @@ declare namespace ts.server.protocol {
* line, col.
*/
export interface QuickInfoRequest extends FileLocationRequest {
+ command: CommandTypes.Quickinfo;
}
/**
@@ -1136,12 +1309,12 @@ declare namespace ts.server.protocol {
/**
* End position of the range for which to format text in file.
*/
+ /* @internal */
endPosition?: number;
-
/**
* Format options to be used.
*/
- options?: ts.FormatCodeOptions;
+ options?: FormatCodeSettings;
}
/**
@@ -1152,6 +1325,7 @@ declare namespace ts.server.protocol {
* reformatted text.
*/
export interface FormatRequest extends FileLocationRequest {
+ command: CommandTypes.Format;
arguments: FormatRequestArgs;
}
@@ -1213,7 +1387,7 @@ declare namespace ts.server.protocol {
*/
key: string;
- options?: ts.FormatCodeOptions;
+ options?: FormatCodeSettings;
}
/**
@@ -1225,6 +1399,7 @@ declare namespace ts.server.protocol {
* reformatted text.
*/
export interface FormatOnKeyRequest extends FileLocationRequest {
+ command: CommandTypes.Formatonkey;
arguments: FormatOnKeyRequestArgs;
}
@@ -1245,6 +1420,7 @@ declare namespace ts.server.protocol {
* begin with prefix.
*/
export interface CompletionsRequest extends FileLocationRequest {
+ command: CommandTypes.Completions;
arguments: CompletionsRequestArgs;
}
@@ -1265,6 +1441,7 @@ declare namespace ts.server.protocol {
* detailed information for each completion entry.
*/
export interface CompletionDetailsRequest extends FileLocationRequest {
+ command: CommandTypes.CompletionDetails;
arguments: CompletionDetailsRequestArgs;
}
@@ -1451,6 +1628,7 @@ declare namespace ts.server.protocol {
* help.
*/
export interface SignatureHelpRequest extends FileLocationRequest {
+ command: CommandTypes.SignatureHelp;
arguments: SignatureHelpRequestArgs;
}
@@ -1465,6 +1643,7 @@ declare namespace ts.server.protocol {
* Synchronous request for semantic diagnostics of one file.
*/
export interface SemanticDiagnosticsSyncRequest extends FileRequest {
+ command: CommandTypes.SemanticDiagnosticsSync;
arguments: SemanticDiagnosticsSyncRequestArgs;
}
@@ -1483,6 +1662,7 @@ declare namespace ts.server.protocol {
* Synchronous request for syntactic diagnostics of one file.
*/
export interface SyntacticDiagnosticsSyncRequest extends FileRequest {
+ command: CommandTypes.SyntacticDiagnosticsSync;
arguments: SyntacticDiagnosticsSyncRequestArgs;
}
@@ -1519,6 +1699,7 @@ declare namespace ts.server.protocol {
* it request for every file in this project.
*/
export interface GeterrForProjectRequest extends Request {
+ command: CommandTypes.GeterrForProject;
arguments: GeterrForProjectRequestArgs;
}
@@ -1550,6 +1731,7 @@ declare namespace ts.server.protocol {
* file that is currently visible, in most-recently-used order.
*/
export interface GeterrRequest extends Request {
+ command: CommandTypes.Geterr;
arguments: GeterrRequestArgs;
}
@@ -1642,11 +1824,12 @@ declare namespace ts.server.protocol {
* The two names can be identical.
*/
export interface ReloadRequest extends FileRequest {
+ command: CommandTypes.Reload;
arguments: ReloadRequestArgs;
}
/**
- * Response to "reload" request. This is just an acknowledgement, so
+ * Response to "reload" request. This is just an acknowledgement, so
* no body field is required.
*/
export interface ReloadResponse extends Response {
@@ -1671,6 +1854,7 @@ declare namespace ts.server.protocol {
* "saveto" request.
*/
export interface SavetoRequest extends FileRequest {
+ command: CommandTypes.Saveto;
arguments: SavetoRequestArgs;
}
@@ -1703,6 +1887,7 @@ declare namespace ts.server.protocol {
* context for the search is given by the named file.
*/
export interface NavtoRequest extends FileRequest {
+ command: CommandTypes.Navto;
arguments: NavtoRequestArgs;
}
@@ -1786,6 +1971,7 @@ declare namespace ts.server.protocol {
* Server does not currently send a response to a change request.
*/
export interface ChangeRequest extends FileLocationRequest {
+ command: CommandTypes.Change;
arguments: ChangeRequestArgs;
}
@@ -1802,6 +1988,7 @@ declare namespace ts.server.protocol {
* found in file at location line, offset.
*/
export interface BraceRequest extends FileLocationRequest {
+ command: CommandTypes.Brace;
}
/**
@@ -1810,6 +1997,7 @@ declare namespace ts.server.protocol {
* extracted from the requested file.
*/
export interface NavBarRequest extends FileRequest {
+ command: CommandTypes.NavBar;
}
/**
@@ -1817,6 +2005,7 @@ declare namespace ts.server.protocol {
* Return response giving the navigation tree of the requested file.
*/
export interface NavTreeRequest extends FileRequest {
+ command: CommandTypes.NavTree;
}
export interface NavigationBarItem {
diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts
index ee5122ff4e13c..68dd59d2d3266 100644
--- a/src/server/scriptInfo.ts
+++ b/src/server/scriptInfo.ts
@@ -91,7 +91,7 @@ namespace ts.server {
return this.containingProjects[0];
}
- setFormatOptions(formatSettings: protocol.FormatOptions): void {
+ setFormatOptions(formatSettings: FormatCodeSettings): void {
if (formatSettings) {
if (!this.formatCodeSettings) {
this.formatCodeSettings = getDefaultFormatCodeSettings(this.host);
diff --git a/src/server/scriptVersionCache.ts b/src/server/scriptVersionCache.ts
index 1508187c13e72..8d0efa081adaf 100644
--- a/src/server/scriptVersionCache.ts
+++ b/src/server/scriptVersionCache.ts
@@ -1,6 +1,5 @@
///
///
-///
///
namespace ts.server {
diff --git a/src/server/session.ts b/src/server/session.ts
index 172ae70d95a84..111ba53a700d7 100644
--- a/src/server/session.ts
+++ b/src/server/session.ts
@@ -1,6 +1,6 @@
///
///
-///
+///
///
namespace ts.server {
@@ -83,74 +83,74 @@ namespace ts.server {
}
export namespace CommandNames {
- export const Brace = "brace";
- export const BraceFull = "brace-full";
- export const BraceCompletion = "braceCompletion";
- export const Change = "change";
- export const Close = "close";
- export const Completions = "completions";
- export const CompletionsFull = "completions-full";
- export const CompletionDetails = "completionEntryDetails";
- export const CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList";
- export const CompileOnSaveEmitFile = "compileOnSaveEmitFile";
- export const Configure = "configure";
- export const Definition = "definition";
- export const DefinitionFull = "definition-full";
- export const Exit = "exit";
- export const Format = "format";
- export const Formatonkey = "formatonkey";
- export const FormatFull = "format-full";
- export const FormatonkeyFull = "formatonkey-full";
- export const FormatRangeFull = "formatRange-full";
- export const Geterr = "geterr";
- export const GeterrForProject = "geterrForProject";
- export const Implementation = "implementation";
- export const ImplementationFull = "implementation-full";
- export const SemanticDiagnosticsSync = "semanticDiagnosticsSync";
- export const SyntacticDiagnosticsSync = "syntacticDiagnosticsSync";
- export const NavBar = "navbar";
- export const NavBarFull = "navbar-full";
- export const NavTree = "navtree";
- export const NavTreeFull = "navtree-full";
- export const Navto = "navto";
- export const NavtoFull = "navto-full";
- export const Occurrences = "occurrences";
- export const DocumentHighlights = "documentHighlights";
- export const DocumentHighlightsFull = "documentHighlights-full";
- export const Open = "open";
- export const Quickinfo = "quickinfo";
- export const QuickinfoFull = "quickinfo-full";
- export const References = "references";
- export const ReferencesFull = "references-full";
- export const Reload = "reload";
- export const Rename = "rename";
- export const RenameInfoFull = "rename-full";
- export const RenameLocationsFull = "renameLocations-full";
- export const Saveto = "saveto";
- export const SignatureHelp = "signatureHelp";
- export const SignatureHelpFull = "signatureHelp-full";
- export const TypeDefinition = "typeDefinition";
- export const ProjectInfo = "projectInfo";
- export const ReloadProjects = "reloadProjects";
- export const Unknown = "unknown";
- export const OpenExternalProject = "openExternalProject";
- export const OpenExternalProjects = "openExternalProjects";
- export const CloseExternalProject = "closeExternalProject";
- export const SynchronizeProjectList = "synchronizeProjectList";
- export const ApplyChangedToOpenFiles = "applyChangedToOpenFiles";
- export const EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full";
- export const Cleanup = "cleanup";
- export const OutliningSpans = "outliningSpans";
- export const TodoComments = "todoComments";
- export const Indentation = "indentation";
- export const DocCommentTemplate = "docCommentTemplate";
- export const CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full";
- export const NameOrDottedNameSpan = "nameOrDottedNameSpan";
- export const BreakpointStatement = "breakpointStatement";
- export const CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects";
- export const GetCodeFixes = "getCodeFixes";
- export const GetCodeFixesFull = "getCodeFixes-full";
- export const GetSupportedCodeFixes = "getSupportedCodeFixes";
+ export const Brace: protocol.CommandTypes.Brace = "brace";
+ export const BraceFull: protocol.CommandTypes.BraceFull = "brace-full";
+ export const BraceCompletion: protocol.CommandTypes.BraceCompletion = "braceCompletion";
+ export const Change: protocol.CommandTypes.Change = "change";
+ export const Close: protocol.CommandTypes.Close = "close";
+ export const Completions: protocol.CommandTypes.Completions = "completions";
+ export const CompletionsFull: protocol.CommandTypes.CompletionsFull = "completions-full";
+ export const CompletionDetails: protocol.CommandTypes.CompletionDetails = "completionEntryDetails";
+ export const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList";
+ export const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile = "compileOnSaveEmitFile";
+ export const Configure: protocol.CommandTypes.Configure = "configure";
+ export const Definition: protocol.CommandTypes.Definition = "definition";
+ export const DefinitionFull: protocol.CommandTypes.DefinitionFull = "definition-full";
+ export const Exit: protocol.CommandTypes.Exit = "exit";
+ export const Format: protocol.CommandTypes.Format = "format";
+ export const Formatonkey: protocol.CommandTypes.Formatonkey = "formatonkey";
+ export const FormatFull: protocol.CommandTypes.FormatFull = "format-full";
+ export const FormatonkeyFull: protocol.CommandTypes.FormatonkeyFull = "formatonkey-full";
+ export const FormatRangeFull: protocol.CommandTypes.FormatRangeFull = "formatRange-full";
+ export const Geterr: protocol.CommandTypes.Geterr = "geterr";
+ export const GeterrForProject: protocol.CommandTypes.GeterrForProject = "geterrForProject";
+ export const Implementation: protocol.CommandTypes.Implementation = "implementation";
+ export const ImplementationFull: protocol.CommandTypes.ImplementationFull = "implementation-full";
+ export const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync = "semanticDiagnosticsSync";
+ export const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync";
+ export const NavBar: protocol.CommandTypes.NavBar = "navbar";
+ export const NavBarFull: protocol.CommandTypes.NavBarFull = "navbar-full";
+ export const NavTree: protocol.CommandTypes.NavTree = "navtree";
+ export const NavTreeFull: protocol.CommandTypes.NavTreeFull = "navtree-full";
+ export const Navto: protocol.CommandTypes.Navto = "navto";
+ export const NavtoFull: protocol.CommandTypes.NavtoFull = "navto-full";
+ export const Occurrences: protocol.CommandTypes.Occurrences = "occurrences";
+ export const DocumentHighlights: protocol.CommandTypes.DocumentHighlights = "documentHighlights";
+ export const DocumentHighlightsFull: protocol.CommandTypes.DocumentHighlightsFull = "documentHighlights-full";
+ export const Open: protocol.CommandTypes.Open = "open";
+ export const Quickinfo: protocol.CommandTypes.Quickinfo = "quickinfo";
+ export const QuickinfoFull: protocol.CommandTypes.QuickinfoFull = "quickinfo-full";
+ export const References: protocol.CommandTypes.References = "references";
+ export const ReferencesFull: protocol.CommandTypes.ReferencesFull = "references-full";
+ export const Reload: protocol.CommandTypes.Reload = "reload";
+ export const Rename: protocol.CommandTypes.Rename = "rename";
+ export const RenameInfoFull: protocol.CommandTypes.RenameInfoFull = "rename-full";
+ export const RenameLocationsFull: protocol.CommandTypes.RenameLocationsFull = "renameLocations-full";
+ export const Saveto: protocol.CommandTypes.Saveto = "saveto";
+ export const SignatureHelp: protocol.CommandTypes.SignatureHelp = "signatureHelp";
+ export const SignatureHelpFull: protocol.CommandTypes.SignatureHelpFull = "signatureHelp-full";
+ export const TypeDefinition: protocol.CommandTypes.TypeDefinition = "typeDefinition";
+ export const ProjectInfo: protocol.CommandTypes.ProjectInfo = "projectInfo";
+ export const ReloadProjects: protocol.CommandTypes.ReloadProjects = "reloadProjects";
+ export const Unknown: protocol.CommandTypes.Unknown = "unknown";
+ export const OpenExternalProject: protocol.CommandTypes.OpenExternalProject = "openExternalProject";
+ export const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects = "openExternalProjects";
+ export const CloseExternalProject: protocol.CommandTypes.CloseExternalProject = "closeExternalProject";
+ export const SynchronizeProjectList: protocol.CommandTypes.SynchronizeProjectList = "synchronizeProjectList";
+ export const ApplyChangedToOpenFiles: protocol.CommandTypes.ApplyChangedToOpenFiles = "applyChangedToOpenFiles";
+ export const EncodedSemanticClassificationsFull: protocol.CommandTypes.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full";
+ export const Cleanup: protocol.CommandTypes.Cleanup = "cleanup";
+ export const OutliningSpans: protocol.CommandTypes.OutliningSpans = "outliningSpans";
+ export const TodoComments: protocol.CommandTypes.TodoComments = "todoComments";
+ export const Indentation: protocol.CommandTypes.Indentation = "indentation";
+ export const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate = "docCommentTemplate";
+ export const CompilerOptionsDiagnosticsFull: protocol.CommandTypes.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full";
+ export const NameOrDottedNameSpan: protocol.CommandTypes.NameOrDottedNameSpan = "nameOrDottedNameSpan";
+ export const BreakpointStatement: protocol.CommandTypes.BreakpointStatement = "breakpointStatement";
+ export const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects";
+ export const GetCodeFixes: protocol.CommandTypes.GetCodeFixes = "getCodeFixes";
+ export const GetCodeFixesFull: protocol.CommandTypes.GetCodeFixesFull = "getCodeFixes-full";
+ export const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes = "getSupportedCodeFixes";
}
export function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string {
@@ -363,7 +363,7 @@ namespace ts.server {
}
}
- private getEncodedSemanticClassifications(args: protocol.SemanticDiagnosticsRequestArgs) {
+ private getEncodedSemanticClassifications(args: protocol.EncodedSemanticClassificationsRequestArgs) {
const { file, project } = this.getFileAndProject(args);
return project.getLanguageService().getEncodedSemanticClassifications(file, args);
}
@@ -1470,7 +1470,7 @@ namespace ts.server {
[CommandNames.BraceCompletion]: (request: protocol.BraceCompletionRequest) => {
return this.requiredResponse(this.isValidBraceCompletion(request.arguments));
},
- [CommandNames.DocCommentTemplate]: (request: protocol.FileLocationRequest) => {
+ [CommandNames.DocCommentTemplate]: (request: protocol.DocCommentTemplateRequest) => {
return this.requiredResponse(this.getDocCommentTemplate(request.arguments));
},
[CommandNames.Format]: (request: protocol.FormatRequest) => {
@@ -1512,7 +1512,7 @@ namespace ts.server {
[CommandNames.CompilerOptionsDiagnosticsFull]: (request: protocol.CompilerOptionsDiagnosticsRequest) => {
return this.requiredResponse(this.getCompilerOptionsDiagnostics(request.arguments));
},
- [CommandNames.EncodedSemanticClassificationsFull]: (request: protocol.SemanticDiagnosticsRequest) => {
+ [CommandNames.EncodedSemanticClassificationsFull]: (request: protocol.EncodedSemanticClassificationsRequest) => {
return this.requiredResponse(this.getEncodedSemanticClassifications(request.arguments));
},
[CommandNames.Cleanup]: (request: protocol.Request) => {
diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json
index 7eb8c28f3834c..9f907446c0349 100644
--- a/src/server/tsconfig.json
+++ b/src/server/tsconfig.json
@@ -22,7 +22,7 @@
"typingsCache.ts",
"project.ts",
"editorServices.ts",
- "protocol.d.ts",
+ "protocol.ts",
"session.ts",
"server.ts"
]
diff --git a/src/services/types.ts b/src/services/types.ts
index 9797c07b086f3..3d2bcf4c36019 100644
--- a/src/services/types.ts
+++ b/src/services/types.ts
@@ -403,11 +403,11 @@ namespace ts {
export interface EditorSettings {
baseIndentSize?: number;
- indentSize: number;
- tabSize: number;
- newLineCharacter: string;
- convertTabsToSpaces: boolean;
- indentStyle: IndentStyle;
+ indentSize?: number;
+ tabSize?: number;
+ newLineCharacter?: string;
+ convertTabsToSpaces?: boolean;
+ indentStyle?: IndentStyle;
}
/* @deprecated - consider using FormatCodeSettings instead */
@@ -428,19 +428,19 @@ namespace ts {
}
export interface FormatCodeSettings extends EditorSettings {
- insertSpaceAfterCommaDelimiter: boolean;
- insertSpaceAfterSemicolonInForStatements: boolean;
- insertSpaceBeforeAndAfterBinaryOperators: boolean;
- insertSpaceAfterKeywordsInControlFlowStatements: boolean;
- insertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean;
- insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
- insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
+ insertSpaceAfterCommaDelimiter?: boolean;
+ insertSpaceAfterSemicolonInForStatements?: boolean;
+ insertSpaceBeforeAndAfterBinaryOperators?: boolean;
+ insertSpaceAfterKeywordsInControlFlowStatements?: boolean;
+ insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean;
+ insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean;
+ insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean;
insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean;
- insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
- insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: boolean;
+ insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean;
+ insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
insertSpaceAfterTypeAssertion?: boolean;
- placeOpenBraceOnNewLineForFunctions: boolean;
- placeOpenBraceOnNewLineForControlBlocks: boolean;
+ placeOpenBraceOnNewLineForFunctions?: boolean;
+ placeOpenBraceOnNewLineForControlBlocks?: boolean;
}
export interface DefinitionInfo {