From e61045c2c27a7a4f33ad83712f21060e9ac01fc8 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 14 Jun 2024 17:24:52 +0200 Subject: [PATCH] scala scope migration (#2345) ## Checklist - [/] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet --- .../cursorless-engine/src/languages/scala.ts | 17 ---------- queries/scala.scm | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/packages/cursorless-engine/src/languages/scala.ts b/packages/cursorless-engine/src/languages/scala.ts index a46d34022c..4a9f9d0f7d 100644 --- a/packages/cursorless-engine/src/languages/scala.ts +++ b/packages/cursorless-engine/src/languages/scala.ts @@ -13,19 +13,6 @@ import { childRangeSelector } from "../util/nodeSelectors"; const nodeMatchers: Partial< Record > = { - // treating classes = classlike - class: ["class_definition", "object_definition", "trait_definition"], - className: [ - "class_definition[name]", - "object_definition[name]", - "trait_definition[name]", - ], - - // list.size(), does not count foo.size (field_expression), or foo size (postfix_expression) - functionCall: "call_expression", - namedFunction: "function_definition", - anonymousFunction: "lambda_expression", - argumentOrParameter: argumentMatcher( "arguments", "parameters", @@ -39,10 +26,6 @@ const nodeMatchers: Partial< }), ), - ["private.switchStatementSubject"]: "match_expression[value]", - name: ["*[name]", "*[pattern]"], - functionName: "function_definition[name]", - // *[type] does not work here because while we want most of these we don't want "compound" types, // eg `generic_type[type]`, because that will grab just the inner generic (the String of List[String]) // and as a rule we want to grab entire type definitions. diff --git a/queries/scala.scm b/queries/scala.scm index 66ccc666df..1e86123c6f 100644 --- a/queries/scala.scm +++ b/queries/scala.scm @@ -6,3 +6,36 @@ ] @string @textFragment (comment) @comment @textFragment + +;; treating classes = classlike +[ + (class_definition + name: (_) @className + ) + (object_definition + name: (_) @className + ) + (trait_definition + name: (_) @className + ) +] @class @className.domain + +;; list.size(), does not count foo.size (field_expression), or foo size (postfix_expression) +(call_expression) @functionCall + +(lambda_expression) @anonymousFunction + +(function_definition + name: (_) @functionName +) @namedFunction @functionName.domain + +(match_expression + value: (_) @private.switchStatementSubject +) @_.domain + +(_ + name: (_) @name +) @_.domain +(_ + pattern: (_) @name +) @_.domain