cluaupp 0.1.4 → 0.2.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/CHANGELOG.md +21 -0
- package/README.md +12 -7
- package/bin/cluau.js +1 -1
- package/bin/cluaupp.js +1 -1
- package/docs/README.md +1 -1
- package/docs/architecture.md +52 -77
- package/docs/cli.md +29 -9
- package/docs/comparison.md +3 -3
- package/docs/config.md +6 -6
- package/docs/cpp-organization.md +2 -2
- package/docs/examples/index.md +2 -0
- package/docs/getting-started.md +7 -5
- package/docs/intellisense.md +49 -31
- package/docs/intro.md +2 -2
- package/docs/oop/file-tags.md +16 -17
- package/docs/oop/index.md +2 -2
- package/docs/oop/modules.md +3 -1
- package/docs/oop/services.md +7 -14
- package/docs/syntax.md +6 -5
- package/editors/vscode/extension.js +97 -146
- package/editors/vscode/package.json +6 -6
- package/examples/README.md +18 -0
- package/examples/game/.clangd +25 -0
- package/examples/game/.vscode/c_cpp_properties.json +27 -0
- package/examples/game/.vscode/extensions.json +5 -0
- package/examples/game/.vscode/settings.json +27 -0
- package/examples/game/Packages/.gitkeep +0 -0
- package/examples/game/cluaupp.config.json +6 -0
- package/examples/game/compile_flags.txt +6 -0
- package/examples/game/default.project.json +39 -0
- package/examples/game/package.json +9 -0
- package/examples/game/rokit.toml +5 -0
- package/examples/game/src/client/hud.client.cpp +12 -0
- package/{src → examples/game/src}/client/init.client.cpp +1 -0
- package/examples/game/src/server/combat.server.cpp +23 -0
- package/{src → examples/game/src}/server/leaderstats.server.cpp +1 -0
- package/examples/game/wally.toml +11 -0
- package/generated/api.js +51 -0
- package/generated/architecture.js +473 -0
- package/generated/ast.js +2 -0
- package/generated/cli.js +191 -0
- package/generated/compile.js +115 -0
- package/generated/editor-install.js +170 -0
- package/generated/emit.js +503 -0
- package/generated/emitter/luau-codegen.js +167 -0
- package/generated/emitter/translators.js +164 -0
- package/generated/headers.js +220 -0
- package/generated/index.html +49 -0
- package/generated/intellisense.js +277 -0
- package/generated/layout.js +112 -0
- package/generated/lex.js +146 -0
- package/generated/libs.js +484 -0
- package/generated/lsp.js +55 -0
- package/generated/package-info.js +11 -0
- package/generated/parse.js +607 -0
- package/generated/parser/collector.js +100 -0
- package/generated/parser/index.js +30 -0
- package/generated/preprocess.js +181 -0
- package/generated/system-understander.js +443 -0
- package/generated/transpile.js +66 -0
- package/generated/types.js +2 -0
- package/generated/understand.js +298 -0
- package/generated/utils/process-orchestrator.js +63 -0
- package/generated/utils/project.js +491 -0
- package/generated/utils/rojo-mapper.js +181 -0
- package/generated/utils/safe-paths.js +104 -0
- package/package.json +25 -8
- package/src/api.ts +53 -0
- package/src/{architecture.js → architecture.ts} +80 -33
- package/src/ast.ts +37 -0
- package/src/cli.ts +214 -0
- package/src/compile.ts +118 -0
- package/src/editor-install.ts +182 -0
- package/src/{emit.js → emit.ts} +5 -6
- package/src/emitter/luau-codegen.ts +187 -0
- package/src/emitter/translators.ts +168 -0
- package/src/headers.ts +233 -0
- package/src/intellisense.ts +286 -0
- package/src/{layout.js → layout.ts} +114 -129
- package/src/{lex.js → lex.ts} +4 -6
- package/src/{libs.js → libs.ts} +119 -46
- package/src/lsp.ts +60 -0
- package/src/package-info.ts +7 -0
- package/src/{parse.js → parse.ts} +3 -4
- package/src/parser/collector.ts +115 -0
- package/src/parser/index.ts +27 -0
- package/src/{preprocess.js → preprocess.ts} +64 -32
- package/src/system-understander.ts +501 -0
- package/src/transpile.ts +64 -0
- package/src/tree-sitter-cpp.d.ts +4 -0
- package/src/types.ts +81 -0
- package/src/{understand.js → understand.ts} +24 -213
- package/src/utils/process-orchestrator.ts +72 -0
- package/src/utils/project.ts +506 -0
- package/src/utils/rojo-mapper.ts +190 -0
- package/src/utils/safe-paths.ts +98 -0
- package/templates/game/.clangd +9 -0
- package/templates/game/.vscode/c_cpp_properties.json +1 -1
- package/templates/game/.vscode/extensions.json +5 -6
- package/templates/game/.vscode/settings.json +7 -6
- package/templates/game/cluaupp.config.json +2 -2
- package/templates/game/compile_flags.txt +1 -0
- package/templates/game/rokit.toml +5 -0
- package/templates/game/src/client/init.client.cpp +1 -0
- package/templates/game/src/server/leaderstats.server.cpp +1 -0
- package/src/api.js +0 -57
- package/src/cli.js +0 -481
- package/src/compile.js +0 -56
- package/src/editor-install.js +0 -218
- package/src/intellisense.js +0 -1368
- package/src/lsp.js +0 -227
- /package/{src → examples/game/src}/shared/config.cpp +0 -0
- /package/{src → examples/game/src}/shared/config.h +0 -0
package/src/lsp.js
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { completeAt, hoverAt, definitionAt, diagnosticsFor } = require("./intellisense");
|
|
4
|
-
|
|
5
|
-
function readMessage(buffer) {
|
|
6
|
-
const headerEnd = buffer.indexOf("\r\n\r\n");
|
|
7
|
-
if (headerEnd < 0) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
const header = buffer.slice(0, headerEnd).toString("utf8");
|
|
11
|
-
const match = header.match(/Content-Length:\s*(\d+)/i);
|
|
12
|
-
if (!match) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
const length = Number(match[1]);
|
|
16
|
-
const start = headerEnd + 4;
|
|
17
|
-
if (buffer.length < start + length) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
const json = buffer.slice(start, start + length).toString("utf8");
|
|
21
|
-
return { message: JSON.parse(json), rest: buffer.slice(start + length) };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function send(message) {
|
|
25
|
-
const json = JSON.stringify(message);
|
|
26
|
-
const payload = Buffer.from(json, "utf8");
|
|
27
|
-
process.stdout.write(`Content-Length: ${payload.length}\r\n\r\n`);
|
|
28
|
-
process.stdout.write(payload);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function posToOffset(text, position) {
|
|
32
|
-
const lines = text.split(/\n/);
|
|
33
|
-
let offset = 0;
|
|
34
|
-
for (let i = 0; i < position.line; i += 1) {
|
|
35
|
-
offset += (lines[i] || "").length + 1;
|
|
36
|
-
}
|
|
37
|
-
return offset + (position.character || 0);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function kindNumber(kind) {
|
|
41
|
-
switch (kind) {
|
|
42
|
-
case "method":
|
|
43
|
-
case "function":
|
|
44
|
-
return 3;
|
|
45
|
-
case "constructor":
|
|
46
|
-
return 4;
|
|
47
|
-
case "property":
|
|
48
|
-
case "variable":
|
|
49
|
-
return 6;
|
|
50
|
-
case "class":
|
|
51
|
-
return 7;
|
|
52
|
-
case "enum":
|
|
53
|
-
return 13;
|
|
54
|
-
case "keyword":
|
|
55
|
-
return 14;
|
|
56
|
-
case "event":
|
|
57
|
-
return 23;
|
|
58
|
-
case "file":
|
|
59
|
-
return 17;
|
|
60
|
-
default:
|
|
61
|
-
return 1;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function start(options = {}) {
|
|
66
|
-
const projectRoot = options.projectRoot || process.cwd();
|
|
67
|
-
const documents = new Map();
|
|
68
|
-
let buffer = Buffer.alloc(0);
|
|
69
|
-
let id = 0;
|
|
70
|
-
|
|
71
|
-
const uriPath = (uri) => {
|
|
72
|
-
let file = String(uri || "").replace(/^file:\/\//, "");
|
|
73
|
-
if (/^\/[A-Za-z]:/.test(file)) {
|
|
74
|
-
file = file.slice(1);
|
|
75
|
-
}
|
|
76
|
-
return decodeURIComponent(file);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const docText = (uri) => documents.get(uri) || "";
|
|
80
|
-
|
|
81
|
-
const publishDiagnostics = (uri) => {
|
|
82
|
-
const file = uriPath(uri);
|
|
83
|
-
const text = docText(uri);
|
|
84
|
-
const items = diagnosticsFor(text, file, {
|
|
85
|
-
filePath: file,
|
|
86
|
-
projectRoot,
|
|
87
|
-
includeDirs: [pathDirname(file), require("path").join(projectRoot, "src"), require("path").join(projectRoot, "include")],
|
|
88
|
-
});
|
|
89
|
-
send({
|
|
90
|
-
jsonrpc: "2.0",
|
|
91
|
-
method: "textDocument/publishDiagnostics",
|
|
92
|
-
params: {
|
|
93
|
-
uri,
|
|
94
|
-
diagnostics: items.map((item) => ({
|
|
95
|
-
range: {
|
|
96
|
-
start: { line: Math.max(0, (item.line || 1) - 1), character: Math.max(0, (item.col || 1) - 1) },
|
|
97
|
-
end: { line: Math.max(0, (item.line || 1) - 1), character: Math.max(1, item.col || 1) },
|
|
98
|
-
},
|
|
99
|
-
severity: 1,
|
|
100
|
-
source: "cluaupp",
|
|
101
|
-
message: item.message,
|
|
102
|
-
})),
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const pathDirname = (file) => require("path").dirname(file);
|
|
108
|
-
|
|
109
|
-
const handle = (message) => {
|
|
110
|
-
const { method, params, id: reqId } = message;
|
|
111
|
-
if (method === "initialize") {
|
|
112
|
-
send({
|
|
113
|
-
jsonrpc: "2.0",
|
|
114
|
-
id: reqId,
|
|
115
|
-
result: {
|
|
116
|
-
capabilities: {
|
|
117
|
-
textDocumentSync: 1,
|
|
118
|
-
completionProvider: { triggerCharacters: [".", ":", ">", "<", '"', "/"] },
|
|
119
|
-
hoverProvider: true,
|
|
120
|
-
definitionProvider: true,
|
|
121
|
-
},
|
|
122
|
-
serverInfo: { name: "cluaupp", version: require("../package.json").version },
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
if (method === "initialized" || method === "shutdown") {
|
|
128
|
-
if (reqId !== undefined) {
|
|
129
|
-
send({ jsonrpc: "2.0", id: reqId, result: null });
|
|
130
|
-
}
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
if (method === "exit") {
|
|
134
|
-
process.exit(0);
|
|
135
|
-
}
|
|
136
|
-
if (method === "textDocument/didOpen") {
|
|
137
|
-
documents.set(params.textDocument.uri, params.textDocument.text);
|
|
138
|
-
publishDiagnostics(params.textDocument.uri);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
if (method === "textDocument/didChange") {
|
|
142
|
-
const last = params.contentChanges[params.contentChanges.length - 1];
|
|
143
|
-
if (last && last.text !== undefined && !last.range) {
|
|
144
|
-
documents.set(params.textDocument.uri, last.text);
|
|
145
|
-
}
|
|
146
|
-
publishDiagnostics(params.textDocument.uri);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
if (method === "textDocument/didClose") {
|
|
150
|
-
documents.delete(params.textDocument.uri);
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
if (method === "textDocument/completion") {
|
|
154
|
-
const uri = params.textDocument.uri;
|
|
155
|
-
const text = docText(uri);
|
|
156
|
-
const offset = posToOffset(text, params.position);
|
|
157
|
-
const items = completeAt(text, offset, { projectRoot, file: uriPath(uri) });
|
|
158
|
-
send({
|
|
159
|
-
jsonrpc: "2.0",
|
|
160
|
-
id: reqId,
|
|
161
|
-
result: {
|
|
162
|
-
isIncomplete: false,
|
|
163
|
-
items: items.map((item) => ({
|
|
164
|
-
label: item.name,
|
|
165
|
-
kind: kindNumber(item.kind),
|
|
166
|
-
detail: item.detail,
|
|
167
|
-
sortText: `${item.kind === "keyword" ? "2" : "0"}_${item.name}`,
|
|
168
|
-
insertText: item.name,
|
|
169
|
-
})),
|
|
170
|
-
},
|
|
171
|
-
});
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (method === "textDocument/hover") {
|
|
175
|
-
const uri = params.textDocument.uri;
|
|
176
|
-
const text = docText(uri);
|
|
177
|
-
const offset = posToOffset(text, params.position);
|
|
178
|
-
const hover = hoverAt(text, offset, { projectRoot, file: uriPath(uri) });
|
|
179
|
-
send({
|
|
180
|
-
jsonrpc: "2.0",
|
|
181
|
-
id: reqId,
|
|
182
|
-
result: hover
|
|
183
|
-
? { contents: { kind: "markdown", value: `**${hover.name}**\n\n\`${hover.detail || hover.type || ""}\`` } }
|
|
184
|
-
: null,
|
|
185
|
-
});
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
if (method === "textDocument/definition") {
|
|
189
|
-
const uri = params.textDocument.uri;
|
|
190
|
-
const text = docText(uri);
|
|
191
|
-
const offset = posToOffset(text, params.position);
|
|
192
|
-
const def = definitionAt(text, offset, { projectRoot, file: uriPath(uri) });
|
|
193
|
-
if (!def) {
|
|
194
|
-
send({ jsonrpc: "2.0", id: reqId, result: null });
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
send({
|
|
198
|
-
jsonrpc: "2.0",
|
|
199
|
-
id: reqId,
|
|
200
|
-
result: {
|
|
201
|
-
uri: "file:///" + String(def.file).replace(/\\/g, "/"),
|
|
202
|
-
range: {
|
|
203
|
-
start: { line: Math.max(0, (def.line || 1) - 1), character: 0 },
|
|
204
|
-
end: { line: Math.max(0, (def.line || 1) - 1), character: 0 },
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
});
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
if (reqId !== undefined) {
|
|
211
|
-
send({ jsonrpc: "2.0", id: reqId, result: null });
|
|
212
|
-
}
|
|
213
|
-
id += 1;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
process.stdin.on("data", (chunk) => {
|
|
217
|
-
buffer = Buffer.concat([buffer, chunk]);
|
|
218
|
-
let parsed = readMessage(buffer);
|
|
219
|
-
while (parsed) {
|
|
220
|
-
handle(parsed.message);
|
|
221
|
-
buffer = parsed.rest;
|
|
222
|
-
parsed = readMessage(buffer);
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
module.exports = { start };
|
|
File without changes
|
|
File without changes
|