firefly-compiler 0.5.70 → 0.5.71
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/compiler/Dependencies.ff +1 -1
- package/compiler/Main.ff +1 -1
- package/compiler/Syntax.ff +2 -0
- package/lsp/CompletionHandler.ff +2 -4
- package/lsp/Handler.ff +12 -7
- package/output/js/ff/compiler/Dependencies.mjs +2 -2
- package/output/js/ff/compiler/Main.mjs +2 -2
- package/output/js/ff/compiler/Syntax.mjs +1 -1
- package/package.json +1 -1
- package/vscode/package.json +1 -1
package/compiler/Dependencies.ff
CHANGED
|
@@ -145,7 +145,7 @@ extend self: Dependencies {
|
|
|
145
145
|
process(fetch: HttpClient, dependencyLock: DependencyLock, path: Path): ResolvedDependencies {
|
|
146
146
|
let workspace = Workspace.loadWorkspace(path)
|
|
147
147
|
let self = Dependencies(workspace, [].toMap(), [].toMap(), [].toSet())
|
|
148
|
-
let packageInfo = self.loadPackageInfo(
|
|
148
|
+
let packageInfo = self.loadPackageInfo(Syntax.scriptPackagePair, path).else {
|
|
149
149
|
if(!path.exists()) {
|
|
150
150
|
throw(CompileError(Location(path.absolute(), 1, 1), "File not found"))
|
|
151
151
|
} else {
|
package/compiler/Main.ff
CHANGED
|
@@ -150,7 +150,7 @@ main(system: NodeSystem): Unit {
|
|
|
150
150
|
let columns = filePaths.flatMap {filePath =>
|
|
151
151
|
let path = system.path(filePath)
|
|
152
152
|
let code = path.readText()
|
|
153
|
-
let packagePair =
|
|
153
|
+
let packagePair = Syntax.scriptPackagePair
|
|
154
154
|
let moduleKey = ModuleKey(packagePair, [], path.base().removeLast(".ff").grab())
|
|
155
155
|
let tokens = Tokenizer.tokenize(path.absolute(), code, None, False)
|
|
156
156
|
let parser = Parser.new(moduleKey, tokens, True, LspHook.disabled())
|
package/compiler/Syntax.ff
CHANGED
package/lsp/CompletionHandler.ff
CHANGED
|
@@ -240,7 +240,7 @@ completionsToJson(completions: List[CompletionInfo]): Json {
|
|
|
240
240
|
importCompletion(moduleKeys: List[ModuleKey]): List[CompletionInfo] {
|
|
241
241
|
moduleKeys.map {moduleKey =>
|
|
242
242
|
let label = moduleKey.folders.map {_ + "."}.join() + moduleKey.name
|
|
243
|
-
let extra = if(moduleKey.packagePair
|
|
243
|
+
let extra = if(moduleKey.packagePair == Syntax.scriptPackagePair) {
|
|
244
244
|
""
|
|
245
245
|
} else {
|
|
246
246
|
" from " + moduleKey.packagePair.groupName(":")
|
|
@@ -374,9 +374,7 @@ completion(
|
|
|
374
374
|
|
|
375
375
|
makeAutoimportCompletion(info: ImportSymbolInfo, importLine: Int, name: String, isType: Bool): CompletionInfo {
|
|
376
376
|
let moduleName = info.moduleKey.folders.map {_ + "."}.join() + info.moduleKey.name
|
|
377
|
-
let fromName = if(
|
|
378
|
-
info.moduleKey.packagePair.name == "script" && info.moduleKey.packagePair.group == "script"
|
|
379
|
-
) {
|
|
377
|
+
let fromName = if(info.moduleKey.packagePair == Syntax.scriptPackagePair) {
|
|
380
378
|
""
|
|
381
379
|
} else {
|
|
382
380
|
info.moduleKey.packagePair.groupName(":")
|
package/lsp/Handler.ff
CHANGED
|
@@ -76,7 +76,6 @@ extend self: Handler {
|
|
|
76
76
|
let diagnostics = self.handleFocusDiagnostic(system, parameters, version)
|
|
77
77
|
[Pair("textDocument/publishDiagnostics", diagnostics)]
|
|
78
78
|
| "custom/focusDocument" =>
|
|
79
|
-
self.importSymbolsCache = Pair("", [])
|
|
80
79
|
let diagnostics = self.handleFocusDiagnostic(system, parameters, version)
|
|
81
80
|
[Pair("textDocument/publishDiagnostics", diagnostics)]
|
|
82
81
|
| "workspace/didRenameFiles" =>
|
|
@@ -283,7 +282,7 @@ extend self: Handler {
|
|
|
283
282
|
let lspHook = LspHook.new(at = None, definedAt = None, insertIdentifier = False, trackSymbols = True)
|
|
284
283
|
let code = self.virtualFiles.get(path.absolute()).else {path.readText()}
|
|
285
284
|
let tokens = Tokenizer.tokenize(path.absolute(), code, None, True)
|
|
286
|
-
let dummyModuleKey = ModuleKey(
|
|
285
|
+
let dummyModuleKey = ModuleKey(Syntax.scriptPackagePair, [], path.base())
|
|
287
286
|
let parser = Parser.new(dummyModuleKey, tokens, False, lspHook)
|
|
288
287
|
parser.parseModuleWithPackageInfo()
|
|
289
288
|
SymbolHandler.readAllSymbols(lspHook.results())
|
|
@@ -339,9 +338,14 @@ extend self: Handler {
|
|
|
339
338
|
let creates = parameters.grab("changes").grabArray().filter {_.field("type").grabInt() == 1}
|
|
340
339
|
let changes = parameters.grab("changes").grabArray().filter {_.field("type").grabInt() == 2}
|
|
341
340
|
let deletes = parameters.grab("changes").grabArray().filter {_.field("type").grabInt() == 3}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
341
|
+
function invalidate(url: String) {
|
|
342
|
+
let path = system.pathFromUrl(url)
|
|
343
|
+
if(self.importSymbolsCache.first != path.absolute()) {self.importSymbolsCache = Pair("", [])}
|
|
344
|
+
self.moduleCache.invalidate(path.absolute())
|
|
345
|
+
}
|
|
346
|
+
creates.map {_.field("uri").grabString()}.each {invalidate(_)}
|
|
347
|
+
changes.map {_.field("uri").grabString()}.each {invalidate(_)}
|
|
348
|
+
deletes.map {_.field("uri").grabString()}.each {invalidate(_)}
|
|
345
349
|
let diagnostics = self.handleClearDiagnostic(system, [Pair("files", Json.array(deletes))].toMap())
|
|
346
350
|
diagnostics.map {Pair("textDocument/publishDiagnostics", _)}
|
|
347
351
|
}
|
|
@@ -358,6 +362,7 @@ extend self: Handler {
|
|
|
358
362
|
handleDidChange(system: NodeSystem, parameters: Map[String, Json]): Unit {
|
|
359
363
|
let uri = parameters.grab("textDocument").field("uri").grabString()
|
|
360
364
|
let path = system.pathFromUrl(uri)
|
|
365
|
+
if(self.importSymbolsCache.first != path.absolute()) {self.importSymbolsCache = Pair("", [])}
|
|
361
366
|
self.responseCache = Map.new()
|
|
362
367
|
self.fileSymbolsCache = self.fileSymbolsCache.remove(path.absolute())
|
|
363
368
|
self.moduleCache.invalidate(path.absolute())
|
|
@@ -428,7 +433,7 @@ extend self: Handler {
|
|
|
428
433
|
try {
|
|
429
434
|
let code = self.virtualFiles.get(cursorAt.file).else {system.path(cursorAt.file).readText()}
|
|
430
435
|
let tokens = Tokenizer.tokenize(cursorAt.file, code, None, True)
|
|
431
|
-
let dummyModuleKey = ModuleKey(
|
|
436
|
+
let dummyModuleKey = ModuleKey(Syntax.scriptPackagePair, [], "<LSP>")
|
|
432
437
|
let parser = Parser.new(dummyModuleKey, tokens, False, lspHook)
|
|
433
438
|
parser.parseModuleWithPackageInfo()
|
|
434
439
|
} tryCatch {| CompileError(at, message), error =>
|
|
@@ -651,7 +656,7 @@ extend self: Handler {
|
|
|
651
656
|
let imports = try {
|
|
652
657
|
let code = self.virtualFiles.get(modulePath.absolute()).else {modulePath.readText()}
|
|
653
658
|
let tokens = Tokenizer.tokenize(modulePath.absolute(), code, Some(lspHook.at), True)
|
|
654
|
-
let parser = Parser.new(ModuleKey(
|
|
659
|
+
let parser = Parser.new(ModuleKey(Syntax.scriptPackagePair, [], ""), tokens, True, lspHook)
|
|
655
660
|
tokens.each {token =>
|
|
656
661
|
if(token.is(LKeyword) && token.rawIs4("import", "include", "package", "dependency")) {
|
|
657
662
|
importLine = token.startLine + 1
|
|
@@ -123,7 +123,7 @@ return {mainPackagePair_, packages_, packagePaths_, singleFilePackages_};
|
|
|
123
123
|
export function process_(fetch_, dependencyLock_, path_) {
|
|
124
124
|
const workspace_ = ff_compiler_Workspace.loadWorkspace_(path_);
|
|
125
125
|
const self_ = ff_compiler_Dependencies.Dependencies(workspace_, ff_core_List.List_toMap([], ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ff_core_List.List_toMap([], ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ff_core_List.List_toSet([], ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
|
|
126
|
-
const packageInfo_ = ff_core_Option.Option_else(ff_compiler_Dependencies.Dependencies_loadPackageInfo(self_, ff_compiler_Syntax.
|
|
126
|
+
const packageInfo_ = ff_core_Option.Option_else(ff_compiler_Dependencies.Dependencies_loadPackageInfo(self_, ff_compiler_Syntax.scriptPackagePair_, path_), (() => {
|
|
127
127
|
if((!ff_core_Path.Path_exists(path_, false, false, false))) {
|
|
128
128
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_compiler_Syntax.Location(ff_core_Path.Path_absolute(path_), 1, 1), "File not found"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
129
129
|
} else {
|
|
@@ -167,7 +167,7 @@ tar_.extract({file: tarGzPath_.absolutePath_, cwd: path_.absolutePath_, strict:
|
|
|
167
167
|
export async function process_$(fetch_, dependencyLock_, path_, $task) {
|
|
168
168
|
const workspace_ = (await ff_compiler_Workspace.loadWorkspace_$(path_, $task));
|
|
169
169
|
const self_ = ff_compiler_Dependencies.Dependencies(workspace_, ff_core_List.List_toMap([], ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ff_core_List.List_toMap([], ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ff_core_List.List_toSet([], ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
|
|
170
|
-
const packageInfo_ = (await ff_core_Option.Option_else$((await ff_compiler_Dependencies.Dependencies_loadPackageInfo$(self_, ff_compiler_Syntax.
|
|
170
|
+
const packageInfo_ = (await ff_core_Option.Option_else$((await ff_compiler_Dependencies.Dependencies_loadPackageInfo$(self_, ff_compiler_Syntax.scriptPackagePair_, path_, $task)), (async ($task) => {
|
|
171
171
|
if((!(await ff_core_Path.Path_exists$(path_, false, false, false, $task)))) {
|
|
172
172
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_compiler_Syntax.Location((await ff_core_Path.Path_absolute$(path_, $task)), 1, 1), "File not found"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
173
173
|
} else {
|
|
@@ -246,7 +246,7 @@ const filePaths_ = command_a.filePaths_;
|
|
|
246
246
|
const columns_ = ff_core_List.List_flatMap(filePaths_, ((filePath_) => {
|
|
247
247
|
const path_ = ff_core_NodeSystem.NodeSystem_path(system_, filePath_);
|
|
248
248
|
const code_ = ff_core_Path.Path_readText(path_);
|
|
249
|
-
const packagePair_ = ff_compiler_Syntax.
|
|
249
|
+
const packagePair_ = ff_compiler_Syntax.scriptPackagePair_;
|
|
250
250
|
const moduleKey_ = ff_compiler_Syntax.ModuleKey(packagePair_, [], ff_core_Option.Option_grab(ff_core_String.String_removeLast(ff_core_Path.Path_base(path_), ".ff")));
|
|
251
251
|
const tokens_ = ff_compiler_Tokenizer.tokenize_(ff_core_Path.Path_absolute(path_), code_, ff_core_Option.None(), false);
|
|
252
252
|
const parser_ = ff_compiler_Parser.new_(moduleKey_, tokens_, true, ff_compiler_LspHook.disabled_());
|
|
@@ -650,7 +650,7 @@ const filePaths_ = command_a.filePaths_;
|
|
|
650
650
|
const columns_ = (await ff_core_List.List_flatMap$(filePaths_, (async (filePath_, $task) => {
|
|
651
651
|
const path_ = (await ff_core_NodeSystem.NodeSystem_path$(system_, filePath_, $task));
|
|
652
652
|
const code_ = (await ff_core_Path.Path_readText$(path_, $task));
|
|
653
|
-
const packagePair_ = ff_compiler_Syntax.
|
|
653
|
+
const packagePair_ = ff_compiler_Syntax.scriptPackagePair_;
|
|
654
654
|
const moduleKey_ = ff_compiler_Syntax.ModuleKey(packagePair_, [], ff_core_Option.Option_grab(ff_core_String.String_removeLast((await ff_core_Path.Path_base$(path_, $task)), ".ff")));
|
|
655
655
|
const tokens_ = ff_compiler_Tokenizer.tokenize_((await ff_core_Path.Path_absolute$(path_, $task)), code_, ff_core_Option.None(), false);
|
|
656
656
|
const parser_ = ff_compiler_Parser.new_(moduleKey_, tokens_, true, ff_compiler_LspHook.disabled_());
|
|
@@ -361,7 +361,7 @@ export function Version(at_, major_, minor_, patch_) {
|
|
|
361
361
|
return {at_, major_, minor_, patch_};
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
|
|
364
|
+
export const scriptPackagePair_ = ff_compiler_Syntax.PackagePair("script", "script");
|
|
365
365
|
|
|
366
366
|
export function catchMany_(list_, body_) {
|
|
367
367
|
const errors_ = ff_core_Array.new_();
|
package/package.json
CHANGED