mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-30 01:07:01 +08:00
The Chromium/Google style guides does not enforce curly braces for single-line if-statements, but does strongly recommend doing so. Adding braces will improve code readability, by visually separating code blocks. This will also prevent issues where accidental additions are pushed to the "else"-clause instead of in the if-block. This CL also updates the presubmit `eslint` to run the fix with the correct configuration. It will now fix all issues it can fix. Change-Id: I4b616f21a99393f168dec743c0bcbdc7f5db04a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1821526 Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Reviewed-by: Jeff Fisher <jeffish@microsoft.com> Cr-Original-Commit-Position: refs/heads/master@{#701070} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 7e0bdbe2d7f9fc2386bfaefda3cc29c66ccc18f9
79 lines
2.4 KiB
JavaScript
79 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.
|
|
|
|
/**
|
|
* @implements {Common.JavaScriptMetadata}
|
|
*/
|
|
JavaScriptMetadata.JavaScriptMetadata = class {
|
|
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 JavaScriptMetadata.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;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @type {!Array<{
|
|
* name: string,
|
|
* signatures: !Array<!Array<string>>,
|
|
* static: (boolean|undefined),
|
|
* receiver: (string|undefined),
|
|
* }>}
|
|
*/
|
|
JavaScriptMetadata.NativeFunctions;
|