diff --git a/snapshots/input/enclosing-ranges-ts/index.ts b/snapshots/input/enclosing-ranges-ts/index.ts new file mode 100644 index 00000000..f0a46c22 --- /dev/null +++ b/snapshots/input/enclosing-ranges-ts/index.ts @@ -0,0 +1,19 @@ +// format-options: showRanges + +interface Foo { + bar: string + test: () => void +} + +interface Single { + t: T +} + +enum SimpleEnum { + Case1, + Case2, +} + +type SimpleTypeAlias = SimpleEnum + +type ComplexTypeAlias = Single> diff --git a/snapshots/input/enclosing-ranges-ts/package.json b/snapshots/input/enclosing-ranges-ts/package.json new file mode 100644 index 00000000..fb5eb65a --- /dev/null +++ b/snapshots/input/enclosing-ranges-ts/package.json @@ -0,0 +1,4 @@ +{ + "name": "enclosing-ranges-ts", + "version": "1.0.0" +} diff --git a/snapshots/input/enclosing-ranges-ts/tsconfig.json b/snapshots/input/enclosing-ranges-ts/tsconfig.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/snapshots/input/enclosing-ranges-ts/tsconfig.json @@ -0,0 +1 @@ +{} diff --git a/snapshots/input/enclosing-ranges/package.json b/snapshots/input/enclosing-ranges/package.json new file mode 100644 index 00000000..4323fbea --- /dev/null +++ b/snapshots/input/enclosing-ranges/package.json @@ -0,0 +1,4 @@ +{ + "name": "enclosing-ranges", + "version": "0.0.1" +} diff --git a/snapshots/input/enclosing-ranges/range.js b/snapshots/input/enclosing-ranges/range.js new file mode 100644 index 00000000..9bfeebef --- /dev/null +++ b/snapshots/input/enclosing-ranges/range.js @@ -0,0 +1,38 @@ +// format-options: showRanges + +const test = () => { + const a = 'a' + const b = 'b' + + return a + b +} + +function test2() { + const a = 'a' + const b = 'b' + + return a + b +} + +class Test { + constructor() { + const a = 'a' + const b = 'b' + + return a + b + } + + test() { + const a = 'a' + const b = 'b' + + return a + b + } + + static test() { + const a = 'a' + const b = 'b' + + return a + b + } +} diff --git a/snapshots/input/enclosing-ranges/tsconfig.json b/snapshots/input/enclosing-ranges/tsconfig.json new file mode 100644 index 00000000..5312e315 --- /dev/null +++ b/snapshots/input/enclosing-ranges/tsconfig.json @@ -0,0 +1 @@ +{ "compilerOptions": { "allowJs": true } } diff --git a/snapshots/output/enclosing-ranges-ts/index.ts b/snapshots/output/enclosing-ranges-ts/index.ts new file mode 100644 index 00000000..430c1451 --- /dev/null +++ b/snapshots/output/enclosing-ranges-ts/index.ts @@ -0,0 +1,51 @@ +// < definition enclosing-ranges-ts 1.0.0 `index.ts`/ + +// format-options: showRanges + +// < start enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/Foo# +// < start enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/ +interface Foo { +// ^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/Foo# + bar: string +//^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/Foo#bar. + test: () => void +//^^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/Foo#test. +} +// < end enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/Foo# + +// < start enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/Single# +interface Single { +// ^^^^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/Single# +// ^ definition enclosing-ranges-ts 1.0.0 `index.ts`/Single#[T] + t: T +//^ definition enclosing-ranges-ts 1.0.0 `index.ts`/Single#t. +// ^ reference enclosing-ranges-ts 1.0.0 `index.ts`/Single#[T] +} +// < end enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/Single# + +// < start enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/SimpleEnum# +enum SimpleEnum { +// ^^^^^^^^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/SimpleEnum# + Case1, +//^^^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/SimpleEnum#Case1. + Case2, +//^^^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/SimpleEnum#Case2. +} +// < end enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/SimpleEnum# + +// < start enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/SimpleTypeAlias# +type SimpleTypeAlias = SimpleEnum +// ^^^^^^^^^^^^^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/SimpleTypeAlias# +// ^^^^^^^^^^ reference enclosing-ranges-ts 1.0.0 `index.ts`/SimpleEnum# +// < end enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/SimpleTypeAlias# + +// < start enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/ComplexTypeAlias# +type ComplexTypeAlias = Single> +// ^^^^^^^^^^^^^^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/ComplexTypeAlias# +// ^ definition enclosing-ranges-ts 1.0.0 `index.ts`/ComplexTypeAlias#[T] +// ^^^^^^ reference enclosing-ranges-ts 1.0.0 `index.ts`/Single# +// ^^^^^^ reference enclosing-ranges-ts 1.0.0 `index.ts`/Single# +// ^ reference enclosing-ranges-ts 1.0.0 `index.ts`/ComplexTypeAlias#[T] +// < end enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/ComplexTypeAlias# + +// < end enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/ diff --git a/snapshots/output/enclosing-ranges/range.js b/snapshots/output/enclosing-ranges/range.js new file mode 100644 index 00000000..89afef4b --- /dev/null +++ b/snapshots/output/enclosing-ranges/range.js @@ -0,0 +1,79 @@ +// < definition enclosing-ranges 0.0.1 `range.js`/ + +// format-options: showRanges + +// < start enclosing_range enclosing-ranges 0.0.1 `range.js`/ +// ⌄ start enclosing_range enclosing-ranges 0.0.1 `range.js`/test. +const test = () => { +// ^^^^ definition enclosing-ranges 0.0.1 `range.js`/test. + const a = 'a' +// ^ definition local 2 + const b = 'b' +// ^ definition local 5 + + return a + b +// ^ reference local 2 +// ^ reference local 5 +} +// ^ end enclosing_range enclosing-ranges 0.0.1 `range.js`/test. + +// < start enclosing_range enclosing-ranges 0.0.1 `range.js`/test2(). +function test2() { +// ^^^^^ definition enclosing-ranges 0.0.1 `range.js`/test2(). + const a = 'a' +// ^ definition local 8 + const b = 'b' +// ^ definition local 11 + + return a + b +// ^ reference local 8 +// ^ reference local 11 +} +// < end enclosing_range enclosing-ranges 0.0.1 `range.js`/test2(). + +// < start enclosing_range enclosing-ranges 0.0.1 `range.js`/Test# +class Test { +// ^^^^ definition enclosing-ranges 0.0.1 `range.js`/Test# + constructor() { +//^^^^^^^^^^^ definition enclosing-ranges 0.0.1 `range.js`/Test#``(). + const a = 'a' +// ^ definition local 14 + const b = 'b' +// ^ definition local 17 + + return a + b +// ^ reference local 14 +// ^ reference local 17 + } + +// ⌄ start enclosing_range enclosing-ranges 0.0.1 `range.js`/Test#test(). + test() { +//^^^^ definition enclosing-ranges 0.0.1 `range.js`/Test#test(). + const a = 'a' +// ^ definition local 20 + const b = 'b' +// ^ definition local 23 + + return a + b +// ^ reference local 20 +// ^ reference local 23 + } +// ^ end enclosing_range enclosing-ranges 0.0.1 `range.js`/Test#test(). + +// ⌄ start enclosing_range enclosing-ranges 0.0.1 `range.js`/Test#test(). + static test() { +// ^^^^ definition enclosing-ranges 0.0.1 `range.js`/Test#test(). + const a = 'a' +// ^ definition local 26 + const b = 'b' +// ^ definition local 29 + + return a + b +// ^ reference local 26 +// ^ reference local 29 + } +// ^ end enclosing_range enclosing-ranges 0.0.1 `range.js`/Test#test(). +} +// < end enclosing_range enclosing-ranges 0.0.1 `range.js`/Test# + +// < end enclosing_range enclosing-ranges 0.0.1 `range.js`/ diff --git a/src/Descriptor.ts b/src/Descriptor.ts index 7734b716..57fd61b3 100644 --- a/src/Descriptor.ts +++ b/src/Descriptor.ts @@ -6,7 +6,7 @@ type Suffix = scip.scip.Descriptor.Suffix const Suffix = scip.scip.Descriptor.Suffix export function packageDescriptor(name: string): Descriptor { - return new Descriptor({ name, suffix: Suffix.Package }) + return new Descriptor({ name, suffix: Suffix.Namespace }) } export function typeDescriptor(name: string): Descriptor { @@ -35,7 +35,7 @@ export function typeParameterDescriptor(name: string): Descriptor { export function descriptorString(desc: Descriptor): string { switch (desc.suffix) { - case Suffix.Package: { + case Suffix.Namespace: { return escapedName(desc) + '/' } case Suffix.Type: { diff --git a/src/FileIndexer.ts b/src/FileIndexer.ts index c8de3d37..3b7f0acb 100644 --- a/src/FileIndexer.ts +++ b/src/FileIndexer.ts @@ -71,6 +71,7 @@ export class FileIndexer { this.pushOccurrence( new scip.scip.Occurrence({ range: [0, 0, 0], + enclosing_range: Range.fromNode(this.sourceFile).toLsif(), symbol: symbol.value, symbol_roles: scip.scip.SymbolRole.Definition, }) @@ -168,6 +169,27 @@ export class FileIndexer { for (const declaration of declarations) { let scipSymbol = this.scipSymbol(declaration) + let enclosingRange: number[] | undefined + + if (!isDefinitionNode || scipSymbol.isEmpty() || scipSymbol.isLocal()) { + // Skip enclosing ranges for these cases + } else if ( + ts.isVariableDeclaration(declaration) && + declaration.initializer && + ts.isFunctionLike(declaration.initializer) + ) { + enclosingRange = Range.fromNode(declaration.initializer).toLsif() + } else if ( + ts.isFunctionDeclaration(declaration) || + ts.isEnumDeclaration(declaration) || + ts.isTypeAliasDeclaration(declaration) || + ts.isClassDeclaration(declaration) || + ts.isMethodDeclaration(declaration) || + ts.isInterfaceDeclaration(declaration) + ) { + enclosingRange = Range.fromNode(declaration).toLsif() + } + if ( ((ts.isIdentifier(node) && ts.isNewExpression(node.parent)) || (ts.isPropertyAccessExpression(node.parent) && @@ -187,6 +209,7 @@ export class FileIndexer { } this.pushOccurrence( new scip.scip.Occurrence({ + enclosing_range: enclosingRange, range, symbol: scipSymbol.value, symbol_roles: role, diff --git a/src/SnapshotTesting.ts b/src/SnapshotTesting.ts index 782221b6..b04578f9 100644 --- a/src/SnapshotTesting.ts +++ b/src/SnapshotTesting.ts @@ -67,6 +67,7 @@ export function formatSnapshot( externalSymbolTable.set(externalSymbol.symbol, externalSymbol) } + const enclosingRanges: { range: Range; symbol: string }[] = [] const symbolsWithDefinitions: Set = new Set() const formatOptions = parseOptions(input.lines) @@ -77,6 +78,29 @@ export function formatSnapshot( if (isDefinition) { symbolsWithDefinitions.add(occurrence.symbol) } + + if (formatOptions.showRanges && occurrence.enclosing_range.length > 0) { + enclosingRanges.push({ + range: Range.fromLsif(occurrence.enclosing_range), + symbol: occurrence.symbol, + }) + } + } + + enclosingRanges.sort(enclosingRangesByLine) + + const enclosingRangeStarts: (typeof enclosingRanges)[number][][] = Array.from( + new Array(input.lines.length), + () => [] + ) + const enclosingRangeEnds: (typeof enclosingRanges)[number][][] = Array.from( + new Array(input.lines.length), + () => [] + ) + + for (const enclosingRange of enclosingRanges) { + enclosingRangeStarts[enclosingRange.range.start.line].push(enclosingRange) + enclosingRangeEnds[enclosingRange.range.end.line].unshift(enclosingRange) } const emittedDocstrings: Set = new Set() @@ -162,6 +186,38 @@ export function formatSnapshot( out.push('\n') } + const pushEnclosingRange = ( + enclosingRange: { + range: Range + symbol: string + }, + end: boolean = false + ): void => { + if (!formatOptions.showRanges) { + return + } + + out.push(commentSyntax) + out.push(' '.repeat(Math.max(1, enclosingRange.range.start.character - 2))) + + if (enclosingRange.range.start.character < 2) { + out.push('<') + } else if (end) { + out.push('^') + } else { + out.push('⌄') + } + + if (end) { + out.push(' end ') + } else { + out.push(' start ') + } + out.push('enclosing_range ') + out.push(symbolNameForSnapshot(enclosingRange.symbol)) + out.push('\n') + } + doc.occurrences.sort(occurrencesByLine) let occurrenceIndex = 0 @@ -189,6 +245,11 @@ export function formatSnapshot( } } + // Check if any enclosing ranges start on this line + for (const enclosingRange of enclosingRangeStarts[lineNumber]) { + pushEnclosingRange(enclosingRange) + } + out.push('') out.push(line) out.push('\n') @@ -235,6 +296,11 @@ export function formatSnapshot( pushDoc(range, occurrence.symbol, isDefinition, isStartOfLine) } + + // Check if any enclosing ranges end on this line + for (const enclosingRange of enclosingRangeEnds[lineNumber]) { + pushEnclosingRange(enclosingRange, true) + } } return out.join('') } @@ -242,3 +308,17 @@ export function formatSnapshot( function occurrencesByLine(a: scip.Occurrence, b: scip.Occurrence): number { return Range.fromLsif(a.range).compare(Range.fromLsif(b.range)) } + +function enclosingRangesByLine( + a: { range: Range; symbol: string }, + b: { range: Range; symbol: string } +): number { + // Return the range that starts first, and if they start at the same line, the one that ends last (enclosing). + const rangeCompare = a.range.compare(b.range) + + if (rangeCompare !== 0) { + return rangeCompare + } + + return b.range.end.line - a.range.end.line +} diff --git a/src/scip.ts b/src/scip.ts index b7dd3059..6531818d 100644 --- a/src/scip.ts +++ b/src/scip.ts @@ -2,8 +2,7 @@ * Generated by the protoc-gen-ts. DO NOT EDIT! * compiler version: 0.0.0 * source: scip.proto - * git: https://github.com/thesayyn/protoc-gen-ts - * */ + * git: https://github.com/thesayyn/protoc-gen-ts */ import * as pb_1 from "google-protobuf"; export namespace scip { export enum ProtocolVersion { @@ -21,7 +20,8 @@ export namespace scip { WriteAccess = 4, ReadAccess = 8, Generated = 16, - Test = 32 + Test = 32, + ForwardDefinition = 64 } export enum SyntaxKind { UnspecifiedSyntaxKind = 0, @@ -29,6 +29,7 @@ export namespace scip { PunctuationDelimiter = 2, PunctuationBracket = 3, Keyword = 4, + /** @deprecated*/ IdentifierKeyword = 4, IdentifierOperator = 5, Identifier = 6, @@ -40,6 +41,7 @@ export namespace scip { IdentifierLocal = 12, IdentifierShadowed = 13, IdentifierNamespace = 14, + /** @deprecated*/ IdentifierModule = 14, IdentifierFunction = 15, IdentifierFunctionDefinition = 16, @@ -79,6 +81,7 @@ export namespace scip { export enum Language { UnspecifiedLanguage = 0, ABAP = 60, + Apex = 96, APL = 49, Ada = 39, Agda = 45, @@ -96,6 +99,7 @@ export namespace scip { Coffeescript = 21, CommonLisp = 9, Coq = 47, + CUDA = 97, Dart = 3, Delphi = 57, Diff = 88, @@ -111,6 +115,7 @@ export namespace scip { Git_Config = 89, Git_Rebase = 92, Go = 33, + GraphQL = 98, Groovy = 7, HTML = 30, Hack = 20, @@ -125,28 +130,34 @@ export namespace scip { JavaScriptReact = 93, Jsonnet = 76, Julia = 55, + Justfile = 109, Kotlin = 4, LaTeX = 83, Lean = 48, Less = 27, Lua = 12, + Luau = 108, Makefile = 79, Markdown = 84, Matlab = 52, + Nickel = 110, Nix = 77, OCaml = 41, Objective_C = 36, Objective_CPP = 37, + Pascal = 99, PHP = 19, PLSQL = 70, Perl = 13, PowerShell = 67, Prolog = 71, + Protobuf = 100, Python = 15, R = 54, Racket = 11, Raku = 14, Razor = 62, + Repro = 102, ReST = 85, Ruby = 16, Rust = 40, @@ -159,11 +170,18 @@ export namespace scip { Scheme = 10, ShellScript = 64, Skylark = 78, + Slang = 107, + Solidity = 95, + Svelte = 106, Swift = 2, + Tcl = 101, TOML = 73, TeX = 82, + Thrift = 103, TypeScript = 23, TypeScriptReact = 94, + Verilog = 104, + VHDL = 105, VisualBasic = 63, Vue = 25, Wolfram = 53, @@ -173,13 +191,14 @@ export namespace scip { Zig = 38 } export class Index extends pb_1.Message { + #one_of_decls: number[][] = []; constructor(data?: any[] | { metadata?: Metadata; documents?: Document[]; external_symbols?: SymbolInformation[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3], []); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("metadata" in data && data.metadata != undefined) { this.metadata = data.metadata; @@ -198,6 +217,9 @@ export namespace scip { set metadata(value: Metadata) { pb_1.Message.setWrapperField(this, 1, value); } + get has_metadata() { + return pb_1.Message.getField(this, 1) != null; + } get documents() { return pb_1.Message.getRepeatedWrapperField(this, Document, 2) as Document[]; } @@ -214,7 +236,7 @@ export namespace scip { metadata?: ReturnType; documents?: ReturnType[]; external_symbols?: ReturnType[]; - }) { + }): Index { const message = new Index({}); if (data.metadata != null) { message.metadata = Metadata.fromObject(data.metadata); @@ -248,11 +270,11 @@ export namespace scip { serialize(w: pb_1.BinaryWriter): void; serialize(w?: pb_1.BinaryWriter): Uint8Array | void { const writer = w || new pb_1.BinaryWriter(); - if (this.metadata !== undefined) + if (this.has_metadata) writer.writeMessage(1, this.metadata, () => this.metadata.serialize(writer)); - if (this.documents !== undefined) + if (this.documents.length) writer.writeRepeatedMessage(2, this.documents, (item: Document) => item.serialize(writer)); - if (this.external_symbols !== undefined) + if (this.external_symbols.length) writer.writeRepeatedMessage(3, this.external_symbols, (item: SymbolInformation) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); @@ -285,6 +307,7 @@ export namespace scip { } } export class Metadata extends pb_1.Message { + #one_of_decls: number[][] = []; constructor(data?: any[] | { version?: ProtocolVersion; tool_info?: ToolInfo; @@ -292,7 +315,7 @@ export namespace scip { text_document_encoding?: TextEncoding; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("version" in data && data.version != undefined) { this.version = data.version; @@ -309,7 +332,7 @@ export namespace scip { } } get version() { - return pb_1.Message.getField(this, 1) as ProtocolVersion; + return pb_1.Message.getFieldWithDefault(this, 1, ProtocolVersion.UnspecifiedProtocolVersion) as ProtocolVersion; } set version(value: ProtocolVersion) { pb_1.Message.setField(this, 1, value); @@ -320,14 +343,17 @@ export namespace scip { set tool_info(value: ToolInfo) { pb_1.Message.setWrapperField(this, 2, value); } + get has_tool_info() { + return pb_1.Message.getField(this, 2) != null; + } get project_root() { - return pb_1.Message.getField(this, 3) as string; + return pb_1.Message.getFieldWithDefault(this, 3, "") as string; } set project_root(value: string) { pb_1.Message.setField(this, 3, value); } get text_document_encoding() { - return pb_1.Message.getField(this, 4) as TextEncoding; + return pb_1.Message.getFieldWithDefault(this, 4, TextEncoding.UnspecifiedTextEncoding) as TextEncoding; } set text_document_encoding(value: TextEncoding) { pb_1.Message.setField(this, 4, value); @@ -337,7 +363,7 @@ export namespace scip { tool_info?: ReturnType; project_root?: string; text_document_encoding?: TextEncoding; - }) { + }): Metadata { const message = new Metadata({}); if (data.version != null) { message.version = data.version; @@ -378,13 +404,13 @@ export namespace scip { serialize(w: pb_1.BinaryWriter): void; serialize(w?: pb_1.BinaryWriter): Uint8Array | void { const writer = w || new pb_1.BinaryWriter(); - if (this.version !== undefined) + if (this.version != ProtocolVersion.UnspecifiedProtocolVersion) writer.writeEnum(1, this.version); - if (this.tool_info !== undefined) + if (this.has_tool_info) writer.writeMessage(2, this.tool_info, () => this.tool_info.serialize(writer)); - if (typeof this.project_root === "string" && this.project_root.length) + if (this.project_root.length) writer.writeString(3, this.project_root); - if (this.text_document_encoding !== undefined) + if (this.text_document_encoding != TextEncoding.UnspecifiedTextEncoding) writer.writeEnum(4, this.text_document_encoding); if (!w) return writer.getResultBuffer(); @@ -420,13 +446,14 @@ export namespace scip { } } export class ToolInfo extends pb_1.Message { + #one_of_decls: number[][] = []; constructor(data?: any[] | { name?: string; version?: string; arguments?: string[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], []); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("name" in data && data.name != undefined) { this.name = data.name; @@ -440,19 +467,19 @@ export namespace scip { } } get name() { - return pb_1.Message.getField(this, 1) as string; + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; } set name(value: string) { pb_1.Message.setField(this, 1, value); } get version() { - return pb_1.Message.getField(this, 2) as string; + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; } set version(value: string) { pb_1.Message.setField(this, 2, value); } get arguments() { - return pb_1.Message.getField(this, 3) as string[]; + return pb_1.Message.getFieldWithDefault(this, 3, []) as string[]; } set arguments(value: string[]) { pb_1.Message.setField(this, 3, value); @@ -461,7 +488,7 @@ export namespace scip { name?: string; version?: string; arguments?: string[]; - }) { + }): ToolInfo { const message = new ToolInfo({}); if (data.name != null) { message.name = data.name; @@ -495,11 +522,11 @@ export namespace scip { serialize(w: pb_1.BinaryWriter): void; serialize(w?: pb_1.BinaryWriter): Uint8Array | void { const writer = w || new pb_1.BinaryWriter(); - if (typeof this.name === "string" && this.name.length) + if (this.name.length) writer.writeString(1, this.name); - if (typeof this.version === "string" && this.version.length) + if (this.version.length) writer.writeString(2, this.version); - if (this.arguments !== undefined) + if (this.arguments.length) writer.writeRepeatedString(3, this.arguments); if (!w) return writer.getResultBuffer(); @@ -532,14 +559,16 @@ export namespace scip { } } export class Document extends pb_1.Message { + #one_of_decls: number[][] = []; constructor(data?: any[] | { language?: string; relative_path?: string; occurrences?: Occurrence[]; symbols?: SymbolInformation[]; + text?: string; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3], []); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("language" in data && data.language != undefined) { this.language = data.language; @@ -553,16 +582,19 @@ export namespace scip { if ("symbols" in data && data.symbols != undefined) { this.symbols = data.symbols; } + if ("text" in data && data.text != undefined) { + this.text = data.text; + } } } get language() { - return pb_1.Message.getField(this, 4) as string; + return pb_1.Message.getFieldWithDefault(this, 4, "") as string; } set language(value: string) { pb_1.Message.setField(this, 4, value); } get relative_path() { - return pb_1.Message.getField(this, 1) as string; + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; } set relative_path(value: string) { pb_1.Message.setField(this, 1, value); @@ -579,12 +611,19 @@ export namespace scip { set symbols(value: SymbolInformation[]) { pb_1.Message.setRepeatedWrapperField(this, 3, value); } + get text() { + return pb_1.Message.getFieldWithDefault(this, 5, "") as string; + } + set text(value: string) { + pb_1.Message.setField(this, 5, value); + } static fromObject(data: { language?: string; relative_path?: string; occurrences?: ReturnType[]; symbols?: ReturnType[]; - }) { + text?: string; + }): Document { const message = new Document({}); if (data.language != null) { message.language = data.language; @@ -598,6 +637,9 @@ export namespace scip { if (data.symbols != null) { message.symbols = data.symbols.map(item => SymbolInformation.fromObject(item)); } + if (data.text != null) { + message.text = data.text; + } return message; } toObject() { @@ -606,6 +648,7 @@ export namespace scip { relative_path?: string; occurrences?: ReturnType[]; symbols?: ReturnType[]; + text?: string; } = {}; if (this.language != null) { data.language = this.language; @@ -619,20 +662,25 @@ export namespace scip { if (this.symbols != null) { data.symbols = this.symbols.map((item: SymbolInformation) => item.toObject()); } + if (this.text != null) { + data.text = this.text; + } return data; } serialize(): Uint8Array; serialize(w: pb_1.BinaryWriter): void; serialize(w?: pb_1.BinaryWriter): Uint8Array | void { const writer = w || new pb_1.BinaryWriter(); - if (typeof this.language === "string" && this.language.length) + if (this.language.length) writer.writeString(4, this.language); - if (typeof this.relative_path === "string" && this.relative_path.length) + if (this.relative_path.length) writer.writeString(1, this.relative_path); - if (this.occurrences !== undefined) + if (this.occurrences.length) writer.writeRepeatedMessage(2, this.occurrences, (item: Occurrence) => item.serialize(writer)); - if (this.symbols !== undefined) + if (this.symbols.length) writer.writeRepeatedMessage(3, this.symbols, (item: SymbolInformation) => item.serialize(writer)); + if (this.text.length) + writer.writeString(5, this.text); if (!w) return writer.getResultBuffer(); } @@ -654,6 +702,9 @@ export namespace scip { case 3: reader.readMessage(message.symbols, () => pb_1.Message.addToRepeatedWrapperField(message, 3, SymbolInformation.deserialize(reader), SymbolInformation)); break; + case 5: + message.text = reader.readString(); + break; default: reader.skipField(); } } @@ -667,13 +718,14 @@ export namespace scip { } } export class Symbol extends pb_1.Message { + #one_of_decls: number[][] = []; constructor(data?: any[] | { scheme?: string; package?: Package; descriptors?: Descriptor[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], []); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("scheme" in data && data.scheme != undefined) { this.scheme = data.scheme; @@ -687,7 +739,7 @@ export namespace scip { } } get scheme() { - return pb_1.Message.getField(this, 1) as string; + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; } set scheme(value: string) { pb_1.Message.setField(this, 1, value); @@ -698,6 +750,9 @@ export namespace scip { set package(value: Package) { pb_1.Message.setWrapperField(this, 2, value); } + get has_package() { + return pb_1.Message.getField(this, 2) != null; + } get descriptors() { return pb_1.Message.getRepeatedWrapperField(this, Descriptor, 3) as Descriptor[]; } @@ -708,7 +763,7 @@ export namespace scip { scheme?: string; package?: ReturnType; descriptors?: ReturnType[]; - }) { + }): Symbol { const message = new Symbol({}); if (data.scheme != null) { message.scheme = data.scheme; @@ -742,11 +797,11 @@ export namespace scip { serialize(w: pb_1.BinaryWriter): void; serialize(w?: pb_1.BinaryWriter): Uint8Array | void { const writer = w || new pb_1.BinaryWriter(); - if (typeof this.scheme === "string" && this.scheme.length) + if (this.scheme.length) writer.writeString(1, this.scheme); - if (this.package !== undefined) + if (this.has_package) writer.writeMessage(2, this.package, () => this.package.serialize(writer)); - if (this.descriptors !== undefined) + if (this.descriptors.length) writer.writeRepeatedMessage(3, this.descriptors, (item: Descriptor) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); @@ -779,13 +834,14 @@ export namespace scip { } } export class Package extends pb_1.Message { + #one_of_decls: number[][] = []; constructor(data?: any[] | { manager?: string; name?: string; version?: string; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("manager" in data && data.manager != undefined) { this.manager = data.manager; @@ -799,19 +855,19 @@ export namespace scip { } } get manager() { - return pb_1.Message.getField(this, 1) as string; + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; } set manager(value: string) { pb_1.Message.setField(this, 1, value); } get name() { - return pb_1.Message.getField(this, 2) as string; + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; } set name(value: string) { pb_1.Message.setField(this, 2, value); } get version() { - return pb_1.Message.getField(this, 3) as string; + return pb_1.Message.getFieldWithDefault(this, 3, "") as string; } set version(value: string) { pb_1.Message.setField(this, 3, value); @@ -820,7 +876,7 @@ export namespace scip { manager?: string; name?: string; version?: string; - }) { + }): Package { const message = new Package({}); if (data.manager != null) { message.manager = data.manager; @@ -854,11 +910,11 @@ export namespace scip { serialize(w: pb_1.BinaryWriter): void; serialize(w?: pb_1.BinaryWriter): Uint8Array | void { const writer = w || new pb_1.BinaryWriter(); - if (typeof this.manager === "string" && this.manager.length) + if (this.manager.length) writer.writeString(1, this.manager); - if (typeof this.name === "string" && this.name.length) + if (this.name.length) writer.writeString(2, this.name); - if (typeof this.version === "string" && this.version.length) + if (this.version.length) writer.writeString(3, this.version); if (!w) return writer.getResultBuffer(); @@ -891,13 +947,14 @@ export namespace scip { } } export class Descriptor extends pb_1.Message { + #one_of_decls: number[][] = []; constructor(data?: any[] | { name?: string; disambiguator?: string; suffix?: Descriptor.Suffix; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("name" in data && data.name != undefined) { this.name = data.name; @@ -911,19 +968,19 @@ export namespace scip { } } get name() { - return pb_1.Message.getField(this, 1) as string; + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; } set name(value: string) { pb_1.Message.setField(this, 1, value); } get disambiguator() { - return pb_1.Message.getField(this, 2) as string; + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; } set disambiguator(value: string) { pb_1.Message.setField(this, 2, value); } get suffix() { - return pb_1.Message.getField(this, 3) as Descriptor.Suffix; + return pb_1.Message.getFieldWithDefault(this, 3, Descriptor.Suffix.UnspecifiedSuffix) as Descriptor.Suffix; } set suffix(value: Descriptor.Suffix) { pb_1.Message.setField(this, 3, value); @@ -932,7 +989,7 @@ export namespace scip { name?: string; disambiguator?: string; suffix?: Descriptor.Suffix; - }) { + }): Descriptor { const message = new Descriptor({}); if (data.name != null) { message.name = data.name; @@ -966,11 +1023,11 @@ export namespace scip { serialize(w: pb_1.BinaryWriter): void; serialize(w?: pb_1.BinaryWriter): Uint8Array | void { const writer = w || new pb_1.BinaryWriter(); - if (typeof this.name === "string" && this.name.length) + if (this.name.length) writer.writeString(1, this.name); - if (typeof this.disambiguator === "string" && this.disambiguator.length) + if (this.disambiguator.length) writer.writeString(2, this.disambiguator); - if (this.suffix !== undefined) + if (this.suffix != Descriptor.Suffix.UnspecifiedSuffix) writer.writeEnum(3, this.suffix); if (!w) return writer.getResultBuffer(); @@ -1006,25 +1063,31 @@ export namespace scip { export enum Suffix { UnspecifiedSuffix = 0, Namespace = 1, + /** @deprecated*/ Package = 1, Type = 2, Term = 3, Method = 4, TypeParameter = 5, Parameter = 6, - Macro = 9, Meta = 7, - Local = 8 + Local = 8, + Macro = 9 } } export class SymbolInformation extends pb_1.Message { + #one_of_decls: number[][] = []; constructor(data?: any[] | { symbol?: string; documentation?: string[]; relationships?: Relationship[]; + kind?: SymbolInformation.Kind; + display_name?: string; + signature_documentation?: Document; + enclosing_symbol?: string; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3, 4], []); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3, 4], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("symbol" in data && data.symbol != undefined) { this.symbol = data.symbol; @@ -1035,16 +1098,28 @@ export namespace scip { if ("relationships" in data && data.relationships != undefined) { this.relationships = data.relationships; } + if ("kind" in data && data.kind != undefined) { + this.kind = data.kind; + } + if ("display_name" in data && data.display_name != undefined) { + this.display_name = data.display_name; + } + if ("signature_documentation" in data && data.signature_documentation != undefined) { + this.signature_documentation = data.signature_documentation; + } + if ("enclosing_symbol" in data && data.enclosing_symbol != undefined) { + this.enclosing_symbol = data.enclosing_symbol; + } } } get symbol() { - return pb_1.Message.getField(this, 1) as string; + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; } set symbol(value: string) { pb_1.Message.setField(this, 1, value); } get documentation() { - return pb_1.Message.getField(this, 3) as string[]; + return pb_1.Message.getFieldWithDefault(this, 3, []) as string[]; } set documentation(value: string[]) { pb_1.Message.setField(this, 3, value); @@ -1055,11 +1130,42 @@ export namespace scip { set relationships(value: Relationship[]) { pb_1.Message.setRepeatedWrapperField(this, 4, value); } + get kind() { + return pb_1.Message.getFieldWithDefault(this, 5, SymbolInformation.Kind.UnspecifiedKind) as SymbolInformation.Kind; + } + set kind(value: SymbolInformation.Kind) { + pb_1.Message.setField(this, 5, value); + } + get display_name() { + return pb_1.Message.getFieldWithDefault(this, 6, "") as string; + } + set display_name(value: string) { + pb_1.Message.setField(this, 6, value); + } + get signature_documentation() { + return pb_1.Message.getWrapperField(this, Document, 7) as Document; + } + set signature_documentation(value: Document) { + pb_1.Message.setWrapperField(this, 7, value); + } + get has_signature_documentation() { + return pb_1.Message.getField(this, 7) != null; + } + get enclosing_symbol() { + return pb_1.Message.getFieldWithDefault(this, 8, "") as string; + } + set enclosing_symbol(value: string) { + pb_1.Message.setField(this, 8, value); + } static fromObject(data: { symbol?: string; documentation?: string[]; relationships?: ReturnType[]; - }) { + kind?: SymbolInformation.Kind; + display_name?: string; + signature_documentation?: ReturnType; + enclosing_symbol?: string; + }): SymbolInformation { const message = new SymbolInformation({}); if (data.symbol != null) { message.symbol = data.symbol; @@ -1070,6 +1176,18 @@ export namespace scip { if (data.relationships != null) { message.relationships = data.relationships.map(item => Relationship.fromObject(item)); } + if (data.kind != null) { + message.kind = data.kind; + } + if (data.display_name != null) { + message.display_name = data.display_name; + } + if (data.signature_documentation != null) { + message.signature_documentation = Document.fromObject(data.signature_documentation); + } + if (data.enclosing_symbol != null) { + message.enclosing_symbol = data.enclosing_symbol; + } return message; } toObject() { @@ -1077,6 +1195,10 @@ export namespace scip { symbol?: string; documentation?: string[]; relationships?: ReturnType[]; + kind?: SymbolInformation.Kind; + display_name?: string; + signature_documentation?: ReturnType; + enclosing_symbol?: string; } = {}; if (this.symbol != null) { data.symbol = this.symbol; @@ -1087,18 +1209,38 @@ export namespace scip { if (this.relationships != null) { data.relationships = this.relationships.map((item: Relationship) => item.toObject()); } + if (this.kind != null) { + data.kind = this.kind; + } + if (this.display_name != null) { + data.display_name = this.display_name; + } + if (this.signature_documentation != null) { + data.signature_documentation = this.signature_documentation.toObject(); + } + if (this.enclosing_symbol != null) { + data.enclosing_symbol = this.enclosing_symbol; + } return data; } serialize(): Uint8Array; serialize(w: pb_1.BinaryWriter): void; serialize(w?: pb_1.BinaryWriter): Uint8Array | void { const writer = w || new pb_1.BinaryWriter(); - if (typeof this.symbol === "string" && this.symbol.length) + if (this.symbol.length) writer.writeString(1, this.symbol); - if (this.documentation !== undefined) + if (this.documentation.length) writer.writeRepeatedString(3, this.documentation); - if (this.relationships !== undefined) + if (this.relationships.length) writer.writeRepeatedMessage(4, this.relationships, (item: Relationship) => item.serialize(writer)); + if (this.kind != SymbolInformation.Kind.UnspecifiedKind) + writer.writeEnum(5, this.kind); + if (this.display_name.length) + writer.writeString(6, this.display_name); + if (this.has_signature_documentation) + writer.writeMessage(7, this.signature_documentation, () => this.signature_documentation.serialize(writer)); + if (this.enclosing_symbol.length) + writer.writeString(8, this.enclosing_symbol); if (!w) return writer.getResultBuffer(); } @@ -1117,6 +1259,18 @@ export namespace scip { case 4: reader.readMessage(message.relationships, () => pb_1.Message.addToRepeatedWrapperField(message, 4, Relationship.deserialize(reader), Relationship)); break; + case 5: + message.kind = reader.readEnum(); + break; + case 6: + message.display_name = reader.readString(); + break; + case 7: + reader.readMessage(message.signature_documentation, () => message.signature_documentation = Document.deserialize(reader)); + break; + case 8: + message.enclosing_symbol = reader.readString(); + break; default: reader.skipField(); } } @@ -1129,7 +1283,95 @@ export namespace scip { return SymbolInformation.deserialize(bytes); } } + export namespace SymbolInformation { + export enum Kind { + UnspecifiedKind = 0, + AbstractMethod = 66, + Accessor = 72, + Array = 1, + Assertion = 2, + AssociatedType = 3, + Attribute = 4, + Axiom = 5, + Boolean = 6, + Class = 7, + Constant = 8, + Constructor = 9, + Contract = 62, + DataFamily = 10, + Delegate = 73, + Enum = 11, + EnumMember = 12, + Error = 63, + Event = 13, + Fact = 14, + Field = 15, + File = 16, + Function = 17, + Getter = 18, + Grammar = 19, + Instance = 20, + Interface = 21, + Key = 22, + Lang = 23, + Lemma = 24, + Library = 64, + Macro = 25, + Method = 26, + MethodAlias = 74, + MethodReceiver = 27, + MethodSpecification = 67, + Message = 28, + Modifier = 65, + Module = 29, + Namespace = 30, + Null = 31, + Number = 32, + Object = 33, + Operator = 34, + Package = 35, + PackageObject = 36, + Parameter = 37, + ParameterLabel = 38, + Pattern = 39, + Predicate = 40, + Property = 41, + Protocol = 42, + ProtocolMethod = 68, + PureVirtualMethod = 69, + Quasiquoter = 43, + SelfParameter = 44, + Setter = 45, + Signature = 46, + SingletonClass = 75, + SingletonMethod = 76, + StaticDataMember = 77, + StaticEvent = 78, + StaticField = 79, + StaticMethod = 80, + StaticProperty = 81, + StaticVariable = 82, + String = 48, + Struct = 49, + Subscript = 47, + Tactic = 50, + Theorem = 51, + ThisParameter = 52, + Trait = 53, + TraitMethod = 70, + Type = 54, + TypeAlias = 55, + TypeClass = 56, + TypeClassMethod = 71, + TypeFamily = 57, + TypeParameter = 58, + Union = 59, + Value = 60, + Variable = 61 + } + } export class Relationship extends pb_1.Message { + #one_of_decls: number[][] = []; constructor(data?: any[] | { symbol?: string; is_reference?: boolean; @@ -1138,7 +1380,7 @@ export namespace scip { is_definition?: boolean; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("symbol" in data && data.symbol != undefined) { this.symbol = data.symbol; @@ -1158,31 +1400,31 @@ export namespace scip { } } get symbol() { - return pb_1.Message.getField(this, 1) as string; + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; } set symbol(value: string) { pb_1.Message.setField(this, 1, value); } get is_reference() { - return pb_1.Message.getField(this, 2) as boolean; + return pb_1.Message.getFieldWithDefault(this, 2, false) as boolean; } set is_reference(value: boolean) { pb_1.Message.setField(this, 2, value); } get is_implementation() { - return pb_1.Message.getField(this, 3) as boolean; + return pb_1.Message.getFieldWithDefault(this, 3, false) as boolean; } set is_implementation(value: boolean) { pb_1.Message.setField(this, 3, value); } get is_type_definition() { - return pb_1.Message.getField(this, 4) as boolean; + return pb_1.Message.getFieldWithDefault(this, 4, false) as boolean; } set is_type_definition(value: boolean) { pb_1.Message.setField(this, 4, value); } get is_definition() { - return pb_1.Message.getField(this, 5) as boolean; + return pb_1.Message.getFieldWithDefault(this, 5, false) as boolean; } set is_definition(value: boolean) { pb_1.Message.setField(this, 5, value); @@ -1193,7 +1435,7 @@ export namespace scip { is_implementation?: boolean; is_type_definition?: boolean; is_definition?: boolean; - }) { + }): Relationship { const message = new Relationship({}); if (data.symbol != null) { message.symbol = data.symbol; @@ -1241,15 +1483,15 @@ export namespace scip { serialize(w: pb_1.BinaryWriter): void; serialize(w?: pb_1.BinaryWriter): Uint8Array | void { const writer = w || new pb_1.BinaryWriter(); - if (typeof this.symbol === "string" && this.symbol.length) + if (this.symbol.length) writer.writeString(1, this.symbol); - if (this.is_reference !== undefined) + if (this.is_reference != false) writer.writeBool(2, this.is_reference); - if (this.is_implementation !== undefined) + if (this.is_implementation != false) writer.writeBool(3, this.is_implementation); - if (this.is_type_definition !== undefined) + if (this.is_type_definition != false) writer.writeBool(4, this.is_type_definition); - if (this.is_definition !== undefined) + if (this.is_definition != false) writer.writeBool(5, this.is_definition); if (!w) return writer.getResultBuffer(); @@ -1288,6 +1530,7 @@ export namespace scip { } } export class Occurrence extends pb_1.Message { + #one_of_decls: number[][] = []; constructor(data?: any[] | { range?: number[]; symbol?: string; @@ -1295,9 +1538,10 @@ export namespace scip { override_documentation?: string[]; syntax_kind?: SyntaxKind; diagnostics?: Diagnostic[]; + enclosing_range?: number[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 4, 6], []); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 4, 6, 7], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("range" in data && data.range != undefined) { this.range = data.range; @@ -1317,34 +1561,37 @@ export namespace scip { if ("diagnostics" in data && data.diagnostics != undefined) { this.diagnostics = data.diagnostics; } + if ("enclosing_range" in data && data.enclosing_range != undefined) { + this.enclosing_range = data.enclosing_range; + } } } get range() { - return pb_1.Message.getField(this, 1) as number[]; + return pb_1.Message.getFieldWithDefault(this, 1, []) as number[]; } set range(value: number[]) { pb_1.Message.setField(this, 1, value); } get symbol() { - return pb_1.Message.getField(this, 2) as string; + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; } set symbol(value: string) { pb_1.Message.setField(this, 2, value); } get symbol_roles() { - return pb_1.Message.getField(this, 3) as number; + return pb_1.Message.getFieldWithDefault(this, 3, 0) as number; } set symbol_roles(value: number) { pb_1.Message.setField(this, 3, value); } get override_documentation() { - return pb_1.Message.getField(this, 4) as string[]; + return pb_1.Message.getFieldWithDefault(this, 4, []) as string[]; } set override_documentation(value: string[]) { pb_1.Message.setField(this, 4, value); } get syntax_kind() { - return pb_1.Message.getField(this, 5) as SyntaxKind; + return pb_1.Message.getFieldWithDefault(this, 5, SyntaxKind.UnspecifiedSyntaxKind) as SyntaxKind; } set syntax_kind(value: SyntaxKind) { pb_1.Message.setField(this, 5, value); @@ -1355,6 +1602,12 @@ export namespace scip { set diagnostics(value: Diagnostic[]) { pb_1.Message.setRepeatedWrapperField(this, 6, value); } + get enclosing_range() { + return pb_1.Message.getFieldWithDefault(this, 7, []) as number[]; + } + set enclosing_range(value: number[]) { + pb_1.Message.setField(this, 7, value); + } static fromObject(data: { range?: number[]; symbol?: string; @@ -1362,7 +1615,8 @@ export namespace scip { override_documentation?: string[]; syntax_kind?: SyntaxKind; diagnostics?: ReturnType[]; - }) { + enclosing_range?: number[]; + }): Occurrence { const message = new Occurrence({}); if (data.range != null) { message.range = data.range; @@ -1382,6 +1636,9 @@ export namespace scip { if (data.diagnostics != null) { message.diagnostics = data.diagnostics.map(item => Diagnostic.fromObject(item)); } + if (data.enclosing_range != null) { + message.enclosing_range = data.enclosing_range; + } return message; } toObject() { @@ -1392,6 +1649,7 @@ export namespace scip { override_documentation?: string[]; syntax_kind?: SyntaxKind; diagnostics?: ReturnType[]; + enclosing_range?: number[]; } = {}; if (this.range != null) { data.range = this.range; @@ -1411,24 +1669,29 @@ export namespace scip { if (this.diagnostics != null) { data.diagnostics = this.diagnostics.map((item: Diagnostic) => item.toObject()); } + if (this.enclosing_range != null) { + data.enclosing_range = this.enclosing_range; + } return data; } serialize(): Uint8Array; serialize(w: pb_1.BinaryWriter): void; serialize(w?: pb_1.BinaryWriter): Uint8Array | void { const writer = w || new pb_1.BinaryWriter(); - if (this.range !== undefined) + if (this.range.length) writer.writePackedInt32(1, this.range); - if (typeof this.symbol === "string" && this.symbol.length) + if (this.symbol.length) writer.writeString(2, this.symbol); - if (this.symbol_roles !== undefined) + if (this.symbol_roles != 0) writer.writeInt32(3, this.symbol_roles); - if (this.override_documentation !== undefined) + if (this.override_documentation.length) writer.writeRepeatedString(4, this.override_documentation); - if (this.syntax_kind !== undefined) + if (this.syntax_kind != SyntaxKind.UnspecifiedSyntaxKind) writer.writeEnum(5, this.syntax_kind); - if (this.diagnostics !== undefined) + if (this.diagnostics.length) writer.writeRepeatedMessage(6, this.diagnostics, (item: Diagnostic) => item.serialize(writer)); + if (this.enclosing_range.length) + writer.writePackedInt32(7, this.enclosing_range); if (!w) return writer.getResultBuffer(); } @@ -1456,6 +1719,9 @@ export namespace scip { case 6: reader.readMessage(message.diagnostics, () => pb_1.Message.addToRepeatedWrapperField(message, 6, Diagnostic.deserialize(reader), Diagnostic)); break; + case 7: + message.enclosing_range = reader.readPackedInt32(); + break; default: reader.skipField(); } } @@ -1469,6 +1735,7 @@ export namespace scip { } } export class Diagnostic extends pb_1.Message { + #one_of_decls: number[][] = []; constructor(data?: any[] | { severity?: Severity; code?: string; @@ -1477,7 +1744,7 @@ export namespace scip { tags?: DiagnosticTag[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [5], []); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [5], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("severity" in data && data.severity != undefined) { this.severity = data.severity; @@ -1497,31 +1764,31 @@ export namespace scip { } } get severity() { - return pb_1.Message.getField(this, 1) as Severity; + return pb_1.Message.getFieldWithDefault(this, 1, Severity.UnspecifiedSeverity) as Severity; } set severity(value: Severity) { pb_1.Message.setField(this, 1, value); } get code() { - return pb_1.Message.getField(this, 2) as string; + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; } set code(value: string) { pb_1.Message.setField(this, 2, value); } get message() { - return pb_1.Message.getField(this, 3) as string; + return pb_1.Message.getFieldWithDefault(this, 3, "") as string; } set message(value: string) { pb_1.Message.setField(this, 3, value); } get source() { - return pb_1.Message.getField(this, 4) as string; + return pb_1.Message.getFieldWithDefault(this, 4, "") as string; } set source(value: string) { pb_1.Message.setField(this, 4, value); } get tags() { - return pb_1.Message.getField(this, 5) as DiagnosticTag[]; + return pb_1.Message.getFieldWithDefault(this, 5, []) as DiagnosticTag[]; } set tags(value: DiagnosticTag[]) { pb_1.Message.setField(this, 5, value); @@ -1532,7 +1799,7 @@ export namespace scip { message?: string; source?: string; tags?: DiagnosticTag[]; - }) { + }): Diagnostic { const message = new Diagnostic({}); if (data.severity != null) { message.severity = data.severity; @@ -1580,15 +1847,15 @@ export namespace scip { serialize(w: pb_1.BinaryWriter): void; serialize(w?: pb_1.BinaryWriter): Uint8Array | void { const writer = w || new pb_1.BinaryWriter(); - if (this.severity !== undefined) + if (this.severity != Severity.UnspecifiedSeverity) writer.writeEnum(1, this.severity); - if (typeof this.code === "string" && this.code.length) + if (this.code.length) writer.writeString(2, this.code); - if (typeof this.message === "string" && this.message.length) + if (this.message.length) writer.writeString(3, this.message); - if (typeof this.source === "string" && this.source.length) + if (this.source.length) writer.writeString(4, this.source); - if (this.tags !== undefined) + if (this.tags.length) writer.writePackedEnum(5, this.tags); if (!w) return writer.getResultBuffer();