Skip to content

Commit 8fad1ee

Browse files
committed
use new getAllPropertyNames-util instead of for-in-loop
1 parent 340f01e commit 8fad1ee

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

src/vs/base/common/types.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,17 @@ function isNativeClass(thing): boolean {
176176
&& thing.hasOwnProperty('prototype')
177177
&& !thing.hasOwnProperty('arguments');
178178
}
179+
180+
/**
181+
*
182+
*
183+
*/
184+
export function getAllPropertyNames(obj: object): string[] {
185+
let res: string[] = [];
186+
let proto = Object.getPrototypeOf(obj);
187+
while (Object.prototype !== proto) {
188+
res = res.concat(Object.getOwnPropertyNames(proto));
189+
proto = Object.getPrototypeOf(proto);
190+
}
191+
return res;
192+
}

src/vs/base/common/worker/simpleWorker.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { transformErrorForSerialization } from 'vs/base/common/errors';
77
import { Disposable } from 'vs/base/common/lifecycle';
88
import { isWeb } from 'vs/base/common/platform';
9+
import { getAllPropertyNames } from 'vs/base/common/types';
910

1011
const INITIALIZE = '$initialize';
1112

@@ -324,7 +325,7 @@ export class SimpleWorkerServer {
324325
if (this._requestHandler) {
325326
// static request handler
326327
let methods: string[] = [];
327-
for (let prop in this._requestHandler) {
328+
for (const prop of getAllPropertyNames(this._requestHandler)) {
328329
if (typeof this._requestHandler[prop] === 'function') {
329330
methods.push(prop);
330331
}
@@ -360,7 +361,7 @@ export class SimpleWorkerServer {
360361
}
361362

362363
let methods: string[] = [];
363-
for (let prop in this._requestHandler) {
364+
for (const prop of getAllPropertyNames(this._requestHandler)) {
364365
if (typeof this._requestHandler[prop] === 'function') {
365366
methods.push(prop);
366367
}

src/vs/editor/common/services/editorSimpleWorker.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { ILinkComputerTarget, computeLinks } from 'vs/editor/common/modes/linkCo
2222
import { BasicInplaceReplace } from 'vs/editor/common/modes/supports/inplaceReplaceSupport';
2323
import { IDiffComputationResult } from 'vs/editor/common/services/editorWorkerService';
2424
import { createMonacoBaseAPI } from 'vs/editor/common/standalone/standaloneBase';
25+
import { getAllPropertyNames } from 'vs/base/common/types';
2526

2627
export interface IMirrorModel {
2728
readonly uri: URI;
@@ -599,7 +600,7 @@ export abstract class BaseEditorSimpleWorker {
599600
this._foreignModule = this._foreignModuleFactory(ctx, createData);
600601
// static foreing module
601602
let methods: string[] = [];
602-
for (let prop in this._foreignModule) {
603+
for (const prop of getAllPropertyNames(this._foreignModule)) {
603604
if (typeof this._foreignModule[prop] === 'function') {
604605
methods.push(prop);
605606
}
@@ -612,7 +613,7 @@ export abstract class BaseEditorSimpleWorker {
612613
this._foreignModule = foreignModule.create(ctx, createData);
613614

614615
let methods: string[] = [];
615-
for (let prop in this._foreignModule) {
616+
for (const prop of getAllPropertyNames(this._foreignModule)) {
616617
if (typeof this._foreignModule[prop] === 'function') {
617618
methods.push(prop);
618619
}

0 commit comments

Comments
 (0)