Skip to content

Add new oneOf compound scope type #1045

Closed
@pokey

Description

@pokey

Not sure if oneOf is the right name, but we should support a way to compose scope types like the following:

interface OneOfScopeType {
    type: "oneOf";
    scopeTypes: ScopeType[]
}

Then we can construct a OneOfScopeHandler that will behave the same as a hierarchical scope where each scope can be any of scopeTypes. So basically:

  • getScopesTouchingPosition: return smallest scopes of any of scopeTypes touching position
  • getScopesOverlappingRange: call getScopesOverlappingRange on all scopeTypes and then remove any scopes that are contained by another scope
  • getScopeRelativeToPosition: pick first scope of any of the scopeTypes, then skip it for offset > 1, etc
  • iterationScope: apply oneOf to the iteration scopes of scopeTypes

Use cases

  • Add a proper scope type for "inside" #1046
  • Create a smarter iteration scope for "item" #1047
  • defining "name" as a union of "class name", "function name", etc
  • to define iteration scope of surrounding pair to be union of "inside" and "file"
  • users could map a custom scope type Talon side that constructs an oneOf scope type to enable them to construct their own unions of other scope types
  • we could maybe map a spoken form "<scope> or <scope>" to construct these on the fly, eg "take next funk or class"

Possible names

  • cascading
  • union
  • oneOf
  • anyOf
  • or

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions