@compilr-dev/agents-coding-python 0.1.0
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 +21 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/parser/index.d.ts +6 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +5 -0
- package/dist/parser/node-types.d.ts +119 -0
- package/dist/parser/node-types.d.ts.map +1 -0
- package/dist/parser/node-types.js +4 -0
- package/dist/parser/python-parser.d.ts +85 -0
- package/dist/parser/python-parser.d.ts.map +1 -0
- package/dist/parser/python-parser.js +477 -0
- package/dist/skills/index.d.ts +26 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +36 -0
- package/dist/skills/python-best-practices.d.ts +7 -0
- package/dist/skills/python-best-practices.d.ts.map +1 -0
- package/dist/skills/python-best-practices.js +78 -0
- package/dist/skills/python-code-health.d.ts +7 -0
- package/dist/skills/python-code-health.d.ts.map +1 -0
- package/dist/skills/python-code-health.js +209 -0
- package/dist/skills/python-code-structure.d.ts +7 -0
- package/dist/skills/python-code-structure.d.ts.map +1 -0
- package/dist/skills/python-code-structure.js +155 -0
- package/dist/skills/python-dependency-audit.d.ts +7 -0
- package/dist/skills/python-dependency-audit.d.ts.map +1 -0
- package/dist/skills/python-dependency-audit.js +246 -0
- package/dist/skills/python-refactor-impact.d.ts +7 -0
- package/dist/skills/python-refactor-impact.d.ts.map +1 -0
- package/dist/skills/python-refactor-impact.js +232 -0
- package/dist/tools/extract-docstrings.d.ts +70 -0
- package/dist/tools/extract-docstrings.d.ts.map +1 -0
- package/dist/tools/extract-docstrings.js +575 -0
- package/dist/tools/find-dead-code.d.ts +62 -0
- package/dist/tools/find-dead-code.d.ts.map +1 -0
- package/dist/tools/find-dead-code.js +422 -0
- package/dist/tools/find-duplicates.d.ts +65 -0
- package/dist/tools/find-duplicates.d.ts.map +1 -0
- package/dist/tools/find-duplicates.js +289 -0
- package/dist/tools/find-implementations.d.ts +71 -0
- package/dist/tools/find-implementations.d.ts.map +1 -0
- package/dist/tools/find-implementations.js +342 -0
- package/dist/tools/find-patterns.d.ts +71 -0
- package/dist/tools/find-patterns.d.ts.map +1 -0
- package/dist/tools/find-patterns.js +477 -0
- package/dist/tools/find-references.d.ts +66 -0
- package/dist/tools/find-references.d.ts.map +1 -0
- package/dist/tools/find-references.js +306 -0
- package/dist/tools/find-symbol.d.ts +86 -0
- package/dist/tools/find-symbol.d.ts.map +1 -0
- package/dist/tools/find-symbol.js +414 -0
- package/dist/tools/get-call-graph.d.ts +89 -0
- package/dist/tools/get-call-graph.d.ts.map +1 -0
- package/dist/tools/get-call-graph.js +431 -0
- package/dist/tools/get-class-hierarchy.d.ts +38 -0
- package/dist/tools/get-class-hierarchy.d.ts.map +1 -0
- package/dist/tools/get-class-hierarchy.js +289 -0
- package/dist/tools/get-complexity.d.ts +61 -0
- package/dist/tools/get-complexity.d.ts.map +1 -0
- package/dist/tools/get-complexity.js +384 -0
- package/dist/tools/get-dependency-graph.d.ts +85 -0
- package/dist/tools/get-dependency-graph.d.ts.map +1 -0
- package/dist/tools/get-dependency-graph.js +387 -0
- package/dist/tools/get-exports.d.ts +78 -0
- package/dist/tools/get-exports.d.ts.map +1 -0
- package/dist/tools/get-exports.js +437 -0
- package/dist/tools/get-file-structure.d.ts +28 -0
- package/dist/tools/get-file-structure.d.ts.map +1 -0
- package/dist/tools/get-file-structure.js +186 -0
- package/dist/tools/get-imports.d.ts +34 -0
- package/dist/tools/get-imports.d.ts.map +1 -0
- package/dist/tools/get-imports.js +455 -0
- package/dist/tools/get-signature.d.ts +100 -0
- package/dist/tools/get-signature.d.ts.map +1 -0
- package/dist/tools/get-signature.js +800 -0
- package/dist/tools/index.d.ts +55 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +75 -0
- package/dist/tools/types.d.ts +378 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +4 -0
- package/package.json +85 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 scozzola
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @compilr-dev/agents-coding-python
|
|
3
|
+
*
|
|
4
|
+
* Python analysis tools for AI agents.
|
|
5
|
+
* AST-based code analysis using Tree-sitter.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./parser/index.js";
|
|
8
|
+
export * from "./tools/index.js";
|
|
9
|
+
export * from "./skills/index.js";
|
|
10
|
+
import { allPythonTools } from "./tools/index.js";
|
|
11
|
+
import { pythonSkills, pythonSkillsMap, pythonBestPracticesSkill, pythonCodeHealthSkill, pythonCodeStructureSkill, pythonDependencyAuditSkill, pythonRefactorImpactSkill } from "./skills/index.js";
|
|
12
|
+
/**
|
|
13
|
+
* All Python analysis tools (named exports)
|
|
14
|
+
*/
|
|
15
|
+
export declare const pythonTools: {
|
|
16
|
+
readonly getFileStructure: import("@compilr-dev/agents").Tool<import("./tools/get-file-structure.js").GetFileStructureInput>;
|
|
17
|
+
readonly findSymbol: import("@compilr-dev/agents").Tool<import("./tools/find-symbol.js").FindSymbolInput>;
|
|
18
|
+
readonly findReferences: import("@compilr-dev/agents").Tool<import("./tools/find-references.js").FindReferencesInput>;
|
|
19
|
+
readonly getImports: import("@compilr-dev/agents").Tool<import("./tools/get-imports.js").GetImportsInput>;
|
|
20
|
+
readonly getClassHierarchy: import("@compilr-dev/agents").Tool<import("./tools/get-class-hierarchy.js").GetClassHierarchyInput>;
|
|
21
|
+
readonly getComplexity: import("@compilr-dev/agents").Tool<import("./tools/get-complexity.js").GetComplexityInput>;
|
|
22
|
+
readonly extractDocstrings: import("@compilr-dev/agents").Tool<import("./tools/extract-docstrings.js").ExtractDocstringsInput>;
|
|
23
|
+
readonly findDeadCode: import("@compilr-dev/agents").Tool<import("./tools/find-dead-code.js").FindDeadCodeInput>;
|
|
24
|
+
readonly findDuplicates: import("@compilr-dev/agents").Tool<import("./tools/find-duplicates.js").FindDuplicatesInput>;
|
|
25
|
+
readonly findImplementations: import("@compilr-dev/agents").Tool<import("./tools/find-implementations.js").FindImplementationsInput>;
|
|
26
|
+
readonly findPatterns: import("@compilr-dev/agents").Tool<import("./tools/find-patterns.js").FindPatternsInput>;
|
|
27
|
+
readonly getCallGraph: import("@compilr-dev/agents").Tool<import("./tools/get-call-graph.js").GetCallGraphInput>;
|
|
28
|
+
readonly getDependencyGraph: import("@compilr-dev/agents").Tool<import("./tools/get-dependency-graph.js").GetDependencyGraphInput>;
|
|
29
|
+
readonly getSignature: import("@compilr-dev/agents").Tool<import("./tools/get-signature.js").GetSignatureInput>;
|
|
30
|
+
readonly getExports: import("@compilr-dev/agents").Tool<import("./tools/get-exports.js").GetExportsInput>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Array of all Python tools
|
|
34
|
+
*/
|
|
35
|
+
export { allPythonTools };
|
|
36
|
+
/**
|
|
37
|
+
* All Python skills
|
|
38
|
+
*/
|
|
39
|
+
export { pythonSkills, pythonSkillsMap, pythonBestPracticesSkill, pythonCodeHealthSkill, pythonCodeStructureSkill, pythonDependencyAuditSkill, pythonRefactorImpactSkill, };
|
|
40
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,mBAAmB,CAAC;AAGlC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,cAAc,EAAkB,MAAM,kBAAkB,CAAC;AAClE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;CAAiB,CAAC;AAE1C;;GAEG;AACH,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B;;GAEG;AACH,OAAO,EACL,YAAY,EACZ,eAAe,EACf,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,0BAA0B,EAC1B,yBAAyB,GAC1B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @compilr-dev/agents-coding-python
|
|
3
|
+
*
|
|
4
|
+
* Python analysis tools for AI agents.
|
|
5
|
+
* AST-based code analysis using Tree-sitter.
|
|
6
|
+
*/
|
|
7
|
+
// Parser
|
|
8
|
+
export * from "./parser/index.js";
|
|
9
|
+
// Tools
|
|
10
|
+
export * from "./tools/index.js";
|
|
11
|
+
// Skills
|
|
12
|
+
export * from "./skills/index.js";
|
|
13
|
+
// Re-export commonly used items at top level
|
|
14
|
+
import { allPythonTools, pythonToolsMap } from "./tools/index.js";
|
|
15
|
+
import { pythonSkills, pythonSkillsMap, pythonBestPracticesSkill, pythonCodeHealthSkill, pythonCodeStructureSkill, pythonDependencyAuditSkill, pythonRefactorImpactSkill, } from "./skills/index.js";
|
|
16
|
+
/**
|
|
17
|
+
* All Python analysis tools (named exports)
|
|
18
|
+
*/
|
|
19
|
+
export const pythonTools = pythonToolsMap;
|
|
20
|
+
/**
|
|
21
|
+
* Array of all Python tools
|
|
22
|
+
*/
|
|
23
|
+
export { allPythonTools };
|
|
24
|
+
/**
|
|
25
|
+
* All Python skills
|
|
26
|
+
*/
|
|
27
|
+
export { pythonSkills, pythonSkillsMap, pythonBestPracticesSkill, pythonCodeHealthSkill, pythonCodeStructureSkill, pythonDependencyAuditSkill, pythonRefactorImpactSkill, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Python AST node type definitions for Tree-sitter
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Python AST node types from tree-sitter-python
|
|
6
|
+
*/
|
|
7
|
+
export type PythonNodeType = "module" | "expression_statement" | "import_statement" | "import_from_statement" | "future_import_statement" | "class_definition" | "function_definition" | "decorated_definition" | "async_function_definition" | "assignment" | "augmented_assignment" | "annotated_assignment" | "return_statement" | "yield" | "raise_statement" | "pass_statement" | "break_statement" | "continue_statement" | "if_statement" | "for_statement" | "while_statement" | "try_statement" | "with_statement" | "match_statement" | "global_statement" | "nonlocal_statement" | "assert_statement" | "type_alias_statement" | "identifier" | "string" | "integer" | "float" | "true" | "false" | "none" | "binary_operator" | "unary_operator" | "comparison_operator" | "boolean_operator" | "not_operator" | "lambda" | "attribute" | "subscript" | "call" | "list" | "list_comprehension" | "dictionary" | "dictionary_comprehension" | "set" | "set_comprehension" | "tuple" | "generator_expression" | "parenthesized_expression" | "conditional_expression" | "await" | "named_expression" | "parameters" | "typed_parameter" | "default_parameter" | "typed_default_parameter" | "list_splat_pattern" | "dictionary_splat_pattern" | "decorator" | "argument_list" | "keyword_argument" | "block" | "comment" | "type" | "ellipsis";
|
|
8
|
+
/**
|
|
9
|
+
* Decorator information
|
|
10
|
+
*/
|
|
11
|
+
export interface DecoratorInfo {
|
|
12
|
+
name: string;
|
|
13
|
+
arguments?: string[];
|
|
14
|
+
line: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parameter information
|
|
18
|
+
*/
|
|
19
|
+
export interface ParameterInfo {
|
|
20
|
+
name: string;
|
|
21
|
+
type?: string;
|
|
22
|
+
default?: string;
|
|
23
|
+
isArgs: boolean;
|
|
24
|
+
isKwargs: boolean;
|
|
25
|
+
isPositionalOnly: boolean;
|
|
26
|
+
isKeywordOnly: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Function/method information
|
|
30
|
+
*/
|
|
31
|
+
export interface FunctionInfo {
|
|
32
|
+
name: string;
|
|
33
|
+
line: number;
|
|
34
|
+
endLine: number;
|
|
35
|
+
column: number;
|
|
36
|
+
parameters: ParameterInfo[];
|
|
37
|
+
returnType?: string;
|
|
38
|
+
decorators: DecoratorInfo[];
|
|
39
|
+
isAsync: boolean;
|
|
40
|
+
isGenerator: boolean;
|
|
41
|
+
docstring?: string;
|
|
42
|
+
body?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Method information (function within a class)
|
|
46
|
+
*/
|
|
47
|
+
export interface MethodInfo extends FunctionInfo {
|
|
48
|
+
isClassMethod: boolean;
|
|
49
|
+
isStaticMethod: boolean;
|
|
50
|
+
isProperty: boolean;
|
|
51
|
+
isAbstract: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Class attribute information
|
|
55
|
+
*/
|
|
56
|
+
export interface AttributeInfo {
|
|
57
|
+
name: string;
|
|
58
|
+
type?: string;
|
|
59
|
+
default?: string;
|
|
60
|
+
line: number;
|
|
61
|
+
isClassAttribute: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Class information
|
|
65
|
+
*/
|
|
66
|
+
export interface ClassInfo {
|
|
67
|
+
name: string;
|
|
68
|
+
line: number;
|
|
69
|
+
endLine: number;
|
|
70
|
+
column: number;
|
|
71
|
+
bases: string[];
|
|
72
|
+
decorators: DecoratorInfo[];
|
|
73
|
+
methods: MethodInfo[];
|
|
74
|
+
attributes: AttributeInfo[];
|
|
75
|
+
docstring?: string;
|
|
76
|
+
isAbstract: boolean;
|
|
77
|
+
isDataclass: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Variable/constant information
|
|
81
|
+
*/
|
|
82
|
+
export interface VariableInfo {
|
|
83
|
+
name: string;
|
|
84
|
+
type?: string;
|
|
85
|
+
value?: string;
|
|
86
|
+
line: number;
|
|
87
|
+
column: number;
|
|
88
|
+
isConstant: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Import information
|
|
92
|
+
*/
|
|
93
|
+
export interface ImportInfo {
|
|
94
|
+
module: string;
|
|
95
|
+
names: Array<{
|
|
96
|
+
name: string;
|
|
97
|
+
alias?: string;
|
|
98
|
+
}>;
|
|
99
|
+
alias?: string;
|
|
100
|
+
line: number;
|
|
101
|
+
isFromImport: boolean;
|
|
102
|
+
isRelative: boolean;
|
|
103
|
+
relativeDots: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Position in source code
|
|
107
|
+
*/
|
|
108
|
+
export interface Position {
|
|
109
|
+
line: number;
|
|
110
|
+
column: number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Range in source code
|
|
114
|
+
*/
|
|
115
|
+
export interface Range {
|
|
116
|
+
start: Position;
|
|
117
|
+
end: Position;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=node-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-types.d.ts","sourceRoot":"","sources":["../../src/parser/node-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAEtB,QAAQ,GAER,sBAAsB,GACtB,kBAAkB,GAClB,uBAAuB,GACvB,yBAAyB,GACzB,kBAAkB,GAClB,qBAAqB,GACrB,sBAAsB,GACtB,2BAA2B,GAC3B,YAAY,GACZ,sBAAsB,GACtB,sBAAsB,GACtB,kBAAkB,GAClB,OAAO,GACP,iBAAiB,GACjB,gBAAgB,GAChB,iBAAiB,GACjB,oBAAoB,GACpB,cAAc,GACd,eAAe,GACf,iBAAiB,GACjB,eAAe,GACf,gBAAgB,GAChB,iBAAiB,GACjB,kBAAkB,GAClB,oBAAoB,GACpB,kBAAkB,GAClB,sBAAsB,GAEtB,YAAY,GACZ,QAAQ,GACR,SAAS,GACT,OAAO,GACP,MAAM,GACN,OAAO,GACP,MAAM,GACN,iBAAiB,GACjB,gBAAgB,GAChB,qBAAqB,GACrB,kBAAkB,GAClB,cAAc,GACd,QAAQ,GACR,WAAW,GACX,WAAW,GACX,MAAM,GACN,MAAM,GACN,oBAAoB,GACpB,YAAY,GACZ,0BAA0B,GAC1B,KAAK,GACL,mBAAmB,GACnB,OAAO,GACP,sBAAsB,GACtB,0BAA0B,GAC1B,wBAAwB,GACxB,OAAO,GACP,kBAAkB,GAElB,YAAY,GACZ,iBAAiB,GACjB,mBAAmB,GACnB,yBAAyB,GACzB,oBAAoB,GACpB,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|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Python Parser using Tree-sitter
|
|
3
|
+
*
|
|
4
|
+
* Provides AST parsing and traversal for Python source files.
|
|
5
|
+
*/
|
|
6
|
+
import Parser from "tree-sitter";
|
|
7
|
+
import type { ClassInfo, FunctionInfo, MethodInfo, VariableInfo, ImportInfo, ParameterInfo, DecoratorInfo } from "./node-types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Parse result containing the tree and source
|
|
10
|
+
*/
|
|
11
|
+
export interface ParseResult {
|
|
12
|
+
tree: Parser.Tree;
|
|
13
|
+
source: string;
|
|
14
|
+
hasErrors: boolean;
|
|
15
|
+
errors: ParseError[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Parse error information
|
|
19
|
+
*/
|
|
20
|
+
export interface ParseError {
|
|
21
|
+
message: string;
|
|
22
|
+
line: number;
|
|
23
|
+
column: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parse Python source code
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseSource(source: string): ParseResult;
|
|
29
|
+
/**
|
|
30
|
+
* Parse Python file
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseFile(path: string): Promise<ParseResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Get text from a node
|
|
35
|
+
*/
|
|
36
|
+
export declare function getNodeText(node: Parser.SyntaxNode, source: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Extract docstring from a block
|
|
39
|
+
*/
|
|
40
|
+
export declare function extractDocstring(node: Parser.SyntaxNode, source: string): string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Parse decorators from a decorated_definition
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseDecorators(node: Parser.SyntaxNode, source: string): DecoratorInfo[];
|
|
45
|
+
/**
|
|
46
|
+
* Parse function parameters
|
|
47
|
+
*/
|
|
48
|
+
export declare function parseParameters(node: Parser.SyntaxNode, source: string): ParameterInfo[];
|
|
49
|
+
/**
|
|
50
|
+
* Parse a function definition
|
|
51
|
+
*/
|
|
52
|
+
export declare function parseFunction(node: Parser.SyntaxNode, source: string, decorators?: DecoratorInfo[]): FunctionInfo;
|
|
53
|
+
/**
|
|
54
|
+
* Parse a method (function inside a class)
|
|
55
|
+
*/
|
|
56
|
+
export declare function parseMethod(node: Parser.SyntaxNode, source: string, decorators?: DecoratorInfo[]): MethodInfo;
|
|
57
|
+
/**
|
|
58
|
+
* Parse a class definition
|
|
59
|
+
*/
|
|
60
|
+
export declare function parseClass(node: Parser.SyntaxNode, source: string, decorators?: DecoratorInfo[]): ClassInfo;
|
|
61
|
+
/**
|
|
62
|
+
* Parse import statement
|
|
63
|
+
*/
|
|
64
|
+
export declare function parseImport(node: Parser.SyntaxNode, source: string): ImportInfo;
|
|
65
|
+
/**
|
|
66
|
+
* Parse variable assignment
|
|
67
|
+
*/
|
|
68
|
+
export declare function parseVariable(node: Parser.SyntaxNode, source: string): VariableInfo | null;
|
|
69
|
+
/**
|
|
70
|
+
* Walk the AST and collect all nodes of given types
|
|
71
|
+
*/
|
|
72
|
+
export declare function walkTree(node: Parser.SyntaxNode, types?: string[]): Generator<Parser.SyntaxNode>;
|
|
73
|
+
/**
|
|
74
|
+
* Find all nodes matching a predicate
|
|
75
|
+
*/
|
|
76
|
+
export declare function findNodes(node: Parser.SyntaxNode, predicate: (n: Parser.SyntaxNode) => boolean): Parser.SyntaxNode[];
|
|
77
|
+
/**
|
|
78
|
+
* Get the containing scope for a node (function or class)
|
|
79
|
+
*/
|
|
80
|
+
export declare function getContainingScope(node: Parser.SyntaxNode): {
|
|
81
|
+
type: "function" | "class" | "module";
|
|
82
|
+
name: string;
|
|
83
|
+
node: Parser.SyntaxNode;
|
|
84
|
+
} | null;
|
|
85
|
+
//# sourceMappingURL=python-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python-parser.d.ts","sourceRoot":"","sources":["../../src/parser/python-parser.ts"],"names":[],"m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