firefly-compiler 0.4.14 → 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/core/Json.ff CHANGED
@@ -177,7 +177,7 @@ extend self: Json {
177
177
 
178
178
  isNull(): Bool
179
179
  target js sync """
180
- return typeof self_ === null;
180
+ return self_ === null;
181
181
  """
182
182
 
183
183
  field(key: String): Json
package/guide/Main.ff ADDED
@@ -0,0 +1,3 @@
1
+ nodeMain(system: NodeSystem) {
2
+ Json.object()
3
+ }
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]): Unit {
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
- | "textDocument/didClose" => self.handleDidClose(system, parameters)
55
- | "exit" => system.exit(0)
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
- | "textDocument/diagnostic" => self.handleDiagnostic(system, parameters)
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" => self.printTime(system.mainTask(), "handleWorkspaceSymbol") {self.handleWorkspaceSymbol(system, parameters)}
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
- .with("diagnosticProvider", Json.object()
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
- Some(SignatureHelpHandler.pickActiveParameter(help, h.argumentIndex, h.parameterName))
367
+ if(!help.isNull()) {
368
+ SignatureHelpHandler.pickActiveParameter(help, h.argumentIndex, h.parameterName)
369
+ }
330
370
  | _ =>
331
371
  None
332
372
  }
@@ -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
- None
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())
@@ -313,7 +313,7 @@ throw new Error('Function internalCompare is missing on this target in async con
313
313
 
314
314
  export function Json_write(self_, indentation_ = ff_core_Option.None()) {
315
315
 
316
- return JSON.stringify(self_, null, space_.value_);
316
+ return JSON.stringify(self_, null, indentation_.value_);
317
317
 
318
318
  }
319
319
 
@@ -451,7 +451,7 @@ export function Json_isObject(self_) {
451
451
 
452
452
  export function Json_isNull(self_) {
453
453
 
454
- return typeof self_ === null;
454
+ return self_ === null;
455
455
 
456
456
  }
457
457
 
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "description": "Firefly compiler",
5
5
  "author": "Firefly team",
6
6
  "license": "MIT",
7
- "version": "0.4.14",
7
+ "version": "0.4.16",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"
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 {
@@ -4,7 +4,7 @@
4
4
  "description": "Firefly language support",
5
5
  "author": "Firefly team",
6
6
  "license": "MIT",
7
- "version": "0.4.14",
7
+ "version": "0.4.16",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"