mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-01 01:38:07 +08:00
R=aerotwist@chromium.org, jacktfranklin@chromium.org Bug: 1101738 Change-Id: I1d0e27e5d2946d4cd47a6602cedb1c71a5ec4b3b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2318254 Commit-Queue: Jan Scheffler <janscheffler@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
76 lines
2.4 KiB
JavaScript
76 lines
2.4 KiB
JavaScript
// 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.
|
|
|
|
// @ts-nocheck
|
|
// TODO(crbug.com/1011811): Enable TypeScript compiler checks
|
|
|
|
import * as Common from '../common/common.js'; // eslint-disable-line no-unused-vars
|
|
|
|
import {NativeFunctions} from './NativeFunctions.js';
|
|
|
|
/**
|
|
* @implements {Common.JavaScriptMetaData.JavaScriptMetaData}
|
|
*/
|
|
export class JavaScriptMetadataImpl {
|
|
constructor() {
|
|
/** @type {!Map<string, !Array<!Array<string>>>} */
|
|
this._uniqueFunctions = new Map();
|
|
/** @type {!Map<string, !Map<string, !Array<!Array<string>>>>} */
|
|
this._instanceMethods = new Map();
|
|
/** @type {!Map<string, !Map<string, !Array<!Array<string>>>>} */
|
|
this._staticMethods = new Map();
|
|
|
|
for (const nativeFunction of NativeFunctions) {
|
|
if (!nativeFunction.receiver) {
|
|
this._uniqueFunctions.set(nativeFunction.name, nativeFunction.signatures);
|
|
} else if (nativeFunction.static) {
|
|
if (!this._staticMethods.has(nativeFunction.receiver)) {
|
|
this._staticMethods.set(nativeFunction.receiver, new Map());
|
|
}
|
|
this._staticMethods.get(nativeFunction.receiver).set(nativeFunction.name, nativeFunction.signatures);
|
|
} else {
|
|
if (!this._instanceMethods.has(nativeFunction.receiver)) {
|
|
this._instanceMethods.set(nativeFunction.receiver, new Map());
|
|
}
|
|
this._instanceMethods.get(nativeFunction.receiver).set(nativeFunction.name, nativeFunction.signatures);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @param {string} name
|
|
* @return {?Array<!Array<string>>}
|
|
*/
|
|
signaturesForNativeFunction(name) {
|
|
return this._uniqueFunctions.get(name) || null;
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @param {string} name
|
|
* @param {string} receiverClassName
|
|
* @return {?Array<!Array<string>>}
|
|
*/
|
|
signaturesForInstanceMethod(name, receiverClassName) {
|
|
if (!this._instanceMethods.has(receiverClassName)) {
|
|
return null;
|
|
}
|
|
return this._instanceMethods.get(receiverClassName).get(name) || null;
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @param {string} name
|
|
* @param {string} receiverConstructorName
|
|
* @return {?Array<!Array<string>>}
|
|
*/
|
|
signaturesForStaticMethod(name, receiverConstructorName) {
|
|
if (!this._staticMethods.has(receiverConstructorName)) {
|
|
return null;
|
|
}
|
|
return this._staticMethods.get(receiverConstructorName).get(name) || null;
|
|
}
|
|
}
|