@jpoly1219/context-extractor 0.2.7 → 0.2.9
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/dist/src/app.d.ts +7 -4
- package/dist/src/app.js +319 -97
- package/dist/src/ast.d.ts +6 -0
- package/dist/src/ast.js +80 -0
- package/dist/src/codeql.js +17 -7
- package/dist/src/constants.js +17 -7
- package/dist/src/core.d.ts +0 -1
- package/dist/src/core.js +17 -7
- package/dist/src/main.d.ts +8 -2
- package/dist/src/main.js +53 -13
- package/dist/src/ocaml-driver.d.ts +55 -5
- package/dist/src/ocaml-driver.js +296 -191
- package/dist/src/ocaml-utils/_build/default/test_parser.bc.cjs +194658 -0
- package/dist/src/runner.js +143 -10
- package/dist/src/tree-sitter-files/queries/hole-queries/typescript.scm +36 -0
- package/dist/src/tree-sitter-files/queries/relevant-headers-queries/typescript-get-toplevel-headers.scm +22 -0
- package/dist/src/tree-sitter-files/queries/relevant-types-queries/typescript-extract-identifiers.scm +10 -0
- package/dist/src/tree-sitter-files/queries/relevant-types-queries/typescript-find-typedecl-given-typeidentifier.scm +11 -0
- package/dist/src/tree-sitter-files/wasms/tree-sitter-ocaml.wasm +0 -0
- package/dist/src/tree-sitter-files/wasms/tree-sitter-typescript.wasm +0 -0
- package/dist/src/tree-sitter-files/wasms/tree-sitter.wasm +0 -0
- package/dist/src/tree-sitter.d.ts +40 -0
- package/dist/src/tree-sitter.js +311 -0
- package/dist/src/types.d.ts +80 -9
- package/dist/src/types.js +1 -6
- package/dist/src/typescript-driver.d.ts +86 -12
- package/dist/src/typescript-driver.js +1276 -205
- package/dist/src/typescript-type-checker.d.ts +22 -2
- package/dist/src/typescript-type-checker.js +290 -9
- package/dist/src/utils.d.ts +11 -1
- package/dist/src/utils.js +87 -10
- package/dist/src/vscode-ide.d.ts +29 -0
- package/dist/src/vscode-ide.js +161 -0
- package/package.json +12 -6
@@ -0,0 +1,161 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
36
|
+
exports.VsCode = void 0;
|
37
|
+
const vscode = __importStar(require("vscode"));
|
38
|
+
var VsCode;
|
39
|
+
(function (VsCode) {
|
40
|
+
const MAX_CACHE_SIZE = 50;
|
41
|
+
const lspCache = new Map();
|
42
|
+
function gotoInputKey(input) {
|
43
|
+
return `${input.name}${input.uri.toString()}${input.line}${input.character}`;
|
44
|
+
}
|
45
|
+
async function hover(location) {
|
46
|
+
const result = await executeHoverProvider({
|
47
|
+
uri: vscode.Uri.parse(location.filepath),
|
48
|
+
line: location.position.line,
|
49
|
+
character: location.position.character,
|
50
|
+
name: "vscode.executeHoverProvider",
|
51
|
+
});
|
52
|
+
return result;
|
53
|
+
}
|
54
|
+
VsCode.hover = hover;
|
55
|
+
async function gotoTypeDefinition(location) {
|
56
|
+
const result = await executeGotoProvider({
|
57
|
+
uri: vscode.Uri.parse(location.filepath),
|
58
|
+
line: location.position.line,
|
59
|
+
character: location.position.character,
|
60
|
+
name: "vscode.executeTypeDefinitionProvider",
|
61
|
+
});
|
62
|
+
return result;
|
63
|
+
}
|
64
|
+
VsCode.gotoTypeDefinition = gotoTypeDefinition;
|
65
|
+
async function getDocumentSymbols(location) {
|
66
|
+
const result = await executeDocumentSymbolProvider({
|
67
|
+
uri: vscode.Uri.parse(location.filepath),
|
68
|
+
name: "vscode.executeDocumentSymbolProvider",
|
69
|
+
});
|
70
|
+
return result;
|
71
|
+
}
|
72
|
+
VsCode.getDocumentSymbols = getDocumentSymbols;
|
73
|
+
// Core logic for executing vscode providers.
|
74
|
+
async function executeGotoProvider(input) {
|
75
|
+
// Check the cache before executing vscode command.
|
76
|
+
const cacheKey = gotoInputKey(input);
|
77
|
+
const cached = lspCache.get(cacheKey);
|
78
|
+
if (cached) {
|
79
|
+
return cached;
|
80
|
+
}
|
81
|
+
try {
|
82
|
+
const definitions = (await vscode.commands.executeCommand(input.name, input.uri, new vscode.Position(input.line, input.character)));
|
83
|
+
const results = definitions
|
84
|
+
.filter((d) => (d.targetUri || d.uri) && (d.targetRange || d.range))
|
85
|
+
.map((d) => ({
|
86
|
+
filepath: (d.targetUri || d.uri).toString(),
|
87
|
+
range: d.targetRange || d.range,
|
88
|
+
}));
|
89
|
+
// Update the cache via LRU.
|
90
|
+
if (lspCache.size >= MAX_CACHE_SIZE) {
|
91
|
+
const oldestKey = lspCache.keys().next().value;
|
92
|
+
if (oldestKey) {
|
93
|
+
lspCache.delete(oldestKey);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
lspCache.set(cacheKey, results);
|
97
|
+
return results;
|
98
|
+
}
|
99
|
+
catch (e) {
|
100
|
+
console.warn(`Error executing ${input.name}:`, e);
|
101
|
+
return [];
|
102
|
+
}
|
103
|
+
}
|
104
|
+
async function executeHoverProvider(input) {
|
105
|
+
// Check the cache before executing vscode command.
|
106
|
+
const cacheKey = gotoInputKey(input);
|
107
|
+
const cached = lspCache.get(cacheKey);
|
108
|
+
if (cached) {
|
109
|
+
return cached;
|
110
|
+
}
|
111
|
+
try {
|
112
|
+
const definitions = (await vscode.commands.executeCommand(input.name, input.uri, new vscode.Position(input.line, input.character)));
|
113
|
+
const result = definitions[0].contents[0].value;
|
114
|
+
// Update the cache via LRU.
|
115
|
+
if (lspCache.size >= MAX_CACHE_SIZE) {
|
116
|
+
const oldestKey = lspCache.keys().next().value;
|
117
|
+
if (oldestKey) {
|
118
|
+
lspCache.delete(oldestKey);
|
119
|
+
}
|
120
|
+
}
|
121
|
+
lspCache.set(cacheKey, result);
|
122
|
+
return result;
|
123
|
+
}
|
124
|
+
catch (e) {
|
125
|
+
console.warn(`Error executing ${input.name}:`, e);
|
126
|
+
return { text: "" };
|
127
|
+
}
|
128
|
+
}
|
129
|
+
async function executeDocumentSymbolProvider(input) {
|
130
|
+
// Check the cache before executing vscode command.
|
131
|
+
const cacheKey = gotoInputKey(input);
|
132
|
+
const cached = lspCache.get(cacheKey);
|
133
|
+
if (cached) {
|
134
|
+
return cached;
|
135
|
+
}
|
136
|
+
try {
|
137
|
+
const definitions = (await vscode.commands.executeCommand(input.name, input.uri));
|
138
|
+
const results = definitions
|
139
|
+
.filter((d) => d.location && d.location.uri && d.range && d.selectionRange && d.name)
|
140
|
+
.map((d) => ({
|
141
|
+
filepath: (d.location.uri).toString(),
|
142
|
+
range: d.range,
|
143
|
+
selectionRange: d.selectionRange,
|
144
|
+
name: d.name
|
145
|
+
}));
|
146
|
+
// Update the cache via LRU.
|
147
|
+
if (lspCache.size >= MAX_CACHE_SIZE) {
|
148
|
+
const oldestKey = lspCache.keys().next().value;
|
149
|
+
if (oldestKey) {
|
150
|
+
lspCache.delete(oldestKey);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
lspCache.set(cacheKey, results);
|
154
|
+
return results;
|
155
|
+
}
|
156
|
+
catch (e) {
|
157
|
+
console.warn(`Error executing ${input.name}:`, e);
|
158
|
+
return [];
|
159
|
+
}
|
160
|
+
}
|
161
|
+
})(VsCode || (exports.VsCode = VsCode = {}));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jpoly1219/context-extractor",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.9",
|
4
4
|
"description": "Extract relevant context from an incomplete program sketch.",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -13,22 +13,28 @@
|
|
13
13
|
],
|
14
14
|
"scripts": {
|
15
15
|
"build": "rm -rf dist/ && npx tsc && npm run copy-deps",
|
16
|
-
"copy-deps": "npm run copy-lsp-client && npm run copy-ocaml",
|
16
|
+
"copy-deps": "npm run copy-lsp-client && npm run copy-ocaml && npm run copy-tree-sitter",
|
17
17
|
"copy-lsp-client": "shx cp -r ts-lsp-client-dist dist/",
|
18
18
|
"copy-ocaml": "shx mkdir -p dist/src/ocaml-utils/ && shx cp -r src/ocaml-utils/_build dist/src/ocaml-utils/_build/",
|
19
|
+
"copy-tree-sitter": "shx cp -r src/tree-sitter-files/ dist/src/",
|
19
20
|
"test": "echo \"Error: no test specified\" && exit 1"
|
20
21
|
},
|
21
22
|
"author": "",
|
22
23
|
"license": "ISC",
|
23
24
|
"dependencies": {
|
24
25
|
"json-rpc-2.0": "^1.7.0",
|
25
|
-
"openai": "^4.
|
26
|
-
"pino": "^9.
|
26
|
+
"openai": "^4.86.2",
|
27
|
+
"pino": "^9.6.0",
|
28
|
+
"pprof": "^4.0.0",
|
27
29
|
"shx": "^0.3.4",
|
30
|
+
"tree-sitter-wasms": "^0.1.11",
|
28
31
|
"ts-node": "^10.9.2",
|
29
|
-
"tslib": "^2.
|
32
|
+
"tslib": "^2.8.1",
|
33
|
+
"uri-js": "^4.4.1",
|
34
|
+
"web-tree-sitter": "^0.21.0"
|
30
35
|
},
|
31
36
|
"devDependencies": {
|
32
|
-
"
|
37
|
+
"@types/vscode": "^1.99.1",
|
38
|
+
"typescript": "^5.8.2"
|
33
39
|
}
|
34
40
|
}
|