firefly-compiler 0.4.15 → 0.4.16
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/guide/Main.ff +1 -1
- package/lsp/Handler.ff +48 -8
- package/lsp/LanguageServer.ff +9 -2
- package/package.json +1 -1
- package/vscode/README.md +1 -4
- package/vscode/client/src/extension.ts +12 -1
- package/vscode/package.json +1 -1
package/guide/Main.ff
CHANGED
package/lsp/Handler.ff
CHANGED
|
@@ -46,21 +46,33 @@ data TokenLocation(
|
|
|
46
46
|
|
|
47
47
|
extend self: Handler {
|
|
48
48
|
|
|
49
|
-
handleNotification(system: NodeSystem, method: String, parameters: Map[String, Json]):
|
|
49
|
+
handleNotification(system: NodeSystem, method: String, parameters: Map[String, Json]): Option[Pair[String, Json]] {
|
|
50
50
|
method.{
|
|
51
51
|
| "initialized" =>
|
|
52
|
+
None
|
|
52
53
|
| "textDocument/didChange" =>
|
|
53
54
|
self.handleDidChange(system, parameters)
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
let diagnostics = self.handleFocusDiagnostic(system, parameters)
|
|
56
|
+
Some(Pair("textDocument/publishDiagnostics", diagnostics))
|
|
57
|
+
| "textDocument/didClose" =>
|
|
58
|
+
self.handleDidClose(system, parameters)
|
|
59
|
+
let diagnostics = self.handleFocusDiagnostic(system, parameters)
|
|
60
|
+
Some(Pair("textDocument/publishDiagnostics", diagnostics))
|
|
61
|
+
| "custom/focusDocument" =>
|
|
62
|
+
let diagnostics = self.handleFocusDiagnostic(system, parameters)
|
|
63
|
+
Some(Pair("textDocument/publishDiagnostics", diagnostics))
|
|
64
|
+
| "exit" =>
|
|
65
|
+
system.exit(0)
|
|
66
|
+
None
|
|
56
67
|
| _ =>
|
|
68
|
+
None
|
|
57
69
|
}
|
|
58
70
|
}
|
|
59
71
|
|
|
60
72
|
handleRequest(system: NodeSystem, method: String, parameters: Map[String, Json]): ResultOrError {
|
|
61
73
|
method.{
|
|
62
74
|
| "initialize" => self.handleInitialize(system, parameters)
|
|
63
|
-
|
|
75
|
+
//| "textDocument/diagnostic" => self.handleDiagnostic(system, parameters)
|
|
64
76
|
| "textDocument/documentSymbol" => self.handleDocumentSymbol(system, parameters)
|
|
65
77
|
| "textDocument/completion" => self.handleCompletion(system, parameters)
|
|
66
78
|
| "textDocument/signatureHelp" => self.handleSignatureHelp(system, parameters)
|
|
@@ -81,7 +93,10 @@ extend self: Handler {
|
|
|
81
93
|
self.handleTokenRequestWithCache(system, method, parameters) {targetAt =>
|
|
82
94
|
self.handleReferences(system, targetAt, local = True)
|
|
83
95
|
}
|
|
84
|
-
| "workspace/symbol" =>
|
|
96
|
+
| "workspace/symbol" =>
|
|
97
|
+
self.printTime(system.mainTask(), "handleWorkspaceSymbol") {
|
|
98
|
+
self.handleWorkspaceSymbol(system, parameters)
|
|
99
|
+
}
|
|
85
100
|
| "shutdown" => Result(Json.null().write())
|
|
86
101
|
| _ => self.handleUnsupported()
|
|
87
102
|
}
|
|
@@ -129,10 +144,10 @@ extend self: Handler {
|
|
|
129
144
|
.with("hoverProvider", True)
|
|
130
145
|
.with("definitionProvider", True)
|
|
131
146
|
.with("documentHighlightProvider", True)
|
|
132
|
-
|
|
147
|
+
/*.with("diagnosticProvider", Json.object()
|
|
133
148
|
.with("interFileDependencies", False)
|
|
134
149
|
.with("workspaceDiagnostics", False)
|
|
135
|
-
)
|
|
150
|
+
)*/
|
|
136
151
|
.with("documentSymbolProvider", True)
|
|
137
152
|
.with("completionProvider", Json.object()
|
|
138
153
|
.with("triggerCharacters", [".", " ", "("])
|
|
@@ -187,6 +202,29 @@ extend self: Handler {
|
|
|
187
202
|
Result(o.write())
|
|
188
203
|
}
|
|
189
204
|
|
|
205
|
+
handleFocusDiagnostic(system: NodeSystem, parameters: Map[String, Json]): Json {
|
|
206
|
+
let js = system.js()
|
|
207
|
+
let uri = parameters.grab("textDocument").field("uri").grabString()
|
|
208
|
+
let path = system.pathFromUrl(uri)
|
|
209
|
+
let fireflyPath = system.path(".")
|
|
210
|
+
let diagnostics = try {
|
|
211
|
+
Builder.check(system, fireflyPath, path, self.virtualFiles, LspHook.disabled(), True)
|
|
212
|
+
[]
|
|
213
|
+
} catch {| CompileError(at, message), error =>
|
|
214
|
+
let tokenLocation = self.findToken(system, at)
|
|
215
|
+
let diagnostic = Json.object()
|
|
216
|
+
.with("range", self.tokenLocationToLspRange(tokenLocation))
|
|
217
|
+
.with("severity", 1)
|
|
218
|
+
.with("message", message)
|
|
219
|
+
[diagnostic]
|
|
220
|
+
} grab()
|
|
221
|
+
|
|
222
|
+
Json.object()
|
|
223
|
+
.with("uri", uri)
|
|
224
|
+
.with("version", parameters.grab("textDocument").field("version"))
|
|
225
|
+
.with("diagnostics", diagnostics)
|
|
226
|
+
}
|
|
227
|
+
|
|
190
228
|
handleDocumentSymbol(system: NodeSystem, parameters: Map[String, Json]): ResultOrError {
|
|
191
229
|
let uri = parameters.grab("textDocument").field("uri").grabString()
|
|
192
230
|
let path = system.pathFromUrl(uri)
|
|
@@ -326,7 +364,9 @@ extend self: Handler {
|
|
|
326
364
|
Log.trace("handleSignatureHelp check 2 error: " + message)
|
|
327
365
|
} grab()
|
|
328
366
|
let help = SignatureHelpHandler.handleSignatureHelp(system, callLspHook)
|
|
329
|
-
|
|
367
|
+
if(!help.isNull()) {
|
|
368
|
+
SignatureHelpHandler.pickActiveParameter(help, h.argumentIndex, h.parameterName)
|
|
369
|
+
}
|
|
330
370
|
| _ =>
|
|
331
371
|
None
|
|
332
372
|
}
|
package/lsp/LanguageServer.ff
CHANGED
|
@@ -203,8 +203,8 @@ handleRequestMessage(system: NodeSystem, handler: Handler, message: RequestMessa
|
|
|
203
203
|
)
|
|
204
204
|
None
|
|
205
205
|
| None =>
|
|
206
|
-
handler.handleNotification(system, message.method, message.parameters)
|
|
207
|
-
|
|
206
|
+
let notification = handler.handleNotification(system, message.method, message.parameters)
|
|
207
|
+
notification.map {| Pair(method, params) => makeNotificationMessage(method, params)}
|
|
208
208
|
| Some(id) {handler.cancelledRequests.contains(id)} =>
|
|
209
209
|
handler.cancelledRequests = handler.cancelledRequests.remove(id)
|
|
210
210
|
Some(makeResponseMessage(id, Error(-32800, "Request cancelled")))
|
|
@@ -236,6 +236,13 @@ makeResponseMessage(id: MessageId, result: ResultOrError): Json {
|
|
|
236
236
|
o
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
+
makeNotificationMessage(method: String, params: Json): Json {
|
|
240
|
+
Json.object()
|
|
241
|
+
.with("jsonrpc", "2.0")
|
|
242
|
+
.with("method", method)
|
|
243
|
+
.with("params", params)
|
|
244
|
+
}
|
|
245
|
+
|
|
239
246
|
logMessage(directory: Path, messageType: String, body: Json, method: String) {
|
|
240
247
|
let id = if(method == "$/cancelRequest") {
|
|
241
248
|
Some(body.field("params").field("id").grabInt())
|
package/package.json
CHANGED
package/vscode/README.md
CHANGED
|
@@ -9,9 +9,6 @@ This extension adds support for the Firefly programming language (`.ff` files).
|
|
|
9
9
|
- Symbol renaming
|
|
10
10
|
- Document and workspace symbols
|
|
11
11
|
- Show type on hover
|
|
12
|
-
- Diagnostics
|
|
13
|
-
|
|
14
|
-
`*` Diagnostics don't currently update automatically when included files have been edited. It's disabled for performance reasons, and we're working on a solution.
|
|
12
|
+
- Diagnostics
|
|
15
13
|
|
|
16
14
|
You can run `.ff` main files via the usual *Run and Debug* side panel - just choose *create a launch.json file*. After that you can also press *F5* to run the currently open file.
|
|
17
|
-
|
|
@@ -26,7 +26,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|
|
26
26
|
context.subscriptions.push(vscode.commands.registerCommand('extension.firefly-lang.getFireflyCompiler', config => {
|
|
27
27
|
return fireflyCompiler;
|
|
28
28
|
}));
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
const runOrDebug = {
|
|
31
31
|
module: fireflyCompiler,
|
|
32
32
|
args: ['LanguageServer.ff'],
|
|
@@ -54,6 +54,17 @@ export function activate(context: vscode.ExtensionContext) {
|
|
|
54
54
|
);
|
|
55
55
|
|
|
56
56
|
client.start();
|
|
57
|
+
|
|
58
|
+
vscode.window.onDidChangeActiveTextEditor(editor => {
|
|
59
|
+
if(editor && editor.document.languageId === 'firefly') {
|
|
60
|
+
client.sendNotification('custom/focusDocument', {
|
|
61
|
+
"textDocument": {
|
|
62
|
+
uri: editor.document.uri.toString(),
|
|
63
|
+
version: editor.document.version,
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
57
68
|
}
|
|
58
69
|
|
|
59
70
|
export function deactivate(): Thenable<void> | undefined {
|