From afe3694a887298066ae06da78faf4c89a861c746 Mon Sep 17 00:00:00 2001 From: CismonX Date: Thu, 4 Apr 2024 04:15:19 +0800 Subject: [PATCH] refactor: underscore-prefix kwargs so that they could be mangled by terser, producing shorter output --- src/providers/completion_item.ts | 92 ++++++++++++++++---------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/src/providers/completion_item.ts b/src/providers/completion_item.ts index cd808ef..3bec8a1 100644 --- a/src/providers/completion_item.ts +++ b/src/providers/completion_item.ts @@ -49,24 +49,24 @@ export default class CompletionItemProvider return this._completionItems ??= [ command('ampchar', 'Insert an ampersand, "&"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), command('atchar', 'Insert an at sign, "@"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), command('backslashchar', 'Insert a blackslash, "\\"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), command( 'lbracechar', 'Insert a left brace, "{"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), command('rbracechar', 'Insert a right brace, "}"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...braceCommand('abbr', 'Indicate a general abbreviation', @@ -84,7 +84,7 @@ export default class CompletionItemProvider ), command('alias', 'Defines a new command to be just like an existing one', - { snippet: true }, + { _snippet: true }, ), ...lineCommandEnum('allowcodebreaks', 'Control breaking at "-" and "_" in TeX', @@ -116,7 +116,7 @@ export default class CompletionItemProvider ), command('arrow', 'Generate a right arrow glyph, "→"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), command('asis', 'Print the table’s first column without highlighting', @@ -134,7 +134,7 @@ export default class CompletionItemProvider ), command('bullet', 'Generate a large round dot, "•"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), command('bye', 'Stop formatting', @@ -182,7 +182,7 @@ export default class CompletionItemProvider ), command('click', 'Represent a single "click" in a GUI', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...braceCommand('clicksequence', 'Represent a sequence of clicks in a GUI', @@ -206,7 +206,7 @@ export default class CompletionItemProvider ), command('comma', 'Insert a comma character, ","', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...braceCommand('command', 'Indicate a command name', @@ -224,7 +224,7 @@ export default class CompletionItemProvider ), command('copyright', 'The copyright symbol, "©"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...lineCommand('defcodeindex', 'Define a new index, print entries in an @code font', @@ -386,7 +386,7 @@ export default class CompletionItemProvider ), command('dots', 'Generate an ellipsis, "…"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...braceCommand('email', 'Indicate an electronic mail address', @@ -402,7 +402,7 @@ export default class CompletionItemProvider ), command('enddots', 'Generate an end-of-sentence ellipsis, "..."', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...blockCommand('enumerate', 'Begin a numbered list, using @item for each entry', @@ -414,12 +414,12 @@ export default class CompletionItemProvider ), command('equiv', 'Insert a glyph indicating exact equivalence, "≡"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), command('error', 'Indicate that the following text is an error message, ' + '"error→"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...braceCommand('errormsg', 'Report message as an error to standard error, ' + @@ -428,7 +428,7 @@ export default class CompletionItemProvider ), command('euro', 'Generate the Euro currency sign, "€"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...headingFootingCommand('evenfooting', 'Generate page footers that are the same for ' + @@ -457,7 +457,7 @@ export default class CompletionItemProvider ), command('expansion', 'Indicate the result of a macro expansion with a glyph, "→"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...braceCommand('file', 'Highlight the name of a file', @@ -509,14 +509,14 @@ export default class CompletionItemProvider ), command('geq', 'Generate a greater-than-or-equal sign, "≥"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...blockCommand('group', 'Disallow page breaks within following text', ), command('hashchar', 'Insert a hash character, "#"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...lineCommand('heading', 'Print an unnumbered section-like heading', @@ -683,11 +683,11 @@ export default class CompletionItemProvider ), command('LaTeX', 'Generate the LaTeX logo', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), command('leq', 'Generate a less-than-or-equal sign, "≤"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...blockCommand('lisp', 'Begin an example of Lisp code', @@ -716,7 +716,7 @@ export default class CompletionItemProvider ), command('minus', 'Generate a minus sign, "-"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...blockCommand('multitable', 'Begin a multi-column table', @@ -760,7 +760,7 @@ export default class CompletionItemProvider ), command('pagesizes', 'Change page dimensions', - { snippet: true }, + { _snippet: true }, ), ...lineCommand('paragraphindent', 'Indent paragraphs by spaces', @@ -776,15 +776,15 @@ export default class CompletionItemProvider ), command('point', 'Indicate the position of point in a buffer with "∗"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), command('pounds', 'Generate the pounds sterling currency sign, "£"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), command('print', 'Indicate printed output to the reader with "-|"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...lineCommand('printindex', 'Generate the alphabetized index for index name', @@ -801,19 +801,19 @@ export default class CompletionItemProvider ), command('quotedblleft', 'Produce quotation mark "“"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), command('quotedblright', 'Produce quotation mark "”"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), command('quoteleft', 'Produce quotation mark "‘"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), command('quoteright', 'Produce quotation mark "’"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...braceCommand('r', 'Set text in the regular roman font', @@ -834,11 +834,11 @@ export default class CompletionItemProvider ), command('registeredsymbol', 'Generate the legal symbol, "®"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), command('result', 'Indicate the result of an expression with "⇒"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...braceCommand('samp', 'Indicate a literal example of a sequence of characters', @@ -976,14 +976,14 @@ export default class CompletionItemProvider ), command('TeX', 'Generate the TeX logo', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...blockCommand('tex', 'Enter TeX completely', ), command('textdegree', 'Generate the degree symbol, "◦"', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), command('thischapter', 'Insert the number and name of the current chapter', @@ -1006,7 +1006,7 @@ export default class CompletionItemProvider command('tie', 'Generate a normal interword space at which a line break ' + 'is not allowed', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...braceCommand('tieaccent', 'Generate a tie-after accent over the two characters', @@ -1029,7 +1029,7 @@ export default class CompletionItemProvider ), command('today', 'Insert the current date', - { hasEmptyBrace: true }, + { _hasEmptyBrace: true }, ), ...lineCommand('top', 'Mark the topmost @node in the file', @@ -1213,20 +1213,20 @@ function command(name: string, detail: string, extraArgs?: { /** * Whether this command has a snippet. */ - snippet?: boolean, + _snippet?: boolean, /** * Whether this command takes no arguments and braces are required. */ - hasEmptyBrace?: boolean, + _hasEmptyBrace?: boolean, }): CompletionItem { return { label: '@' + name, kind: vscode.CompletionItemKind.Function, detail: detail, - sortText: name + (extraArgs?.snippet ? '1' : ''), + sortText: name + (extraArgs?._snippet ? '1' : ''), filterText: name, - insertText: name + (extraArgs?.hasEmptyBrace ? '{}' : ''), - snippet: extraArgs?.snippet, + insertText: name + (extraArgs?._hasEmptyBrace ? '{}' : ''), + snippet: extraArgs?._snippet, }; } @@ -1243,7 +1243,7 @@ function blockCommand( ...args: string[] ) { return [blockSnippet(name, detail, ...args), - command(name, detail, { snippet: true })]; + command(name, detail, { _snippet: true })]; } /** @@ -1260,7 +1260,7 @@ function braceCommand( ...args: string[] ) { return [braceCommandSnippet(name, detail, numArgsRequired, ...args), - command(name, detail, { snippet: true })]; + command(name, detail, { _snippet: true })]; } /** @@ -1272,7 +1272,7 @@ function braceCommand( */ function lineCommand(name: string, detail: string, ...args: string[]) { return [lineCommandSnippet(name, detail, ...args), - command(name, detail, { snippet: true })]; + command(name, detail, { _snippet: true })]; } /** @@ -1300,7 +1300,7 @@ function lineCommandEnum(name: string, detail: string, ...items: string[]) { `@${name} ${items.join('/')}`, `${name} \${1|${items.join(',')}|}`, ), - command(name, detail, { snippet: true }), + command(name, detail, { _snippet: true }), ]; } @@ -1314,7 +1314,7 @@ function headingFootingCommand(name: string, detail: string) { return [ snippet(name, name, detail, 0, `@${name} left @| center @| right`, name + ' ${1:left} @| ${2:center} @| ${3:right}'), - command(name, detail, { snippet: true }), + command(name, detail, { _snippet: true }), ]; }