cluaupp 1.4.1 → 1.5.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 +8 -0
- package/README.md +1 -1
- package/editors/vscode/README.md +17 -0
- package/editors/vscode/extension.js +140 -21
- package/editors/vscode/icons/flare.svg +5 -0
- package/editors/vscode/language-configuration.json +21 -0
- package/editors/vscode/package.json +61 -7
- package/editors/vscode/snippets/flare.json +27 -0
- package/editors/vscode/syntaxes/flare.tmLanguage.json +75 -0
- package/examples/game/.vscode/extensions.json +3 -1
- package/examples/game/.vscode/settings.json +2 -1
- package/examples/game/include/clpp/libs/roster.clh +6 -0
- package/examples/game/src/ReplicatedStorage/Shared/Net/Net.flare +5 -0
- package/examples/game/src/ServerScriptService/Boot/DataBoot.server.clpp +1 -1
- package/generated/cli.js +2 -2
- package/generated/flare/index.js +15 -3
- package/generated/flare/language.js +561 -0
- package/generated/flare/parse.js +7 -6
- package/generated/intellisense.js +20 -2
- package/generated/lsp.js +118 -7
- package/include/clpp/libs/roster.clh +6 -0
- package/package.json +1 -1
- package/runtime/Roster/init.luau +6 -0
- package/src/cli.ts +2 -2
- package/src/flare/index.ts +20 -1
- package/src/flare/language.ts +708 -0
- package/src/flare/parse.ts +6 -6
- package/src/intellisense.ts +19 -2
- package/src/lsp.ts +151 -8
- package/templates/game/.vscode/extensions.json +3 -1
- package/templates/game/.vscode/settings.json +2 -1
- package/templates/game/include/clpp/libs/roster.clh +6 -0
- package/templates/game/src/ReplicatedStorage/Shared/Net/Net.flare +5 -0
- package/templates/game/src/ServerScriptService/Boot/DataBoot.server.clpp +1 -1
package/generated/lsp.js
CHANGED
|
@@ -3,22 +3,133 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.start = start;
|
|
4
4
|
const node_1 = require("vscode-languageserver/node");
|
|
5
5
|
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
6
|
+
const language_js_1 = require("./flare/language.js");
|
|
6
7
|
const package_info_js_1 = require("./package-info.js");
|
|
8
|
+
const KIND = {
|
|
9
|
+
keyword: node_1.CompletionItemKind.Keyword,
|
|
10
|
+
type: node_1.CompletionItemKind.TypeParameter,
|
|
11
|
+
snippet: node_1.CompletionItemKind.Snippet,
|
|
12
|
+
value: node_1.CompletionItemKind.EnumMember,
|
|
13
|
+
field: node_1.CompletionItemKind.Field,
|
|
14
|
+
};
|
|
15
|
+
const SEVERITY = {
|
|
16
|
+
error: node_1.DiagnosticSeverity.Error,
|
|
17
|
+
warning: node_1.DiagnosticSeverity.Warning,
|
|
18
|
+
hint: node_1.DiagnosticSeverity.Hint,
|
|
19
|
+
};
|
|
20
|
+
const SYMBOL = {
|
|
21
|
+
packet: node_1.SymbolKind.Event,
|
|
22
|
+
query: node_1.SymbolKind.Method,
|
|
23
|
+
option: node_1.SymbolKind.Namespace,
|
|
24
|
+
};
|
|
25
|
+
function flareDiagnostics(document) {
|
|
26
|
+
return (0, language_js_1.diagnoseFlare)(document.getText(), document.uri).map((item) => ({
|
|
27
|
+
range: {
|
|
28
|
+
start: { line: item.line, character: item.start },
|
|
29
|
+
end: { line: item.line, character: Math.max(item.end, item.start + 1) },
|
|
30
|
+
},
|
|
31
|
+
message: item.message,
|
|
32
|
+
severity: SEVERITY[item.severity],
|
|
33
|
+
source: "flare",
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
7
36
|
function start(_options = {}) {
|
|
8
37
|
const connection = (0, node_1.createConnection)(node_1.ProposedFeatures.all);
|
|
9
38
|
const documents = new node_1.TextDocuments(vscode_languageserver_textdocument_1.TextDocument);
|
|
10
39
|
connection.onInitialize(() => ({
|
|
11
40
|
capabilities: {
|
|
12
|
-
textDocumentSync: node_1.TextDocumentSyncKind.
|
|
41
|
+
textDocumentSync: node_1.TextDocumentSyncKind.Incremental,
|
|
42
|
+
completionProvider: {
|
|
43
|
+
triggerCharacters: [" ", "(", ",", ">", "="],
|
|
44
|
+
resolveProvider: false,
|
|
45
|
+
},
|
|
46
|
+
hoverProvider: true,
|
|
47
|
+
documentSymbolProvider: true,
|
|
48
|
+
signatureHelpProvider: {
|
|
49
|
+
triggerCharacters: ["(", ","],
|
|
50
|
+
},
|
|
13
51
|
},
|
|
14
|
-
serverInfo: { name: "cluaupp", version: package_info_js_1.pkg.version },
|
|
52
|
+
serverInfo: { name: "cluaupp-flare", version: package_info_js_1.pkg.version },
|
|
15
53
|
}));
|
|
16
|
-
const
|
|
17
|
-
|
|
54
|
+
const publish = (document) => {
|
|
55
|
+
if (!(0, language_js_1.isFlareDocument)(document.uri)) {
|
|
56
|
+
connection.sendDiagnostics({ uri: document.uri, diagnostics: [] });
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
connection.sendDiagnostics({ uri: document.uri, diagnostics: flareDiagnostics(document) });
|
|
18
60
|
};
|
|
19
|
-
documents.onDidOpen((event) =>
|
|
20
|
-
documents.onDidChangeContent((event) =>
|
|
21
|
-
documents.onDidClose((event) =>
|
|
61
|
+
documents.onDidOpen((event) => publish(event.document));
|
|
62
|
+
documents.onDidChangeContent((event) => publish(event.document));
|
|
63
|
+
documents.onDidClose((event) => {
|
|
64
|
+
connection.sendDiagnostics({ uri: event.document.uri, diagnostics: [] });
|
|
65
|
+
});
|
|
66
|
+
connection.onCompletion((params) => {
|
|
67
|
+
const document = documents.get(params.textDocument.uri);
|
|
68
|
+
if (!document || !(0, language_js_1.isFlareDocument)(document.uri)) {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
return (0, language_js_1.completionsAt)(document.getText(), params.position.line, params.position.character).map((item) => ({
|
|
72
|
+
label: item.label,
|
|
73
|
+
kind: KIND[item.kind],
|
|
74
|
+
detail: item.detail,
|
|
75
|
+
documentation: { kind: node_1.MarkupKind.Markdown, value: item.documentation },
|
|
76
|
+
insertText: item.insertText,
|
|
77
|
+
insertTextFormat: item.snippet ? 2 : 1,
|
|
78
|
+
sortText: item.sortText,
|
|
79
|
+
}));
|
|
80
|
+
});
|
|
81
|
+
connection.onHover((params) => {
|
|
82
|
+
const document = documents.get(params.textDocument.uri);
|
|
83
|
+
if (!document || !(0, language_js_1.isFlareDocument)(document.uri)) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const hover = (0, language_js_1.hoverAt)(document.getText(), params.position.line, params.position.character);
|
|
87
|
+
if (!hover) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
contents: { kind: node_1.MarkupKind.Markdown, value: hover.contents },
|
|
92
|
+
range: {
|
|
93
|
+
start: { line: params.position.line, character: hover.start },
|
|
94
|
+
end: { line: params.position.line, character: hover.end },
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
connection.onDocumentSymbol((params) => {
|
|
99
|
+
const document = documents.get(params.textDocument.uri);
|
|
100
|
+
if (!document || !(0, language_js_1.isFlareDocument)(document.uri)) {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
return (0, language_js_1.symbolsIn)(document.getText()).map((symbol) => ({
|
|
104
|
+
name: symbol.name,
|
|
105
|
+
detail: symbol.detail,
|
|
106
|
+
kind: SYMBOL[symbol.kind],
|
|
107
|
+
range: {
|
|
108
|
+
start: { line: symbol.line, character: 0 },
|
|
109
|
+
end: { line: symbol.line, character: Math.max(symbol.end, 1) },
|
|
110
|
+
},
|
|
111
|
+
selectionRange: {
|
|
112
|
+
start: { line: symbol.line, character: symbol.start },
|
|
113
|
+
end: { line: symbol.line, character: Math.max(symbol.end, symbol.start + 1) },
|
|
114
|
+
},
|
|
115
|
+
}));
|
|
116
|
+
});
|
|
117
|
+
connection.onSignatureHelp((params) => {
|
|
118
|
+
const document = documents.get(params.textDocument.uri);
|
|
119
|
+
if (!document || !(0, language_js_1.isFlareDocument)(document.uri)) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const signature = (0, language_js_1.signatureAt)(document.getText(), params.position.line, params.position.character);
|
|
123
|
+
if (!signature) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
const info = node_1.SignatureInformation.create(signature.label, signature.documentation, ...signature.parameters.map((parameter) => node_1.ParameterInformation.create(parameter.label, parameter.documentation)));
|
|
127
|
+
return {
|
|
128
|
+
signatures: [info],
|
|
129
|
+
activeSignature: 0,
|
|
130
|
+
activeParameter: signature.activeParameter,
|
|
131
|
+
};
|
|
132
|
+
});
|
|
22
133
|
documents.listen(connection);
|
|
23
134
|
connection.listen();
|
|
24
135
|
}
|
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
// Table = u16 count + key/value pairs. Array = u16 len + values. Methods also work as Roster::X(rawTable).
|
|
6
6
|
|
|
7
7
|
struct Roster {
|
|
8
|
+
// Construct with `new Roster()` / `new Roster(table)` — emits Luau Roster.new.
|
|
9
|
+
// `New` is the CL++ name because `new` is a keyword.
|
|
8
10
|
static Roster New();
|
|
11
|
+
static Roster New(auto initial);
|
|
9
12
|
|
|
10
13
|
int Size();
|
|
11
14
|
int Length();
|
|
@@ -13,6 +16,7 @@ struct Roster {
|
|
|
13
16
|
auto GetData();
|
|
14
17
|
|
|
15
18
|
auto At(int index);
|
|
19
|
+
// Array value search (1-based index). Dictionary keys: Has / Get / Set / Remove.
|
|
16
20
|
int Find(auto value);
|
|
17
21
|
int Find(auto value, int initPos);
|
|
18
22
|
int Find(auto value, int initPos, int maxPos);
|
|
@@ -23,6 +27,7 @@ struct Roster {
|
|
|
23
27
|
auto Shift();
|
|
24
28
|
int Unshift(auto value);
|
|
25
29
|
auto RemoveAt(int index);
|
|
30
|
+
Roster Remove(auto key);
|
|
26
31
|
|
|
27
32
|
Roster Map(func mapper);
|
|
28
33
|
Roster Filter(func predicate);
|
|
@@ -74,6 +79,7 @@ struct Roster {
|
|
|
74
79
|
static auto Shift(auto data);
|
|
75
80
|
static int Unshift(auto data, auto value);
|
|
76
81
|
static auto RemoveAt(auto data, int index);
|
|
82
|
+
static Roster Remove(auto data, auto key);
|
|
77
83
|
static Roster Map(auto data, func mapper);
|
|
78
84
|
static Roster Filter(auto data, func predicate);
|
|
79
85
|
static auto Reduce(auto data, func reducer, auto initial);
|
package/package.json
CHANGED
package/runtime/Roster/init.luau
CHANGED
|
@@ -352,6 +352,12 @@ function Roster.RemoveAt(source: any, index: number): any
|
|
|
352
352
|
return table.remove(unwrap(source), index)
|
|
353
353
|
end
|
|
354
354
|
|
|
355
|
+
function Roster.Remove(source: any, key: any): any
|
|
356
|
+
local data = unwrap(source)
|
|
357
|
+
data[key] = nil
|
|
358
|
+
return asRoster(source, data)
|
|
359
|
+
end
|
|
360
|
+
|
|
355
361
|
function Roster.Map(source: any, mapper: (value: any, index: any) -> any): any
|
|
356
362
|
local data = unwrap(source)
|
|
357
363
|
local result = {}
|
package/src/cli.ts
CHANGED
|
@@ -92,7 +92,7 @@ program
|
|
|
92
92
|
|
|
93
93
|
program
|
|
94
94
|
.command("lsp")
|
|
95
|
-
.description("Language server stdio
|
|
95
|
+
.description("Language server stdio — Flare `.flare` IntelliSense. CL++ still uses `clpp setup`.")
|
|
96
96
|
.argument("[folder]", "project folder", ".")
|
|
97
97
|
.action((folder: string) => {
|
|
98
98
|
startLsp({ projectRoot: path.resolve(process.cwd(), folder) });
|
|
@@ -101,7 +101,7 @@ program
|
|
|
101
101
|
program
|
|
102
102
|
.command("intellisense")
|
|
103
103
|
.alias("intelisense")
|
|
104
|
-
.description("
|
|
104
|
+
.description("Install Flare IntelliSense and point CL++ at `clpp setup`")
|
|
105
105
|
.argument("[folder]", "project folder", ".")
|
|
106
106
|
.action(async (folder: string) => {
|
|
107
107
|
try {
|
package/src/flare/index.ts
CHANGED
|
@@ -5,8 +5,27 @@ import { parseFlare } from "./parse.js";
|
|
|
5
5
|
import type { FlareEmitResult, FlareSchema } from "./types.js";
|
|
6
6
|
|
|
7
7
|
export type { FlareEmitResult, FlareSchema } from "./types.js";
|
|
8
|
-
export { parseFlare } from "./parse.js";
|
|
9
8
|
export { emitFlare, emitFlareHeader, emitFlareLuau } from "./emit.js";
|
|
9
|
+
export { parseFlare, FLARE_TYPE_ALIASES, FLARE_IDENT } from "./parse.js";
|
|
10
|
+
export {
|
|
11
|
+
analyzeFlare,
|
|
12
|
+
completionsAt,
|
|
13
|
+
diagnoseFlare,
|
|
14
|
+
hoverAt,
|
|
15
|
+
isFlareDocument,
|
|
16
|
+
signatureAt,
|
|
17
|
+
symbolsIn,
|
|
18
|
+
FLARE_CANONICAL_TYPES,
|
|
19
|
+
FLARE_TYPE_DOCS,
|
|
20
|
+
} from "./language.js";
|
|
21
|
+
export type {
|
|
22
|
+
FlareAnalysis,
|
|
23
|
+
FlareCompletion,
|
|
24
|
+
FlareDiagnostic,
|
|
25
|
+
FlareHover,
|
|
26
|
+
FlareSignature,
|
|
27
|
+
FlareSymbol,
|
|
28
|
+
} from "./language.js";
|
|
10
29
|
|
|
11
30
|
export function isFlareFile(fileName: string): boolean {
|
|
12
31
|
return path.extname(fileName).toLowerCase() === ".flare";
|