mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-21 04:41:16 -05:00
Refactor analyze-project to parse-source-code
This commit is contained in:
23
src/parse-source-code/queries/c-sharp.ts
Normal file
23
src/parse-source-code/queries/c-sharp.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
- class declarations
|
||||
- interface declarations
|
||||
- method declarations
|
||||
- namespace declarations
|
||||
*/
|
||||
export default `
|
||||
(class_declaration
|
||||
name: (identifier) @name.definition.class
|
||||
) @definition.class
|
||||
|
||||
(interface_declaration
|
||||
name: (identifier) @name.definition.interface
|
||||
) @definition.interface
|
||||
|
||||
(method_declaration
|
||||
name: (identifier) @name.definition.method
|
||||
) @definition.method
|
||||
|
||||
(namespace_declaration
|
||||
name: (identifier) @name.definition.module
|
||||
) @definition.module
|
||||
`
|
||||
15
src/parse-source-code/queries/c.ts
Normal file
15
src/parse-source-code/queries/c.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
- struct declarations
|
||||
- union declarations
|
||||
- function declarations
|
||||
- typedef declarations
|
||||
*/
|
||||
export default `
|
||||
(struct_specifier name: (type_identifier) @name.definition.class body:(_)) @definition.class
|
||||
|
||||
(declaration type: (union_specifier name: (type_identifier) @name.definition.class)) @definition.class
|
||||
|
||||
(function_declarator declarator: (identifier) @name.definition.function) @definition.function
|
||||
|
||||
(type_definition declarator: (type_identifier) @name.definition.type) @definition.type
|
||||
`
|
||||
23
src/parse-source-code/queries/cpp.ts
Normal file
23
src/parse-source-code/queries/cpp.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
- struct declarations
|
||||
- union declarations
|
||||
- function declarations
|
||||
- method declarations (with namespace scope)
|
||||
- typedef declarations
|
||||
- class declarations
|
||||
*/
|
||||
export default `
|
||||
(struct_specifier name: (type_identifier) @name.definition.class body:(_)) @definition.class
|
||||
|
||||
(declaration type: (union_specifier name: (type_identifier) @name.definition.class)) @definition.class
|
||||
|
||||
(function_declarator declarator: (identifier) @name.definition.function) @definition.function
|
||||
|
||||
(function_declarator declarator: (field_identifier) @name.definition.function) @definition.function
|
||||
|
||||
(function_declarator declarator: (qualified_identifier scope: (namespace_identifier) @scope name: (identifier) @name.definition.method)) @definition.method
|
||||
|
||||
(type_definition declarator: (type_identifier) @name.definition.type) @definition.type
|
||||
|
||||
(class_specifier name: (type_identifier) @name.definition.class) @definition.class
|
||||
`
|
||||
27
src/parse-source-code/queries/go.ts
Normal file
27
src/parse-source-code/queries/go.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
- function declarations (with associated comments)
|
||||
- method declarations (with associated comments)
|
||||
- type specifications
|
||||
*/
|
||||
export default `
|
||||
(
|
||||
(comment)* @doc
|
||||
.
|
||||
(function_declaration
|
||||
name: (identifier) @name.definition.function) @definition.function
|
||||
(#strip! @doc "^//\\s*")
|
||||
(#set-adjacent! @doc @definition.function)
|
||||
)
|
||||
|
||||
(
|
||||
(comment)* @doc
|
||||
.
|
||||
(method_declaration
|
||||
name: (field_identifier) @name.definition.method) @definition.method
|
||||
(#strip! @doc "^//\\s*")
|
||||
(#set-adjacent! @doc @definition.method)
|
||||
)
|
||||
|
||||
(type_spec
|
||||
name: (type_identifier) @name.definition.type) @definition.type
|
||||
`
|
||||
12
src/parse-source-code/queries/index.ts
Normal file
12
src/parse-source-code/queries/index.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
export { default as phpQuery } from "./php"
|
||||
export { default as typescriptQuery } from "./typescript"
|
||||
export { default as pythonQuery } from "./python"
|
||||
export { default as javascriptQuery } from "./javascript"
|
||||
export { default as javaQuery } from "./java"
|
||||
export { default as rustQuery } from "./rust"
|
||||
export { default as rubyQuery } from "./ruby"
|
||||
export { default as cppQuery } from "./cpp"
|
||||
export { default as cQuery } from "./c"
|
||||
export { default as csharpQuery } from "./c-sharp"
|
||||
export { default as goQuery } from "./go"
|
||||
export { default as swiftQuery } from "./swift"
|
||||
15
src/parse-source-code/queries/java.ts
Normal file
15
src/parse-source-code/queries/java.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
- class declarations
|
||||
- method declarations
|
||||
- interface declarations
|
||||
*/
|
||||
export default `
|
||||
(class_declaration
|
||||
name: (identifier) @name.definition.class) @definition.class
|
||||
|
||||
(method_declaration
|
||||
name: (identifier) @name.definition.method) @definition.method
|
||||
|
||||
(interface_declaration
|
||||
name: (identifier) @name.definition.interface) @definition.interface
|
||||
`
|
||||
65
src/parse-source-code/queries/javascript.ts
Normal file
65
src/parse-source-code/queries/javascript.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
- class definitions
|
||||
- method definitions
|
||||
- named function declarations
|
||||
- arrow functions and function expressions assigned to variables
|
||||
*/
|
||||
export default `
|
||||
(
|
||||
(comment)* @doc
|
||||
.
|
||||
(method_definition
|
||||
name: (property_identifier) @name) @definition.method
|
||||
(#not-eq? @name "constructor")
|
||||
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
||||
(#select-adjacent! @doc @definition.method)
|
||||
)
|
||||
|
||||
(
|
||||
(comment)* @doc
|
||||
.
|
||||
[
|
||||
(class
|
||||
name: (_) @name)
|
||||
(class_declaration
|
||||
name: (_) @name)
|
||||
] @definition.class
|
||||
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
||||
(#select-adjacent! @doc @definition.class)
|
||||
)
|
||||
|
||||
(
|
||||
(comment)* @doc
|
||||
.
|
||||
[
|
||||
(function_declaration
|
||||
name: (identifier) @name)
|
||||
(generator_function_declaration
|
||||
name: (identifier) @name)
|
||||
] @definition.function
|
||||
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
||||
(#select-adjacent! @doc @definition.function)
|
||||
)
|
||||
|
||||
(
|
||||
(comment)* @doc
|
||||
.
|
||||
(lexical_declaration
|
||||
(variable_declarator
|
||||
name: (identifier) @name
|
||||
value: [(arrow_function) (function_expression)]) @definition.function)
|
||||
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
||||
(#select-adjacent! @doc @definition.function)
|
||||
)
|
||||
|
||||
(
|
||||
(comment)* @doc
|
||||
.
|
||||
(variable_declaration
|
||||
(variable_declarator
|
||||
name: (identifier) @name
|
||||
value: [(arrow_function) (function_expression)]) @definition.function)
|
||||
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
||||
(#select-adjacent! @doc @definition.function)
|
||||
)
|
||||
`
|
||||
15
src/parse-source-code/queries/php.ts
Normal file
15
src/parse-source-code/queries/php.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
- class declarations
|
||||
- function definitions
|
||||
- method declarations
|
||||
*/
|
||||
export default `
|
||||
(class_declaration
|
||||
name: (name) @name.definition.class) @definition.class
|
||||
|
||||
(function_definition
|
||||
name: (name) @name.definition.function) @definition.function
|
||||
|
||||
(method_declaration
|
||||
name: (name) @name.definition.function) @definition.function
|
||||
`
|
||||
11
src/parse-source-code/queries/python.ts
Normal file
11
src/parse-source-code/queries/python.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
- class definitions
|
||||
- function definitions
|
||||
*/
|
||||
export default `
|
||||
(class_definition
|
||||
name: (identifier) @name.definition.class) @definition.class
|
||||
|
||||
(function_definition
|
||||
name: (identifier) @name.definition.function) @definition.function
|
||||
`
|
||||
52
src/parse-source-code/queries/ruby.ts
Normal file
52
src/parse-source-code/queries/ruby.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
- method definitions (including singleton methods and aliases, with associated comments)
|
||||
- class definitions (including singleton classes, with associated comments)
|
||||
- module definitions
|
||||
*/
|
||||
export default `
|
||||
(
|
||||
(comment)* @doc
|
||||
.
|
||||
[
|
||||
(method
|
||||
name: (_) @name.definition.method) @definition.method
|
||||
(singleton_method
|
||||
name: (_) @name.definition.method) @definition.method
|
||||
]
|
||||
(#strip! @doc "^#\\s*")
|
||||
(#select-adjacent! @doc @definition.method)
|
||||
)
|
||||
|
||||
(alias
|
||||
name: (_) @name.definition.method) @definition.method
|
||||
|
||||
(
|
||||
(comment)* @doc
|
||||
.
|
||||
[
|
||||
(class
|
||||
name: [
|
||||
(constant) @name.definition.class
|
||||
(scope_resolution
|
||||
name: (_) @name.definition.class)
|
||||
]) @definition.class
|
||||
(singleton_class
|
||||
value: [
|
||||
(constant) @name.definition.class
|
||||
(scope_resolution
|
||||
name: (_) @name.definition.class)
|
||||
]) @definition.class
|
||||
]
|
||||
(#strip! @doc "^#\\s*")
|
||||
(#select-adjacent! @doc @definition.class)
|
||||
)
|
||||
|
||||
(
|
||||
(module
|
||||
name: [
|
||||
(constant) @name.definition.module
|
||||
(scope_resolution
|
||||
name: (_) @name.definition.module)
|
||||
]) @definition.module
|
||||
)
|
||||
`
|
||||
16
src/parse-source-code/queries/rust.ts
Normal file
16
src/parse-source-code/queries/rust.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
- struct definitions
|
||||
- method definitions
|
||||
- function definitions
|
||||
*/
|
||||
export default `
|
||||
(struct_item
|
||||
name: (type_identifier) @name.definition.class) @definition.class
|
||||
|
||||
(declaration_list
|
||||
(function_item
|
||||
name: (identifier) @name.definition.method)) @definition.method
|
||||
|
||||
(function_item
|
||||
name: (identifier) @name.definition.function) @definition.function
|
||||
`
|
||||
45
src/parse-source-code/queries/swift.ts
Normal file
45
src/parse-source-code/queries/swift.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
- class declarations
|
||||
- method declarations (including initializers and deinitializers)
|
||||
- property declarations
|
||||
- function declarations
|
||||
*/
|
||||
export default `
|
||||
(class_declaration
|
||||
name: (type_identifier) @name) @definition.class
|
||||
|
||||
(protocol_declaration
|
||||
name: (type_identifier) @name) @definition.interface
|
||||
|
||||
(class_declaration
|
||||
(class_body
|
||||
[
|
||||
(function_declaration
|
||||
name: (simple_identifier) @name
|
||||
)
|
||||
(subscript_declaration
|
||||
(parameter (simple_identifier) @name)
|
||||
)
|
||||
(init_declaration "init" @name)
|
||||
(deinit_declaration "deinit" @name)
|
||||
]
|
||||
)
|
||||
) @definition.method
|
||||
|
||||
(class_declaration
|
||||
(class_body
|
||||
[
|
||||
(property_declaration
|
||||
(pattern (simple_identifier) @name)
|
||||
)
|
||||
]
|
||||
)
|
||||
) @definition.property
|
||||
|
||||
(property_declaration
|
||||
(pattern (simple_identifier) @name)
|
||||
) @definition.property
|
||||
|
||||
(function_declaration
|
||||
name: (simple_identifier) @name) @definition.function
|
||||
`
|
||||
32
src/parse-source-code/queries/typescript.ts
Normal file
32
src/parse-source-code/queries/typescript.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
- function signatures and declarations
|
||||
- method signatures and definitions
|
||||
- abstract method signatures
|
||||
- class declarations (including abstract classes)
|
||||
- module declarations
|
||||
*/
|
||||
export default `
|
||||
(function_signature
|
||||
name: (identifier) @name.definition.function) @definition.function
|
||||
|
||||
(method_signature
|
||||
name: (property_identifier) @name.definition.method) @definition.method
|
||||
|
||||
(abstract_method_signature
|
||||
name: (property_identifier) @name.definition.method) @definition.method
|
||||
|
||||
(abstract_class_declaration
|
||||
name: (type_identifier) @name.definition.class) @definition.class
|
||||
|
||||
(module
|
||||
name: (identifier) @name.definition.module) @definition.module
|
||||
|
||||
(function_declaration
|
||||
name: (identifier) @name.definition.function) @definition.function
|
||||
|
||||
(method_definition
|
||||
name: (property_identifier) @name.definition.method) @definition.method
|
||||
|
||||
(class_declaration
|
||||
name: (type_identifier) @name.definition.class) @definition.class
|
||||
`
|
||||
Reference in New Issue
Block a user