Skip to content

Commit e62108c

Browse files
committed
Removing throttling until tests prove it is required
1 parent 497d8d3 commit e62108c

File tree

8 files changed

+142
-187
lines changed

8 files changed

+142
-187
lines changed

src/compiler/program.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,6 @@ namespace ts {
7272
return getNormalizedPathFromPathComponents(commonPathComponents);
7373
}
7474

75-
/* @internal */
76-
export function runWithCancellationToken<T>(func: () => T, onCancel?: () => void): T {
77-
try {
78-
return func();
79-
}
80-
catch (e) {
81-
if (e instanceof OperationCanceledException && onCancel) {
82-
// We were canceled while performing the operation.
83-
onCancel();
84-
}
85-
throw e;
86-
}
87-
}
88-
8975
interface OutputFingerprint {
9076
hash: string;
9177
byteOrderMark: boolean;

src/compiler/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,8 +2262,6 @@
22622262

22632263
/** @throws OperationCanceledException if isCancellationRequested is true */
22642264
throwIfCancellationRequested(): void;
2265-
2266-
throttleWaitMilliseconds?: number;
22672265
}
22682266

22692267
export interface Program extends ScriptReferenceHost {

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,6 @@ namespace ts.projectSystem {
555555
constructor(private cancelAfterRequest = 0) {
556556
}
557557

558-
get throttleWaitMilliseconds() {
559-
// For testing purposes disable the throttle
560-
return 0;
561-
}
562-
563558
setRequest(requestId: number) {
564559
this.currentId = requestId;
565560
}
@@ -3495,8 +3490,6 @@ namespace ts.projectSystem {
34953490
compilerOptions: {}
34963491
})
34973492
};
3498-
3499-
let operationCanceledExceptionThrown = false;
35003493
const cancellationToken = new TestServerCancellationToken(/*cancelAfterRequest*/ 3);
35013494
const host = createServerHost([f1, config]);
35023495
const session = createSession(host, /*typingsInstaller*/ undefined, () => { }, cancellationToken);
@@ -3536,7 +3529,7 @@ namespace ts.projectSystem {
35363529
// The cancellation token will cancel the request the third time
35373530
// isCancellationRequested() is called.
35383531
cancellationToken.setRequestToCancel(session.getNextSeq());
3539-
operationCanceledExceptionThrown = false;
3532+
let operationCanceledExceptionThrown = false;
35403533

35413534
try {
35423535
session.executeCommandSeq(request);

src/services/navigationBar.ts

Lines changed: 114 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,27 @@ namespace ts.NavigationBar {
1414
indent: number; // # of parents
1515
}
1616

17-
export function getNavigationBarItems(sourceFile: SourceFile, cancellationToken: ThrottledCancellationToken): NavigationBarItem[] {
17+
export function getNavigationBarItems(sourceFile: SourceFile, cancellationToken: CancellationToken): NavigationBarItem[] {
1818
curCancellationToken = cancellationToken;
1919
curSourceFile = sourceFile;
2020
try {
2121
return map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem);
2222
}
2323
finally {
2424
curSourceFile = undefined;
25+
curCancellationToken = undefined;
2526
}
2627
}
2728

28-
export function getNavigationTree(sourceFile: SourceFile, cancellationToken: ThrottledCancellationToken): NavigationTree {
29+
export function getNavigationTree(sourceFile: SourceFile, cancellationToken: CancellationToken): NavigationTree {
2930
curCancellationToken = cancellationToken;
3031
curSourceFile = sourceFile;
3132
try {
3233
return convertToTree(rootNavigationBarNode(sourceFile));
3334
}
3435
finally {
3536
curSourceFile = undefined;
37+
curCancellationToken = undefined;
3638
}
3739
}
3840

@@ -112,144 +114,140 @@ namespace ts.NavigationBar {
112114
parent = parentsStack.pop();
113115
}
114116

115-
function addNodeWithRecursiveChild(node: Node, child: Node, addChildrenRecursively: (node: Node) => void): void {
117+
function addNodeWithRecursiveChild(node: Node, child: Node): void {
116118
startNode(node);
117119
addChildrenRecursively(child);
118120
endNode();
119121
}
120122

121123
/** Look for navigation bar items in node's subtree, adding them to the current `parent`. */
122124
function addChildrenRecursively(node: Node): void {
123-
function addChildrenRecursively(node: Node): void {
124-
curCancellationToken.throwIfCancellationRequested();
125+
curCancellationToken.throwIfCancellationRequested();
125126

126-
if (!node || isToken(node)) {
127-
return;
128-
}
127+
if (!node || isToken(node)) {
128+
return;
129+
}
129130

130-
switch (node.kind) {
131-
case SyntaxKind.Constructor:
132-
// Get parameter properties, and treat them as being on the *same* level as the constructor, not under it.
133-
const ctr = <ConstructorDeclaration>node;
134-
addNodeWithRecursiveChild(ctr, ctr.body, addChildrenRecursively);
135-
136-
// Parameter properties are children of the class, not the constructor.
137-
for (const param of ctr.parameters) {
138-
if (isParameterPropertyDeclaration(param)) {
139-
addLeafNode(param);
140-
}
131+
switch (node.kind) {
132+
case SyntaxKind.Constructor:
133+
// Get parameter properties, and treat them as being on the *same* level as the constructor, not under it.
134+
const ctr = <ConstructorDeclaration>node;
135+
addNodeWithRecursiveChild(ctr, ctr.body);
136+
137+
// Parameter properties are children of the class, not the constructor.
138+
for (const param of ctr.parameters) {
139+
if (isParameterPropertyDeclaration(param)) {
140+
addLeafNode(param);
141141
}
142-
break;
142+
}
143+
break;
144+
145+
case SyntaxKind.MethodDeclaration:
146+
case SyntaxKind.GetAccessor:
147+
case SyntaxKind.SetAccessor:
148+
case SyntaxKind.MethodSignature:
149+
if (!hasDynamicName((<ClassElement | TypeElement>node))) {
150+
addNodeWithRecursiveChild(node, (<FunctionLikeDeclaration>node).body);
151+
}
152+
break;
143153

144-
case SyntaxKind.MethodDeclaration:
145-
case SyntaxKind.GetAccessor:
146-
case SyntaxKind.SetAccessor:
147-
case SyntaxKind.MethodSignature:
148-
if (!hasDynamicName((<ClassElement | TypeElement>node))) {
149-
addNodeWithRecursiveChild(node, (<FunctionLikeDeclaration>node).body, addChildrenRecursively);
150-
}
151-
break;
154+
case SyntaxKind.PropertyDeclaration:
155+
case SyntaxKind.PropertySignature:
156+
if (!hasDynamicName((<ClassElement | TypeElement>node))) {
157+
addLeafNode(node);
158+
}
159+
break;
160+
161+
case SyntaxKind.ImportClause:
162+
const importClause = <ImportClause>node;
163+
// Handle default import case e.g.:
164+
// import d from "mod";
165+
if (importClause.name) {
166+
addLeafNode(importClause);
167+
}
152168

153-
case SyntaxKind.PropertyDeclaration:
154-
case SyntaxKind.PropertySignature:
155-
if (!hasDynamicName((<ClassElement | TypeElement>node))) {
156-
addLeafNode(node);
169+
// Handle named bindings in imports e.g.:
170+
// import * as NS from "mod";
171+
// import {a, b as B} from "mod";
172+
const {namedBindings} = importClause;
173+
if (namedBindings) {
174+
if (namedBindings.kind === SyntaxKind.NamespaceImport) {
175+
addLeafNode(<NamespaceImport>namedBindings);
157176
}
158-
break;
159-
160-
case SyntaxKind.ImportClause:
161-
const importClause = <ImportClause>node;
162-
// Handle default import case e.g.:
163-
// import d from "mod";
164-
if (importClause.name) {
165-
addLeafNode(importClause);
166-
}
167-
168-
// Handle named bindings in imports e.g.:
169-
// import * as NS from "mod";
170-
// import {a, b as B} from "mod";
171-
const {namedBindings} = importClause;
172-
if (namedBindings) {
173-
if (namedBindings.kind === SyntaxKind.NamespaceImport) {
174-
addLeafNode(<NamespaceImport>namedBindings);
175-
}
176-
else {
177-
for (const element of (<NamedImports>namedBindings).elements) {
178-
addLeafNode(element);
179-
}
177+
else {
178+
for (const element of (<NamedImports>namedBindings).elements) {
179+
addLeafNode(element);
180180
}
181181
}
182-
break;
182+
}
183+
break;
184+
185+
case SyntaxKind.BindingElement:
186+
case SyntaxKind.VariableDeclaration:
187+
const decl = <VariableDeclaration>node;
188+
const name = decl.name;
189+
if (isBindingPattern(name)) {
190+
addChildrenRecursively(name);
191+
}
192+
else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) {
193+
// For `const x = function() {}`, just use the function node, not the const.
194+
addChildrenRecursively(decl.initializer);
195+
}
196+
else {
197+
addNodeWithRecursiveChild(decl, decl.initializer);
198+
}
199+
break;
183200

184-
case SyntaxKind.BindingElement:
185-
case SyntaxKind.VariableDeclaration:
186-
const decl = <VariableDeclaration>node;
187-
const name = decl.name;
188-
if (isBindingPattern(name)) {
189-
addChildrenRecursively(name);
190-
}
191-
else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) {
192-
// For `const x = function() {}`, just use the function node, not the const.
193-
addChildrenRecursively(decl.initializer);
194-
}
195-
else {
196-
addNodeWithRecursiveChild(decl, decl.initializer, addChildrenRecursively);
201+
case SyntaxKind.ArrowFunction:
202+
case SyntaxKind.FunctionDeclaration:
203+
case SyntaxKind.FunctionExpression:
204+
addNodeWithRecursiveChild(node, (<FunctionLikeDeclaration>node).body);
205+
break;
206+
207+
case SyntaxKind.EnumDeclaration:
208+
startNode(node);
209+
for (const member of (<EnumDeclaration>node).members) {
210+
if (!isComputedProperty(member)) {
211+
addLeafNode(member);
197212
}
198-
break;
199-
200-
case SyntaxKind.ArrowFunction:
201-
case SyntaxKind.FunctionDeclaration:
202-
case SyntaxKind.FunctionExpression:
203-
addNodeWithRecursiveChild(node, (<FunctionLikeDeclaration>node).body, addChildrenRecursively);
204-
break;
213+
}
214+
endNode();
215+
break;
205216

206-
case SyntaxKind.EnumDeclaration:
207-
startNode(node);
208-
for (const member of (<EnumDeclaration>node).members) {
209-
if (!isComputedProperty(member)) {
210-
addLeafNode(member);
211-
}
212-
}
213-
endNode();
214-
break;
217+
case SyntaxKind.ClassDeclaration:
218+
case SyntaxKind.ClassExpression:
219+
case SyntaxKind.InterfaceDeclaration:
220+
startNode(node);
221+
for (const member of (<InterfaceDeclaration>node).members) {
222+
addChildrenRecursively(member);
223+
}
224+
endNode();
225+
break;
215226

216-
case SyntaxKind.ClassDeclaration:
217-
case SyntaxKind.ClassExpression:
218-
case SyntaxKind.InterfaceDeclaration:
219-
startNode(node);
220-
for (const member of (<InterfaceDeclaration>node).members) {
221-
addChildrenRecursively(member);
222-
}
223-
endNode();
224-
break;
227+
case SyntaxKind.ModuleDeclaration:
228+
addNodeWithRecursiveChild(node, getInteriorModule(<ModuleDeclaration>node).body);
229+
break;
225230

226-
case SyntaxKind.ModuleDeclaration:
227-
addNodeWithRecursiveChild(node, getInteriorModule(<ModuleDeclaration>node).body, addChildrenRecursively);
228-
break;
229-
230-
case SyntaxKind.ExportSpecifier:
231-
case SyntaxKind.ImportEqualsDeclaration:
232-
case SyntaxKind.IndexSignature:
233-
case SyntaxKind.CallSignature:
234-
case SyntaxKind.ConstructSignature:
235-
case SyntaxKind.TypeAliasDeclaration:
236-
addLeafNode(node);
237-
break;
231+
case SyntaxKind.ExportSpecifier:
232+
case SyntaxKind.ImportEqualsDeclaration:
233+
case SyntaxKind.IndexSignature:
234+
case SyntaxKind.CallSignature:
235+
case SyntaxKind.ConstructSignature:
236+
case SyntaxKind.TypeAliasDeclaration:
237+
addLeafNode(node);
238+
break;
238239

239-
default:
240-
forEach(node.jsDoc, jsDoc => {
241-
forEach(jsDoc.tags, tag => {
242-
if (tag.kind === SyntaxKind.JSDocTypedefTag) {
243-
addLeafNode(tag);
244-
}
245-
});
240+
default:
241+
forEach(node.jsDoc, jsDoc => {
242+
forEach(jsDoc.tags, tag => {
243+
if (tag.kind === SyntaxKind.JSDocTypedefTag) {
244+
addLeafNode(tag);
245+
}
246246
});
247+
});
247248

248-
forEachChild(node, addChildrenRecursively);
249-
}
249+
forEachChild(node, addChildrenRecursively);
250250
}
251-
252-
addChildrenRecursively(node);
253251
}
254252

255253
/** Merge declarations of the same kind. */

src/services/outliningElementsCollector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @internal */
22
namespace ts.OutliningElementsCollector {
3-
export function collectElements(sourceFile: SourceFile, cancellationToken: ThrottledCancellationToken): OutliningSpan[] {
3+
export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] {
44
const elements: OutliningSpan[] = [];
55
const collapseText = "...";
66

0 commit comments

Comments
 (0)