Files
react-native-devtools-frontend/scripts/component_bridges/utils.ts
T
Jack Franklin 12bc13e26d Add enum parsing support to component bridges
This CL introduces the parsing aspect of adding TS enum support to the component
bridges generation code. It _does not_ add full support for them, we still do
not output anything into the generated bridge, but I'm splitting it up into
smaller CLs.

This CL makes the tree walker understand and be aware of enums such that we can
then generate the relevant Closure doc comments (which will be in a follow-up
CL).

Change-Id: I5c91bb6bac291eef1aa99e685bbdee55e82ccd48
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2346369
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
2020-08-10 15:16:25 +00:00

17 lines
642 B
TypeScript

// Copyright 2020 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 ts from 'typescript';
import {WalkerState} from './walk_tree.js';
export const findNodeForTypeReferenceName = (state: WalkerState, typeReferenceName: string): ts.InterfaceDeclaration|
ts.TypeAliasDeclaration|ts.EnumDeclaration|null => {
const matchingNode = [...state.foundInterfaces, ...state.foundEnums].find(dec => {
return dec.name.escapedText === typeReferenceName;
});
return matchingNode || null;
};