Files
react-native-devtools-frontend/front_end/models/javascript_metadata/JavaScriptMetadata.ts
T
Benedikt Meurer 67b69bf002 [cleanup] Remove "Highlight important DOM properties in the Object Properties viewer" experiment.
This feature never made it past the experiment stage and while we believe
that it's beneficial to highlight important DOM properties, we aren't
convinced that this approach is the right one. Since we have no capacity
or intention to work on this experiment, we are removing the code now.

Doc: http://go/pinned-properties
Bug: 40267030, 40840064
Change-Id: Ib2d0f287834ca9ee87d957bd64f77a450c322f46
Fixed: 315126594
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5836838
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Victor Porof <victorporof@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
2024-09-04 14:40:11 +00:00

64 lines
2.1 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.
import type * as Common from '../../core/common/common.js';
import {NativeFunctions} from './NativeFunctions.js';
let javaScriptMetadataInstance: JavaScriptMetadataImpl;
export class JavaScriptMetadataImpl implements Common.JavaScriptMetaData.JavaScriptMetaData {
private readonly uniqueFunctions: Map<string, string[][]>;
private readonly receiverMethods: 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.receiverMethods = new Map();
for (const nativeFunction of NativeFunctions) {
if (!nativeFunction.receivers) {
this.uniqueFunctions.set(nativeFunction.name, nativeFunction.signatures);
continue;
}
for (const receiver of nativeFunction.receivers) {
let method = this.receiverMethods.get(receiver);
if (!method) {
method = new Map();
this.receiverMethods.set(receiver, method);
}
method.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.receiverMethods.get(receiverClassName);
if (!instanceMethod) {
return null;
}
return instanceMethod.get(name) || null;
}
signaturesForStaticMethod(name: string, receiverConstructorName: string): string[][]|null {
const staticMethod = this.receiverMethods.get(receiverConstructorName + 'Constructor');
if (!staticMethod) {
return null;
}
return staticMethod.get(name) || null;
}
}