diff --git a/data/fixtures/scopes/properties/comment.line.scope b/data/fixtures/scopes/properties/comment.line.scope new file mode 100644 index 0000000000..42719cdbb8 --- /dev/null +++ b/data/fixtures/scopes/properties/comment.line.scope @@ -0,0 +1,10 @@ +# Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| # Hello world + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/properties/key.mapPair.iteration.scope b/data/fixtures/scopes/properties/key.mapPair.iteration.scope new file mode 100644 index 0000000000..379107f231 --- /dev/null +++ b/data/fixtures/scopes/properties/key.mapPair.iteration.scope @@ -0,0 +1,12 @@ + +foo=bar + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| foo=bar +2| + < diff --git a/data/fixtures/scopes/properties/key.mapPair.scope b/data/fixtures/scopes/properties/key.mapPair.scope new file mode 100644 index 0000000000..193ff7b458 --- /dev/null +++ b/data/fixtures/scopes/properties/key.mapPair.scope @@ -0,0 +1,13 @@ +foo=bar +--- + +[Content] = +[Removal] = 0:0-0:3 + >---< +0| foo=bar + +[Domain] = 0:0-0:7 + >-------< +0| foo=bar + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/properties/key.mapPair2.scope b/data/fixtures/scopes/properties/key.mapPair2.scope new file mode 100644 index 0000000000..7761824c9b --- /dev/null +++ b/data/fixtures/scopes/properties/key.mapPair2.scope @@ -0,0 +1,13 @@ +foo.bar=baz +--- + +[Content] = +[Removal] = 0:0-0:7 + >-------< +0| foo.bar=baz + +[Domain] = 0:0-0:11 + >-----------< +0| foo.bar=baz + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/properties/name.iteration.document.scope b/data/fixtures/scopes/properties/name.iteration.document.scope new file mode 100644 index 0000000000..379107f231 --- /dev/null +++ b/data/fixtures/scopes/properties/name.iteration.document.scope @@ -0,0 +1,12 @@ + +foo=bar + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| foo=bar +2| + < diff --git a/data/fixtures/scopes/properties/name.variable.scope b/data/fixtures/scopes/properties/name.variable.scope new file mode 100644 index 0000000000..193ff7b458 --- /dev/null +++ b/data/fixtures/scopes/properties/name.variable.scope @@ -0,0 +1,13 @@ +foo=bar +--- + +[Content] = +[Removal] = 0:0-0:3 + >---< +0| foo=bar + +[Domain] = 0:0-0:7 + >-------< +0| foo=bar + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/properties/name.variable2.scope b/data/fixtures/scopes/properties/name.variable2.scope new file mode 100644 index 0000000000..7761824c9b --- /dev/null +++ b/data/fixtures/scopes/properties/name.variable2.scope @@ -0,0 +1,13 @@ +foo.bar=baz +--- + +[Content] = +[Removal] = 0:0-0:7 + >-------< +0| foo.bar=baz + +[Domain] = 0:0-0:11 + >-----------< +0| foo.bar=baz + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/properties/statement.iteration.document.scope b/data/fixtures/scopes/properties/statement.iteration.document.scope new file mode 100644 index 0000000000..379107f231 --- /dev/null +++ b/data/fixtures/scopes/properties/statement.iteration.document.scope @@ -0,0 +1,12 @@ + +foo=bar + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| foo=bar +2| + < diff --git a/data/fixtures/scopes/properties/statement.variable.scope b/data/fixtures/scopes/properties/statement.variable.scope new file mode 100644 index 0000000000..e3a44a1c0e --- /dev/null +++ b/data/fixtures/scopes/properties/statement.variable.scope @@ -0,0 +1,10 @@ +foo=bar +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:7 + >-------< +0| foo=bar + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/properties/textFragment.comment.line.scope b/data/fixtures/scopes/properties/textFragment.comment.line.scope new file mode 100644 index 0000000000..2c362ef415 --- /dev/null +++ b/data/fixtures/scopes/properties/textFragment.comment.line.scope @@ -0,0 +1,10 @@ +# Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| # Hello world + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/properties/value.iteration.document.scope b/data/fixtures/scopes/properties/value.iteration.document.scope new file mode 100644 index 0000000000..379107f231 --- /dev/null +++ b/data/fixtures/scopes/properties/value.iteration.document.scope @@ -0,0 +1,12 @@ + +foo=bar + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| foo=bar +2| + < diff --git a/data/fixtures/scopes/properties/value.mapPair.iteration.scope b/data/fixtures/scopes/properties/value.mapPair.iteration.scope new file mode 100644 index 0000000000..379107f231 --- /dev/null +++ b/data/fixtures/scopes/properties/value.mapPair.iteration.scope @@ -0,0 +1,12 @@ + +foo=bar + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| foo=bar +2| + < diff --git a/data/fixtures/scopes/properties/value.mapPair.scope b/data/fixtures/scopes/properties/value.mapPair.scope new file mode 100644 index 0000000000..39ca35fcc4 --- /dev/null +++ b/data/fixtures/scopes/properties/value.mapPair.scope @@ -0,0 +1,13 @@ +foo=bar +--- + +[Content] = +[Removal] = 0:4-0:7 + >---< +0| foo=bar + +[Domain] = 0:0-0:7 + >-------< +0| foo=bar + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/properties/value.variable.scope b/data/fixtures/scopes/properties/value.variable.scope new file mode 100644 index 0000000000..39ca35fcc4 --- /dev/null +++ b/data/fixtures/scopes/properties/value.variable.scope @@ -0,0 +1,13 @@ +foo=bar +--- + +[Content] = +[Removal] = 0:4-0:7 + >---< +0| foo=bar + +[Domain] = 0:0-0:7 + >-------< +0| foo=bar + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/properties/value.variable2.scope b/data/fixtures/scopes/properties/value.variable2.scope new file mode 100644 index 0000000000..adcaa3065b --- /dev/null +++ b/data/fixtures/scopes/properties/value.variable2.scope @@ -0,0 +1,13 @@ +foo=123 +--- + +[Content] = +[Removal] = 0:4-0:7 + >---< +0| foo=123 + +[Domain] = 0:0-0:7 + >-------< +0| foo=123 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/properties/value.variable3.scope b/data/fixtures/scopes/properties/value.variable3.scope new file mode 100644 index 0000000000..4e567ad7dd --- /dev/null +++ b/data/fixtures/scopes/properties/value.variable3.scope @@ -0,0 +1,13 @@ +foo=${bar} +--- + +[Content] = +[Removal] = 0:4-0:10 + >------< +0| foo=${bar} + +[Domain] = 0:0-0:10 + >----------< +0| foo=${bar} + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/languageScopeSupport.ts b/packages/common/src/scopeSupportFacets/languageScopeSupport.ts index ea98a324c7..31778fa1a2 100644 --- a/packages/common/src/scopeSupportFacets/languageScopeSupport.ts +++ b/packages/common/src/scopeSupportFacets/languageScopeSupport.ts @@ -17,6 +17,7 @@ import { latexScopeSupport } from "./latex"; import { luaScopeSupport } from "./lua"; import { markdownScopeSupport } from "./markdown"; import { phpScopeSupport } from "./php"; +import { propertiesScopeSupport } from "./properties"; import { pythonScopeSupport } from "./python"; import { rScopeSupport } from "./r"; import { rubyScopeSupport } from "./ruby"; @@ -51,6 +52,7 @@ export const languageScopeSupport: StringRecord = lua: luaScopeSupport, markdown: markdownScopeSupport, php: phpScopeSupport, + properties: propertiesScopeSupport, python: pythonScopeSupport, r: rScopeSupport, ruby: rubyScopeSupport, diff --git a/packages/common/src/scopeSupportFacets/properties.ts b/packages/common/src/scopeSupportFacets/properties.ts new file mode 100644 index 0000000000..3a830f6521 --- /dev/null +++ b/packages/common/src/scopeSupportFacets/properties.ts @@ -0,0 +1,333 @@ +import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; +import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; + +const { supported, notApplicable } = ScopeSupportFacetLevel; + +export const propertiesScopeSupport: LanguageScopeSupportFacetMap = { + "statement.variable": supported, + "statement.iteration.document": supported, + + "key.mapPair.iteration": supported, + "key.mapPair": supported, + "name.iteration.document": supported, + "name.variable": supported, + + "value.iteration.document": supported, + "value.mapPair.iteration": supported, + "value.mapPair": supported, + "value.variable": supported, + + "comment.line": supported, + "textFragment.comment.line": supported, + + /* NOT APPLICABLE */ + + // Class + class: notApplicable, + "class.iteration.block": notApplicable, + "class.iteration.document": notApplicable, + "name.class": notApplicable, + "name.field.class": notApplicable, + "name.iteration.class": notApplicable, + "statement.class": notApplicable, + "statement.field.class": notApplicable, + "statement.iteration.class": notApplicable, + "type.class": notApplicable, + "type.field.class": notApplicable, + "type.iteration.class": notApplicable, + "value.field.class": notApplicable, + "value.iteration.class": notApplicable, + "interior.class": notApplicable, + + // Constructor + "statement.constructor": notApplicable, + "namedFunction.constructor": notApplicable, + "functionCall.constructor": notApplicable, + "functionCallee.constructor": notApplicable, + "argument.actual.constructor.singleLine": notApplicable, + "argument.actual.constructor.multiLine": notApplicable, + "argument.actual.constructor.iteration": notApplicable, + "argument.formal.constructor.singleLine": notApplicable, + "argument.formal.constructor.multiLine": notApplicable, + "argument.formal.constructor.iteration": notApplicable, + "argumentList.actual.constructor.empty": notApplicable, + "argumentList.actual.constructor.singleLine": notApplicable, + "argumentList.actual.constructor.multiLine": notApplicable, + "argumentList.formal.constructor.empty": notApplicable, + "argumentList.formal.constructor.singleLine": notApplicable, + "argumentList.formal.constructor.multiLine": notApplicable, + "interior.constructor": notApplicable, + "name.argument.formal.constructor": notApplicable, + "name.argument.formal.constructor.iteration": notApplicable, + "name.constructor": notApplicable, + "type.argument.formal.constructor": notApplicable, + "type.argument.formal.constructor.iteration": notApplicable, + "value.argument.formal.constructor": notApplicable, + "value.argument.formal.constructor.iteration": notApplicable, + + // Method + "statement.method": notApplicable, + "namedFunction.method": notApplicable, + "argument.actual.method.singleLine": notApplicable, + "argument.actual.method.multiLine": notApplicable, + "argument.actual.method.iteration": notApplicable, + "argument.formal.method.singleLine": notApplicable, + "argument.formal.method.multiLine": notApplicable, + "argument.formal.method.iteration": notApplicable, + "argumentList.actual.method.multiLine": notApplicable, + "argumentList.actual.method.singleLine": notApplicable, + "argumentList.actual.method.empty": notApplicable, + "argumentList.formal.method.empty": notApplicable, + "argumentList.formal.method.singleLine": notApplicable, + "argumentList.formal.method.multiLine": notApplicable, + "interior.method": notApplicable, + "name.argument.formal.method": notApplicable, + "name.argument.formal.method.iteration": notApplicable, + "name.method": notApplicable, + "type.argument.formal.method": notApplicable, + "type.argument.formal.method.iteration": notApplicable, + "value.argument.formal.method": notApplicable, + "value.argument.formal.method.iteration": notApplicable, + "functionCall.method": notApplicable, + "functionCallee.method": notApplicable, + + // Function + namedFunction: notApplicable, + "namedFunction.iteration.document": notApplicable, + "namedFunction.iteration.class": notApplicable, + "statement.function": notApplicable, + "name.function": notApplicable, + "interior.function": notApplicable, + "argument.actual.iteration": notApplicable, + "argument.actual.singleLine": notApplicable, + "argument.actual.multiLine": notApplicable, + "argumentList.actual.empty": notApplicable, + "argumentList.actual.singleLine": notApplicable, + "argumentList.actual.multiLine": notApplicable, + "argumentList.formal.empty": notApplicable, + "argumentList.formal.singleLine": notApplicable, + "argumentList.formal.multiLine": notApplicable, + "argument.formal.singleLine": notApplicable, + "argument.formal.multiLine": notApplicable, + "argument.formal.iteration": notApplicable, + "name.argument.formal": notApplicable, + "name.argument.formal.iteration": notApplicable, + "type.argument.formal": notApplicable, + "type.argument.formal.iteration": notApplicable, + "value.argument.formal": notApplicable, + "value.argument.formal.iteration": notApplicable, + functionCall: notApplicable, + functionCallee: notApplicable, + "functionCall.chain": notApplicable, + "functionCallee.chain": notApplicable, + + // Anonymous function / lambda + anonymousFunction: notApplicable, + "argumentList.formal.lambda.empty": notApplicable, + "argumentList.formal.lambda.singleLine": notApplicable, + "argumentList.formal.lambda.multiLine": notApplicable, + "argument.formal.lambda.singleLine": notApplicable, + "argument.formal.lambda.multiLine": notApplicable, + "argument.formal.lambda.iteration": notApplicable, + "value.return.lambda": notApplicable, + "interior.lambda": notApplicable, + + // Keyword argument + "name.argument.actual": notApplicable, + "name.argument.actual.iteration": notApplicable, + "value.argument.actual": notApplicable, + "value.argument.actual.iteration": notApplicable, + + // Return statement + "statement.return": notApplicable, + "type.return": notApplicable, + "value.return": notApplicable, + + // Yield statement + "statement.yield": notApplicable, + "value.yield": notApplicable, + + // Interface + "statement.interface": notApplicable, + "statement.field.interface": notApplicable, + "statement.iteration.interface": notApplicable, + "interior.interface": notApplicable, + "name.interface": notApplicable, + "name.field.interface": notApplicable, + "name.iteration.interface": notApplicable, + "type.interface": notApplicable, + "type.field.interface": notApplicable, + "type.iteration.interface": notApplicable, + + // Enum + "statement.enum": notApplicable, + "name.enum": notApplicable, + "name.field.enum": notApplicable, + "name.iteration.enum": notApplicable, + "value.field.enum": notApplicable, + "value.iteration.enum": notApplicable, + "type.enum": notApplicable, + "interior.enum": notApplicable, + + // Try catch + "statement.try": notApplicable, + "branch.try": notApplicable, + "branch.try.iteration": notApplicable, + "interior.try": notApplicable, + "argument.catch": notApplicable, + "name.argument.catch": notApplicable, + "type.argument.catch": notApplicable, + + // If statement + ifStatement: notApplicable, + "statement.if": notApplicable, + "branch.if": notApplicable, + "branch.if.elif.else": notApplicable, + "branch.if.else": notApplicable, + "branch.if.iteration": notApplicable, + "condition.if": notApplicable, + "interior.if": notApplicable, + + // Switch statement + "statement.switch": notApplicable, + "branch.switchCase": notApplicable, + "branch.switchCase.iteration": notApplicable, + "condition.switchCase": notApplicable, + "condition.switchCase.iteration": notApplicable, + "interior.switch": notApplicable, + "interior.switchCase": notApplicable, + "value.switch": notApplicable, + + // Loop + "branch.loop": notApplicable, + "branch.loop.iteration": notApplicable, + + // For loop + "statement.for": notApplicable, + "condition.for": notApplicable, + "interior.for": notApplicable, + + // For-each loop + "statement.foreach": notApplicable, + "interior.foreach": notApplicable, + "name.foreach": notApplicable, + "type.foreach": notApplicable, + "value.foreach": notApplicable, + + // While loop + "statement.while": notApplicable, + "condition.while": notApplicable, + "interior.while": notApplicable, + + // Do-while loop + "statement.doWhile": notApplicable, + "condition.doWhile": notApplicable, + "interior.doWhile": notApplicable, + + // Resource statement + "statement.resource": notApplicable, + "interior.resource": notApplicable, + "name.resource": notApplicable, + "name.resource.iteration": notApplicable, + "type.resource": notApplicable, + "type.resource.iteration": notApplicable, + "value.resource": notApplicable, + "value.resource.iteration": notApplicable, + + // Pattern destruction + "name.assignment.pattern": notApplicable, + "name.variable.pattern": notApplicable, + "value.variable.pattern": notApplicable, + + // String + "string.singleLine": notApplicable, + "string.multiLine": notApplicable, + "textFragment.string.singleLine": notApplicable, + "textFragment.string.multiLine": notApplicable, + + // Block comment + "comment.block": notApplicable, + "textFragment.comment.block": notApplicable, + + // Static + "statement.static": notApplicable, + "interior.static": notApplicable, + + // Namespace + "statement.namespace": notApplicable, + "interior.namespace": notApplicable, + "name.namespace": notApplicable, + + // Ternary + "branch.ternary": notApplicable, + "branch.ternary.iteration": notApplicable, + "condition.ternary": notApplicable, + + // Section + section: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, + + // Element + element: notApplicable, + "interior.element": notApplicable, + "textFragment.element": notApplicable, + tags: notApplicable, + startTag: notApplicable, + endTag: notApplicable, + + // Attribute + attribute: notApplicable, + "key.attribute": notApplicable, + "value.attribute": notApplicable, + + // Notebook cell + notebookCell: notApplicable, + "interior.cell": notApplicable, + + // Type alias + "type.alias": notApplicable, + "value.typeAlias": notApplicable, + + // Collection item + "collectionItem.unenclosed.singleLine": notApplicable, + "collectionItem.unenclosed.multiLine": notApplicable, + "collectionItem.unenclosed.iteration": notApplicable, + + // Command + command: notApplicable, + "statement.command": notApplicable, + "name.command": notApplicable, + "value.command": notApplicable, + "interior.command": notApplicable, + + // Miscellaneous statements + "statement.break": notApplicable, + "statement.continue": notApplicable, + "statement.assignment": notApplicable, + "statement.iteration.block": notApplicable, + + // Assignment + "name.assignment": notApplicable, + "value.assignment": notApplicable, + + // Miscellaneous + "name.iteration.block": notApplicable, + "statement.misc": notApplicable, + "type.cast": notApplicable, + "type.iteration.block": notApplicable, + "type.iteration.document": notApplicable, + "type.typeArgument.iteration": notApplicable, + "type.typeArgument": notApplicable, + "type.variable": notApplicable, + "value.iteration.block": notApplicable, + disqualifyDelimiter: notApplicable, + environment: notApplicable, + fieldAccess: notApplicable, + list: notApplicable, + map: notApplicable, + pairDelimiter: notApplicable, + regularExpression: notApplicable, + selector: notApplicable, + unit: notApplicable, +}; diff --git a/packages/cursorless-org-docs/src/docs/user/languages/properties.mdx b/packages/cursorless-org-docs/src/docs/user/languages/properties.mdx new file mode 100644 index 0000000000..3f894dbaca --- /dev/null +++ b/packages/cursorless-org-docs/src/docs/user/languages/properties.mdx @@ -0,0 +1,5 @@ +import { Language } from "./components/Language"; + +# Properties + + diff --git a/queries/java-properties.scm b/queries/java-properties.scm new file mode 100644 index 0000000000..bbcff4af12 --- /dev/null +++ b/queries/java-properties.scm @@ -0,0 +1,3 @@ +;; These files can have language id "properties" or `java-properties` + +;; import properties.scm diff --git a/queries/properties.scm b/queries/properties.scm new file mode 100644 index 0000000000..423fa24e90 --- /dev/null +++ b/queries/properties.scm @@ -0,0 +1,9 @@ +(comment) @comment @textFragment + +(property + (key) @collectionKey @name + (value) @value +) @statement @_.domain + +(file) @statement.iteration @comment.iteration +(file) @collectionKey.iteration @name.iteration @value.iteration