mirror of
https://github.com/github/codeql-action.git
synced 2025-12-27 17:50:07 +08:00
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com> Co-authored-by: Henry Mercer <henrymercer@github.com>
66 lines
2.4 KiB
TypeScript
66 lines
2.4 KiB
TypeScript
import * as ts from "typescript";
|
|
import * as rt from "@protobuf-ts/runtime";
|
|
import { DescriptorProto, DescriptorRegistry, FieldDescriptorProto, OneofDescriptorProto, SymbolTable, TypescriptFile, TypeScriptImports } from "@protobuf-ts/plugin-framework";
|
|
import { CommentGenerator } from "./comment-generator";
|
|
import { Interpreter } from "../interpreter";
|
|
import { GeneratorBase } from "./generator-base";
|
|
export declare class MessageInterfaceGenerator extends GeneratorBase {
|
|
private readonly options;
|
|
constructor(symbols: SymbolTable, registry: DescriptorRegistry, imports: TypeScriptImports, comments: CommentGenerator, interpreter: Interpreter, options: {
|
|
oneofKindDiscriminator: string;
|
|
normalLongType: rt.LongType;
|
|
});
|
|
registerSymbols(source: TypescriptFile, descriptor: DescriptorProto): void;
|
|
/**
|
|
* `message` as an interface.
|
|
*
|
|
* For the following .proto:
|
|
*
|
|
* message MyMessage {
|
|
* string str_field = 1;
|
|
* }
|
|
*
|
|
* We generate the following interface:
|
|
*
|
|
* interface MyMessage {
|
|
* strField: string;
|
|
* }
|
|
*
|
|
*/
|
|
generateMessageInterface(source: TypescriptFile, descriptor: DescriptorProto): ts.InterfaceDeclaration;
|
|
/**
|
|
* Create property signature for a protobuf field. Example:
|
|
*
|
|
* fieldName: number
|
|
*
|
|
*/
|
|
protected createFieldPropertySignature(source: TypescriptFile, fieldDescriptor: FieldDescriptorProto, fieldInfo: rt.FieldInfo): ts.PropertySignature;
|
|
/**
|
|
* `oneof` as an algebraic data type.
|
|
*
|
|
* For the following .proto:
|
|
*
|
|
* oneof result {
|
|
* int32 value = 1;
|
|
* string error = 2;
|
|
* }
|
|
*
|
|
* We generate the following property signature:
|
|
*
|
|
* result: { oneofKind: "value"; value: number; }
|
|
* | { oneofKind: "error"; error: string; }
|
|
* | { oneofKind: undefined; };
|
|
*/
|
|
protected createOneofADTPropertySignature(source: TypescriptFile, oneofDescriptor: OneofDescriptorProto): ts.PropertySignature;
|
|
/**
|
|
* Helper to find for a OneofDescriptorProto:
|
|
* [0] the message descriptor
|
|
* [1] a corresponding message type generated by the interpreter
|
|
* [2] the runtime local name of the oneof
|
|
*/
|
|
private oneofInfo;
|
|
private createScalarTypeNode;
|
|
private createMessageTypeNode;
|
|
private createEnumTypeNode;
|
|
}
|