mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 04:26:32 +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>
65 lines
1.8 KiB
JavaScript
65 lines
1.8 KiB
JavaScript
import { Base } from "./base.js";
|
|
import {
|
|
unescape,
|
|
type_with_extended_attributes,
|
|
autoParenter,
|
|
} from "./helpers.js";
|
|
import { ExtendedAttributes } from "./extended-attributes.js";
|
|
import { Default } from "./default.js";
|
|
|
|
export class Field extends Base {
|
|
/**
|
|
* @param {import("../tokeniser").Tokeniser} tokeniser
|
|
*/
|
|
static parse(tokeniser) {
|
|
/** @type {Base["tokens"]} */
|
|
const tokens = {};
|
|
const ret = autoParenter(new Field({ source: tokeniser.source, tokens }));
|
|
ret.extAttrs = ExtendedAttributes.parse(tokeniser);
|
|
tokens.required = tokeniser.consume("required");
|
|
ret.idlType =
|
|
type_with_extended_attributes(tokeniser, "dictionary-type") ||
|
|
tokeniser.error("Dictionary member lacks a type");
|
|
tokens.name =
|
|
tokeniser.consumeKind("identifier") ||
|
|
tokeniser.error("Dictionary member lacks a name");
|
|
ret.default = Default.parse(tokeniser);
|
|
if (tokens.required && ret.default)
|
|
tokeniser.error("Required member must not have a default");
|
|
tokens.termination =
|
|
tokeniser.consume(";") ||
|
|
tokeniser.error("Unterminated dictionary member, expected `;`");
|
|
return ret.this;
|
|
}
|
|
|
|
get type() {
|
|
return "field";
|
|
}
|
|
get name() {
|
|
return unescape(this.tokens.name.value);
|
|
}
|
|
get required() {
|
|
return !!this.tokens.required;
|
|
}
|
|
|
|
*validate(defs) {
|
|
yield* this.idlType.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.required),
|
|
w.ts.type(this.idlType.write(w)),
|
|
w.name_token(this.tokens.name, { data: this, parent }),
|
|
this.default ? this.default.write(w) : "",
|
|
w.token(this.tokens.termination),
|
|
]),
|
|
{ data: this, parent }
|
|
);
|
|
}
|
|
}
|