diff --git a/modules/core/src/main/scala/playground/MultiServiceResolver.scala b/modules/core/src/main/scala/playground/MultiServiceResolver.scala index 587958e2..ff35f20f 100644 --- a/modules/core/src/main/scala/playground/MultiServiceResolver.scala +++ b/modules/core/src/main/scala/playground/MultiServiceResolver.scala @@ -60,7 +60,7 @@ object MultiServiceResolver { ): EitherNel[CompilationError, Option[QualifiedIdentifier]] = queryOperationName .name .flatTraverse { opName => - queryOperationName.identifier.flatMap(_.qualified_identifier) match { + queryOperationName.service_identifier match { case Some(explicitRef) => resolveExplicitTs(serviceIndex, explicitRef, opName) case None => resolveImplicitTs(opName, serviceIndex, useClauses).map(_.some) } diff --git a/modules/language-support/src/main/scala/playground/language/CompletionProvider.scala b/modules/language-support/src/main/scala/playground/language/CompletionProvider.scala index c2f7186f..ddf18c29 100644 --- a/modules/language-support/src/main/scala/playground/language/CompletionProvider.scala +++ b/modules/language-support/src/main/scala/playground/language/CompletionProvider.scala @@ -120,7 +120,7 @@ object CompletionProvider { // includes the current query's service reference // as it wouldn't result in ading a use clause val presentServiceIdentifiers = { - q.select(_.operation_name.identifier.qualified_identifier) ++ + q.select(_.operation_name.service_identifier) ++ sf.select(_.prelude.use_clause.identifier) }.flatMap(ASTAdapter.decodeQI) diff --git a/modules/treesitter/src/main/resources/darwin-aarch64/libtree-sitter-smithyql.dylib b/modules/treesitter/src/main/resources/darwin-aarch64/libtree-sitter-smithyql.dylib index b6e1fde7..e9e2482f 100755 Binary files a/modules/treesitter/src/main/resources/darwin-aarch64/libtree-sitter-smithyql.dylib and b/modules/treesitter/src/main/resources/darwin-aarch64/libtree-sitter-smithyql.dylib differ diff --git a/modules/treesitter/src/main/resources/darwin-x86-64/libtree-sitter-smithyql.dylib b/modules/treesitter/src/main/resources/darwin-x86-64/libtree-sitter-smithyql.dylib index 4ab1b3b4..fa33dd70 100755 Binary files a/modules/treesitter/src/main/resources/darwin-x86-64/libtree-sitter-smithyql.dylib and b/modules/treesitter/src/main/resources/darwin-x86-64/libtree-sitter-smithyql.dylib differ diff --git a/modules/treesitter/src/main/resources/linux-aarch64/libtree-sitter-smithyql.so b/modules/treesitter/src/main/resources/linux-aarch64/libtree-sitter-smithyql.so index 616d0dab..87a4d8ac 100755 Binary files a/modules/treesitter/src/main/resources/linux-aarch64/libtree-sitter-smithyql.so and b/modules/treesitter/src/main/resources/linux-aarch64/libtree-sitter-smithyql.so differ diff --git a/modules/treesitter/src/main/resources/linux-x86-64/libtree-sitter-smithyql.so b/modules/treesitter/src/main/resources/linux-x86-64/libtree-sitter-smithyql.so index a29d0195..1e26ac39 100755 Binary files a/modules/treesitter/src/main/resources/linux-x86-64/libtree-sitter-smithyql.so and b/modules/treesitter/src/main/resources/linux-x86-64/libtree-sitter-smithyql.so differ diff --git a/modules/treesitter/src/main/scala/playground/generated/nodes/OperationNameQualifier.scala b/modules/treesitter/src/main/scala/playground/generated/nodes/OperationNameQualifier.scala deleted file mode 100644 index a193f952..00000000 --- a/modules/treesitter/src/main/scala/playground/generated/nodes/OperationNameQualifier.scala +++ /dev/null @@ -1,39 +0,0 @@ -// Generated code! Do not modify by hand. -package playground.generated.nodes - -import org.polyvariant.treesitter4s.Node -import playground.treesitter4s.std.Selection - -opaque type OperationNameQualifier <: Node = Node - -object OperationNameQualifier { - extension (node: OperationNameQualifier) { - def select[A](f: OperationNameQualifier.Selector => Selection[A]): List[A] = f(OperationNameQualifier.Selector(List(node))).path - // fields - - // typed children - def typedChildren: Option[QualifiedIdentifier] = node.children.collectFirst { - case QualifiedIdentifier(node) => node - } - // precise typed children - def qualified_identifier: Option[QualifiedIdentifier] = node.children.collectFirst { - case QualifiedIdentifier(node) => node - } - } - - def apply(node: Node): Either[String, OperationNameQualifier] = - if node.tpe == "operation_name_qualifier" - then Right(node) - else Left(s"Expected OperationNameQualifier, got ${node.tpe}") - - def unsafeApply(node: Node): OperationNameQualifier = apply(node).fold(sys.error, identity) - - def unapply(node: Node): Option[OperationNameQualifier] = apply(node).toOption - - final case class Selector(path: List[OperationNameQualifier]) extends Selection[OperationNameQualifier] { - def qualified_identifier: QualifiedIdentifier.Selector = QualifiedIdentifier.Selector(path.flatMap(_.qualified_identifier)) - - type Self = Selector - protected val remake = Selector.apply - } -} diff --git a/modules/treesitter/src/main/scala/playground/generated/nodes/QueryOperationName.scala b/modules/treesitter/src/main/scala/playground/generated/nodes/QueryOperationName.scala index cae47bc5..9480e227 100644 --- a/modules/treesitter/src/main/scala/playground/generated/nodes/QueryOperationName.scala +++ b/modules/treesitter/src/main/scala/playground/generated/nodes/QueryOperationName.scala @@ -10,13 +10,13 @@ object QueryOperationName { extension (node: QueryOperationName) { def select[A](f: QueryOperationName.Selector => Selection[A]): List[A] = f(QueryOperationName.Selector(List(node))).path // fields - def identifier: Option[OperationNameQualifier] = node.fields.getOrElse("identifier", Nil).headOption.map { - case OperationNameQualifier(node) => node - } - def name: Option[OperationName] = node.fields.getOrElse("name", Nil).headOption.map { case OperationName(node) => node } + + def service_identifier: Option[QualifiedIdentifier] = node.fields.getOrElse("service_identifier", Nil).headOption.map { + case QualifiedIdentifier(node) => node + } // typed children // precise typed children @@ -33,8 +33,8 @@ object QueryOperationName { def unapply(node: Node): Option[QueryOperationName] = apply(node).toOption final case class Selector(path: List[QueryOperationName]) extends Selection[QueryOperationName] { - def identifier: OperationNameQualifier.Selector = OperationNameQualifier.Selector(path.flatMap(_.identifier)) def name: OperationName.Selector = OperationName.Selector(path.flatMap(_.name)) + def service_identifier: QualifiedIdentifier.Selector = QualifiedIdentifier.Selector(path.flatMap(_.service_identifier)) type Self = Selector protected val remake = Selector.apply diff --git a/tree-sitter-smithyql/grammar.js b/tree-sitter-smithyql/grammar.js index c7d8e716..01ee9c70 100644 --- a/tree-sitter-smithyql/grammar.js +++ b/tree-sitter-smithyql/grammar.js @@ -47,12 +47,13 @@ module.exports = grammar({ field("selection", $.identifier) ), - operation_name_qualifier: ($) => seq($.qualified_identifier, "."), - - // todo: model as union? query_operation_name: ($) => - seq( - field("identifier", optional($.operation_name_qualifier)), + choice( + seq( + field("service_identifier", $.qualified_identifier), + ".", + field("name", $.operation_name) + ), field("name", $.operation_name) ),