Skip to content

Commit 99cbd1f

Browse files
committed
Merge branch 'master' into cleanup-TypeFlags
2 parents 84e319e + 4800464 commit 99cbd1f

File tree

943 files changed

+22277
-8366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

943 files changed

+22277
-8366
lines changed

Gulpfile.ts

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ declare module "gulp-typescript" {
1717
stripInternal?: boolean;
1818
types?: string[];
1919
}
20-
interface CompileStream extends NodeJS.ReadWriteStream { } // Either gulp or gulp-typescript has some odd typings which don't reflect reality, making this required
2120
}
2221
import * as insert from "gulp-insert";
2322
import * as sourcemaps from "gulp-sourcemaps";
@@ -169,7 +168,7 @@ for (const i in libraryTargets) {
169168
gulp.task(target, false, [], function() {
170169
return gulp.src(sources)
171170
.pipe(newer(target))
172-
.pipe(concat(target, { newLine: "" }))
171+
.pipe(concat(target, { newLine: "\n\n" }))
173172
.pipe(gulp.dest("."));
174173
});
175174
}
@@ -380,18 +379,18 @@ gulp.task(builtLocalCompiler, false, [servicesFile], () => {
380379
return localCompilerProject.src()
381380
.pipe(newer(builtLocalCompiler))
382381
.pipe(sourcemaps.init())
383-
.pipe(tsc(localCompilerProject))
382+
.pipe(localCompilerProject())
384383
.pipe(prependCopyright())
385384
.pipe(sourcemaps.write("."))
386-
.pipe(gulp.dest(builtLocalDirectory));
385+
.pipe(gulp.dest("."));
387386
});
388387

389388
gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => {
390389
const servicesProject = tsc.createProject("src/services/tsconfig.json", getCompilerSettings({ removeComments: false }, /*useBuiltCompiler*/false));
391390
const {js, dts} = servicesProject.src()
392391
.pipe(newer(servicesFile))
393392
.pipe(sourcemaps.init())
394-
.pipe(tsc(servicesProject));
393+
.pipe(servicesProject());
395394
const completedJs = js.pipe(prependCopyright())
396395
.pipe(sourcemaps.write("."));
397396
const completedDts = dts.pipe(prependCopyright(/*outputCopyright*/true))
@@ -409,26 +408,52 @@ gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => {
409408
file.path = nodeDefinitionsFile;
410409
return content + "\r\nexport = ts;";
411410
}))
412-
.pipe(gulp.dest(builtLocalDirectory)),
411+
.pipe(gulp.dest(".")),
413412
completedDts.pipe(clone())
414413
.pipe(insert.transform((content, file) => {
415414
file.path = nodeStandaloneDefinitionsFile;
416415
return content.replace(/declare (namespace|module) ts/g, 'declare module "typescript"');
417416
}))
418-
]).pipe(gulp.dest(builtLocalDirectory));
417+
]).pipe(gulp.dest("."));
418+
});
419+
420+
// cancellationToken.js
421+
const cancellationTokenJs = path.join(builtLocalDirectory, "cancellationToken.js");
422+
gulp.task(cancellationTokenJs, false, [servicesFile], () => {
423+
const cancellationTokenProject = tsc.createProject("src/server/cancellationToken/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/true));
424+
return cancellationTokenProject.src()
425+
.pipe(newer(cancellationTokenJs))
426+
.pipe(sourcemaps.init())
427+
.pipe(cancellationTokenProject())
428+
.pipe(prependCopyright())
429+
.pipe(sourcemaps.write("."))
430+
.pipe(gulp.dest(builtLocalDirectory));
431+
});
432+
433+
// typingsInstallerFile.js
434+
const typingsInstallerJs = path.join(builtLocalDirectory, "typingsInstaller.js");
435+
gulp.task(typingsInstallerJs, false, [servicesFile], () => {
436+
const cancellationTokenProject = tsc.createProject("src/server/typingsInstaller/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/true));
437+
return cancellationTokenProject.src()
438+
.pipe(newer(typingsInstallerJs))
439+
.pipe(sourcemaps.init())
440+
.pipe(cancellationTokenProject())
441+
.pipe(prependCopyright())
442+
.pipe(sourcemaps.write("."))
443+
.pipe(gulp.dest("."));
419444
});
420445

421446
const serverFile = path.join(builtLocalDirectory, "tsserver.js");
422447

423-
gulp.task(serverFile, false, [servicesFile], () => {
448+
gulp.task(serverFile, false, [servicesFile, typingsInstallerJs, cancellationTokenJs], () => {
424449
const serverProject = tsc.createProject("src/server/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/true));
425450
return serverProject.src()
426451
.pipe(newer(serverFile))
427452
.pipe(sourcemaps.init())
428-
.pipe(tsc(serverProject))
453+
.pipe(serverProject())
429454
.pipe(prependCopyright())
430455
.pipe(sourcemaps.write("."))
431-
.pipe(gulp.dest(builtLocalDirectory));
456+
.pipe(gulp.dest("."));
432457
});
433458

434459
const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
@@ -439,22 +464,21 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
439464
const {js, dts}: { js: NodeJS.ReadableStream, dts: NodeJS.ReadableStream } = serverLibraryProject.src()
440465
.pipe(sourcemaps.init())
441466
.pipe(newer(tsserverLibraryFile))
442-
.pipe(tsc(serverLibraryProject));
467+
.pipe(serverLibraryProject());
443468

444469
return merge2([
445470
js.pipe(prependCopyright())
446471
.pipe(sourcemaps.write("."))
447-
.pipe(gulp.dest(builtLocalDirectory)),
472+
.pipe(gulp.dest(".")),
448473
dts.pipe(prependCopyright())
449-
.pipe(gulp.dest(builtLocalDirectory))
474+
.pipe(gulp.dest("."))
450475
]);
451476
});
452477

453478
gulp.task("lssl", "Builds language service server library", [tsserverLibraryFile]);
454479
gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON, tsserverLibraryFile]);
455480
gulp.task("tsc", "Builds only the compiler", [builtLocalCompiler]);
456481

457-
458482
// Generate Markdown spec
459483
const word2mdJs = path.join(scriptsDirectory, "word2md.js");
460484
const word2mdTs = path.join(scriptsDirectory, "word2md.ts");
@@ -493,7 +517,7 @@ gulp.task("useDebugMode", false, [], (done) => { useDebugMode = true; done(); })
493517
gulp.task("dontUseDebugMode", false, [], (done) => { useDebugMode = false; done(); });
494518

495519
gulp.task("VerifyLKG", false, [], () => {
496-
const expectedFiles = [builtLocalCompiler, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile].concat(libraryTargets);
520+
const expectedFiles = [builtLocalCompiler, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile, typingsInstallerJs, cancellationTokenJs].concat(libraryTargets);
497521
const missingFiles = expectedFiles.filter(function(f) {
498522
return !fs.existsSync(f);
499523
});
@@ -519,9 +543,9 @@ gulp.task(run, false, [servicesFile], () => {
519543
return testProject.src()
520544
.pipe(newer(run))
521545
.pipe(sourcemaps.init())
522-
.pipe(tsc(testProject))
546+
.pipe(testProject())
523547
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "../../" }))
524-
.pipe(gulp.dest(builtLocalDirectory));
548+
.pipe(gulp.dest("."));
525549
});
526550

527551
const internalTests = "internal/";
@@ -705,7 +729,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo
705729
return testProject.src()
706730
.pipe(newer("built/local/bundle.js"))
707731
.pipe(sourcemaps.init())
708-
.pipe(tsc(testProject))
732+
.pipe(testProject)
709733
.pipe(through2.obj((file, enc, next) => {
710734
const originalMap = file.sourceMap;
711735
const prebundledContent = file.contents.toString();

Jakefile.js

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ var runTestsInParallel = require("./scripts/mocha-parallel").runTestsInParallel;
1111
var compilerDirectory = "src/compiler/";
1212
var servicesDirectory = "src/services/";
1313
var serverDirectory = "src/server/";
14+
var typingsInstallerDirectory = "src/server/typingsInstaller";
15+
var cancellationTokenDirectory = "src/server/cancellationToken";
1416
var harnessDirectory = "src/harness/";
1517
var libraryDirectory = "src/lib/";
1618
var scriptsDirectory = "scripts/";
@@ -164,6 +166,13 @@ var servicesSources = [
164166
}));
165167

166168
var serverCoreSources = [
169+
"types.d.ts",
170+
"utilities.ts",
171+
"scriptVersionCache.ts",
172+
"typingsCache.ts",
173+
"scriptInfo.ts",
174+
"lsHost.ts",
175+
"project.ts",
167176
"editorServices.ts",
168177
"protocol.d.ts",
169178
"session.ts",
@@ -172,12 +181,33 @@ var serverCoreSources = [
172181
return path.join(serverDirectory, f);
173182
});
174183

184+
var cancellationTokenSources = [
185+
"cancellationToken.ts"
186+
].map(function (f) {
187+
return path.join(cancellationTokenDirectory, f);
188+
});
189+
190+
var typingsInstallerSources = [
191+
"../types.d.ts",
192+
"typingsInstaller.ts",
193+
"nodeTypingsInstaller.ts"
194+
].map(function (f) {
195+
return path.join(typingsInstallerDirectory, f);
196+
});
197+
175198
var serverSources = serverCoreSources.concat(servicesSources);
176199

177200
var languageServiceLibrarySources = [
201+
"protocol.d.ts",
202+
"utilities.ts",
203+
"scriptVersionCache.ts",
204+
"scriptInfo.ts",
205+
"lsHost.ts",
206+
"project.ts",
178207
"editorServices.ts",
179208
"protocol.d.ts",
180-
"session.ts"
209+
"session.ts",
210+
181211
].map(function (f) {
182212
return path.join(serverDirectory, f);
183213
}).concat(servicesSources);
@@ -221,15 +251,24 @@ var harnessSources = harnessCoreSources.concat([
221251
"convertCompilerOptionsFromJson.ts",
222252
"convertTypingOptionsFromJson.ts",
223253
"tsserverProjectSystem.ts",
254+
"compileOnSave.ts",
255+
"typingsInstaller.ts",
256+
"projectErrors.ts",
224257
"matchFiles.ts",
225258
"initializeTSConfig.ts",
226259
].map(function (f) {
227260
return path.join(unittestsDirectory, f);
228261
})).concat([
262+
"protocol.d.ts",
263+
"utilities.ts",
264+
"scriptVersionCache.ts",
265+
"scriptInfo.ts",
266+
"lsHost.ts",
267+
"project.ts",
268+
"typingsCache.ts",
269+
"editorServices.ts",
229270
"protocol.d.ts",
230271
"session.ts",
231-
"client.ts",
232-
"editorServices.ts"
233272
].map(function (f) {
234273
return path.join(serverDirectory, f);
235274
}));
@@ -616,8 +655,14 @@ compileFile(
616655
inlineSourceMap: true
617656
});
618657

658+
var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js");
659+
compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: true });
660+
661+
var typingsInstallerFile = path.join(builtLocalDirectory, "typingsInstaller.js");
662+
compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false });
663+
619664
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
620-
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/[copyright], /*useBuiltCompiler*/ true, { types: ["node"] });
665+
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"] });
621666
var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
622667
var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
623668
compileFile(
@@ -700,7 +745,7 @@ task("generate-spec", [specMd]);
700745
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
701746
desc("Makes a new LKG out of the built js files");
702747
task("LKG", ["clean", "release", "local"].concat(libraryTargets), function () {
703-
var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile].concat(libraryTargets);
748+
var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile, cancellationTokenFile, typingsInstallerFile].concat(libraryTargets);
704749
var missingFiles = expectedFiles.filter(function (f) {
705750
return !fs.existsSync(f);
706751
});
@@ -948,7 +993,7 @@ desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is
948993
task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function () {
949994
cleanTestDirs();
950995
host = "node";
951-
browser = process.env.browser || process.env.b || "IE";
996+
browser = process.env.browser || process.env.b || (os.platform() === "linux" ? "chrome" : "IE");
952997
tests = process.env.test || process.env.tests || process.env.t;
953998
var light = process.env.light || false;
954999
var testConfigFile = 'test.config';
@@ -1130,6 +1175,8 @@ var lintTargets = compilerSources
11301175
.concat(serverCoreSources)
11311176
.concat(tslintRulesFiles)
11321177
.concat(servicesSources)
1178+
.concat(typingsInstallerSources)
1179+
.concat(cancellationTokenSources)
11331180
.concat(["Gulpfile.ts"])
11341181
.concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath]);
11351182

lib/cancellationToken.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*! *****************************************************************************
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4+
this file except in compliance with the License. You may obtain a copy of the
5+
License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10+
MERCHANTABLITY OR NON-INFRINGEMENT.
11+
12+
See the Apache Version 2.0 License for specific language governing permissions
13+
and limitations under the License.
14+
***************************************************************************** */
15+
16+
"use strict";
17+
var fs = require("fs");
18+
function createCancellationToken(args) {
19+
var cancellationPipeName;
20+
for (var i = 0; i < args.length - 1; i++) {
21+
if (args[i] === "--cancellationPipeName") {
22+
cancellationPipeName = args[i + 1];
23+
break;
24+
}
25+
}
26+
if (!cancellationPipeName) {
27+
return { isCancellationRequested: function () { return false; } };
28+
}
29+
return {
30+
isCancellationRequested: function () {
31+
try {
32+
fs.statSync(cancellationPipeName);
33+
return true;
34+
}
35+
catch (e) {
36+
return false;
37+
}
38+
}
39+
};
40+
}
41+
module.exports = createCancellationToken;

0 commit comments

Comments
 (0)