diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2c9bc3ffdb..4853f7168e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,6 +34,9 @@ jobs: NODE_OPTIONS: "--max-old-space-size=4096" steps: + - name: Git config + run: git config --global core.autocrlf false + - name: Checkout repository uses: actions/checkout@v4 diff --git a/data/scopeSupportFacetInfos.md b/data/scopeSupportFacetInfos.md new file mode 100644 index 0000000000..b24e051327 --- /dev/null +++ b/data/scopeSupportFacetInfos.md @@ -0,0 +1,408 @@ +### anonymousFunction + +- `anonymousFunction` An anonymous function, eg a lambda function, an arrow function, etc + +### argumentOrParameter + +- `argument.actual.constructor.iteration` Iteration scope for arguments in a constructor call: the argument list. The domain should be the entire constructor call. +- `argument.actual.constructor.multiLine` A multi line argument in a constructor call. Insertion delimiter should include new line. +- `argument.actual.constructor.singleLine` A single line argument in a constructor call +- `argument.actual.iteration` Iteration scope for arguments in a function call: the argument list. The domain should be the entire function call. +- `argument.actual.method.iteration` Iteration scope for arguments in a method call: the argument list. The domain should be the entire method call. +- `argument.actual.method.multiLine` A multi line argument in a method call. Insertion delimiter should include new line. +- `argument.actual.method.singleLine` A single line argument in a method call +- `argument.actual.multiLine` A multiline argument in a function call. Insertion delimiter should include new line. +- `argument.actual.singleLine` A single line argument in a function call +- `argument.catch` A parameter in a catch clause +- `argument.formal.constructor.iteration` Iteration scope for formal parameters in a constructor declaration: the parameter list. The domain should be the entire constructor. +- `argument.formal.constructor.multiLine` A multi line parameter in a constructor declaration. Insertion delimiter should include new line. +- `argument.formal.constructor.singleLine` A single line parameter in a constructor declaration +- `argument.formal.iteration` Iteration scope for formal parameters in a function declaration: the parameters list. The domain should be the entire function. +- `argument.formal.lambda.iteration` Iteration scope for formal parameters in a lambda declaration: the parameter list. The domain should be the entire lambda. +- `argument.formal.lambda.multiLine` A multi line parameter in a lambda declaration. Insertion delimiter should include new line. +- `argument.formal.lambda.singleLine` A single line parameter in a lambda declaration +- `argument.formal.method.iteration` Iteration scope for formal parameters in a method declaration: the parameter list. The domain should be the entire method. +- `argument.formal.method.multiLine` A multi line parameter in a class method declaration. Insertion delimiter should include new line. +- `argument.formal.method.singleLine` A single line parameter in a class method declaration +- `argument.formal.multiLine` A multi line parameter in a function declaration. Insertion delimiter should include new line. +- `argument.formal.singleLine` A single line parameter in a function declaration + +### argumentList + +- `argumentList.actual.constructor.empty` An empty list of arguments in a constructor call. Insertion delimiter should be empty. +- `argumentList.actual.constructor.multiLine` A multi line list of arguments in a constructor call. Insertion delimiter should include new line. +- `argumentList.actual.constructor.singleLine` A single line list of arguments in a constructor call +- `argumentList.actual.empty` An empty list of arguments in a function call. Insertion delimiter should be empty. +- `argumentList.actual.method.empty` An empty list of arguments in a method call. Insertion delimiter should be empty. +- `argumentList.actual.method.multiLine` A multi line list of arguments in a method call. Insertion delimiter should include new line. +- `argumentList.actual.method.singleLine` A single line list of arguments in a method call +- `argumentList.actual.multiLine` A multi line list of arguments in a function call. Insertion delimiter should include new line. +- `argumentList.actual.singleLine` A single line list of arguments in a function call +- `argumentList.formal.constructor.empty` An empty list of parameters in a constructor declaration. Insertion delimiter should be empty. +- `argumentList.formal.constructor.multiLine` A multi line list of parameters in a constructor declaration. Insertion delimiter should include new line. +- `argumentList.formal.constructor.singleLine` A single line list of parameters in a constructor declaration +- `argumentList.formal.empty` An empty list of parameters in a function declaration. Insertion delimiter should be empty. +- `argumentList.formal.lambda.empty` An empty list of parameters in a lambda declaration. Insertion delimiter should be empty. +- `argumentList.formal.lambda.multiLine` A multi line list of parameters in a lambda declaration. Insertion delimiter should include new line. +- `argumentList.formal.lambda.singleLine` A single line list of parameters in a lambda declaration +- `argumentList.formal.method.empty` An empty list of parameters in a class method declaration. Insertion delimiter should be empty. +- `argumentList.formal.method.multiLine` A multi line list of parameters in a class method declaration. Insertion delimiter should include new line. +- `argumentList.formal.method.singleLine` A single line list of parameters in a class method declaration +- `argumentList.formal.multiLine` A multi line list of parameters in a function declaration. Insertion delimiter should include new line. +- `argumentList.formal.singleLine` A single line list of parameters in a function declaration + +### attribute + +- `attribute` A attribute, eg of a html element or a C++ attribute + +### boundedNonWhitespaceSequence + +- `boundedNonWhitespaceSequence` A sequence of non-whitespace characters bounded by matching pair +- `boundedNonWhitespaceSequence.iteration` Iteration scope for bounded non-whitespace sequence + +### boundedParagraph + +- `boundedParagraph` A single paragraph(contiguous block of lines) in the document bounded by matching pair +- `boundedParagraph.iteration` Iteration scope for bounded paragraph + +### branch + +- `branch.if` An if branch +- `branch.if.elif.else` An if-elif-else branch. The removal range for the if branch should include the trailing `else` keyword. +- `branch.if.else` An if-else branch +- `branch.if.iteration` Iteration scope for if/elif/else branches: the if-else statement. +- `branch.loop` A for / while loop branch. For most languages this is not supported, but eg in Python you can have an else branch for a loop. +- `branch.loop.iteration` Iteration scope for loop branches: the loop statement. +- `branch.switchCase` A case/default branch in a switch statement +- `branch.switchCase.iteration` Iteration scope for switch branches: the switch statement body. +- `branch.ternary` A branch in a ternary expression +- `branch.ternary.iteration` Iteration scope for ternary expression branches: the ternary expression. +- `branch.try` A try/catch/finally branch +- `branch.try.iteration` Iteration scope for try/catch/finally branches: the try-catch statement. + +### character + +- `character` A single character in the document + +### class + +- `class` A class in an object-oriented language +- `class.iteration.block` Iteration scope for classes: statement blocks (body of functions/if-statements/for-loops/etc). +- `class.iteration.document` Iteration scope for classes: the entire document including leading and trailing empty lines. + +### className + +- `className` The name of a class +- `className.iteration.block` Iteration scope for class names: statement blocks (body of functions/if-statements/for-loops/etc). +- `className.iteration.document` Iteration scope for class names: the entire document including leading and trailing empty lines. + +### collectionItem + +- `collectionItem.textual` A text based collection item +- `collectionItem.textual.iteration` Iteration scope for text based collection items +- `collectionItem.unenclosed` An item in a comma-separated list without enclosing delimiters. This could be multi-variable declarations, import statements, etc. +- `collectionItem.unenclosed.iteration` Iteration scope for items in a comma-separated list without enclosing delimiters + +### command + +- `command` A command, for example Talon spoken command or bash + +### comment + +- `comment.block` A block comment +- `comment.line` A line comment + +### condition + +- `condition.doWhile` A condition in a do while loop +- `condition.for` A condition in a for loop +- `condition.if` A condition in an if statement +- `condition.switchCase` A condition in a switch statement +- `condition.switchCase.iteration` Iteration scope for conditions in a switch statement: the switch statement body. +- `condition.ternary` A condition in a ternary expression +- `condition.while` A condition in a while loop + +### disqualifyDelimiter + +- `disqualifyDelimiter` Used to disqualify a token from being treated as a surrounding pair delimiter. This will usually be operators containing `>` or `<`, eg `<`, `<=`, `->`, etc + +### document + +- `document` The entire document + +### xmlElement + +- `element` A xml/html element. Also used for LaTeX environments + +### xmlEndTag + +- `endTag` The end tag of a xml element + +### environment + +- `environment` An environment, eg in LaTeX + +### private.fieldAccess + +- `fieldAccess` A field access + +### functionCall + +- `functionCall` A function call +- `functionCall.constructor` A constructor call + +### functionCallee + +- `functionCallee` The function being called in a function call +- `functionCallee.constructor` The class being constructed in a class instantiation, including the `new` keyword + +### functionName + +- `functionName` The name of a function +- `functionName.constructor` The name of a constructor in a class +- `functionName.iteration.block` Iteration scope for function names: statement blocks (body of functions/if-statements/for-loops/etc). +- `functionName.iteration.document` Iteration scope for function names: the entire document including leading and trailing empty lines. +- `functionName.method` The name of a method in a class +- `functionName.method.iteration.class` Iteration scope for method names: class bodies. + +### identifier + +- `identifier` A single alphanumeric identifier in the document + +### ifStatement + +- `ifStatement` An if statement + +### interior + +- `interior.cell` The body of a code cell in markdown +- `interior.class` The body of a class +- `interior.command` The body of a command, eg Talon spoken command +- `interior.constructor` The body of a constructor declaration +- `interior.doWhile` The body of a do-while loop +- `interior.element` The interior/children of a XML element +- `interior.for` The body of a for loop +- `interior.foreach` The body of a for-each loop +- `interior.function` The body of a function declaration +- `interior.if` The body of an if/elif/else branch +- `interior.interface` The body of a interface +- `interior.lambda.block` The block body of a lambda/anonymous function +- `interior.lambda.expression` The expression body of a lambda/anonymous function +- `interior.method` The body of a method declaration +- `interior.namespace` the body of a namespace statement +- `interior.resource` the body of a 'with' / 'use' / 'using' statement +- `interior.static` the body of a static statement +- `interior.surroundingPair` The interior scope of a surrounding pair +- `interior.switch` The body of a switch statement +- `interior.switchCase` The body of a switch case branch +- `interior.ternary` The body of a ternary condition/branch +- `interior.try` The body of a try/catch/finally branch +- `interior.while` The body of a while loop + +### collectionKey + +- `key.attribute` Key (LHS) of an attribute eg in a xml element +- `key.mapPair` Key (LHS) of a key-value pair of a map +- `key.mapPair.iteration` Iteration scope for keys of key-value pairs in a map: should be between the braces. + +### line + +- `line` A single line in the document + +### list + +- `list` A list/array + +### map + +- `map` A map/dictionary + +### name + +- `name.argument.actual` Name of a (keyword) argument in a function call +- `name.argument.actual.iteration` Iteration scope for names of the arguments in a function call: the argument list. The domain should be the whole function call. +- `name.argument.catch` Name of a parameter in a catch clause +- `name.argument.formal` Name of a parameter in a function declaration +- `name.argument.formal.constructor` The name of a parameter in a constructor declaration +- `name.argument.formal.constructor.iteration` Iteration scope for names of formal parameters in a constructor declaration: the parameters list. The domain should be the entire constructor. +- `name.argument.formal.iteration` Iteration scope for names of formal parameters in a function declaration: the parameters list. The domain should be the entire function. +- `name.argument.formal.method` Name of a parameter in a class method declaration +- `name.argument.formal.method.iteration` Iteration scope for names of formal parameters in a method declaration: the parameters list. The domain should be the entire method. +- `name.assignment` Name (LHS) of an assignment +- `name.assignment.pattern` LHS of an assignment with pattern destructuring +- `name.class` Name of a class +- `name.command` LHS of a command, eg Talon spoken command or bash +- `name.constructor` Name of a constructor +- `name.field.class` Name (LHS) of a field in a class +- `name.field.interface` Name (LHS) of a field in a interface +- `name.foreach` Iteration variable name in a for each loop +- `name.function` Name of a function +- `name.interface` Name of a interface +- `name.iteration.block` Iteration scope for names: statement blocks (body of functions/if-statements/for-loops/etc). +- `name.iteration.class` Iteration scope for names: class bodies. +- `name.iteration.document` Iteration scope for names: the entire document including leading and trailing empty lines. +- `name.iteration.interface` Iteration scope for names: interface bodies. +- `name.method` Name of a class method +- `name.namespace` Name of a namespace +- `name.resource` Name in a 'with' / 'use' / 'using' statement +- `name.resource.iteration` Iteration scope for names in a 'with' / 'use' / 'using' statement: the resource list. The domain should be the entire statement. +- `name.variable` Name (LHS) of a variable declaration +- `name.variable.pattern` Name (LHS) of a variable declaration with pattern destructuring + +### namedFunction + +- `namedFunction` A named function declaration +- `namedFunction.constructor` A constructor declaration in a class +- `namedFunction.iteration.block` Iteration scope for named functions: statement blocks (body of functions/if-statements/for-loops/etc). +- `namedFunction.iteration.document` Iteration scope for named functions: the entire document including leading and trailing empty lines. +- `namedFunction.method` A named method declaration in a class +- `namedFunction.method.iteration.class` Iteration scope for named functions: class bodies. + +### nonWhitespaceSequence + +- `nonWhitespaceSequence` A sequence of non-whitespace characters + +### notebookCell + +- `notebookCell` A cell in a notebook or a markdown code block + +### pairDelimiter + +- `pairDelimiter` A pair delimiter, eg parentheses, brackets, braces, quotes, etc + +### paragraph + +- `paragraph` A single paragraph(contiguous block of lines) in the document + +### regularExpression + +- `regularExpression` A regular expression + +### section + +- `section` A document section +- `section.iteration.document` Iteration scope for sections: the entire document including leading and trailing empty lines. +- `section.iteration.parent` Iteration scope for sections: the parent section. + +### selector + +- `selector` A selector in a css rule set + +### sentence + +- `sentence` A single sentence in the document + +### xmlStartTag + +- `startTag` The start tag of a xml element + +### statement + +- `statement` A statement, eg assignment, for loop, etc +- `statement.class` A class declaration +- `statement.field.class` A field declaration in a class +- `statement.field.interface` A field declaration in a interface +- `statement.interface` A interface declaration +- `statement.iteration.block` Iteration scope for statements: statement blocks (body of functions/if-statements/for-loops/etc). +- `statement.iteration.class` Iteration scope for statements: class bodies. +- `statement.iteration.document` Iteration scope for statements: the entire document including leading and trailing empty lines. +- `statement.iteration.interface` Iteration scope for statements: interface bodies. + +### string + +- `string.multiLine` A multi-line string +- `string.singleLine` A single-line string + +### surroundingPair + +- `surroundingPair` A delimiter pair, such as parentheses or quotes +- `surroundingPair.iteration` The iteration scope for delimiter pairs + +### private.switchStatementSubject + +- `switchStatementSubject` The subject of a switch statement + +### xmlBothTags + +- `tags` Both tags in a xml element + +### textFragment + +- `textFragment.comment.block` Text fragment consisting of a block comment +- `textFragment.comment.line` Text fragment consisting of a line comment +- `textFragment.element` Text fragment consisting of a xml element interior +- `textFragment.string.multiLine` Text fragment consisting of a multi-line string +- `textFragment.string.singleLine` Text fragment consisting of a single-line string + +### token + +- `token` A single token in the document + +### type + +- `type.alias` A type alias declaration +- `type.argument.catch` Type of parameter in a catch clause +- `type.argument.formal` Type of formal parameter in a function declaration +- `type.argument.formal.constructor` Type of formal parameter in a constructor declaration +- `type.argument.formal.constructor.iteration` Iteration scope for types of formal parameters in a constructor declaration: the parameters list. The domain should be the entire constructor. +- `type.argument.formal.iteration` Iteration scope for types of formal parameters in a function declaration: the parameters list. The domain should be the entire function. +- `type.argument.formal.method` Type of formal parameter in a class method declaration +- `type.argument.formal.method.iteration` Iteration scope for types of formal parameters in a method declaration: the parameters list. The domain should be the entire method. +- `type.cast` A type cast +- `type.class` A class declaration +- `type.enum` An enum declaration +- `type.field.class` Type of field in a class +- `type.field.interface` Type of field in a interface +- `type.foreach` Type of variable in a for each loop +- `type.interface` An interface declaration +- `type.iteration.block` Iteration scope for types: statement blocks (body of functions/if-statements/for-loops/etc). +- `type.iteration.class` Iteration scope for types: class bodies. +- `type.iteration.document` Iteration scope for types: the entire document including leading and trailing empty lines. +- `type.iteration.interface` Iteration scope for types: interface bodies. +- `type.resource` Type in a 'with' / 'use' / 'using' statement +- `type.resource.iteration` Iteration scope for types in a 'with' / 'use' / 'using' statement: the resource list. The domain should be the entire statement. +- `type.return` Type of return value in a function declaration +- `type.typeArgument` Type argument to a generic / parametrized type +- `type.typeArgument.iteration` Iteration scope for type arguments to a generic / parametrized type: the type argument list. +- `type.variable` Type of variable in a variable declaration + +### unit + +- `unit` A unit in a css rule set + +### url + +- `url` A url + +### value + +- `value.argument.actual` The value of a (keyword) argument in a function call +- `value.argument.actual.iteration` Iteration scope for values of arguments in a function call: the arguments list. The domain should be the entire function call. +- `value.argument.formal` The value of a (keyword) argument in a function declaration +- `value.argument.formal.constructor` The value of a parameter in a constructor declaration +- `value.argument.formal.constructor.iteration` Iteration scope for values of formal parameters in a constructor declaration: the parameters list. The domain should be the entire constructor. +- `value.argument.formal.iteration` Iteration scope for values of formal parameters in a function declaration: the parameters list. The domain should be the entire function. +- `value.argument.formal.method` The value of a parameter in a class method declaration +- `value.argument.formal.method.iteration` Iteration scope for values of formal parameters in a method declaration: the parameters list. The domain should be the entire method. +- `value.assignment` Value (RHS) of an assignment +- `value.attribute` Value (RHS) of an attribute eg in a xml element +- `value.command` Value (RHS) of an command, eg Talon spoken command +- `value.field.class` Value (RHS) of a field in a class +- `value.foreach` Iterable in a for each loop +- `value.iteration.block` Iteration scope for values: statement blocks (body of functions/if-statements/for-loops/etc). +- `value.iteration.class` Iteration scope for values: class bodies. +- `value.iteration.document` Iteration scope for values: the entire document including leading and trailing empty lines. +- `value.mapPair` Value (RHS) of a key-value pair in a map +- `value.mapPair.iteration` Iteration scope for values of key-value pairs in a map: should be between the braces. +- `value.resource` Value of a 'with' / 'use' / 'using' statement +- `value.resource.iteration` Iteration scope for values in a 'with' / 'use' / 'using' statement: the resource list. The domain should be the entire statement. +- `value.return` Return value of a function +- `value.return.lambda` Implicit return value from a lambda +- `value.typeAlias` Value of a type alias declaration +- `value.variable` Value (RHS) of a variable declaration +- `value.variable.pattern` Value (RHS) of a variable declaration with pattern destructuring +- `value.yield` Value of a yield statement + +### word + +- `word` A single word in a token diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index 488f87ce3f..45fd51b454 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -109,6 +109,7 @@ export * from "./util/range"; export * from "./util/regex"; export * from "./util/selectionsEqual"; export * from "./util/serializedMarksToTokenHats"; +export * from "./util/serializeScopeType"; export * from "./util/splitKey"; export * from "./util/toPlainObject"; export * from "./util/type"; diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index 23ed91a07c..d3dddc82c9 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts @@ -1,3 +1,4 @@ +import type { SimpleScopeTypeType } from "../types/command/PartialTargetDescriptor.types"; import type { ScopeSupportFacet, ScopeSupportFacetInfo, @@ -42,19 +43,12 @@ export const scopeSupportFacetInfos: Record< description: "A document section", scopeType: "section", }, - "section.iteration.document": { - description: - "Iteration scope for a document section. This is the entire document.", - scopeType: "section", - isIteration: true, - }, - "section.iteration.parent": { - description: - "Iteration scope for a document section. This is the parent section.", - scopeType: "section", - isIteration: true, - }, - + "section.iteration.document": documentIter("section", "sections"), + "section.iteration.parent": iteration( + "section", + "sections", + "the parent section", + ), list: { description: "A list/array", scopeType: "list", @@ -100,58 +94,23 @@ export const scopeSupportFacetInfos: Record< description: "A field declaration in a interface", scopeType: "statement", }, - "statement.iteration.document": { - description: "Iteration scope for statements. The entire document.", - scopeType: "statement", - isIteration: true, - }, - "statement.iteration.class": { - description: "Iteration scope for types; class body", - scopeType: "statement", - isIteration: true, - }, - "statement.iteration.interface": { - description: "Iteration scope for types; interface body", - scopeType: "statement", - isIteration: true, - }, - "statement.iteration.block": { - description: - "Iteration scope for statements. Statement blocks(body of functions/if statements/for loops/etc).", - scopeType: "statement", - isIteration: true, - }, + "statement.iteration.document": documentIter("statement", "statements"), + "statement.iteration.class": classIter("statement", "statements"), + "statement.iteration.interface": interfaceIter("statement", "statements"), + "statement.iteration.block": blockIter("statement", "statements"), class: { description: "A class in an object-oriented language", scopeType: "class", }, - "class.iteration.document": { - description: "Iteration scope for classes. The entire document.", - scopeType: "class", - isIteration: true, - }, - "class.iteration.block": { - description: - "Iteration scope for classes. Statement blocks(body of functions/if statements/for loops/etc).", - scopeType: "class", - isIteration: true, - }, + "class.iteration.document": documentIter("class", "classes"), + "class.iteration.block": blockIter("class", "classes"), className: { description: "The name of a class", scopeType: "className", }, - "className.iteration.document": { - description: "Iteration scope for class names. The entire document.", - scopeType: "className", - isIteration: true, - }, - "className.iteration.block": { - description: - "Iteration scope for class names. Statement blocks(body of functions/if statements/for loops/etc).", - scopeType: "className", - isIteration: true, - }, + "className.iteration.document": documentIter("className", "class names"), + "className.iteration.block": blockIter("className", "class names"), namedFunction: { description: "A named function declaration", @@ -161,26 +120,22 @@ export const scopeSupportFacetInfos: Record< description: "A named method declaration in a class", scopeType: "namedFunction", }, - "namedFunction.method.iteration.class": { - description: "Iteration scope for named functions: class bodies", - scopeType: "namedFunction", - isIteration: true, - }, + "namedFunction.method.iteration.class": classIter( + "namedFunction", + "named functions", + ), "namedFunction.constructor": { description: "A constructor declaration in a class", scopeType: "namedFunction", }, - "namedFunction.iteration.block": { - description: - "Iteration scope for named functions. Statement blocks(body of functions/if statements/for loops/etc).", - scopeType: "namedFunction", - isIteration: true, - }, - "namedFunction.iteration.document": { - description: "Iteration scope for named functions: the entire document", - scopeType: "namedFunction", - isIteration: true, - }, + "namedFunction.iteration.block": blockIter( + "namedFunction", + "named functions", + ), + "namedFunction.iteration.document": documentIter( + "namedFunction", + "named functions", + ), anonymousFunction: { description: "An anonymous function, eg a lambda function, an arrow function, etc", @@ -194,26 +149,19 @@ export const scopeSupportFacetInfos: Record< description: "The name of a method in a class", scopeType: "functionName", }, - "functionName.method.iteration.class": { - description: "Iteration scope for method names: class bodies", - scopeType: "functionName", - isIteration: true, - }, + "functionName.method.iteration.class": classIter( + "functionName", + "method names", + ), "functionName.constructor": { description: "The name of a constructor in a class", scopeType: "functionName", }, - "functionName.iteration.block": { - description: - "Iteration scope for function names. Statement blocks(body of functions/if statements/for loops/etc).", - scopeType: "functionName", - isIteration: true, - }, - "functionName.iteration.document": { - description: "Iteration scope for function names: the entire document", - scopeType: "functionName", - isIteration: true, - }, + "functionName.iteration.block": blockIter("functionName", "function names"), + "functionName.iteration.document": documentIter( + "functionName", + "function names", + ), functionCall: { description: "A function call", @@ -234,232 +182,210 @@ export const scopeSupportFacetInfos: Record< }, "argument.actual.singleLine": { - description: "A single line argument/parameter in a function call", + description: "A single line argument in a function call", scopeType: "argumentOrParameter", - insertionDelimiterHint: '", "', }, "argument.actual.multiLine": { - description: "A multiline argument/parameter in a function call", - scopeType: "argumentOrParameter", - insertionDelimiterHint: '",\n"', - }, - "argument.actual.iteration": { description: - "Iteration scope of arguments in a function call, should be inside the parens of the argument list", + "A multiline argument in a function call. Insertion delimiter should include new line.", scopeType: "argumentOrParameter", - isIteration: true, }, + "argument.actual.iteration": iteration( + "argumentOrParameter", + "arguments in a function call", + "the argument list. The domain should be the entire function call", + ), "argument.actual.method.singleLine": { - description: "A single line argument/parameter in a method call", + description: "A single line argument in a method call", scopeType: "argumentOrParameter", - insertionDelimiterHint: '", "', }, "argument.actual.method.multiLine": { - description: "A multi line argument/parameter in a method call", - scopeType: "argumentOrParameter", - insertionDelimiterHint: '",\n"', - }, - "argument.actual.method.iteration": { description: - "Iteration scope of arguments in a method call, should be inside the parens of the argument list", + "A multi line argument in a method call. Insertion delimiter should include new line.", scopeType: "argumentOrParameter", - isIteration: true, }, + "argument.actual.method.iteration": iteration( + "argumentOrParameter", + "arguments in a method call", + "the argument list. The domain should be the entire method call", + ), "argument.actual.constructor.singleLine": { - description: "A single line argument/parameter in a constructor call", + description: "A single line argument in a constructor call", scopeType: "argumentOrParameter", - insertionDelimiterHint: '", "', }, "argument.actual.constructor.multiLine": { - description: "A multi line argument/parameter in a constructor call", - scopeType: "argumentOrParameter", - insertionDelimiterHint: '",\n"', - }, - "argument.actual.constructor.iteration": { description: - "Iteration scope of arguments in a constructor call, should be inside the parens of the argument list", + "A multi line argument in a constructor call. Insertion delimiter should include new line.", scopeType: "argumentOrParameter", - isIteration: true, }, + "argument.actual.constructor.iteration": iteration( + "argumentOrParameter", + "arguments in a constructor call", + "the argument list. The domain should be the entire constructor call", + ), "argument.formal.singleLine": { description: "A single line parameter in a function declaration", scopeType: "argumentOrParameter", - insertionDelimiterHint: '", "', }, "argument.formal.multiLine": { - description: "A multi line parameter in a function declaration", - scopeType: "argumentOrParameter", - insertionDelimiterHint: '",\n"', - }, - "argument.formal.iteration": { description: - "Iteration scope of the formal parameters of a function declaration; should be the whole parameter list. The domain should be the entire function.", + "A multi line parameter in a function declaration. Insertion delimiter should include new line.", scopeType: "argumentOrParameter", - isIteration: true, }, + "argument.formal.iteration": iteration( + "argumentOrParameter", + "formal parameters in a function declaration", + "the parameters list. The domain should be the entire function", + ), "argument.formal.method.singleLine": { description: "A single line parameter in a class method declaration", scopeType: "argumentOrParameter", - insertionDelimiterHint: '", "', }, "argument.formal.method.multiLine": { - description: "A multi line parameter in a class method declaration", - scopeType: "argumentOrParameter", - insertionDelimiterHint: '",\n"', - }, - "argument.formal.method.iteration": { description: - "Iteration scope of the formal parameters of a class method declaration; should be the whole parameter list. The domain should be the entire function.", + "A multi line parameter in a class method declaration. Insertion delimiter should include new line.", scopeType: "argumentOrParameter", - isIteration: true, }, + "argument.formal.method.iteration": iteration( + "argumentOrParameter", + "formal parameters in a method declaration", + "the parameter list. The domain should be the entire method", + ), + "argument.formal.constructor.singleLine": { description: "A single line parameter in a constructor declaration", scopeType: "argumentOrParameter", - insertionDelimiterHint: '", "', }, "argument.formal.constructor.multiLine": { - description: "A multi line parameter in a constructor declaration", - scopeType: "argumentOrParameter", - insertionDelimiterHint: '",\n"', - }, - "argument.formal.constructor.iteration": { description: - "Iteration scope of the formal parameters of a constructor declaration; should be the whole parameter list. The domain should be the entire function.", + "A multi line parameter in a constructor declaration. Insertion delimiter should include new line.", scopeType: "argumentOrParameter", - isIteration: true, }, + "argument.formal.constructor.iteration": iteration( + "argumentOrParameter", + "formal parameters in a constructor declaration", + "the parameter list. The domain should be the entire constructor", + ), "argument.formal.lambda.singleLine": { description: "A single line parameter in a lambda declaration", scopeType: "argumentOrParameter", - insertionDelimiterHint: '", "', }, "argument.formal.lambda.multiLine": { - description: "A multi line parameter in a lambda declaration", - scopeType: "argumentOrParameter", - insertionDelimiterHint: '",\n"', - }, - "argument.formal.lambda.iteration": { description: - "Iteration scope of the formal parameters of a lambda declaration; should be the whole parameter list. The domain should be the entire function.", + "A multi line parameter in a lambda declaration. Insertion delimiter should include new line.", scopeType: "argumentOrParameter", - isIteration: true, }, + "argument.formal.lambda.iteration": iteration( + "argumentOrParameter", + "formal parameters in a lambda declaration", + "the parameter list. The domain should be the entire lambda", + ), "argument.catch": { description: "A parameter in a catch clause", scopeType: "argumentOrParameter", - insertionDelimiterHint: '", "', }, "argumentList.actual.empty": { - description: "An empty list of arguments in a function call", + description: + "An empty list of arguments in a function call. Insertion delimiter should be empty.", scopeType: "argumentList", - insertionDelimiterHint: '""', }, "argumentList.actual.singleLine": { description: "A single line list of arguments in a function call", scopeType: "argumentList", - insertionDelimiterHint: '", "', }, "argumentList.actual.multiLine": { - description: "A multi line list of arguments in a function call", + description: + "A multi line list of arguments in a function call. Insertion delimiter should include new line.", scopeType: "argumentList", - insertionDelimiterHint: '",\n"', }, "argumentList.actual.method.empty": { - description: "An empty list of arguments in a method call", + description: + "An empty list of arguments in a method call. Insertion delimiter should be empty.", scopeType: "argumentList", - insertionDelimiterHint: '""', }, "argumentList.actual.method.singleLine": { description: "A single line list of arguments in a method call", scopeType: "argumentList", - insertionDelimiterHint: '", "', }, "argumentList.actual.method.multiLine": { - description: "A multi line list of arguments in a method call", + description: + "A multi line list of arguments in a method call. Insertion delimiter should include new line.", scopeType: "argumentList", - insertionDelimiterHint: '",\n"', }, "argumentList.actual.constructor.empty": { - description: "An empty list of arguments in a constructor call", + description: + "An empty list of arguments in a constructor call. Insertion delimiter should be empty.", scopeType: "argumentList", - insertionDelimiterHint: '""', }, "argumentList.actual.constructor.singleLine": { description: "A single line list of arguments in a constructor call", scopeType: "argumentList", - insertionDelimiterHint: '", "', }, "argumentList.actual.constructor.multiLine": { - description: "A multi line list of arguments in a constructor call", + description: + "A multi line list of arguments in a constructor call. Insertion delimiter should include new line.", scopeType: "argumentList", - insertionDelimiterHint: '",\n"', }, "argumentList.formal.empty": { - description: "An empty list of parameters in a function declaration", + description: + "An empty list of parameters in a function declaration. Insertion delimiter should be empty.", scopeType: "argumentList", - insertionDelimiterHint: '""', }, "argumentList.formal.singleLine": { description: "A single line list of parameters in a function declaration", scopeType: "argumentList", - insertionDelimiterHint: '", "', }, "argumentList.formal.multiLine": { - description: "A multi line list of parameters in a function declaration", + description: + "A multi line list of parameters in a function declaration. Insertion delimiter should include new line.", scopeType: "argumentList", - insertionDelimiterHint: '",\n"', }, "argumentList.formal.lambda.empty": { - description: "An empty list of parameters in a lambda declaration", + description: + "An empty list of parameters in a lambda declaration. Insertion delimiter should be empty.", scopeType: "argumentList", - insertionDelimiterHint: '""', }, "argumentList.formal.lambda.singleLine": { description: "A single line list of parameters in a lambda declaration", scopeType: "argumentList", - insertionDelimiterHint: '", "', }, "argumentList.formal.lambda.multiLine": { - description: "A multi line list of parameters in a lambda declaration", + description: + "A multi line list of parameters in a lambda declaration. Insertion delimiter should include new line.", scopeType: "argumentList", - insertionDelimiterHint: '",\n"', }, "argumentList.formal.method.empty": { - description: "An empty list of parameters in a class method declaration", + description: + "An empty list of parameters in a class method declaration. Insertion delimiter should be empty.", scopeType: "argumentList", - insertionDelimiterHint: '""', }, "argumentList.formal.method.singleLine": { description: "A single line list of parameters in a class method declaration", scopeType: "argumentList", - insertionDelimiterHint: '", "', }, "argumentList.formal.method.multiLine": { description: - "A multi line list of parameters in a class method declaration", + "A multi line list of parameters in a class method declaration. Insertion delimiter should include new line.", scopeType: "argumentList", - insertionDelimiterHint: '",\n"', }, "argumentList.formal.constructor.empty": { - description: "An empty list of parameters in a constructor declaration", + description: + "An empty list of parameters in a constructor declaration. Insertion delimiter should be empty.", scopeType: "argumentList", - insertionDelimiterHint: '""', }, "argumentList.formal.constructor.singleLine": { description: "A single line list of parameters in a constructor declaration", scopeType: "argumentList", - insertionDelimiterHint: '", "', }, "argumentList.formal.constructor.multiLine": { - description: "A multi line list of parameters in a constructor declaration", + description: + "A multi line list of parameters in a constructor declaration. Insertion delimiter should include new line.", scopeType: "argumentList", - insertionDelimiterHint: '",\n"', }, "comment.line": { @@ -525,64 +451,57 @@ export const scopeSupportFacetInfos: Record< description: "An if-else branch", scopeType: "branch", }, - "branch.if.iteration": { - description: - "Iteration scope for if/elif/else branch; should be the entire if-else statement", - scopeType: "branch", - isIteration: true, - }, + "branch.if.iteration": iteration( + "branch", + "if/elif/else branches", + "the if-else statement", + ), "branch.loop": { description: "A for / while loop branch. For most languages this is not supported, but eg in Python you can have an else branch for a loop.", scopeType: "branch", }, - "branch.loop.iteration": { - description: - "Iteration scope for loop branch; should be the entire loop statement", - scopeType: "branch", - isIteration: true, - }, + "branch.loop.iteration": iteration( + "branch", + "loop branches", + "the loop statement", + ), "branch.try": { description: "A try/catch/finally branch", scopeType: "branch", }, - "branch.try.iteration": { - description: - "Iteration scope for try/catch/finally branch; should be the entire try-catch statement", - scopeType: "branch", - isIteration: true, - }, + "branch.try.iteration": iteration( + "branch", + "try/catch/finally branches", + "the try-catch statement", + ), "branch.switchCase": { - description: "A case/default branch in a switch/match statement", + description: "A case/default branch in a switch statement", scopeType: "branch", }, - "branch.switchCase.iteration": { - description: - "Iteration scope for branches in a switch/match statement; should be the switch statement body", - scopeType: "branch", - isIteration: true, - }, + "branch.switchCase.iteration": iteration( + "branch", + "switch branches", + "the switch statement body", + ), "branch.ternary": { description: "A branch in a ternary expression", scopeType: "branch", }, - "branch.ternary.iteration": { - description: - "Iteration scope for branches in a ternary expression; should be the entire expression", - scopeType: "branch", - isIteration: true, - }, + "branch.ternary.iteration": iteration( + "branch", + "ternary expression branches", + "the ternary expression", + ), "collectionItem.unenclosed": { description: "An item in a comma-separated list without enclosing delimiters. This could be multi-variable declarations, import statements, etc.", scopeType: "collectionItem", }, - "collectionItem.unenclosed.iteration": { - description: - "Iteration scope for items in a comma-separated list without enclosing delimiters", - scopeType: "collectionItem", - isIteration: true, - }, + "collectionItem.unenclosed.iteration": iteration( + "collectionItem", + "items in a comma-separated list without enclosing delimiters", + ), "condition.if": { description: "A condition in an if statement", @@ -608,12 +527,11 @@ export const scopeSupportFacetInfos: Record< description: "A condition in a switch statement", scopeType: "condition", }, - "condition.switchCase.iteration": { - description: - "The iteration scope for conditions in a switch statement: should contain all the cases, and exclude any curly brackets delimiting the full switch statement body", - scopeType: "condition", - isIteration: true, - }, + "condition.switchCase.iteration": iteration( + "condition", + "conditions in a switch statement", + "the switch statement body", + ), "name.assignment": { description: "Name (LHS) of an assignment", @@ -672,77 +590,55 @@ export const scopeSupportFacetInfos: Record< description: "Name (LHS) of a field in a interface", scopeType: "name", }, - "name.iteration.block": { - description: - "Iteration scope for names: statement blocks (body of functions / if statements / for loops / etc).", - scopeType: "name", - isIteration: true, - }, - "name.iteration.class": { - description: "Iteration scope for names: class body", - scopeType: "name", - isIteration: true, - }, - "name.iteration.interface": { - description: "Iteration scope for names: interface body", - scopeType: "name", - isIteration: true, - }, - "name.iteration.document": { - description: "Iteration scope for names: the entire document", - scopeType: "name", - isIteration: true, - }, + "name.iteration.block": blockIter("name", "names"), + "name.iteration.class": classIter("name", "names"), + "name.iteration.interface": interfaceIter("name", "names"), + "name.iteration.document": documentIter("name", "names"), "name.resource": { description: "Name in a 'with' / 'use' / 'using' statement", scopeType: "name", }, - "name.resource.iteration": { - description: - "Iteration scope for names in a 'with' / 'use' / 'using' statement", - scopeType: "name", - isIteration: true, - }, + "name.resource.iteration": iteration( + "name", + "names in a 'with' / 'use' / 'using' statement", + "the resource list. The domain should be the entire statement", + ), "name.argument.actual": { description: "Name of a (keyword) argument in a function call", scopeType: "name", }, - "name.argument.actual.iteration": { - description: - "Iteration scope of the names of the actual parameters of a function call; should be the whole arguments list", - scopeType: "name", - isIteration: true, - }, + "name.argument.actual.iteration": iteration( + "name", + "names of the arguments in a function call", + "the argument list. The domain should be the whole function call", + ), "name.argument.formal": { description: "Name of a parameter in a function declaration", scopeType: "name", }, - "name.argument.formal.iteration": { - description: - "Iteration scope of the names of the formal parameters of a function declaration; should be the whole parameter list", - scopeType: "name", - isIteration: true, - }, + "name.argument.formal.iteration": iteration( + "name", + "names of formal parameters in a function declaration", + "the parameters list. The domain should be the entire function", + ), "name.argument.formal.method": { description: "Name of a parameter in a class method declaration", scopeType: "name", }, - "name.argument.formal.method.iteration": { - description: - "Iteration scope of the names of the formal parameters of a class method declaration; should be the whole parameter list", - scopeType: "name", - isIteration: true, - }, + "name.argument.formal.method.iteration": iteration( + "name", + "names of formal parameters in a method declaration", + "the parameters list. The domain should be the entire method", + ), "name.argument.formal.constructor": { description: "The name of a parameter in a constructor declaration", scopeType: "name", }, - "name.argument.formal.constructor.iteration": { - description: - "Iteration scope of the names of the formal parameters of a constructor declaration; should be the whole parameter list", - scopeType: "name", - isIteration: true, - }, + "name.argument.formal.constructor.iteration": iteration( + "name", + "names of formal parameters in a constructor declaration", + "the parameters list. The domain should be the entire constructor", + ), "name.argument.catch": { description: "Name of a parameter in a catch clause", scopeType: "name", @@ -756,12 +652,11 @@ export const scopeSupportFacetInfos: Record< description: "Key (LHS) of a key-value pair of a map", scopeType: "collectionKey", }, - "key.mapPair.iteration": { - description: - "Iteration scope of key-value pairs in a map; should be between the braces", - scopeType: "collectionKey", - isIteration: true, - }, + "key.mapPair.iteration": iteration( + "collectionKey", + "keys of key-value pairs in a map", + "should be between the braces", + ), "value.assignment": { description: "Value (RHS) of an assignment", @@ -784,12 +679,11 @@ export const scopeSupportFacetInfos: Record< description: "Value (RHS) of a key-value pair in a map", scopeType: "value", }, - "value.mapPair.iteration": { - description: - "Iteration scope of key-value pairs in a map; should be between the braces", - scopeType: "value", - isIteration: true, - }, + "value.mapPair.iteration": iteration( + "value", + "values of key-value pairs in a map", + "should be between the braces", + ), "value.foreach": { description: "Iterable in a for each loop", scopeType: "value", @@ -814,72 +708,54 @@ export const scopeSupportFacetInfos: Record< description: "Value of a yield statement", scopeType: "value", }, - "value.iteration.block": { - description: - "Iteration scope for values: statement blocks (body of functions / if statements / for loops / etc).", - scopeType: "value", - isIteration: true, - }, - "value.iteration.class": { - description: "Iteration scope for values: class body", - scopeType: "value", - isIteration: true, - }, - "value.iteration.document": { - description: "Iteration scope for values: the entire document", - scopeType: "value", - isIteration: true, - }, + "value.iteration.block": blockIter("value", "values"), + "value.iteration.class": classIter("value", "values"), + "value.iteration.document": documentIter("value", "values"), "value.resource": { description: "Value of a 'with' / 'use' / 'using' statement", scopeType: "value", }, - "value.resource.iteration": { - description: - "Iteration scope for values in a 'with' / 'use' / 'using' statement", - scopeType: "value", - isIteration: true, - }, - "value.argument.formal": { - description: "The value of a (keyword) argument in a function declaration", - scopeType: "value", - }, - "value.argument.formal.iteration": { - description: - "Iteration scope of the values of the formal parameters of a function declaration; should be the whole parameter list", - scopeType: "value", - isIteration: true, - }, + "value.resource.iteration": iteration( + "value", + "values in a 'with' / 'use' / 'using' statement", + "the resource list. The domain should be the entire statement", + ), "value.argument.actual": { description: "The value of a (keyword) argument in a function call", scopeType: "value", }, - "value.argument.actual.iteration": { - description: - "Iteration scope of the values of the actual parameters of a function call; should be the whole arguments list", + "value.argument.actual.iteration": iteration( + "value", + "values of arguments in a function call", + "the arguments list. The domain should be the entire function call", + ), + "value.argument.formal": { + description: "The value of a (keyword) argument in a function declaration", scopeType: "value", - isIteration: true, }, + "value.argument.formal.iteration": iteration( + "value", + "values of formal parameters in a function declaration", + "the parameters list. The domain should be the entire function", + ), "value.argument.formal.method": { description: "The value of a parameter in a class method declaration", scopeType: "value", }, - "value.argument.formal.method.iteration": { - description: - "Iteration scope of the values of the formal parameters of a class method declaration; should be the whole parameter list", - scopeType: "value", - isIteration: true, - }, + "value.argument.formal.method.iteration": iteration( + "value", + "values of formal parameters in a method declaration", + "the parameters list. The domain should be the entire method", + ), "value.argument.formal.constructor": { description: "The value of a parameter in a constructor declaration", scopeType: "value", }, - "value.argument.formal.constructor.iteration": { - description: - "Iteration scope of the values of the formal parameters of a constructor declaration; should be the whole parameter list", - scopeType: "value", - isIteration: true, - }, + "value.argument.formal.constructor.iteration": iteration( + "value", + "values of formal parameters in a constructor declaration", + "the parameters list. The domain should be the entire constructor", + ), "value.typeAlias": { description: "Value of a type alias declaration", scopeType: "value", @@ -893,32 +769,29 @@ export const scopeSupportFacetInfos: Record< description: "Type of formal parameter in a function declaration", scopeType: "type", }, - "type.argument.formal.iteration": { - description: - "Iteration scope of the types of the formal parameters of a function declaration; should be the whole parameter list", - scopeType: "type", - isIteration: true, - }, + "type.argument.formal.iteration": iteration( + "type", + "types of formal parameters in a function declaration", + "the parameters list. The domain should be the entire function", + ), "type.argument.formal.method": { description: "Type of formal parameter in a class method declaration", scopeType: "type", }, - "type.argument.formal.method.iteration": { - description: - "Iteration scope of the types of the formal parameters of a class method declaration; should be the whole parameter list", - scopeType: "type", - isIteration: true, - }, + "type.argument.formal.method.iteration": iteration( + "type", + "types of formal parameters in a method declaration", + "the parameters list. The domain should be the entire method", + ), "type.argument.formal.constructor": { description: "Type of formal parameter in a constructor declaration", scopeType: "type", }, - "type.argument.formal.constructor.iteration": { - description: - "Iteration scope of the types of the formal parameters of a constructor declaration; should be the whole parameter list", - scopeType: "type", - isIteration: true, - }, + "type.argument.formal.constructor.iteration": iteration( + "type", + "types of formal parameters in a constructor declaration", + "the parameters list. The domain should be the entire constructor", + ), "type.argument.catch": { description: "Type of parameter in a catch clause", scopeType: "type", @@ -964,43 +837,24 @@ export const scopeSupportFacetInfos: Record< description: "Type argument to a generic / parametrized type", scopeType: "type", }, - "type.typeArgument.iteration": { - description: - "Iteration scope for type argument to a generic / parametrized type; Should be the list of type arguments", - scopeType: "type", - isIteration: true, - }, + "type.typeArgument.iteration": iteration( + "type", + "type arguments to a generic / parametrized type", + "the type argument list", + ), "type.resource": { description: "Type in a 'with' / 'use' / 'using' statement", scopeType: "type", }, - "type.resource.iteration": { - description: - "Iteration scope for types in a 'with' / 'use' / 'using' statement", - scopeType: "type", - isIteration: true, - }, - "type.iteration.block": { - description: - "Iteration scope for types. Statement blocks(body of functions/if statements/for loops/etc).", - scopeType: "type", - isIteration: true, - }, - "type.iteration.class": { - description: "Iteration scope for types; class body", - scopeType: "type", - isIteration: true, - }, - "type.iteration.interface": { - description: "Iteration scope for types; interface body", - scopeType: "type", - isIteration: true, - }, - "type.iteration.document": { - description: "Iteration scope for types; entire document.", - scopeType: "type", - isIteration: true, - }, + "type.resource.iteration": iteration( + "type", + "types in a 'with' / 'use' / 'using' statement", + "the resource list. The domain should be the entire statement", + ), + "type.iteration.block": blockIter("type", "types"), + "type.iteration.class": classIter("type", "types"), + "type.iteration.interface": interfaceIter("type", "types"), + "type.iteration.document": documentIter("type", "types"), "interior.element": { description: "The interior/children of a XML element", @@ -1104,3 +958,55 @@ export const scopeSupportFacetInfos: Record< scopeType: "unit", }, }; + +function documentIter( + scopeType: SimpleScopeTypeType, + label: string, +): ScopeSupportFacetInfo { + return iteration( + scopeType, + label, + "the entire document including leading and trailing empty lines", + ); +} + +function classIter( + scopeType: SimpleScopeTypeType, + label: string, +): ScopeSupportFacetInfo { + return iteration(scopeType, label, "class bodies"); +} + +function interfaceIter( + scopeType: SimpleScopeTypeType, + label: string, +): ScopeSupportFacetInfo { + return iteration(scopeType, label, "interface bodies"); +} + +function blockIter( + scopeType: SimpleScopeTypeType, + label: string, +): ScopeSupportFacetInfo { + return iteration( + scopeType, + label, + "statement blocks (body of functions/if-statements/for-loops/etc)", + ); +} + +function iteration( + scopeType: SimpleScopeTypeType, + label: string, + desc?: string, +): ScopeSupportFacetInfo { + const description = + desc != null + ? `Iteration scope for ${label}: ${desc}.` + : `Iteration scope for ${label}`; + return { + description, + scopeType, + isIteration: true, + }; +} diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index 044710bcef..e7b368bd65 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -267,9 +267,6 @@ export interface ScopeSupportFacetInfo { readonly description: string; readonly scopeType: SimpleScopeTypeType | ScopeType; readonly isIteration?: boolean; - readonly domainHint?: string; - readonly removalHint?: string; - readonly insertionDelimiterHint?: string; } export enum ScopeSupportFacetLevel { diff --git a/packages/common/src/util/serializeScopeType.ts b/packages/common/src/util/serializeScopeType.ts new file mode 100644 index 0000000000..a1b120fb0c --- /dev/null +++ b/packages/common/src/util/serializeScopeType.ts @@ -0,0 +1,13 @@ +import type { + ScopeType, + SimpleScopeTypeType, +} from "../types/command/PartialTargetDescriptor.types"; + +export function serializeScopeType( + scopeType: SimpleScopeTypeType | ScopeType, +): string { + if (typeof scopeType === "string") { + return scopeType; + } + return scopeType.type; +} diff --git a/packages/cursorless-org-docs/src/docs/contributing/MissingLanguageScopes.tsx b/packages/cursorless-org-docs/src/docs/contributing/MissingLanguageScopes.tsx index dd7ef16a07..e74ab7e762 100644 --- a/packages/cursorless-org-docs/src/docs/contributing/MissingLanguageScopes.tsx +++ b/packages/cursorless-org-docs/src/docs/contributing/MissingLanguageScopes.tsx @@ -3,9 +3,8 @@ import { scopeSupportFacetInfos, ScopeSupportFacetLevel, scopeSupportFacets, + serializeScopeType, type ScopeSupportFacet, - type ScopeType, - type SimpleScopeTypeType, } from "@cursorless/common"; import React, { useState } from "react"; @@ -122,12 +121,3 @@ function facetsToScopes(facets: ScopeSupportFacet[], showPrivate: boolean) { .filter((scope) => showPrivate || !scope.startsWith("private.")) .sort(); } - -function serializeScopeType( - scopeType: SimpleScopeTypeType | ScopeType, -): string { - if (typeof scopeType === "string") { - return scopeType; - } - return scopeType.type; -} diff --git a/packages/cursorless-org-docs/src/docs/user/languages/components/ScopeSupportForLevel.tsx b/packages/cursorless-org-docs/src/docs/user/languages/components/ScopeSupportForLevel.tsx index 347df0d0a7..144d64b9f8 100644 --- a/packages/cursorless-org-docs/src/docs/user/languages/components/ScopeSupportForLevel.tsx +++ b/packages/cursorless-org-docs/src/docs/user/languages/components/ScopeSupportForLevel.tsx @@ -2,11 +2,10 @@ import { camelCaseToAllDown, capitalize, groupBy, + scopeSupportFacetInfos, + serializeScopeType, type ScopeSupportFacet, type ScopeSupportFacetInfo, - scopeSupportFacetInfos, - type ScopeType, - type SimpleScopeTypeType, } from "@cursorless/common"; import React, { useState, type JSX } from "react"; @@ -114,12 +113,3 @@ function prettifyFacet(facet: ScopeSupportFacet): string { const name = capitalize(parts.slice(1).join(" ")); return isIteration ? `${name} (iteration)` : name; } - -function serializeScopeType( - scopeType: SimpleScopeTypeType | ScopeType, -): string { - if (typeof scopeType === "string") { - return scopeType; - } - return scopeType.type; -} diff --git a/packages/meta-updater/src/metaUpdater.ts b/packages/meta-updater/src/metaUpdater.ts index 4aaccd4d30..fe2e2c5c99 100644 --- a/packages/meta-updater/src/metaUpdater.ts +++ b/packages/meta-updater/src/metaUpdater.ts @@ -10,6 +10,7 @@ import { textFormat } from "./textFormat"; import { updateLanguageMdxConfig } from "./updateLanguageScopeSupportConfig"; import { updatePackageJson } from "./updatePackageJson"; import { updateTSConfig } from "./updateTSConfig"; +import { updatesScopeSupportFacetInfos } from "./updatesScopeSupportFacetInfos"; export const updater = async (workspaceDir: string) => { const pnpmLockfile = await readWantedLockfile(workspaceDir, { @@ -29,6 +30,7 @@ export const updater = async (workspaceDir: string) => { files: { ["package.json"]: updatePackageJson.bind(null, context), ["tsconfig.json"]: updateTSConfig.bind(null, context), + ["data/scopeSupportFacetInfos.md"]: updatesScopeSupportFacetInfos, ...Object.fromEntries( Object.keys(languageScopeSupport).map((languageId) => { return [ @@ -39,6 +41,7 @@ export const updater = async (workspaceDir: string) => { ), }, formats: { + md: textFormat, mdx: textFormat, }, }); diff --git a/packages/meta-updater/src/updatesScopeSupportFacetInfos.ts b/packages/meta-updater/src/updatesScopeSupportFacetInfos.ts new file mode 100644 index 0000000000..c5da07d35f --- /dev/null +++ b/packages/meta-updater/src/updatesScopeSupportFacetInfos.ts @@ -0,0 +1,45 @@ +import { + scopeSupportFacetInfos, + serializeScopeType, + textualScopeSupportFacetInfos, + type ScopeSupportFacet, + type TextualScopeSupportFacet, +} from "@cursorless/common"; +import type { FormatPluginFnOptions } from "@pnpm/meta-updater"; + +export function updatesScopeSupportFacetInfos( + actual: string | null, + _options: FormatPluginFnOptions, +): string | null { + if (actual == null) { + return null; + } + + const facetsInfos = { + ...scopeSupportFacetInfos, + ...textualScopeSupportFacetInfos, + }; + + const facets = Object.keys(facetsInfos).sort(); + const rows: string[] = []; + let currentScopeType: string | null = null; + + for (const facet of facets) { + const facetInfo = + facetsInfos[facet as ScopeSupportFacet | TextualScopeSupportFacet]; + const scopeType = serializeScopeType(facetInfo.scopeType); + if (scopeType !== currentScopeType) { + if (currentScopeType != null) { + rows.push(""); + } + currentScopeType = scopeType; + rows.push(`### ${currentScopeType}`); + rows.push(""); + } + rows.push(`- \`${facet}\` ${facetInfo.description}`); + } + + rows.push(""); + + return rows.join("\n"); +}