Files
react-native-devtools-frontend/front_end/models/javascript_metadata/JavaScriptMetadata.ts
T
Tim van der Lippe 877f04aa0e Remove eslint-disable statements from type imports
We no longer use the no-unused-vars and instead use the version
of typescript-eslint. The latter can properly detect unused
type-import usages. Therefore, we can remove the eslint-disable
statements, which are essentially noops.

This CL is the result of replacing

```
import type (.*) // eslint-disable-line no-unused-vars
```

with

```
import type $1
```

R=jacktfranklin@chromium.org

Bug: none
Change-Id: I141edcb7125e414c405760af1e4058bfdc6e30f3
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3048473
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-07-26 12:53:27 +00:00

73 lines
2.5 KiB
TypeScript

// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/* eslint-disable rulesdir/no_underscored_properties */
import type * as Common from '../../core/common/common.js';
import {NativeFunctions} from './NativeFunctions.js';
let javaScriptMetadataInstance: JavaScriptMetadataImpl;
export class JavaScriptMetadataImpl implements Common.JavaScriptMetaData.JavaScriptMetaData {
_uniqueFunctions: Map<string, string[][]>;
_instanceMethods: Map<string, Map<string, string[][]>>;
_staticMethods: Map<string, Map<string, string[][]>>;
static instance(opts: {
forceNew: boolean|null,
} = {forceNew: null}): JavaScriptMetadataImpl {
const {forceNew} = opts;
if (!javaScriptMetadataInstance || forceNew) {
javaScriptMetadataInstance = new JavaScriptMetadataImpl();
}
return javaScriptMetadataInstance;
}
constructor() {
this._uniqueFunctions = new Map();
this._instanceMethods = new Map();
this._staticMethods = new Map();
for (const nativeFunction of NativeFunctions) {
if (!nativeFunction.receiver) {
this._uniqueFunctions.set(nativeFunction.name, nativeFunction.signatures);
} else if (nativeFunction.static) {
let staticMethod = this._staticMethods.get(nativeFunction.receiver);
if (!staticMethod) {
staticMethod = new Map();
this._staticMethods.set(nativeFunction.receiver, staticMethod);
}
staticMethod.set(nativeFunction.name, nativeFunction.signatures);
} else {
let instanceMethod = this._instanceMethods.get(nativeFunction.receiver);
if (!instanceMethod) {
instanceMethod = new Map();
this._instanceMethods.set(nativeFunction.receiver, instanceMethod);
}
instanceMethod.set(nativeFunction.name, nativeFunction.signatures);
}
}
}
signaturesForNativeFunction(name: string): string[][]|null {
return this._uniqueFunctions.get(name) || null;
}
signaturesForInstanceMethod(name: string, receiverClassName: string): string[][]|null {
const instanceMethod = this._instanceMethods.get(receiverClassName);
if (!instanceMethod) {
return null;
}
return instanceMethod.get(name) || null;
}
signaturesForStaticMethod(name: string, receiverConstructorName: string): string[][]|null {
const staticMethod = this._staticMethods.get(receiverConstructorName);
if (!staticMethod) {
return null;
}
return staticMethod.get(name) || null;
}
}