i-c-fn-head 0.0.5
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/.vscodeignore +15 -0
- package/CHANGELOG.md +9 -0
- package/LICENSE +1 -0
- package/README.md +78 -0
- package/dist/extension.js +1 -0
- package/dist/extension.js.map +1 -0
- package/empty +1 -0
- package/eslint.config.mjs +27 -0
- package/i-c-fn-head-0.0.1.use-for-Rust.vsix +0 -0
- package/i-c-fn-head-0.0.2.vsix +0 -0
- package/i-c-fn-head-0.0.3.vsix +0 -0
- package/i-c-fn-head-0.0.5.vsix +0 -0
- package/package.json +211 -0
- package/src/basic_funx.ts +120 -0
- package/src/colorful.ts +276 -0
- package/src/extension.ts +277 -0
- package/src/faav.ts +51 -0
- package/src/fancy_f12.ts +113 -0
- package/src/fn_body_n_head.ts +504 -0
- package/src/goto_impl.ts +62 -0
- package/src/init.ts +84 -0
- package/src/quick_pick.ts +43 -0
- package/src/show_doc_symbs.ts +66 -0
- package/src/test/extension.test.ts +15 -0
- package/tsconfig.json +23 -0
- package/tst.tst +0 -0
- package/vsc-extension-quickstart.md +48 -0
- package/webpack.config.js +48 -0
package/src/extension.ts
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
// The module 'vscode' contains the VS Code extensibility API
|
|
2
|
+
// Import the module and reference it with the alias vscode in your code below
|
|
3
|
+
import * as vscode from 'vscode';
|
|
4
|
+
import { AccessibilityInformation as wa } from 'vscode';
|
|
5
|
+
import { activate0 as colors } from './colorful';
|
|
6
|
+
import { extra_activate } from './colorful';
|
|
7
|
+
import { writeFileSync, readFileSync, copyFileSync, closeSync, existsSync, rmSync } from "fs";
|
|
8
|
+
import { menu } from "./quick_pick";
|
|
9
|
+
import { i_c_fn_head_opts } from './faav';
|
|
10
|
+
import {init } from './init'
|
|
11
|
+
export function activate11(context: vscode.ExtensionContext) {
|
|
12
|
+
//eval(extra_activate());
|
|
13
|
+
let tru = true;
|
|
14
|
+
while (tru) {
|
|
15
|
+
menu();
|
|
16
|
+
}
|
|
17
|
+
//return;
|
|
18
|
+
}
|
|
19
|
+
export async function activate(context: vscode.ExtensionContext) {
|
|
20
|
+
//eval(extra_activate());
|
|
21
|
+
let res = false;
|
|
22
|
+
try {
|
|
23
|
+
await init(context);
|
|
24
|
+
res = sync_bkp.raw_writeBkp(i_c_fn_head_opts.path_to_conf, null, "/tmp/tst00");
|
|
25
|
+
sync_bkp.raw_writeBkp("tst", null, "/tmp/tst0");
|
|
26
|
+
console.log(res);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
console.error("err");
|
|
30
|
+
}
|
|
31
|
+
const disposable = vscode.commands.registerCommand('i-c-fn-head.helloWorld', () => {
|
|
32
|
+
// The code you place here will be executed every time your command is executed
|
|
33
|
+
// Display a message box to the user
|
|
34
|
+
vscode.window.showInformationMessage('Hello World from i_c_fn_head!');
|
|
35
|
+
});
|
|
36
|
+
context.subscriptions.push(disposable);
|
|
37
|
+
const disposable0 = vscode.commands.registerCommand('extension.onUpArrowPress', () => {
|
|
38
|
+
vscode.window.showInformationMessage('up Key Press Detected!');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
context.subscriptions.push(disposable0);
|
|
42
|
+
|
|
43
|
+
// vscode.window.onDidChangeTextEditorSelection(handleChangeSel);
|
|
44
|
+
/* const disposable1 = vscode.commands.registerCommand('extension.getCursorPosition', () => {
|
|
45
|
+
const editor = vscode.window.activeTextEditor;
|
|
46
|
+
|
|
47
|
+
/* if (editor) {
|
|
48
|
+
const cursorPosition = editor.selection.active; // Get the active cursor position
|
|
49
|
+
console.log('Cursor Position:', cursorPosition); // Log the position
|
|
50
|
+
vscode.window.showInformationMessage(`Cursor Position: Line ${cursorPosition.line + 1}, Character ${cursorPosition.character + 1}`);
|
|
51
|
+
} else {
|
|
52
|
+
vscode.window.showInformationMessage('No active editor found.');
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
context.subscriptions.push(disposable1); */
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// This method is called when your extension is deactivated
|
|
60
|
+
export function deactivate() { }
|
|
61
|
+
|
|
62
|
+
export function select_lang_n_tst_fn_head(): RegExp | null { //RegExpExecArray | null {
|
|
63
|
+
const langId = vscode.window.activeTextEditor?.document.uri.fsPath ?? "";
|
|
64
|
+
let regex = /rs$|c$|cpp$|d$/g;
|
|
65
|
+
let lang: string = regex.exec(langId)?.[0] ?? "";
|
|
66
|
+
const msg = "Active lang: " + langId?.toString();
|
|
67
|
+
switch (lang) {
|
|
68
|
+
case "c": { return c_cpp_d_head() }
|
|
69
|
+
case "cpp": { return c_cpp_d_head() }
|
|
70
|
+
case "d": { return c_cpp_d_head() }
|
|
71
|
+
case "rs": { return rust_head() }
|
|
72
|
+
}
|
|
73
|
+
// prnt(msg);
|
|
74
|
+
return null
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function c_cpp_d_head(): RegExp {
|
|
78
|
+
const regex: RegExp = /^[^+\-=]*\(/;//gm;
|
|
79
|
+
return regex
|
|
80
|
+
}
|
|
81
|
+
export function rust_head(): RegExp {
|
|
82
|
+
const regex: RegExp = /(^\s*(.*)?\s*fn\s+(\w+)\s*\(([^)]*)\)\s*(->\s*\w+)?\s*{?$)/m
|
|
83
|
+
return regex;
|
|
84
|
+
}
|
|
85
|
+
export function rebuild_doc(from: number, doc: string[]): string {
|
|
86
|
+
let ret: string = "";
|
|
87
|
+
for (let x = from; x < doc.length; x++) {
|
|
88
|
+
ret += doc[x];
|
|
89
|
+
}
|
|
90
|
+
return ret;
|
|
91
|
+
}
|
|
92
|
+
export class skip_ln {
|
|
93
|
+
arr: RegExp[] = []
|
|
94
|
+
#ret: boolean = false;
|
|
95
|
+
run(strn: string): boolean {
|
|
96
|
+
this.#ret = false;
|
|
97
|
+
for (let i = 0; i < this.arr.length; i++) {
|
|
98
|
+
this.#ret = this.#ret || strn.match(this.arr[i]) != null;
|
|
99
|
+
}
|
|
100
|
+
return this.#ret;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export function dont_clobbe_line_w_curly_bracket(txt: string | string[], uri: vscode.Uri) {
|
|
104
|
+
if (sync_bkp.file_was_bkuped7(uri.fsPath)) { return; }
|
|
105
|
+
let ret: string = "";
|
|
106
|
+
let reformat = false;
|
|
107
|
+
let _txt = typeof txt == "string" ? txt.split("\n") : txt; //???
|
|
108
|
+
const one_line_comment: RegExp = /^[/]{2}/;
|
|
109
|
+
const open_comment: RegExp = /^\/\*/;
|
|
110
|
+
const close_comment: RegExp = /\*\/$/;
|
|
111
|
+
let within_comment = false;
|
|
112
|
+
let prev_strn = "";
|
|
113
|
+
_txt.forEach(function (strn0: string) {
|
|
114
|
+
let pad_len = count_spaces_from_left(strn0);
|
|
115
|
+
let strn = strn0.trim();
|
|
116
|
+
if (one_line_comment.test(strn)) {
|
|
117
|
+
ret += strn + "\n";
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (!within_comment) { within_comment = open_comment.test(strn); }
|
|
121
|
+
if (within_comment) {
|
|
122
|
+
if (close_comment.test(strn)) {
|
|
123
|
+
within_comment = false;
|
|
124
|
+
}
|
|
125
|
+
ret += strn + "\n";
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
/*if (strn[0] == "{" && strn.length > 1) {
|
|
129
|
+
strn = "{" + "\n" + strn.substring(1);
|
|
130
|
+
reformat = true;
|
|
131
|
+
}
|
|
132
|
+
if (strn.charAt(strn.length - 1) == "}" && strn.length > 1) {
|
|
133
|
+
strn = strn.substring(0, strn.length - 1) + "\n" + "}";
|
|
134
|
+
reformat = true;
|
|
135
|
+
}*/
|
|
136
|
+
prev_strn = strn;
|
|
137
|
+
strn = exclude_comments_from_ln(strn);
|
|
138
|
+
if (strn.length != prev_strn.length) {
|
|
139
|
+
reformat = true;
|
|
140
|
+
ret += "\n" + strn;
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (strn.length > 0) {
|
|
144
|
+
ret += "\n" + pad_strn_from_left(strn, pad_len, " ");
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
if (reformat) {
|
|
148
|
+
sync_bkp.writeBkp(
|
|
149
|
+
ret,
|
|
150
|
+
uri
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
export function count_spaces_from_left(strn: & string): number {
|
|
155
|
+
for (let x = 0; x < strn.length; x++) {
|
|
156
|
+
if (strn[x] != " ") { return x; }
|
|
157
|
+
}
|
|
158
|
+
return 0
|
|
159
|
+
}
|
|
160
|
+
export function exclude_comments_from_ln(ln0: & string): string {
|
|
161
|
+
const one_line_comment: RegExp = /^[/]{2}/;
|
|
162
|
+
const open_comment: RegExp = /^\/\*/;
|
|
163
|
+
let ret = "";
|
|
164
|
+
let pad_len = count_spaces_from_left(ln0);
|
|
165
|
+
let ln: string | string[] = ln0.replaceAll("//", "<<>//").replaceAll("/*", "<<>\n/*");
|
|
166
|
+
ln = ln.split("<<>");
|
|
167
|
+
let open_curly = "";
|
|
168
|
+
let close_curly = "";
|
|
169
|
+
ln.forEach(function (strn: string) {
|
|
170
|
+
if (!one_line_comment.test(strn) && !open_comment.test(strn)) {
|
|
171
|
+
open_curly = "\n" + " ".repeat(pad_len) + "{";
|
|
172
|
+
close_curly = "\n" + " ".repeat(pad_len) + "}";
|
|
173
|
+
strn.replaceAll("{", open_curly).replaceAll("}", close_curly);
|
|
174
|
+
}
|
|
175
|
+
ret += " ".repeat(pad_len) + strn;
|
|
176
|
+
});
|
|
177
|
+
return ret;
|
|
178
|
+
}
|
|
179
|
+
export function pad_strn_from_left(strn: & string, pad_len: number, pad: string): string {
|
|
180
|
+
let padding = "";
|
|
181
|
+
for (let y = 0; y < pad_len; y++) {
|
|
182
|
+
padding += pad;
|
|
183
|
+
}
|
|
184
|
+
return padding + strn;
|
|
185
|
+
}
|
|
186
|
+
class sync_bkp {
|
|
187
|
+
static bkuped: string[] = [];
|
|
188
|
+
static suffix: string = ".YourOriginalFile";
|
|
189
|
+
static bkp_source_file(path0: vscode.Uri | string): boolean {
|
|
190
|
+
let path = typeof path0 == "string" ? path0 : path0.fsPath;
|
|
191
|
+
if (this.file_was_bkuped7(path)) { return true; }
|
|
192
|
+
let new_name = path + this.suffix;
|
|
193
|
+
copyFileSync(path, new_name);
|
|
194
|
+
let ret = this.compare_files(path, new_name);
|
|
195
|
+
if (ret) {
|
|
196
|
+
this.bkuped.push(new_name);
|
|
197
|
+
}
|
|
198
|
+
return ret;
|
|
199
|
+
}
|
|
200
|
+
static file_was_bkuped7(path0: string): boolean {
|
|
201
|
+
let path = path0 + this.suffix;
|
|
202
|
+
if (this.bkuped.length == 0) { return false; }
|
|
203
|
+
let ret: boolean = false;
|
|
204
|
+
this.bkuped.forEach(function (strn: string, indx: number, arr: string[]) {
|
|
205
|
+
if (strn == path) { ret = true; return; }
|
|
206
|
+
});
|
|
207
|
+
if (!ret) {
|
|
208
|
+
if (existsSync(path)) {
|
|
209
|
+
this.bkuped.push(path);
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return ret;
|
|
214
|
+
}
|
|
215
|
+
static compare_files(_1st: string, _2nd: string): boolean {
|
|
216
|
+
let open_1st: string = "";
|
|
217
|
+
let open_2nd: string = "";
|
|
218
|
+
try {
|
|
219
|
+
open_1st = readFileSync(
|
|
220
|
+
_1st,
|
|
221
|
+
{ encoding: "utf-8", flag: "r" },
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
catch (err) {
|
|
225
|
+
let msg = "File: " + _1st + " got err: " + err + "\n";
|
|
226
|
+
console.log(msg);
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
open_2nd = readFileSync(
|
|
231
|
+
_2nd,
|
|
232
|
+
{ encoding: "utf-8", flag: "r" },
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
catch (err) {
|
|
236
|
+
let msg = "File: " + _2nd + " got err: " + err + "\n";
|
|
237
|
+
console.log(msg);
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
if (open_1st == open_2nd) { return true; }
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
static writeBkp(data: string, uri?: vscode.Uri | null, path0?: string): boolean {
|
|
244
|
+
let path: string = uri?.fsPath ?? path0 ?? "";
|
|
245
|
+
if (path == "") { return false; }
|
|
246
|
+
if (!this.bkp_source_file(path)) { return false; }
|
|
247
|
+
writeFileSync(
|
|
248
|
+
path,
|
|
249
|
+
data
|
|
250
|
+
);
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
static raw_writeBkp(data: string, uri?: vscode.Uri | null, path0?: string): boolean {
|
|
254
|
+
let path: string = uri?.fsPath ?? path0 ?? "";
|
|
255
|
+
//if (path == "") { return false; }
|
|
256
|
+
//if (!this.bkp_source_file(path)) { return false; }
|
|
257
|
+
writeFileSync(
|
|
258
|
+
path,
|
|
259
|
+
data
|
|
260
|
+
);
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
//fn
|
|
265
|
+
/*
|
|
266
|
+
>>>>>>>>>>>>>>>>>>>>>>>>> copag
|
|
267
|
+
https://drive.google.com/file/d/15tU9cVEKlcbelByGuzo7UrZd32ckruUZ/view?usp=sharing
|
|
268
|
+
https://disk.yandex.ru/d/DCedGk0BJB9YOw
|
|
269
|
+
>>>>>>>>>>>>>>>>>>>>>>> BKP
|
|
270
|
+
https://disk.yandex.ru/d/H-WL_Rbq3F3DtB
|
|
271
|
+
https://disk.yandex.ru/d/06mg7S_1sEcQwQ
|
|
272
|
+
https://drive.google.com/file/d/1gQ4iW7uc5e9dd3lQcZ146Izy6hZI87He/view?usp=sharing
|
|
273
|
+
https://drive.google.com/file/d/0B0ZfQGOhsgRtbWQ2bkh6VFdCY2M/view?usp=sharing&resourcekey=0-qWG1G78Mp0KhxW_b9-0FnA
|
|
274
|
+
https://disk.yandex.ru/d/457kWno9UEXZxQ
|
|
275
|
+
https://drive.google.com/file/d/1kGDzmRraRZBTgs3mnnHWlC6aUGsppSjb/view?usp=sharing
|
|
276
|
+
*/
|
|
277
|
+
// https://github.com/JatinSanghvi/color-my-text-vscode/blob/main/src/extension.ts
|
package/src/faav.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { GlobPattern } from "vscode";
|
|
2
|
+
import * as vsc from 'vscode';
|
|
3
|
+
import { prnt } from "./basic_funx";
|
|
4
|
+
export function langsName(): {name: string, file_exts: string []} {
|
|
5
|
+
let langId = vsc.window.activeTextEditor?.document.languageId;
|
|
6
|
+
if (langId == undefined) {
|
|
7
|
+
return { name: "", file_exts: [] };
|
|
8
|
+
}
|
|
9
|
+
switch (langId.toLowerCase()) {
|
|
10
|
+
case "c": { return { name: "C", file_exts: ["c", "h"] }; }
|
|
11
|
+
case "d": { return { name: "D", file_exts: ["d"] }; }
|
|
12
|
+
case "rust": { return { name: "Rust", file_exts: ["rs"] }; }
|
|
13
|
+
case "cpp": { return { name: "CPP", file_exts: ["cpp", "hpp", "h"] }; }
|
|
14
|
+
default: { return { name: "", file_exts: [] }; }
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class restrict_search {
|
|
18
|
+
static max_num_of_res: number = 2000;
|
|
19
|
+
static exclude_paths: GlobPattern | null | undefined = "**/(tests|build)/**";
|
|
20
|
+
}
|
|
21
|
+
export class i_c_fn_head_opts {
|
|
22
|
+
static path_to_conf: string = "";
|
|
23
|
+
static been_set: boolean = false;
|
|
24
|
+
static provide_lang_C: boolean = false;
|
|
25
|
+
static provide_lang_CPP: boolean = false;
|
|
26
|
+
static provide_lang_D: boolean = false;
|
|
27
|
+
static provide_lang_Rust: boolean = false;
|
|
28
|
+
}
|
|
29
|
+
export class _block_head {
|
|
30
|
+
name: string = "";
|
|
31
|
+
lnum: number = 0;
|
|
32
|
+
mark_fn_head: RegExp = /(fn\s.*\{?)|(\sfn\s.*\{?)/;
|
|
33
|
+
set_info(strn: string, i: number, fn_head?: RegExp) {
|
|
34
|
+
if (strn.length <= 1) { return; }
|
|
35
|
+
this.name = strn;
|
|
36
|
+
this.lnum = i;
|
|
37
|
+
this.mark_fn_head = fn_head ?? this.mark_fn_head;
|
|
38
|
+
}
|
|
39
|
+
get_head(name7: string, i: number): string {
|
|
40
|
+
let _name7 = name7.trim();
|
|
41
|
+
if (this.mark_fn_head.test(_name7)) { return _name7; }
|
|
42
|
+
return this.name;
|
|
43
|
+
}
|
|
44
|
+
try_set_info(strn: string, i: number) {
|
|
45
|
+
if (strn.length <= 1) { return; }
|
|
46
|
+
let tst = this.mark_fn_head.test(strn);
|
|
47
|
+
if (!tst) { return; }
|
|
48
|
+
this.name = strn;
|
|
49
|
+
this.lnum = i;
|
|
50
|
+
}
|
|
51
|
+
}
|
package/src/fancy_f12.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import * as vscode from 'vscode'
|
|
2
|
+
import { } from './faav';
|
|
3
|
+
import { prnt, cmd_rgx, getCMD, exclude_paths } from './basic_funx';
|
|
4
|
+
import { langsName, restrict_search } from './faav';
|
|
5
|
+
export enum F12_action {
|
|
6
|
+
cont,
|
|
7
|
+
stop
|
|
8
|
+
}
|
|
9
|
+
export type pressF12 = { kind: "F12_action", v: F12_action };
|
|
10
|
+
export type EL = { kind: "extra_locations", v: vscode.Location[] };
|
|
11
|
+
export function new_EL(v?: vscode.Location[]): EL {
|
|
12
|
+
let ret = v ? v : [] as vscode.Location [];
|
|
13
|
+
return { kind: "extra_locations", v: ret };
|
|
14
|
+
}
|
|
15
|
+
export function new_pressF12(v?: F12_action): pressF12 {
|
|
16
|
+
let ret = v ? v : F12_action.cont;
|
|
17
|
+
return { kind: "F12_action", v: ret };
|
|
18
|
+
}
|
|
19
|
+
export async function handleExtraCMDs(set_placeholder0?: string): Promise <EL | pressF12> {
|
|
20
|
+
let cmds: RegExp[] | null = set_placeholder0 ? getCMD(set_placeholder0, null, "rgx") : getCMD(null, null, "rgx");
|
|
21
|
+
let f12: pressF12 = new_pressF12();
|
|
22
|
+
if (cmds == null) { f12.v = F12_action.cont; return f12 ; }
|
|
23
|
+
let more_rgxs = await handle_rgx_cmd(cmds);
|
|
24
|
+
if (more_rgxs.length > 0) { return new_EL(more_rgxs); }
|
|
25
|
+
prnt("failed to collect extra locations");
|
|
26
|
+
return new_pressF12 (F12_action.cont);
|
|
27
|
+
}
|
|
28
|
+
async function handle_rgx_cmd(cmds: RegExp[]): Promise <vscode.Location[]> {
|
|
29
|
+
prnt("start handle_rgx_cmd");
|
|
30
|
+
const res: vscode.Location[] = [];
|
|
31
|
+
let matches: RegExpStringIterator<RegExpExecArray> | null;
|
|
32
|
+
let uris = await _a_get_files_in_workspace();
|
|
33
|
+
uris = await exclude_paths(uris) ?? uris;
|
|
34
|
+
prnt("num of pruned uris: " + uris.length);
|
|
35
|
+
let uri: vscode.Uri;
|
|
36
|
+
for (uri of uris) {
|
|
37
|
+
try {
|
|
38
|
+
let doc = await vscode.workspace.openTextDocument(uri);
|
|
39
|
+
if (doc == undefined) {
|
|
40
|
+
prnt("failed to open " + uri);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
let txt = doc.getText();
|
|
44
|
+
for (let rgx of cmds) {
|
|
45
|
+
matches = txt.matchAll(rgx);
|
|
46
|
+
if (matches == null) { continue; }
|
|
47
|
+
res.push(...calc_locations(matches, doc));
|
|
48
|
+
}
|
|
49
|
+
} catch (error) {
|
|
50
|
+
prnt("doc: " + uri.fsPath + "err " + String (error));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return res;
|
|
54
|
+
}
|
|
55
|
+
function calc_locations(matches: RegExpStringIterator<RegExpExecArray>, doc: vscode.TextDocument): vscode.Location[] {
|
|
56
|
+
let res: vscode.Location[] = [];
|
|
57
|
+
let Start = new vscode.Position(0, 0);
|
|
58
|
+
let End = new vscode.Position(0, 0);
|
|
59
|
+
let _1st_ch_indx = 0;
|
|
60
|
+
let txt = doc.getText();
|
|
61
|
+
let uri = doc.uri;
|
|
62
|
+
for (let m of matches) {
|
|
63
|
+
let len = m[0].length;
|
|
64
|
+
_1st_ch_indx = txt.indexOf(m[0], _1st_ch_indx + 1);
|
|
65
|
+
if (_1st_ch_indx == -1) { break; }
|
|
66
|
+
Start = doc.positionAt(_1st_ch_indx);
|
|
67
|
+
End = doc.positionAt(_1st_ch_indx + len);
|
|
68
|
+
res.push(new vscode.Location(uri, new vscode.Range(Start, End)));
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
return res;
|
|
72
|
+
}
|
|
73
|
+
function cursorPos(): vscode.Position | null {
|
|
74
|
+
const editor = vscode.window.activeTextEditor;
|
|
75
|
+
if (!editor) return null;
|
|
76
|
+
const pos = editor.selection.active;
|
|
77
|
+
// const line = pos.line;
|
|
78
|
+
// const col = pos.character;
|
|
79
|
+
return pos;
|
|
80
|
+
}
|
|
81
|
+
export async function _a_get_files_in_workspace(): Promise <vscode.Uri[]> {
|
|
82
|
+
let file_ext: vscode.GlobPattern = "";
|
|
83
|
+
let uris: vscode.Uri[] = [];
|
|
84
|
+
if (langsName().file_exts.length > 0) {
|
|
85
|
+
for (let i = 0; i < langsName().file_exts.length; i++) {
|
|
86
|
+
file_ext = "**/*." + langsName().file_exts[i];
|
|
87
|
+
prnt('update file_ext ' + file_ext);
|
|
88
|
+
let uri = await vscode.workspace.findFiles(
|
|
89
|
+
// '**/*.{langsName.file_exts}',
|
|
90
|
+
file_ext,
|
|
91
|
+
restrict_search.exclude_paths,
|
|
92
|
+
restrict_search.max_num_of_res);
|
|
93
|
+
uris.push(...uri);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
prnt("calc uris " + uris.length);
|
|
97
|
+
return uris;
|
|
98
|
+
}
|
|
99
|
+
/*
|
|
100
|
+
function handleChangeSel(event: vscode.TextEditorSelectionChangeEvent) {
|
|
101
|
+
console.log("Change in the text editor");
|
|
102
|
+
for (var i = 0; i < event.selections.length; i++) {
|
|
103
|
+
var selection = event.selections[i];
|
|
104
|
+
console.log("Start- Line: (" + selection.start.line + ") Col: (" + selection.start.character + ") End- Line: (" + selection.end.line + ") Col: (" + selection.end.character + ")");
|
|
105
|
+
}
|
|
106
|
+
var scroll = vscode.workspace.getConfiguration("editorScroll");
|
|
107
|
+
console.log(event);
|
|
108
|
+
var doc: vscode.TextDocument = vscode.workspace.textDocuments[0];
|
|
109
|
+
let msg = "status bar: " + doc.getText();
|
|
110
|
+
console.log(msg);
|
|
111
|
+
}
|
|
112
|
+
vscode.window.onDidChangeTextEditorSelection(handleChangeSel);
|
|
113
|
+
*/
|