Skip to content

Commit c109d31

Browse files
committed
Second pass converting for index based looping to for-of loops
More manual conversion of index based for loops to for-of loops
1 parent 137dbe9 commit c109d31

59 files changed

Lines changed: 174 additions & 200 deletions

File tree

Some content is hidden

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

extensions/css-language-features/server/src/pathCompletion.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ function escapePath(p: string) {
195195
}
196196

197197
function resolveWorkspaceRoot(activeDoc: TextDocument, workspaceFolders: WorkspaceFolder[]): string | undefined {
198-
for (let i = 0; i < workspaceFolders.length; i++) {
199-
if (startsWith(activeDoc.uri, workspaceFolders[i].uri)) {
200-
return path.resolve(URI.parse(workspaceFolders[i].uri).fsPath);
198+
for (const folder of workspaceFolders) {
199+
if (startsWith(activeDoc.uri, folder.uri)) {
200+
return path.resolve(URI.parse(folder.uri).fsPath);
201201
}
202202
}
203203
return undefined;

extensions/html-language-features/server/src/utils/arrays.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
export function pushAll<T>(to: T[], from: T[]) {
77
if (from) {
8-
for (let i = 0; i < from.length; i++) {
9-
to.push(from[i]);
8+
for (const e of from) {
9+
to.push(e);
1010
}
1111
}
1212
}

extensions/merge-conflict/src/commandHandler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,11 @@ export default class CommandHandler implements vscode.Disposable {
282282
throw new Error(`Unsupported direction ${direction}`);
283283
}
284284

285-
for (let i = 0; i < conflicts.length; i++) {
286-
if (predicate(conflicts[i]) && !conflicts[i].range.contains(selection)) {
285+
for (const conflict of conflicts) {
286+
if (predicate(conflict) && !conflict.range.contains(selection)) {
287287
return {
288288
canNavigate: true,
289-
conflict: conflicts[i]
289+
conflict: conflict
290290
};
291291
}
292292
}

extensions/merge-conflict/src/mergeDecorator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ export default class MergeDecorator implements vscode.Disposable {
153153
}
154154

155155
private applyDecorationsFromEvent(eventDocument: vscode.TextDocument) {
156-
for (let i = 0; i < vscode.window.visibleTextEditors.length; i++) {
157-
if (vscode.window.visibleTextEditors[i].document === eventDocument) {
156+
for (const editor of vscode.window.visibleTextEditors) {
157+
if (editor.document === eventDocument) {
158158
// Attempt to apply
159-
this.applyDecorations(vscode.window.visibleTextEditors[i]);
159+
this.applyDecorations(editor);
160160
}
161161
}
162162
}

extensions/npm/src/features/bowerJSONContribution.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ export class BowerJSONContribution implements IJSONContribution {
6868
const obj = JSON.parse(success.responseText);
6969
if (Array.isArray(obj)) {
7070
const results = <{ name: string; description: string; }[]>obj;
71-
for (let i = 0; i < results.length; i++) {
72-
const name = results[i].name;
73-
const description = results[i].description || '';
71+
for (const result of results) {
72+
const name = result.name;
73+
const description = result.description || '';
7474
const insertText = new SnippetString().appendText(JSON.stringify(name));
7575
if (addValue) {
7676
insertText.appendText(': ').appendPlaceholder('latest');

extensions/npm/src/features/packageJSONContribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ export class PackageJSONContribution implements IJSONContribution {
8787
const obj = JSON.parse(success.responseText);
8888
if (obj && Array.isArray(obj.rows)) {
8989
const results = <{ key: string[]; }[]>obj.rows;
90-
for (let i = 0; i < results.length; i++) {
91-
const keys = results[i].key;
90+
for (const result of results) {
91+
const keys = result.key;
9292
if (Array.isArray(keys) && keys.length > 0) {
9393
const name = keys[0];
9494
const insertText = new SnippetString().appendText(JSON.stringify(name));

src/vs/base/common/glob.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,8 @@ export function splitGlobAware(pattern: string, splitChar: string): string[] {
5858
let inBraces = false;
5959
let inBrackets = false;
6060

61-
let char: string;
6261
let curVal = '';
63-
for (let i = 0; i < pattern.length; i++) {
64-
char = pattern[i];
65-
62+
for (const char of pattern) {
6663
switch (char) {
6764
case splitChar:
6865
if (!inBraces && !inBrackets) {
@@ -136,10 +133,7 @@ function parseRegExp(pattern: string): string {
136133
let inBrackets = false;
137134
let bracketVal = '';
138135

139-
let char: string;
140-
for (let i = 0; i < segment.length; i++) {
141-
char = segment[i];
142-
136+
for (const char of segment) {
143137
// Support brace expansion
144138
if (char !== '}' && inBraces) {
145139
braceVal += char;

src/vs/base/common/labels.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,8 @@ export function template(template: string, values: { [key: string]: string | ISe
286286
const segments: ISegment[] = [];
287287

288288
let inVariable = false;
289-
let char: string;
290289
let curVal = '';
291-
for (let i = 0; i < template.length; i++) {
292-
char = template[i];
293-
290+
for (const char of template) {
294291
// Beginning of variable
295292
if (char === '$' || (inVariable && char === '{')) {
296293
if (curVal) {

src/vs/base/common/mime.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ function guessMimeTypeByFirstline(firstLine: string): string | null {
197197
}
198198

199199
if (firstLine.length > 0) {
200-
for (let i = 0; i < registeredAssociations.length; ++i) {
201-
const association = registeredAssociations[i];
200+
for (const association of registeredAssociations) {
202201
if (!association.firstline) {
203202
continue;
204203
}

src/vs/base/common/objects.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ function _cloneAndChange(obj: any, changer: (orig: any) => any, seen: Set<any>):
6262

6363
if (isArray(obj)) {
6464
const r1: any[] = [];
65-
for (let i1 = 0; i1 < obj.length; i1++) {
66-
r1.push(_cloneAndChange(obj[i1], changer, seen));
65+
for (const e of obj) {
66+
r1.push(_cloneAndChange(e, changer, seen));
6767
}
6868
return r1;
6969
}
@@ -177,8 +177,8 @@ export function equals(one: any, other: any): boolean {
177177

178178
function arrayToHash(array: string[]): { [name: string]: true } {
179179
const result: any = {};
180-
for (let i = 0; i < array.length; ++i) {
181-
result[array[i]] = true;
180+
for (const e of array) {
181+
result[e] = true;
182182
}
183183
return result;
184184
}

0 commit comments

Comments
 (0)