mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 12:33:47 +08:00
This change makes it easier to run the script from directly `roll_py.deps` without having to fetch the dependencies first. This also makes it easier to track which dependencies our tooling have. Change-Id: I1ce55074ee6a1fffa6f2a2f05a56d0d74b4aca90 Bug: 1255619 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3431346 Reviewed-by: Mathias Bynens <mathias@chromium.org> Commit-Queue: Johan Bay <jobay@chromium.org>
58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
import { Base } from "./base.js";
|
|
import { argument_list, autoParenter } from "./helpers.js";
|
|
|
|
export class Constructor extends Base {
|
|
/**
|
|
* @param {import("../tokeniser").Tokeniser} tokeniser
|
|
*/
|
|
static parse(tokeniser) {
|
|
const base = tokeniser.consume("constructor");
|
|
if (!base) {
|
|
return;
|
|
}
|
|
/** @type {Base["tokens"]} */
|
|
const tokens = { base };
|
|
tokens.open =
|
|
tokeniser.consume("(") ||
|
|
tokeniser.error("No argument list in constructor");
|
|
const args = argument_list(tokeniser);
|
|
tokens.close =
|
|
tokeniser.consume(")") || tokeniser.error("Unterminated constructor");
|
|
tokens.termination =
|
|
tokeniser.consume(";") ||
|
|
tokeniser.error("No semicolon after constructor");
|
|
const ret = new Constructor({ source: tokeniser.source, tokens });
|
|
autoParenter(ret).arguments = args;
|
|
return ret;
|
|
}
|
|
|
|
get type() {
|
|
return "constructor";
|
|
}
|
|
|
|
*validate(defs) {
|
|
if (this.idlType) {
|
|
yield* this.idlType.validate(defs);
|
|
}
|
|
for (const argument of this.arguments) {
|
|
yield* argument.validate(defs);
|
|
}
|
|
}
|
|
|
|
/** @param {import("../writer.js").Writer} w */
|
|
write(w) {
|
|
const { parent } = this;
|
|
return w.ts.definition(
|
|
w.ts.wrap([
|
|
this.extAttrs.write(w),
|
|
w.token(this.tokens.base, w.ts.nameless, { data: this, parent }),
|
|
w.token(this.tokens.open),
|
|
w.ts.wrap(this.arguments.map((arg) => arg.write(w))),
|
|
w.token(this.tokens.close),
|
|
w.token(this.tokens.termination),
|
|
]),
|
|
{ data: this, parent }
|
|
);
|
|
}
|
|
}
|