-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.json
More file actions
158 lines (158 loc) · 7.43 KB
/
Copy pathpackage.json
File metadata and controls
158 lines (158 loc) · 7.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
{
"name": "custom-text-transform",
"displayName": "Custom Text Transform",
"description": "Allows applying arbitrary user-defined transforms to the selected code.",
"publisher": "phohale",
"repository": "https://github.com/CommanderPho/vscode-custom-text-transform",
"icon": "images/vscode_xform_icon.png",
"version": "0.0.7",
"engines": {
"vscode": "^1.88.0"
},
"categories": [
"Other"
],
"activationEvents": [],
"main": "./out/extension.js",
"contributes": {
"views": {
"explorer": [
{
"type": "webview",
"id": "custom-text-transform.transformEditorGuiView",
"name": "Transform Editor GUI"
}
]
},
"configuration": {
"title": "Custom Text Transform",
"properties": {
"custom-text-transform.transforms": {
"type": "array",
"default": [
{
"name": "Variable list into Python dictionary",
"function": "const variableList = input.split(',').map(varName => varName.trim()); return '{' + variableList.map(varName => `'${varName}':${varName}`).join(', ') + '}'",
"test_texts": []
},
{
"name": "Variable list into kwargs",
"function": "const variableList = input.split(',').map(varName => varName.trim()); return variableList.map(varName => `${varName}=${varName}`).join(', ')",
"test_texts": []
},
{
"name": "Function definition into classdef method definition",
"function": "const lines = input.trim().split('\\n');\nconst funcName = lines[0].trim().split(' ')[1].split('(')[0];\nconst args = lines[0].trim().split('(')[1].split(')')[0].split(',').map(arg => arg.trim());\nconst body = lines.slice(1, -1).join('\\n');\nreturn `@classmethod\\ndef ${funcName}(cls, ${args.join(', ')}):${body ? '\\n' + body : ''}`",
"test_texts": [
{
"input": "def check_for_and_merge_overlapping_epochs(quiescent_periods: pd.DataFrame, debug_print=False) -> pd.DataFrame:",
"expected": "@classmethod\ndef check_for_and_merge_overlapping_epochs(cls, quiescent_periods: pd.DataFrame, debug_print=False) -> pd.DataFrame:"
}
]
},
{
"name": "Python function definition to kwargs call",
"function": "return input.replace(/def\\s+(\\w+)\\(([^)]*)\\):[\\s\\S]*/, (_, fnName, params) => fnName + '(' + params.replace(/\\w+\\s*(?:\\:[^=,]+)?\\s*(=\\s*[^,]+)?/g, (p) => p.trim().split('=')[0].trim() + '=' + p.trim().split('=')[0].trim()).split(',').join(', ') + ')')",
"test_texts": [
{
"input": "def check_for_and_merge_overlapping_epochs(quiescent_periods: pd.DataFrame, debug_print=False) -> pd.DataFrame:",
"expected": "check_for_and_merge_overlapping_epochs(quiescent_periods=quiescent_periods, debug_print=debug_print)"
},
{
"input": "include_includelist=None, included_computation_filter_names=None, include_global_functions=False, fail_on_exception=False, progress_print=True, debug_print=False, force_recompute:bool=False, force_recompute_override_computations_includelist=None",
"expected": "include_includelist=include_includelist, included_computation_filter_names=included_computation_filter_names, include_global_functions=include_global_functions, fail_on_exception=fail_on_exception, progress_print=progress_print, debug_print=debug_print, force_recompute=force_recompute, force_recompute_override_computations_includelist=force_recompute_override_computations_includelist"
}
]
},
{
"name": "Python strip typehints definition to kwargs call",
"function": "return input.replace(/def\\s+(\\w+)\\(([^)]*)\\):[\\s\\S]*/, (_, fnName, params) => fnName + '(' + params.replace(/(\\w+)\\s*(?::[^=,]+)?\\s*(?:=[^,]+)?/g, (match, p1) => p1 + '=' + p1).split(',').join(', ') + ')');",
"test_texts": [
{
"input": "def check_for_and_merge_overlapping_epochs(quiescent_periods: pd.DataFrame, debug_print=False) -> pd.DataFrame:",
"expected": "check_for_and_merge_overlapping_epochs(quiescent_periods=quiescent_periods, debug_print=debug_print)"
},
{
"input": "include_includelist=None, included_computation_filter_names=None, include_global_functions=False, fail_on_exception=False, progress_print=True, debug_print=False, force_recompute:bool=False, force_recompute_override_computations_includelist=None",
"expected": "include_includelist=include_includelist, included_computation_filter_names=included_computation_filter_names, include_global_functions=include_global_functions, fail_on_exception=fail_on_exception, progress_print=progress_print, debug_print=debug_print, force_recompute=force_recompute, force_recompute_override_computations_includelist=force_recompute_override_computations_includelist"
}
]
}
],
"description": "Array of custom text transformations",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the transform"
},
"function": {
"type": "string",
"description": "Transformation function as a string"
},
"test_texts": {
"type": "array",
"description": "Test cases with input and expected output pairs",
"items": {
"type": "object",
"properties": {
"input": {
"type": "string",
"description": "Input text to transform"
},
"expected": {
"type": "string",
"description": "Expected output after transformation"
}
}
}
}
}
}
}
}
},
"commands": [
{
"command": "custom-text-transform.helloWorld",
"title": "🌀Custom Transform: Hello World"
},
{
"command": "custom-text-transform.listCustomTransforms",
"title": "🌀📜List Custom Transforms"
},
{
"command": "custom-text-transform.transformSelectedText",
"title": "🌀💫Custom Transform Selected Text..."
},
{
"command": "custom-text-transform.openEditor",
"title": "🌀Custom Transform: Open Transform Editor GUI"
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "npm run compile && npm run lint",
"package": "npm run compile && vsce package",
"lint": "eslint src --ext ts",
"test": "vscode-test"
},
"devDependencies": {
"@types/mocha": "^10.0.6",
"@types/node": "18.x",
"@types/vscode": "^1.88.0",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"@vscode/test-cli": "^0.0.4",
"@vscode/test-electron": "^2.3.9",
"eslint": "^8.56.0",
"typescript": "^5.3.3"
},
"dependencies": {
"@vscode-elements/elements": "^1.8.1"
}
}