Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed May 17, 2024
1 parent ea4adc2 commit 2a639cc
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 50 deletions.
42 changes: 0 additions & 42 deletions packages/cursorless-engine/src/languages/cpp.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/cursorless-engine/src/languages/getNodeMatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { notSupported } from "../util/nodeMatchers";
import { selectionWithEditorFromRange } from "../util/selectionUtils";
import clojure from "./clojure";
import { LegacyLanguageId } from "./LegacyLanguageId";
import cpp from "./cpp";
import csharp from "./csharp";
import go from "./go";
import java from "./java";
Expand Down Expand Up @@ -51,9 +50,7 @@ export const languageMatchers: Record<
LegacyLanguageId,
Partial<Record<SimpleScopeTypeType, NodeMatcher>>
> = {
c: cpp,
clojure,
cpp,
csharp,
css: scss,
go,
Expand Down
77 changes: 72 additions & 5 deletions queries/c.scm
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@

(function_definition) @namedFunction

;; void funcName();
;;!! void funcName();
(declaration
(function_declarator
declarator: (_) @functionName
)
) @namedFunction @functionName.domain

;; void C::funcName() {}
;;!! void C::funcName() {}
(function_definition
declarator: (_
declarator: (_
Expand All @@ -80,7 +80,7 @@
)
) @_.domain

;; void funcName() {}
;;!! void funcName() {}
(function_definition
declarator: (_
declarator: (_
Expand All @@ -89,7 +89,7 @@
)
) @_.domain

;; void ClassName::method() {}
;;!! void ClassName::method() {}
(function_definition
declarator: (_
declarator: (_
Expand Down Expand Up @@ -151,9 +151,76 @@
) @_.domain

(assignment_expression
left: (_) @name
left: (_) @name @value.leading.endOf
right: (_) @value @name.trailing.startOf
) @_.domain

(_
name: (_) @name
) @_.domain

;; > curl https://raw.githubusercontent.com/tree-sitter/tree-sitter-cpp/master/src/node-types.json | jq '[.[] | select(.type == "_type_specifier") | .subtypes[].type]'
[
(auto)
(class_specifier)
(decltype)
(dependent_type)
(enum_specifier)
(primitive_type)
(scoped_type_identifier)
(sized_type_specifier)
(struct_specifier)
(template_type)
(type_identifier)
(union_specifier)
] @type

(_
type: (_) @type
) @_.domain

(_
declarator: (_
value: (_) @value
)
) @_.domain

(_
value: (_) @value
) @_.domain

(optional_parameter_declaration
default_value: (_) @value
) @_.domain

;;!! void foo(int value) {}
;;! ^^^^^^^^^
(parameter_list
(_)? @_.leading.endOf
.
(_) @argumentOrParameter
.
(_)? @_.trailing.startOf
)

;;!! foo(5 + 6)
;;! ^^^^^
(argument_list
(_)? @_.leading.endOf
.
(_) @argumentOrParameter
.
(_)? @_.trailing.startOf
)

(_
(parameter_list
"(" @argumentOrParameter.iteration.start.endOf
")" @argumentOrParameter.iteration.end.startOf
)
) @argumentOrParameter.iteration.domain

(argument_list
"(" @argumentOrParameter.iteration.start.endOf
")" @argumentOrParameter.iteration.end.startOf
) @argumentOrParameter.iteration.domain

0 comments on commit 2a639cc

Please sign in to comment.