Skip to content

Commit 23216f9

Browse files
committed
Merge branch 'master' into genericDefaults
2 parents 96181c0 + 87b780d commit 23216f9

File tree

2,203 files changed

+16610
-7373
lines changed

Some content is hidden

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

2,203 files changed

+16610
-7373
lines changed

Jakefile.js

+31-169
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ var path = require("path");
66
var child_process = require("child_process");
77
var fold = require("travis-fold");
88
var runTestsInParallel = require("./scripts/mocha-parallel").runTestsInParallel;
9+
var ts = require("./lib/typescript");
10+
911

1012
// Variables
1113
var compilerDirectory = "src/compiler/";
@@ -34,6 +36,24 @@ if (process.env.path !== undefined) {
3436
process.env.PATH = nodeModulesPathPrefix + process.env.PATH;
3537
}
3638

39+
function filesFromConfig(configPath) {
40+
var configText = fs.readFileSync(configPath).toString();
41+
var config = ts.parseConfigFileTextToJson(configPath, configText, /*stripComments*/ true);
42+
if (config.error) {
43+
throw new Error(diagnosticsToString([config.error]));
44+
}
45+
const configFileContent = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(configPath));
46+
if (configFileContent.errors && configFileContent.errors.length) {
47+
throw new Error(diagnosticsToString(configFileContent.errors));
48+
}
49+
50+
return configFileContent.fileNames;
51+
52+
function diagnosticsToString(s) {
53+
return s.map(function(e) { return ts.flattenDiagnosticMessageText(e.messageText, ts.sys.newLine); }).join(ts.sys.newLine);
54+
}
55+
}
56+
3757
function toNs(diff) {
3858
return diff[0] * 1e9 + diff[1];
3959
}
@@ -56,173 +76,12 @@ function measure(marker) {
5676
console.log("travis_time:end:" + marker.id + ":start=" + toNs(marker.stamp) + ",finish=" + toNs(total) + ",duration=" + toNs(diff) + "\r");
5777
}
5878

59-
var compilerSources = [
60-
"core.ts",
61-
"performance.ts",
62-
"sys.ts",
63-
"types.ts",
64-
"scanner.ts",
65-
"parser.ts",
66-
"utilities.ts",
67-
"binder.ts",
68-
"checker.ts",
69-
"factory.ts",
70-
"visitor.ts",
71-
"transformers/destructuring.ts",
72-
"transformers/ts.ts",
73-
"transformers/jsx.ts",
74-
"transformers/esnext.ts",
75-
"transformers/es2017.ts",
76-
"transformers/es2016.ts",
77-
"transformers/es2015.ts",
78-
"transformers/generators.ts",
79-
"transformers/es5.ts",
80-
"transformers/module/es2015.ts",
81-
"transformers/module/system.ts",
82-
"transformers/module/module.ts",
83-
"transformer.ts",
84-
"sourcemap.ts",
85-
"comments.ts",
86-
"declarationEmitter.ts",
87-
"emitter.ts",
88-
"program.ts",
89-
"commandLineParser.ts",
90-
"tsc.ts",
91-
"diagnosticInformationMap.generated.ts"
92-
].map(function (f) {
93-
return path.join(compilerDirectory, f);
94-
});
95-
96-
var servicesSources = [
97-
"core.ts",
98-
"performance.ts",
99-
"sys.ts",
100-
"types.ts",
101-
"scanner.ts",
102-
"parser.ts",
103-
"utilities.ts",
104-
"binder.ts",
105-
"checker.ts",
106-
"factory.ts",
107-
"visitor.ts",
108-
"transformers/destructuring.ts",
109-
"transformers/ts.ts",
110-
"transformers/jsx.ts",
111-
"transformers/esnext.ts",
112-
"transformers/es2017.ts",
113-
"transformers/es2016.ts",
114-
"transformers/es2015.ts",
115-
"transformers/generators.ts",
116-
"transformers/es5.ts",
117-
"transformers/module/es2015.ts",
118-
"transformers/module/system.ts",
119-
"transformers/module/module.ts",
120-
"transformer.ts",
121-
"sourcemap.ts",
122-
"comments.ts",
123-
"declarationEmitter.ts",
124-
"emitter.ts",
125-
"program.ts",
126-
"commandLineParser.ts",
127-
"diagnosticInformationMap.generated.ts"
128-
].map(function (f) {
129-
return path.join(compilerDirectory, f);
130-
}).concat([
131-
"types.ts",
132-
"utilities.ts",
133-
"breakpoints.ts",
134-
"classifier.ts",
135-
"completions.ts",
136-
"documentHighlights.ts",
137-
"documentRegistry.ts",
138-
"findAllReferences.ts",
139-
"goToDefinition.ts",
140-
"goToImplementation.ts",
141-
"jsDoc.ts",
142-
"jsTyping.ts",
143-
"navigateTo.ts",
144-
"navigationBar.ts",
145-
"outliningElementsCollector.ts",
146-
"patternMatcher.ts",
147-
"preProcess.ts",
148-
"rename.ts",
149-
"services.ts",
150-
"shims.ts",
151-
"signatureHelp.ts",
152-
"symbolDisplay.ts",
153-
"transpile.ts",
154-
// Formatting
155-
"formatting/formatting.ts",
156-
"formatting/formattingContext.ts",
157-
"formatting/formattingRequestKind.ts",
158-
"formatting/formattingScanner.ts",
159-
"formatting/references.ts",
160-
"formatting/rule.ts",
161-
"formatting/ruleAction.ts",
162-
"formatting/ruleDescriptor.ts",
163-
"formatting/ruleFlag.ts",
164-
"formatting/ruleOperation.ts",
165-
"formatting/ruleOperationContext.ts",
166-
"formatting/rules.ts",
167-
"formatting/rulesMap.ts",
168-
"formatting/rulesProvider.ts",
169-
"formatting/smartIndenter.ts",
170-
"formatting/tokenRange.ts",
171-
// CodeFixes
172-
"codeFixProvider.ts",
173-
"codefixes/fixes.ts",
174-
"codefixes/fixExtendsInterfaceBecomesImplements.ts",
175-
"codefixes/fixClassIncorrectlyImplementsInterface.ts",
176-
"codefixes/fixClassDoesntImplementInheritedAbstractMember.ts",
177-
"codefixes/fixClassSuperMustPrecedeThisAccess.ts",
178-
"codefixes/fixConstructorForDerivedNeedSuperCall.ts",
179-
"codefixes/helpers.ts",
180-
"codefixes/importFixes.ts",
181-
"codefixes/unusedIdentifierFixes.ts"
182-
].map(function (f) {
183-
return path.join(servicesDirectory, f);
184-
}));
185-
186-
var baseServerCoreSources = [
187-
"builder.ts",
188-
"editorServices.ts",
189-
"lsHost.ts",
190-
"project.ts",
191-
"protocol.ts",
192-
"scriptInfo.ts",
193-
"scriptVersionCache.ts",
194-
"session.ts",
195-
"shared.ts",
196-
"types.ts",
197-
"typingsCache.ts",
198-
"utilities.ts",
199-
].map(function (f) {
200-
return path.join(serverDirectory, f);
201-
});
202-
203-
var serverCoreSources = [
204-
"server.ts"
205-
].map(function (f) {
206-
return path.join(serverDirectory, f);
207-
}).concat(baseServerCoreSources);
208-
209-
var cancellationTokenSources = [
210-
"cancellationToken.ts"
211-
].map(function (f) {
212-
return path.join(cancellationTokenDirectory, f);
213-
});
214-
215-
var typingsInstallerSources = [
216-
"../types.ts",
217-
"../shared.ts",
218-
"typingsInstaller.ts",
219-
"nodeTypingsInstaller.ts"
220-
].map(function (f) {
221-
return path.join(typingsInstallerDirectory, f);
222-
});
223-
224-
var serverSources = serverCoreSources.concat(servicesSources);
225-
var languageServiceLibrarySources = baseServerCoreSources.concat(servicesSources);
79+
var compilerSources = filesFromConfig("./src/compiler/tsconfig.json");
80+
var servicesSources = filesFromConfig("./src/services/tsconfig.json");
81+
var cancellationTokenSources = filesFromConfig(path.join(serverDirectory, "cancellationToken/tsconfig.json"));
82+
var typingsInstallerSources = filesFromConfig(path.join(serverDirectory, "typingsInstaller/tsconfig.json"));
83+
var serverSources = filesFromConfig(path.join(serverDirectory, "tsconfig.json"))
84+
var languageServiceLibrarySources = filesFromConfig(path.join(serverDirectory, "tsconfig.library.json"));
22685

22786
var harnessCoreSources = [
22887
"harness.ts",
@@ -1230,13 +1089,16 @@ var lintTargets = compilerSources
12301089
.concat(harnessSources)
12311090
// Other harness sources
12321091
.concat(["instrumenter.ts"].map(function (f) { return path.join(harnessDirectory, f) }))
1233-
.concat(serverCoreSources)
1092+
.concat(serverSources)
12341093
.concat(tslintRulesFiles)
12351094
.concat(servicesSources)
12361095
.concat(typingsInstallerSources)
12371096
.concat(cancellationTokenSources)
12381097
.concat(["Gulpfile.ts"])
1239-
.concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath]);
1098+
.concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath])
1099+
.map(function (p) { return path.resolve(p) });
1100+
// keep only unique items
1101+
lintTargets = Array.from(new Set(lintTargets));
12401102

12411103
function sendNextFile(files, child, callback, failures) {
12421104
var file = files.pop();

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "typescript",
33
"author": "Microsoft Corp.",
44
"homepage": "http://typescriptlang.org/",
5-
"version": "2.2.0",
5+
"version": "2.3.0",
66
"license": "Apache-2.0",
77
"description": "TypeScript is a language for application scale JavaScript development",
88
"keywords": [

scripts/buildProtocol.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function generateProtocolFile(protocolTs: string, typeScriptServicesDts: string)
167167
const sanityCheckProgram = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ false);
168168
const diagnostics = [...sanityCheckProgram.getSyntacticDiagnostics(), ...sanityCheckProgram.getSemanticDiagnostics(), ...sanityCheckProgram.getGlobalDiagnostics()];
169169
if (diagnostics.length) {
170-
const flattenedDiagnostics = diagnostics.map(d => ts.flattenDiagnosticMessageText(d.messageText, "\n")).join("\n");
170+
const flattenedDiagnostics = diagnostics.map(d => `${ts.flattenDiagnosticMessageText(d.messageText, "\n")} at ${d.file.fileName} line ${d.start}`).join("\n");
171171
throw new Error(`Unexpected errors during sanity check: ${flattenedDiagnostics}`);
172172
}
173173
return protocolDts;

src/compiler/binder.ts

+34-1
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,35 @@ namespace ts {
10451045
if (node.finallyBlock) {
10461046
// in finally flow is combined from pre-try/flow from try/flow from catch
10471047
// pre-flow is necessary to make sure that finally is reachable even if finally flows in both try and finally blocks are unreachable
1048-
addAntecedent(preFinallyLabel, preTryFlow);
1048+
1049+
// also for finally blocks we inject two extra edges into the flow graph.
1050+
// first -> edge that connects pre-try flow with the label at the beginning of the finally block, it has lock associated with it
1051+
// second -> edge that represents post-finally flow.
1052+
// these edges are used in following scenario:
1053+
// let a; (1)
1054+
// try { a = someOperation(); (2)}
1055+
// finally { (3) console.log(a) } (4)
1056+
// (5) a
1057+
1058+
// flow graph for this case looks roughly like this (arrows show ):
1059+
// (1-pre-try-flow) <--.. <-- (2-post-try-flow)
1060+
// ^ ^
1061+
// |*****(3-pre-finally-label) -----|
1062+
// ^
1063+
// |-- ... <-- (4-post-finally-label) <--- (5)
1064+
// In case when we walk the flow starting from inside the finally block we want to take edge '*****' into account
1065+
// since it ensures that finally is always reachable. However when we start outside the finally block and go through label (5)
1066+
// then edge '*****' should be discarded because label 4 is only reachable if post-finally label-4 is reachable
1067+
// Simply speaking code inside finally block is treated as reachable as pre-try-flow
1068+
// since we conservatively assume that any line in try block can throw or return in which case we'll enter finally.
1069+
// However code after finally is reachable only if control flow was not abrupted in try/catch or finally blocks - it should be composed from
1070+
// final flows of these blocks without taking pre-try flow into account.
1071+
//
1072+
// extra edges that we inject allows to control this behavior
1073+
// if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped.
1074+
const preFinallyFlow: PreFinallyFlow = { flags: FlowFlags.PreFinally, antecedent: preTryFlow, lock: {} };
1075+
addAntecedent(preFinallyLabel, preFinallyFlow);
1076+
10491077
currentFlow = finishFlowLabel(preFinallyLabel);
10501078
bind(node.finallyBlock);
10511079
// if flow after finally is unreachable - keep it
@@ -1061,6 +1089,11 @@ namespace ts {
10611089
: unreachableFlow;
10621090
}
10631091
}
1092+
if (!(currentFlow.flags & FlowFlags.Unreachable)) {
1093+
const afterFinallyFlow: AfterFinallyFlow = { flags: FlowFlags.AfterFinally, antecedent: currentFlow };
1094+
preFinallyFlow.lock = afterFinallyFlow;
1095+
currentFlow = afterFinallyFlow;
1096+
}
10641097
}
10651098
else {
10661099
currentFlow = finishFlowLabel(preFinallyLabel);

0 commit comments

Comments
 (0)