Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scala scope migration #2345

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading