mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-01 01:38:07 +08:00
R=aerotwist@chromium.org Bug: 1011811 Change-Id: I7cb62ed2bdd49fac361168c5e103ea99f07c9828 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2550079 Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
79 lines
2.5 KiB
JavaScript
79 lines
2.5 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.
|
|
|
|
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) {
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @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) {
|
|
const instanceMethod = this._instanceMethods.get(receiverClassName);
|
|
if (!instanceMethod) {
|
|
return null;
|
|
}
|
|
return instanceMethod.get(name) || null;
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @param {string} name
|
|
* @param {string} receiverConstructorName
|
|
* @return {?Array<!Array<string>>}
|
|
*/
|
|
signaturesForStaticMethod(name, receiverConstructorName) {
|
|
const staticMethod = this._staticMethods.get(receiverConstructorName);
|
|
if (!staticMethod) {
|
|
return null;
|
|
}
|
|
return staticMethod.get(name) || null;
|
|
}
|
|
}
|