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.
@@ -0,0 +1,66 @@
1
+ import * as vscode from 'vscode';
2
+ import { _c_fn_body, _rust_fn_body, c_fn_body } from './fn_body_n_head';
3
+ export class ShowDocumentSymbols implements vscode.DocumentSymbolProvider {
4
+ provideDocumentSymbols(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.ProviderResult<vscode.SymbolInformation[]> {
5
+ let symbols: vscode.SymbolInformation[] = [];
6
+ let text0 = document.getText();
7
+ const text = text0.split("\n");
8
+
9
+ // Regular expression patterns for different symbols
10
+ const functionPattern: RegExp[] = [
11
+ /(^(\s*if))/g,
12
+ ];
13
+ const classPattern = /class\s+([a-zA-Z_$][0-9a-zA-Z_$]*)/g;
14
+ const variablePattern = /const\s+([a-zA-Z_$][0-9a-zA-Z_$]*)|let\s+([a-zA-Z_$][0-9a-zA-Z_$]*)|var\s+([a-zA-Z_$][0-9a-zA-Z_$]*)/g;
15
+ let wrong_ending = /;[\s]*}?$/
16
+ const func_ret = /^return\s/;
17
+ const while_op = /[\s]*while[\s]*\(/;
18
+ const for_op = /\s*for[\s]*\(?/;
19
+ const switch_op = /[\s]*switch[\s]*\(?/;
20
+ const if_op = /^[\s]*if[\s]*\(/;
21
+ const scope_op_in_D = /^scope\s*\(/;
22
+ const bad_symbs = /[=+\-]/;
23
+ // Extract functions
24
+ let match: RegExpExecArray | null | undefined = null;
25
+ //console.log("start");
26
+ //console.log(text);
27
+ let yes_D = vscode.window.activeTextEditor?.document.languageId.toLowerCase() === "d";
28
+ let functionName: string = "";
29
+ let _1st: boolean = true;
30
+ let line: number = 0;
31
+ let pos: vscode.Range | undefined = new vscode.Range(0, 0, 0, 100);
32
+ let point: vscode.Position = new vscode.Position(0, 0);
33
+ let set_rng: vscode.Range;
34
+ let default_range = new vscode.Range(0, 0, 0, 100);
35
+ /* while ((match = select_lang_n_tst_fn_head (text0) ) !== null) {
36
+ const fnName = match[1];
37
+ const position = document.positionAt(match.index);
38
+ symbols.push(new vscode.SymbolInformation(fnName, vscode.SymbolKind.Function, '', new vscode.Location(document.uri, position)));
39
+ }*/
40
+ //dont_clobbe_line_w_curly_bracket(text0, document.uri);
41
+ // if (manage_output(text0, document.uri, symbols) != _manage_output.Rust) { return symbols; }
42
+ manage_output(text0, document.uri, symbols);
43
+ return symbols;
44
+ }
45
+ }
46
+ enum _manage_output {
47
+ C,
48
+ D,
49
+ Rust,
50
+ CPP
51
+ }
52
+ export function manage_output(doc: string, uri: vscode.Uri, symbols: & vscode.SymbolInformation[]): _manage_output | RegExp | null {
53
+ const langId = vscode.window.activeTextEditor?.document.uri.fsPath ?? "";
54
+ let regex = /rs$|c$|cpp$|d$/g;
55
+ let lang: string = regex.exec(langId)?.[0] ?? "";
56
+ const msg = "Active lang: " + langId?.toString();
57
+ //vscode.window.showInformationMessage(msg);
58
+ switch (lang) {
59
+ case "c": { c_fn_body(doc, uri, symbols); return _manage_output.C }
60
+ case "cpp": { c_fn_body(doc, uri, symbols); return _manage_output.CPP }
61
+ case "d": { _c_fn_body(doc, uri, symbols); return _manage_output.D }
62
+ case "rs": { _rust_fn_body(doc, uri, symbols); return _manage_output.Rust }// { return rust_head() }
63
+ }
64
+ // prnt(msg);
65
+ return null
66
+ }
@@ -0,0 +1,15 @@
1
+ import * as assert from 'assert';
2
+
3
+ // You can import and use all API from the 'vscode' module
4
+ // as well as import your extension to test it
5
+ import * as vscode from 'vscode';
6
+ // import * as myExtension from '../../extension';
7
+
8
+ suite('Extension Test Suite', () => {
9
+ vscode.window.showInformationMessage('Start all tests.');
10
+
11
+ test('Sample test', () => {
12
+ assert.strictEqual(-1, [1, 2, 3].indexOf(5));
13
+ assert.strictEqual(-1, [1, 2, 3].indexOf(0));
14
+ });
15
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "Node16",
4
+ "target": "ES2022",
5
+ "lib": [
6
+ "ES2022"
7
+ ],
8
+ "sourceMap": true,
9
+ "outDir": "./dist",
10
+ "rootDir": "./src",
11
+ "strict": true
12
+ },
13
+ "exclude": [
14
+ "./github"
15
+ ],
16
+ "keybindings": [
17
+ {
18
+ "command": "i_c_fn_head.onKeyPress",
19
+ "key": "up",
20
+ "when": "editorTextFocus"
21
+ }
22
+ ]
23
+ }
package/tst.tst ADDED
File without changes
@@ -0,0 +1,48 @@
1
+ # Welcome to your VS Code Extension
2
+
3
+ ## What's in the folder
4
+
5
+ * This folder contains all of the files necessary for your extension.
6
+ * `package.json` - this is the manifest file in which you declare your extension and command.
7
+ * The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin.
8
+ * `src/extension.ts` - this is the main file where you will provide the implementation of your command.
9
+ * The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`.
10
+ * We pass the function containing the implementation of the command as the second parameter to `registerCommand`.
11
+
12
+ ## Setup
13
+
14
+ * install the recommended extensions (amodio.tsl-problem-matcher, ms-vscode.extension-test-runner, and dbaeumer.vscode-eslint)
15
+
16
+
17
+ ## Get up and running straight away
18
+
19
+ * Press `F5` to open a new window with your extension loaded.
20
+ * Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`.
21
+ * Set breakpoints in your code inside `src/extension.ts` to debug your extension.
22
+ * Find output from your extension in the debug console.
23
+
24
+ ## Make changes
25
+
26
+ * You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`.
27
+ * You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.
28
+
29
+
30
+ ## Explore the API
31
+
32
+ * You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`.
33
+
34
+ ## Run tests
35
+
36
+ * Install the [Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner)
37
+ * Run the "watch" task via the **Tasks: Run Task** command. Make sure this is running, or tests might not be discovered.
38
+ * Open the Testing view from the activity bar and click the Run Test" button, or use the hotkey `Ctrl/Cmd + ; A`
39
+ * See the output of the test result in the Test Results view.
40
+ * Make changes to `src/test/extension.test.ts` or create new test files inside the `test` folder.
41
+ * The provided test runner will only consider files matching the name pattern `**.test.ts`.
42
+ * You can create folders inside the `test` folder to structure your tests any way you want.
43
+
44
+ ## Go further
45
+
46
+ * Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension).
47
+ * [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VS Code extension marketplace.
48
+ * Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration).
@@ -0,0 +1,48 @@
1
+ //@ts-check
2
+
3
+ 'use strict';
4
+
5
+ const path = require('path');
6
+
7
+ //@ts-check
8
+ /** @typedef {import('webpack').Configuration} WebpackConfig **/
9
+
10
+ /** @type WebpackConfig */
11
+ const extensionConfig = {
12
+ target: 'node', // VS Code extensions run in a Node.js-context πŸ“– -> https://webpack.js.org/configuration/node/
13
+ mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production')
14
+
15
+ entry: './src/extension.ts', // the entry point of this extension, πŸ“– -> https://webpack.js.org/configuration/entry-context/
16
+ output: {
17
+ // the bundle is stored in the 'dist' folder (check package.json), πŸ“– -> https://webpack.js.org/configuration/output/
18
+ path: path.resolve(__dirname, 'dist'),
19
+ filename: 'extension.js',
20
+ libraryTarget: 'commonjs2'
21
+ },
22
+ externals: {
23
+ vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, πŸ“– -> https://webpack.js.org/configuration/externals/
24
+ // modules added here also need to be added in the .vscodeignore file
25
+ },
26
+ resolve: {
27
+ // support reading TypeScript and JavaScript files, πŸ“– -> https://github.com/TypeStrong/ts-loader
28
+ extensions: ['.ts', '.js']
29
+ },
30
+ module: {
31
+ rules: [
32
+ {
33
+ test: /\.ts$/,
34
+ exclude: /node_modules/,
35
+ use: [
36
+ {
37
+ loader: 'ts-loader'
38
+ }
39
+ ]
40
+ }
41
+ ]
42
+ },
43
+ devtool: 'nosources-source-map',
44
+ infrastructureLogging: {
45
+ level: "log", // enables logging required for problem matchers
46
+ },
47
+ };
48
+ module.exports = [ extensionConfig ];