@oisheek_c/codeforge 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -0
- package/README.md +7 -0
- package/apps/cli/bin/codeforge.cmd +2 -0
- package/apps/cli/src/bootstrap.js +115 -0
- package/apps/cli/src/cli.js +189 -0
- package/apps/cli/src/dev/git.js +17 -0
- package/apps/cli/src/dev/index.js +68 -0
- package/apps/cli/src/dev/provider.js +48 -0
- package/apps/cli/src/dev/scanner.js +14 -0
- package/apps/cli/src/index.js +31 -0
- package/bin/codeforge.js +2 -0
- package/package.json +63 -0
- package/packages/agent/contextBuilder.js +234 -0
- package/packages/agent/executor.js +1729 -0
- package/packages/agent/fallback.js +129 -0
- package/packages/agent/index.js +26 -0
- package/packages/agent/intent.js +73 -0
- package/packages/agent/modelSelector.js +469 -0
- package/packages/agent/planner.js +379 -0
- package/packages/agent/rag.js +412 -0
- package/packages/agent/ragSelector.js +570 -0
- package/packages/agent/router.js +121 -0
- package/packages/agent/thinking.js +54 -0
- package/packages/agent/toolCalls.js +258 -0
- package/packages/config/config.js +391 -0
- package/packages/config/defaults.js +72 -0
- package/packages/config/index.js +2 -0
- package/packages/core/approvalPolicy.js +140 -0
- package/packages/core/context.js +0 -0
- package/packages/core/message.js +0 -0
- package/packages/core/plan.js +0 -0
- package/packages/core/reasoning.js +0 -0
- package/packages/core/result.js +0 -0
- package/packages/core/retrieval.js +0 -0
- package/packages/core/tool.js +536 -0
- package/packages/git/branch.js +7 -0
- package/packages/git/commit.js +16 -0
- package/packages/git/diff.js +15 -0
- package/packages/git/git.js +35 -0
- package/packages/git/index.js +6 -0
- package/packages/git/remote.js +9 -0
- package/packages/git/status.js +11 -0
- package/packages/memory/index.js +0 -0
- package/packages/memory/project.js +0 -0
- package/packages/memory/session.js +0 -0
- package/packages/prompts/builder.js +43 -0
- package/packages/prompts/coder.js +38 -0
- package/packages/prompts/index.js +5 -0
- package/packages/prompts/planner.js +49 -0
- package/packages/prompts/reviewer.js +38 -0
- package/packages/prompts/system.js +94 -0
- package/packages/providers/index.js +31 -0
- package/packages/providers/openrouter.js +380 -0
- package/packages/reasoning/budget.js +0 -0
- package/packages/reasoning/chain.js +0 -0
- package/packages/reasoning/coder.js +0 -0
- package/packages/reasoning/evaluator.js +0 -0
- package/packages/reasoning/index.js +8 -0
- package/packages/reasoning/planner.js +0 -0
- package/packages/reasoning/reflector.js +0 -0
- package/packages/reasoning/reviewer.js +0 -0
- package/packages/reasoning/router.js +0 -0
- package/packages/retrieval/budget.js +92 -0
- package/packages/retrieval/cache.js +84 -0
- package/packages/retrieval/embeddings.js +147 -0
- package/packages/retrieval/graph.js +151 -0
- package/packages/retrieval/imports.js +74 -0
- package/packages/retrieval/index.js +9 -0
- package/packages/retrieval/parser/extractors/calls.js +43 -0
- package/packages/retrieval/parser/extractors/comments.js +49 -0
- package/packages/retrieval/parser/extractors/diagnostics.js +21 -0
- package/packages/retrieval/parser/extractors/exports.js +71 -0
- package/packages/retrieval/parser/extractors/imports.js +40 -0
- package/packages/retrieval/parser/extractors/index.js +12 -0
- package/packages/retrieval/parser/extractors/metrics.js +78 -0
- package/packages/retrieval/parser/extractors/symbols.js +51 -0
- package/packages/retrieval/parser/extractors/todos.js +53 -0
- package/packages/retrieval/parser/helpers.js +138 -0
- package/packages/retrieval/parser/index.js +10 -0
- package/packages/retrieval/parser/languages/c.js +14 -0
- package/packages/retrieval/parser/languages/cpp.js +21 -0
- package/packages/retrieval/parser/languages/csharp.js +14 -0
- package/packages/retrieval/parser/languages/go.js +14 -0
- package/packages/retrieval/parser/languages/index.js +12 -0
- package/packages/retrieval/parser/languages/java.js +14 -0
- package/packages/retrieval/parser/languages/javascript.js +14 -0
- package/packages/retrieval/parser/languages/php.js +14 -0
- package/packages/retrieval/parser/languages/python.js +14 -0
- package/packages/retrieval/parser/languages/ruby.js +14 -0
- package/packages/retrieval/parser/languages/rust.js +14 -0
- package/packages/retrieval/parser/languages/swift.js +14 -0
- package/packages/retrieval/parser/languages/typescript.js +14 -0
- package/packages/retrieval/parser/languages.js +218 -0
- package/packages/retrieval/parser/parseFile.js +79 -0
- package/packages/retrieval/parser/parseRepository.js +78 -0
- package/packages/retrieval/parser/queries/c.js +148 -0
- package/packages/retrieval/parser/queries/cpp.js +198 -0
- package/packages/retrieval/parser/queries/csharp.js +151 -0
- package/packages/retrieval/parser/queries/go.js +124 -0
- package/packages/retrieval/parser/queries/index.js +35 -0
- package/packages/retrieval/parser/queries/java.js +128 -0
- package/packages/retrieval/parser/queries/javascript.js +181 -0
- package/packages/retrieval/parser/queries/php.js +140 -0
- package/packages/retrieval/parser/queries/python.js +110 -0
- package/packages/retrieval/parser/queries/ruby.js +105 -0
- package/packages/retrieval/parser/queries/rust.js +175 -0
- package/packages/retrieval/parser/queries/swift.js +134 -0
- package/packages/retrieval/parser/queries/typescript.js +202 -0
- package/packages/retrieval/parser/registry.js +107 -0
- package/packages/retrieval/parser/traverse.js +82 -0
- package/packages/retrieval/parser/types.js +239 -0
- package/packages/retrieval/parser.js +78 -0
- package/packages/retrieval/ranker.js +73 -0
- package/packages/retrieval/retriever.js +910 -0
- package/packages/retrieval/symbols.js +145 -0
- package/packages/scanner/detect.js +69 -0
- package/packages/scanner/ignore.js +12 -0
- package/packages/scanner/index.js +2 -0
- package/packages/scanner/root.js +21 -0
- package/packages/scanner/scanner.js +35 -0
- package/packages/scanner/tree.js +45 -0
- package/packages/terminal/activity.js +514 -0
- package/packages/terminal/banner.js +34 -0
- package/packages/terminal/colors.js +16 -0
- package/packages/terminal/dashboard.js +94 -0
- package/packages/terminal/index.js +19 -0
- package/packages/terminal/logger.js +43 -0
- package/packages/terminal/prompt.js +11 -0
- package/packages/terminal/renderer.js +1209 -0
- package/packages/terminal/spinner.js +9 -0
- package/packages/tools/editFile.js +261 -0
- package/packages/tools/filesystem.js +82 -0
- package/packages/tools/index.js +24 -0
- package/packages/tools/readFile.js +101 -0
- package/packages/tools/registry.js +227 -0
- package/packages/tools/searchFiles.js +322 -0
- package/packages/tools/shell.js +352 -0
- package/packages/tools/writeFile.js +212 -0
- package/packages/utils/constants.js +0 -0
- package/packages/utils/helpers.js +0 -0
- package/packages/utils/logger.js +0 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-sitter queries for C#.
|
|
3
|
+
*
|
|
4
|
+
* Stable capture namespaces:
|
|
5
|
+
*
|
|
6
|
+
* @symbol.namespace
|
|
7
|
+
* @symbol.class
|
|
8
|
+
* @symbol.struct
|
|
9
|
+
* @symbol.interface
|
|
10
|
+
* @symbol.enum
|
|
11
|
+
* @symbol.record
|
|
12
|
+
* @symbol.delegate
|
|
13
|
+
* @symbol.constructor
|
|
14
|
+
* @symbol.method
|
|
15
|
+
* @symbol.property
|
|
16
|
+
* @symbol.field
|
|
17
|
+
* @symbol.event
|
|
18
|
+
* @symbol.variable
|
|
19
|
+
*
|
|
20
|
+
* @import
|
|
21
|
+
* @export
|
|
22
|
+
* @call
|
|
23
|
+
* @comment
|
|
24
|
+
* @todo
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export const SYMBOLS = `
|
|
28
|
+
;; ============================================================
|
|
29
|
+
;; Namespace
|
|
30
|
+
;; ============================================================
|
|
31
|
+
|
|
32
|
+
(namespace_declaration
|
|
33
|
+
name: (qualified_name) @symbol.namespace)
|
|
34
|
+
|
|
35
|
+
(file_scoped_namespace_declaration
|
|
36
|
+
name: (qualified_name) @symbol.namespace)
|
|
37
|
+
|
|
38
|
+
;; ============================================================
|
|
39
|
+
;; Classes
|
|
40
|
+
;; ============================================================
|
|
41
|
+
|
|
42
|
+
(class_declaration
|
|
43
|
+
name: (identifier) @symbol.class)
|
|
44
|
+
|
|
45
|
+
;; ============================================================
|
|
46
|
+
;; Structs
|
|
47
|
+
;; ============================================================
|
|
48
|
+
|
|
49
|
+
(struct_declaration
|
|
50
|
+
name: (identifier) @symbol.struct)
|
|
51
|
+
|
|
52
|
+
;; ============================================================
|
|
53
|
+
;; Interfaces
|
|
54
|
+
;; ============================================================
|
|
55
|
+
|
|
56
|
+
(interface_declaration
|
|
57
|
+
name: (identifier) @symbol.interface)
|
|
58
|
+
|
|
59
|
+
;; ============================================================
|
|
60
|
+
;; Enums
|
|
61
|
+
;; ============================================================
|
|
62
|
+
|
|
63
|
+
(enum_declaration
|
|
64
|
+
name: (identifier) @symbol.enum)
|
|
65
|
+
|
|
66
|
+
;; ============================================================
|
|
67
|
+
;; Records
|
|
68
|
+
;; ============================================================
|
|
69
|
+
|
|
70
|
+
(record_declaration
|
|
71
|
+
name: (identifier) @symbol.record)
|
|
72
|
+
|
|
73
|
+
;; ============================================================
|
|
74
|
+
;; Delegates
|
|
75
|
+
;; ============================================================
|
|
76
|
+
|
|
77
|
+
(delegate_declaration
|
|
78
|
+
name: (identifier) @symbol.delegate)
|
|
79
|
+
|
|
80
|
+
;; ============================================================
|
|
81
|
+
;; Constructors
|
|
82
|
+
;; ============================================================
|
|
83
|
+
|
|
84
|
+
(constructor_declaration
|
|
85
|
+
name: (identifier) @symbol.constructor)
|
|
86
|
+
|
|
87
|
+
;; ============================================================
|
|
88
|
+
;; Methods
|
|
89
|
+
;; ============================================================
|
|
90
|
+
|
|
91
|
+
(method_declaration
|
|
92
|
+
name: (identifier) @symbol.method)
|
|
93
|
+
|
|
94
|
+
;; ============================================================
|
|
95
|
+
;; Properties
|
|
96
|
+
;; ============================================================
|
|
97
|
+
|
|
98
|
+
(property_declaration
|
|
99
|
+
name: (identifier) @symbol.property)
|
|
100
|
+
|
|
101
|
+
;; ============================================================
|
|
102
|
+
;; Fields
|
|
103
|
+
;; ============================================================
|
|
104
|
+
|
|
105
|
+
(field_declaration
|
|
106
|
+
(variable_declaration
|
|
107
|
+
(variable_declarator
|
|
108
|
+
name: (identifier) @symbol.field)))
|
|
109
|
+
|
|
110
|
+
;; ============================================================
|
|
111
|
+
;; Events
|
|
112
|
+
;; ============================================================
|
|
113
|
+
|
|
114
|
+
(event_declaration
|
|
115
|
+
name: (identifier) @symbol.event)
|
|
116
|
+
|
|
117
|
+
;; ============================================================
|
|
118
|
+
;; Local Variables
|
|
119
|
+
;; ============================================================
|
|
120
|
+
|
|
121
|
+
(local_declaration_statement
|
|
122
|
+
(variable_declaration
|
|
123
|
+
(variable_declarator
|
|
124
|
+
name: (identifier) @symbol.variable)))
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
export const IMPORTS = `
|
|
128
|
+
(using_directive) @import
|
|
129
|
+
`;
|
|
130
|
+
|
|
131
|
+
export const EXPORTS = `
|
|
132
|
+
`;
|
|
133
|
+
|
|
134
|
+
export const CALLS = `
|
|
135
|
+
(invocation_expression
|
|
136
|
+
function: (identifier) @call)
|
|
137
|
+
|
|
138
|
+
(invocation_expression
|
|
139
|
+
function:
|
|
140
|
+
(member_access_expression
|
|
141
|
+
name: (identifier) @call))
|
|
142
|
+
`;
|
|
143
|
+
|
|
144
|
+
export const COMMENTS = `
|
|
145
|
+
(comment) @comment
|
|
146
|
+
`;
|
|
147
|
+
|
|
148
|
+
export const TODOS = `
|
|
149
|
+
(comment) @todo
|
|
150
|
+
(#match? @todo "(?i)(TODO|FIXME|BUG|HACK|XXX|NOTE)")
|
|
151
|
+
`;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-sitter queries for Go.
|
|
3
|
+
*
|
|
4
|
+
* Stable capture namespaces:
|
|
5
|
+
*
|
|
6
|
+
* @symbol.package
|
|
7
|
+
* @symbol.struct
|
|
8
|
+
* @symbol.interface
|
|
9
|
+
* @symbol.function
|
|
10
|
+
* @symbol.method
|
|
11
|
+
* @symbol.type
|
|
12
|
+
* @symbol.variable
|
|
13
|
+
* @symbol.constant
|
|
14
|
+
*
|
|
15
|
+
* @import
|
|
16
|
+
* @export
|
|
17
|
+
* @call
|
|
18
|
+
* @comment
|
|
19
|
+
* @todo
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export const SYMBOLS = `
|
|
23
|
+
;; ============================================================
|
|
24
|
+
;; Package
|
|
25
|
+
;; ============================================================
|
|
26
|
+
|
|
27
|
+
(package_clause
|
|
28
|
+
(package_identifier) @symbol.package)
|
|
29
|
+
|
|
30
|
+
;; ============================================================
|
|
31
|
+
;; Structs
|
|
32
|
+
;; ============================================================
|
|
33
|
+
|
|
34
|
+
(type_declaration
|
|
35
|
+
(type_spec
|
|
36
|
+
name: (type_identifier) @symbol.struct
|
|
37
|
+
type: (struct_type)))
|
|
38
|
+
|
|
39
|
+
;; ============================================================
|
|
40
|
+
;; Interfaces
|
|
41
|
+
;; ============================================================
|
|
42
|
+
|
|
43
|
+
(type_declaration
|
|
44
|
+
(type_spec
|
|
45
|
+
name: (type_identifier) @symbol.interface
|
|
46
|
+
type: (interface_type)))
|
|
47
|
+
|
|
48
|
+
;; ============================================================
|
|
49
|
+
;; Type aliases
|
|
50
|
+
;; ============================================================
|
|
51
|
+
|
|
52
|
+
(type_declaration
|
|
53
|
+
(type_spec
|
|
54
|
+
name: (type_identifier) @symbol.type))
|
|
55
|
+
|
|
56
|
+
;; ============================================================
|
|
57
|
+
;; Functions
|
|
58
|
+
;; ============================================================
|
|
59
|
+
|
|
60
|
+
(function_declaration
|
|
61
|
+
name: (identifier) @symbol.function)
|
|
62
|
+
|
|
63
|
+
;; ============================================================
|
|
64
|
+
;; Methods
|
|
65
|
+
;; ============================================================
|
|
66
|
+
|
|
67
|
+
(method_declaration
|
|
68
|
+
name: (field_identifier) @symbol.method)
|
|
69
|
+
|
|
70
|
+
;; ============================================================
|
|
71
|
+
;; Variables
|
|
72
|
+
;; ============================================================
|
|
73
|
+
|
|
74
|
+
(var_declaration
|
|
75
|
+
(var_spec
|
|
76
|
+
name: (identifier) @symbol.variable))
|
|
77
|
+
|
|
78
|
+
(short_var_declaration
|
|
79
|
+
left: (expression_list
|
|
80
|
+
(identifier) @symbol.variable))
|
|
81
|
+
|
|
82
|
+
;; ============================================================
|
|
83
|
+
;; Constants
|
|
84
|
+
;; ============================================================
|
|
85
|
+
|
|
86
|
+
(const_declaration
|
|
87
|
+
(const_spec
|
|
88
|
+
name: (identifier) @symbol.constant))
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
export const IMPORTS = `
|
|
92
|
+
(import_declaration) @import
|
|
93
|
+
`;
|
|
94
|
+
|
|
95
|
+
export const EXPORTS = `
|
|
96
|
+
`;
|
|
97
|
+
|
|
98
|
+
export const CALLS = `
|
|
99
|
+
;; ============================================================
|
|
100
|
+
;; foo()
|
|
101
|
+
;; ============================================================
|
|
102
|
+
|
|
103
|
+
(call_expression
|
|
104
|
+
function: (identifier) @call)
|
|
105
|
+
|
|
106
|
+
;; ============================================================
|
|
107
|
+
;; pkg.Func()
|
|
108
|
+
;; obj.Method()
|
|
109
|
+
;; ============================================================
|
|
110
|
+
|
|
111
|
+
(call_expression
|
|
112
|
+
function:
|
|
113
|
+
(selector_expression
|
|
114
|
+
field: (field_identifier) @call))
|
|
115
|
+
`;
|
|
116
|
+
|
|
117
|
+
export const COMMENTS = `
|
|
118
|
+
(comment) @comment
|
|
119
|
+
`;
|
|
120
|
+
|
|
121
|
+
export const TODOS = `
|
|
122
|
+
(comment) @todo
|
|
123
|
+
(#match? @todo "(?i)(TODO|FIXME|BUG|HACK|XXX|NOTE)")
|
|
124
|
+
`;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as javascript from "./javascript.js";
|
|
2
|
+
import * as typescript from "./typescript.js";
|
|
3
|
+
import * as python from "./python.js";
|
|
4
|
+
import * as java from "./java.js";
|
|
5
|
+
import * as go from "./go.js";
|
|
6
|
+
import * as rust from "./rust.js";
|
|
7
|
+
import * as c from "./c.js";
|
|
8
|
+
import * as cpp from "./cpp.js";
|
|
9
|
+
import * as csharp from "./csharp.js";
|
|
10
|
+
import * as php from "./php.js";
|
|
11
|
+
import * as ruby from "./ruby.js";
|
|
12
|
+
import * as swift from "./swift.js";
|
|
13
|
+
|
|
14
|
+
const QUERIES = {
|
|
15
|
+
javascript,
|
|
16
|
+
jsx: javascript,
|
|
17
|
+
|
|
18
|
+
typescript,
|
|
19
|
+
tsx: typescript,
|
|
20
|
+
|
|
21
|
+
python,
|
|
22
|
+
java,
|
|
23
|
+
go,
|
|
24
|
+
rust,
|
|
25
|
+
c,
|
|
26
|
+
cpp,
|
|
27
|
+
csharp,
|
|
28
|
+
php,
|
|
29
|
+
ruby,
|
|
30
|
+
swift,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function getQuerySet(language) {
|
|
34
|
+
return QUERIES[language] ?? null;
|
|
35
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-sitter queries for Java.
|
|
3
|
+
*
|
|
4
|
+
* Stable capture namespaces:
|
|
5
|
+
*
|
|
6
|
+
* @symbol.class
|
|
7
|
+
* @symbol.interface
|
|
8
|
+
* @symbol.enum
|
|
9
|
+
* @symbol.record
|
|
10
|
+
* @symbol.constructor
|
|
11
|
+
* @symbol.method
|
|
12
|
+
* @symbol.field
|
|
13
|
+
* @symbol.variable
|
|
14
|
+
*
|
|
15
|
+
* @import
|
|
16
|
+
* @export
|
|
17
|
+
* @call
|
|
18
|
+
* @comment
|
|
19
|
+
* @todo
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export const SYMBOLS = `
|
|
23
|
+
;; ============================================================
|
|
24
|
+
;; Classes
|
|
25
|
+
;; ============================================================
|
|
26
|
+
|
|
27
|
+
(class_declaration
|
|
28
|
+
name: (identifier) @symbol.class)
|
|
29
|
+
|
|
30
|
+
;; ============================================================
|
|
31
|
+
;; Interfaces
|
|
32
|
+
;; ============================================================
|
|
33
|
+
|
|
34
|
+
(interface_declaration
|
|
35
|
+
name: (identifier) @symbol.interface)
|
|
36
|
+
|
|
37
|
+
;; ============================================================
|
|
38
|
+
;; Enums
|
|
39
|
+
;; ============================================================
|
|
40
|
+
|
|
41
|
+
(enum_declaration
|
|
42
|
+
name: (identifier) @symbol.enum)
|
|
43
|
+
|
|
44
|
+
;; ============================================================
|
|
45
|
+
;; Records (Java 16+)
|
|
46
|
+
;; ============================================================
|
|
47
|
+
|
|
48
|
+
(record_declaration
|
|
49
|
+
name: (identifier) @symbol.record)
|
|
50
|
+
|
|
51
|
+
;; ============================================================
|
|
52
|
+
;; Constructors
|
|
53
|
+
;; ============================================================
|
|
54
|
+
|
|
55
|
+
(constructor_declaration
|
|
56
|
+
name: (identifier) @symbol.constructor)
|
|
57
|
+
|
|
58
|
+
;; ============================================================
|
|
59
|
+
;; Methods
|
|
60
|
+
;; ============================================================
|
|
61
|
+
|
|
62
|
+
(method_declaration
|
|
63
|
+
name: (identifier) @symbol.method)
|
|
64
|
+
|
|
65
|
+
;; ============================================================
|
|
66
|
+
;; Fields
|
|
67
|
+
;; ============================================================
|
|
68
|
+
|
|
69
|
+
(field_declaration
|
|
70
|
+
declarator:
|
|
71
|
+
(variable_declarator
|
|
72
|
+
name: (identifier) @symbol.field))
|
|
73
|
+
|
|
74
|
+
;; ============================================================
|
|
75
|
+
;; Local Variables
|
|
76
|
+
;; ============================================================
|
|
77
|
+
|
|
78
|
+
(local_variable_declaration
|
|
79
|
+
declarator:
|
|
80
|
+
(variable_declarator
|
|
81
|
+
name: (identifier) @symbol.variable))
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
export const IMPORTS = `
|
|
85
|
+
(import_declaration) @import
|
|
86
|
+
`;
|
|
87
|
+
|
|
88
|
+
export const EXPORTS = `
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
export const CALLS = `
|
|
92
|
+
;; foo()
|
|
93
|
+
|
|
94
|
+
(method_invocation
|
|
95
|
+
name: (identifier) @call)
|
|
96
|
+
|
|
97
|
+
;; obj.foo()
|
|
98
|
+
|
|
99
|
+
(method_invocation
|
|
100
|
+
object: (_)
|
|
101
|
+
name: (identifier) @call)
|
|
102
|
+
|
|
103
|
+
;; this.foo()
|
|
104
|
+
|
|
105
|
+
(method_invocation
|
|
106
|
+
object: (this)
|
|
107
|
+
name: (identifier) @call)
|
|
108
|
+
|
|
109
|
+
;; super.foo()
|
|
110
|
+
|
|
111
|
+
(method_invocation
|
|
112
|
+
object: (super)
|
|
113
|
+
name: (identifier) @call)
|
|
114
|
+
`;
|
|
115
|
+
|
|
116
|
+
export const COMMENTS = `
|
|
117
|
+
(line_comment) @comment
|
|
118
|
+
|
|
119
|
+
(block_comment) @comment
|
|
120
|
+
`;
|
|
121
|
+
|
|
122
|
+
export const TODOS = `
|
|
123
|
+
(line_comment) @todo
|
|
124
|
+
(#match? @todo "(?i)(TODO|FIXME|BUG|HACK|XXX|NOTE)")
|
|
125
|
+
|
|
126
|
+
(block_comment) @todo
|
|
127
|
+
(#match? @todo "(?i)(TODO|FIXME|BUG|HACK|XXX|NOTE)")
|
|
128
|
+
`;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-sitter queries for JavaScript.
|
|
3
|
+
*
|
|
4
|
+
* Every capture uses a stable namespace:
|
|
5
|
+
*
|
|
6
|
+
* @symbol.class
|
|
7
|
+
* @symbol.function
|
|
8
|
+
* @symbol.method
|
|
9
|
+
* @symbol.variable
|
|
10
|
+
*
|
|
11
|
+
* @import
|
|
12
|
+
* @export
|
|
13
|
+
* @call
|
|
14
|
+
* @comment
|
|
15
|
+
* @todo
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export const SYMBOLS = `
|
|
19
|
+
;; ------------------------------------------------------------
|
|
20
|
+
;; Classes
|
|
21
|
+
;; ------------------------------------------------------------
|
|
22
|
+
|
|
23
|
+
(class_declaration
|
|
24
|
+
name: (identifier) @symbol.class)
|
|
25
|
+
|
|
26
|
+
;; ------------------------------------------------------------
|
|
27
|
+
;; Functions
|
|
28
|
+
;; ------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
(function_declaration
|
|
31
|
+
name: (identifier) @symbol.function)
|
|
32
|
+
|
|
33
|
+
(generator_function_declaration
|
|
34
|
+
name: (identifier) @symbol.function)
|
|
35
|
+
|
|
36
|
+
;; ------------------------------------------------------------
|
|
37
|
+
;; Methods
|
|
38
|
+
;; ------------------------------------------------------------
|
|
39
|
+
|
|
40
|
+
(method_definition
|
|
41
|
+
name: (property_identifier) @symbol.method)
|
|
42
|
+
|
|
43
|
+
;; ------------------------------------------------------------
|
|
44
|
+
;; Arrow functions
|
|
45
|
+
;; ------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
(variable_declarator
|
|
48
|
+
name: (identifier) @symbol.function
|
|
49
|
+
value: (arrow_function))
|
|
50
|
+
|
|
51
|
+
(variable_declarator
|
|
52
|
+
name: (identifier) @symbol.function
|
|
53
|
+
value: (function_expression))
|
|
54
|
+
|
|
55
|
+
;; ------------------------------------------------------------
|
|
56
|
+
;; Variables
|
|
57
|
+
;; ------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
(variable_declarator
|
|
60
|
+
name: (identifier) @symbol.variable)
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
export const IMPORTS = `
|
|
64
|
+
;; ES modules
|
|
65
|
+
|
|
66
|
+
(import_statement) @import
|
|
67
|
+
|
|
68
|
+
;; require(...)
|
|
69
|
+
|
|
70
|
+
(call_expression
|
|
71
|
+
function: (identifier) @_require
|
|
72
|
+
(#eq? @_require "require"))
|
|
73
|
+
@import
|
|
74
|
+
`;
|
|
75
|
+
|
|
76
|
+
export const EXPORTS = `
|
|
77
|
+
;; ------------------------------------------------------------
|
|
78
|
+
;; ES module declaration exports
|
|
79
|
+
;; ------------------------------------------------------------
|
|
80
|
+
|
|
81
|
+
(export_statement
|
|
82
|
+
declaration:
|
|
83
|
+
(function_declaration
|
|
84
|
+
name: (identifier) @export.named))
|
|
85
|
+
|
|
86
|
+
(export_statement
|
|
87
|
+
declaration:
|
|
88
|
+
(generator_function_declaration
|
|
89
|
+
name: (identifier) @export.named))
|
|
90
|
+
|
|
91
|
+
(export_statement
|
|
92
|
+
declaration:
|
|
93
|
+
(class_declaration
|
|
94
|
+
name: (identifier) @export.named))
|
|
95
|
+
|
|
96
|
+
(export_statement
|
|
97
|
+
declaration:
|
|
98
|
+
(lexical_declaration
|
|
99
|
+
(variable_declarator
|
|
100
|
+
name: (identifier) @export.named)))
|
|
101
|
+
|
|
102
|
+
;; ------------------------------------------------------------
|
|
103
|
+
;; ES module named exports
|
|
104
|
+
;;
|
|
105
|
+
;; export { foo };
|
|
106
|
+
;; export { foo as bar };
|
|
107
|
+
;; export { foo } from "./module.js";
|
|
108
|
+
;; ------------------------------------------------------------
|
|
109
|
+
|
|
110
|
+
(export_statement
|
|
111
|
+
(export_clause
|
|
112
|
+
(export_specifier
|
|
113
|
+
alias: (identifier) @export.named)))
|
|
114
|
+
|
|
115
|
+
(export_statement
|
|
116
|
+
(export_clause
|
|
117
|
+
(export_specifier
|
|
118
|
+
name: (identifier) @export.named)))
|
|
119
|
+
|
|
120
|
+
;; ------------------------------------------------------------
|
|
121
|
+
;; Default exports with named declarations
|
|
122
|
+
;;
|
|
123
|
+
;; export default function foo() {}
|
|
124
|
+
;; export default class Foo {}
|
|
125
|
+
;; ------------------------------------------------------------
|
|
126
|
+
|
|
127
|
+
(export_statement
|
|
128
|
+
declaration:
|
|
129
|
+
(function_declaration
|
|
130
|
+
name: (identifier) @export.default))
|
|
131
|
+
|
|
132
|
+
(export_statement
|
|
133
|
+
declaration:
|
|
134
|
+
(class_declaration
|
|
135
|
+
name: (identifier) @export.default))
|
|
136
|
+
|
|
137
|
+
;; ------------------------------------------------------------
|
|
138
|
+
;; CommonJS: module.exports = ...
|
|
139
|
+
;;
|
|
140
|
+
;; Store "exports" as the export marker instead of capturing
|
|
141
|
+
;; the complete assignment expression.
|
|
142
|
+
;; ------------------------------------------------------------
|
|
143
|
+
|
|
144
|
+
(assignment_expression
|
|
145
|
+
left:
|
|
146
|
+
(member_expression
|
|
147
|
+
object: (identifier) @_module
|
|
148
|
+
property: (property_identifier) @export.commonjs)
|
|
149
|
+
(#eq? @_module "module")
|
|
150
|
+
(#eq? @export.commonjs "exports"))
|
|
151
|
+
|
|
152
|
+
;; ------------------------------------------------------------
|
|
153
|
+
;; CommonJS: exports.foo = ...
|
|
154
|
+
;; ------------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
(assignment_expression
|
|
157
|
+
left:
|
|
158
|
+
(member_expression
|
|
159
|
+
object: (identifier) @_exports
|
|
160
|
+
property: (property_identifier) @export.commonjs)
|
|
161
|
+
(#eq? @_exports "exports"))
|
|
162
|
+
`;
|
|
163
|
+
|
|
164
|
+
export const CALLS = `
|
|
165
|
+
(call_expression
|
|
166
|
+
function: (identifier) @call)
|
|
167
|
+
|
|
168
|
+
(call_expression
|
|
169
|
+
function:
|
|
170
|
+
(member_expression
|
|
171
|
+
property: (property_identifier) @call))
|
|
172
|
+
`;
|
|
173
|
+
|
|
174
|
+
export const COMMENTS = `
|
|
175
|
+
(comment) @comment
|
|
176
|
+
`;
|
|
177
|
+
|
|
178
|
+
export const TODOS = `
|
|
179
|
+
(comment) @todo
|
|
180
|
+
(#match? @todo "(TODO|FIXME|BUG|HACK|XXX|NOTE)")
|
|
181
|
+
`;
|