Skip to content

Commit

Permalink
scala scope migration (#2345)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Jun 14, 2024
1 parent 008baa1 commit e61045c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
17 changes: 0 additions & 17 deletions packages/cursorless-engine/src/languages/scala.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ import { childRangeSelector } from "../util/nodeSelectors";
const nodeMatchers: Partial<
Record<SimpleScopeTypeType, NodeMatcherAlternative>
> = {
// 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",
Expand All @@ -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.
Expand Down
33 changes: 33 additions & 0 deletions queries/scala.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e61045c

Please sign in to comment.