firefly-compiler 0.5.70 → 0.5.72
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/.vscode/settings.json +1 -1
- package/compiler/Builder.ff +11 -6
- package/compiler/Dependencies.ff +1 -1
- package/compiler/Main.ff +1 -1
- package/compiler/Syntax.ff +2 -0
- package/core/String.ff +2 -2
- package/experimental/foldertest/Root.ff +2 -9
- package/experimental/foldertest/findinfolder/FindInFolder.ff +3 -0
- package/lsp/CompletionHandler.ff +2 -4
- package/lsp/Handler.ff +28 -19
- package/output/js/ff/compiler/Builder.mjs +22 -16
- 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/output/js/ff/core/String.mjs +4 -4
- package/package.json +1 -1
- package/vscode/package.json +1 -1
- package/experimental/foldertest/a/A.ff +0 -3
- package/experimental/foldertest/a/MainA.ff +0 -3
package/.vscode/settings.json
CHANGED
package/compiler/Builder.ff
CHANGED
|
@@ -135,7 +135,7 @@ check(
|
|
|
135
135
|
): List[CompileError] {
|
|
136
136
|
let packages = path.isDirectory().{
|
|
137
137
|
| False {path.endsWith([".firefly", "package.ff"])} => [PackageFiles(path.parent().grab(), Some(path), [])]
|
|
138
|
-
| True => findPackageFilesForDirectory(path, mustContain, skipFiles)
|
|
138
|
+
| True => findPackageFilesForDirectory(path, virtualFiles, mustContain, skipFiles)
|
|
139
139
|
| False => findPackageFilesForFile(path).toList()
|
|
140
140
|
}
|
|
141
141
|
let errors = Array.new()
|
|
@@ -213,10 +213,11 @@ findPackageFilesForFile(file: Path): Option[PackageFiles] {
|
|
|
213
213
|
|
|
214
214
|
findPackageFilesForDirectory(
|
|
215
215
|
directory: Path
|
|
216
|
+
virtualFiles: Map[String, String]
|
|
216
217
|
mustContain: Option[String]
|
|
217
218
|
skipFiles: Set[String]
|
|
218
219
|
): List[PackageFiles] {
|
|
219
|
-
let files = findFireflyFiles(directory, mustContain, skipFiles)
|
|
220
|
+
let files = findFireflyFiles(directory, virtualFiles, mustContain, skipFiles)
|
|
220
221
|
let split = files.partition {_.endsWith([".firefly", "package.ff"])}
|
|
221
222
|
let packageFiles = split.first
|
|
222
223
|
mutable singleFiles = split.second
|
|
@@ -236,6 +237,7 @@ findPackageFilesForDirectory(
|
|
|
236
237
|
|
|
237
238
|
findFireflyFiles(
|
|
238
239
|
path: Path
|
|
240
|
+
virtualFiles: Map[String, String]
|
|
239
241
|
mustContain: Option[String]
|
|
240
242
|
skipFiles: Set[String]
|
|
241
243
|
): List[Path] {
|
|
@@ -246,11 +248,14 @@ findFireflyFiles(
|
|
|
246
248
|
c == '.' || c.isAsciiLower() || c.isAsciiDigit()
|
|
247
249
|
}}
|
|
248
250
|
let fireflyFiles = files.map {_.path()}.filter {file =>
|
|
249
|
-
file.extension() == ".ff" && !skipFiles.contains(file.absolute()) &&
|
|
250
|
-
file.
|
|
251
|
-
|
|
251
|
+
file.extension() == ".ff" && !skipFiles.contains(file.absolute()) && (
|
|
252
|
+
file.endsWith([".firefly", "package.ff"]) || mustContain.all {s =>
|
|
253
|
+
let code = virtualFiles.get(file.absolute()).else {file.readText()}
|
|
254
|
+
code.contains(s)
|
|
255
|
+
}
|
|
256
|
+
)
|
|
252
257
|
}
|
|
253
|
-
[...fireflyFiles, ...relevantDirectories.flatMap {findFireflyFiles(_, mustContain, skipFiles)}]
|
|
258
|
+
[...fireflyFiles, ...relevantDirectories.flatMap {findFireflyFiles(_, virtualFiles, mustContain, skipFiles)}]
|
|
254
259
|
}
|
|
255
260
|
|
|
256
261
|
internalCreateExecutable(
|
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/core/String.ff
CHANGED
|
@@ -150,8 +150,8 @@ extend self: String {
|
|
|
150
150
|
self!->startsWith(prefix, offset)?
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
endsWith(
|
|
154
|
-
self!->endsWith(
|
|
153
|
+
endsWith(suffix: String): Bool {
|
|
154
|
+
self!->endsWith(suffix)?
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
removeFirst(prefix: String): Option[String] {
|
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())
|
|
@@ -317,7 +316,9 @@ extend self: Handler {
|
|
|
317
316
|
let files = if(rootPath.isFile()) {
|
|
318
317
|
[rootPath]
|
|
319
318
|
} else {
|
|
320
|
-
self.printTime(system.mainTask(), "findFireflyFiles") {
|
|
319
|
+
self.printTime(system.mainTask(), "findFireflyFiles") {
|
|
320
|
+
Builder.findFireflyFiles(rootPath, self.virtualFiles, None, Set.new())
|
|
321
|
+
}
|
|
321
322
|
}
|
|
322
323
|
let root = if(rootPath.isFile()) {rootPath.parent().grab()} else {rootPath}
|
|
323
324
|
let query = parameters.grab("query").grabString()
|
|
@@ -339,9 +340,14 @@ extend self: Handler {
|
|
|
339
340
|
let creates = parameters.grab("changes").grabArray().filter {_.field("type").grabInt() == 1}
|
|
340
341
|
let changes = parameters.grab("changes").grabArray().filter {_.field("type").grabInt() == 2}
|
|
341
342
|
let deletes = parameters.grab("changes").grabArray().filter {_.field("type").grabInt() == 3}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
343
|
+
function invalidate(url: String) {
|
|
344
|
+
let path = system.pathFromUrl(url)
|
|
345
|
+
if(self.importSymbolsCache.first != path.absolute()) {self.importSymbolsCache = Pair("", [])}
|
|
346
|
+
self.moduleCache.invalidate(path.absolute())
|
|
347
|
+
}
|
|
348
|
+
creates.map {_.field("uri").grabString()}.each {invalidate(_)}
|
|
349
|
+
changes.map {_.field("uri").grabString()}.each {invalidate(_)}
|
|
350
|
+
deletes.map {_.field("uri").grabString()}.each {invalidate(_)}
|
|
345
351
|
let diagnostics = self.handleClearDiagnostic(system, [Pair("files", Json.array(deletes))].toMap())
|
|
346
352
|
diagnostics.map {Pair("textDocument/publishDiagnostics", _)}
|
|
347
353
|
}
|
|
@@ -358,6 +364,7 @@ extend self: Handler {
|
|
|
358
364
|
handleDidChange(system: NodeSystem, parameters: Map[String, Json]): Unit {
|
|
359
365
|
let uri = parameters.grab("textDocument").field("uri").grabString()
|
|
360
366
|
let path = system.pathFromUrl(uri)
|
|
367
|
+
if(self.importSymbolsCache.first != path.absolute()) {self.importSymbolsCache = Pair("", [])}
|
|
361
368
|
self.responseCache = Map.new()
|
|
362
369
|
self.fileSymbolsCache = self.fileSymbolsCache.remove(path.absolute())
|
|
363
370
|
self.moduleCache.invalidate(path.absolute())
|
|
@@ -428,7 +435,7 @@ extend self: Handler {
|
|
|
428
435
|
try {
|
|
429
436
|
let code = self.virtualFiles.get(cursorAt.file).else {system.path(cursorAt.file).readText()}
|
|
430
437
|
let tokens = Tokenizer.tokenize(cursorAt.file, code, None, True)
|
|
431
|
-
let dummyModuleKey = ModuleKey(
|
|
438
|
+
let dummyModuleKey = ModuleKey(Syntax.scriptPackagePair, [], "<LSP>")
|
|
432
439
|
let parser = Parser.new(dummyModuleKey, tokens, False, lspHook)
|
|
433
440
|
parser.parseModuleWithPackageInfo()
|
|
434
441
|
} tryCatch {| CompileError(at, message), error =>
|
|
@@ -484,7 +491,6 @@ extend self: Handler {
|
|
|
484
491
|
| Some([]) => Result(Json.null().write())
|
|
485
492
|
| Some([first, ...] @ tokens) =>
|
|
486
493
|
let oldName = first.raw
|
|
487
|
-
Log.trace("Rename '" + oldName + "' to '" + newName + "'")
|
|
488
494
|
|
|
489
495
|
// TODO findReferences returns some bad tokens
|
|
490
496
|
let goodTokens = tokens.filter {_.raw == oldName}
|
|
@@ -514,8 +520,8 @@ extend self: Handler {
|
|
|
514
520
|
version: Int
|
|
515
521
|
): Option[List[TokenLocation]] {
|
|
516
522
|
let temporaryLspHook = LspHook.new(at = Some(targetAt), definedAt = None, insertIdentifier = False, trackSymbols = False)
|
|
517
|
-
let
|
|
518
|
-
let errors = self.check(system, self.fireflyPath,
|
|
523
|
+
let targetPath = system.path(targetAt.file)
|
|
524
|
+
let errors = self.check(system, self.fireflyPath, targetPath, None, Set.new(), self.virtualFiles, version, temporaryLspHook, True)
|
|
519
525
|
errors.each {| CompileError(at, message) =>
|
|
520
526
|
Log.trace("findReferences first check error: " + message + " in " + at.file + ":" + at.line + ":" + at.column)
|
|
521
527
|
}
|
|
@@ -543,6 +549,9 @@ extend self: Handler {
|
|
|
543
549
|
| h => None
|
|
544
550
|
}.filter {pair => !pair.at.file.endsWith(">")}
|
|
545
551
|
|
|
552
|
+
Log.trace("findReferences("+Show.show(targetAt)+")")
|
|
553
|
+
Log.trace("definedAtList: " + Show.show(definedAtList))
|
|
554
|
+
|
|
546
555
|
function unqualify(qualifiedName: String): String {
|
|
547
556
|
qualifiedName.split('.').grabLast().split('_').grabLast()
|
|
548
557
|
}
|
|
@@ -561,10 +570,8 @@ extend self: Handler {
|
|
|
561
570
|
| Some(definition) =>
|
|
562
571
|
let lspHook = LspHook.new(at = None, definedAt = Some(definition.at), insertIdentifier = False, trackSymbols = False)
|
|
563
572
|
let localCheck = local || definition.local
|
|
564
|
-
let
|
|
573
|
+
let checkPath = if(localCheck) {targetPath} else {self.rootPath.else {targetPath}}
|
|
565
574
|
let mustContain = Some(definition.name).filter {_ => !localCheck}.map(unqualify)
|
|
566
|
-
Log.trace("findReferences definition: " + Show.show(definition))
|
|
567
|
-
mustContain.each {Log.trace("mustContain: " + _)}
|
|
568
575
|
|
|
569
576
|
let skipFiles = if(definition.name.contains(":")) {
|
|
570
577
|
let list = self.moduleCache.filesNotImporting(extractModuleKey(definition.name))
|
|
@@ -577,8 +584,8 @@ extend self: Handler {
|
|
|
577
584
|
Log.trace("No skip list due to unqualified definition.name: " + definition.name)
|
|
578
585
|
Set.new()
|
|
579
586
|
}
|
|
580
|
-
}
|
|
581
|
-
let errors = self.check(system, self.fireflyPath,
|
|
587
|
+
}.remove(targetPath.absolute())
|
|
588
|
+
let errors = self.check(system, self.fireflyPath, checkPath, mustContain, skipFiles, self.virtualFiles, version, lspHook, True)
|
|
582
589
|
errors.each {| CompileError(at, message) =>
|
|
583
590
|
Log.trace("findReferences second check error: " + message + " in " + at.file + ":" + at.line + ":" + at.column)
|
|
584
591
|
}
|
|
@@ -599,8 +606,6 @@ extend self: Handler {
|
|
|
599
606
|
!at.file.endsWith(">") &&
|
|
600
607
|
(includeDeclaration || at != definition.at)
|
|
601
608
|
}
|
|
602
|
-
|
|
603
|
-
//referencesResult.each {Log.trace(Show.show(_))}
|
|
604
609
|
|
|
605
610
|
let clientLocations = referencesResult.addAll(
|
|
606
611
|
if(includeDeclaration) {[definition.at]} else {[]}
|
|
@@ -635,7 +640,7 @@ extend self: Handler {
|
|
|
635
640
|
}.toOption()
|
|
636
641
|
}
|
|
637
642
|
let symbols = nonCore.flatMap {| Pair(packagePair, packagePath) =>
|
|
638
|
-
let packageFiles = Builder.findPackageFilesForDirectory(packagePath, None, Set.new())
|
|
643
|
+
let packageFiles = Builder.findPackageFilesForDirectory(packagePath, self.virtualFiles, None, Set.new())
|
|
639
644
|
packageFiles.flatMap {_.files.collect {file =>
|
|
640
645
|
parseModule(packagePair, file).map: module =>
|
|
641
646
|
let typeNames = module.types.map {_.name}
|
|
@@ -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
|
|
@@ -789,3 +794,7 @@ extend self: Handler {
|
|
|
789
794
|
}
|
|
790
795
|
|
|
791
796
|
}
|
|
797
|
+
|
|
798
|
+
foo(bb: Int): Int {
|
|
799
|
+
bb
|
|
800
|
+
}
|
|
@@ -214,7 +214,7 @@ if(!_1 && ff_core_Path.Path_endsWith(path_, [".firefly", "package.ff"])) {
|
|
|
214
214
|
return [ff_compiler_Builder.PackageFiles(ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_)), ff_core_Option.Some(path_), [])]
|
|
215
215
|
}
|
|
216
216
|
if(_1) {
|
|
217
|
-
return ff_compiler_Builder.findPackageFilesForDirectory_(path_, mustContain_, skipFiles_)
|
|
217
|
+
return ff_compiler_Builder.findPackageFilesForDirectory_(path_, virtualFiles_, mustContain_, skipFiles_)
|
|
218
218
|
}
|
|
219
219
|
{
|
|
220
220
|
return ff_core_Option.Option_toList(ff_compiler_Builder.findPackageFilesForFile_(path_))
|
|
@@ -315,8 +315,8 @@ return ff_compiler_Builder.PackageFiles(projectRoot_, packageFile_, [file_])
|
|
|
315
315
|
} else return ff_core_Option.None()
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
-
export function findPackageFilesForDirectory_(directory_, mustContain_, skipFiles_) {
|
|
319
|
-
const files_ = ff_compiler_Builder.findFireflyFiles_(directory_, mustContain_, skipFiles_);
|
|
318
|
+
export function findPackageFilesForDirectory_(directory_, virtualFiles_, mustContain_, skipFiles_) {
|
|
319
|
+
const files_ = ff_compiler_Builder.findFireflyFiles_(directory_, virtualFiles_, mustContain_, skipFiles_);
|
|
320
320
|
const split_ = ff_core_List.List_partition(files_, ((_w1) => {
|
|
321
321
|
return ff_core_Path.Path_endsWith(_w1, [".firefly", "package.ff"])
|
|
322
322
|
}));
|
|
@@ -338,7 +338,7 @@ return ff_compiler_Builder.PackageFiles(projectRoot_, ff_core_Option.None(), [fi
|
|
|
338
338
|
return [...multiFileProjects_, ...singleFileProjects_]
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
-
export function findFireflyFiles_(path_, mustContain_, skipFiles_) {
|
|
341
|
+
export function findFireflyFiles_(path_, virtualFiles_, mustContain_, skipFiles_) {
|
|
342
342
|
const split_ = ff_core_List.List_partition(ff_core_Stream.Stream_toList(ff_core_Path.Path_entries(path_)), ((_w1) => {
|
|
343
343
|
return ff_core_Path.PathEntry_isDirectory(_w1)
|
|
344
344
|
}));
|
|
@@ -354,12 +354,15 @@ return (((c_ === 46) || ff_core_Char.Char_isAsciiLower(c_)) || ff_core_Char.Char
|
|
|
354
354
|
const fireflyFiles_ = ff_core_List.List_filter(ff_core_List.List_map(files_, ((_w1) => {
|
|
355
355
|
return ff_core_Path.PathEntry_path(_w1)
|
|
356
356
|
})), ((file_) => {
|
|
357
|
-
return (((ff_core_Path.Path_extension(file_) === ".ff") && (!ff_core_Set.Set_contains(skipFiles_, ff_core_Path.Path_absolute(file_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))) && ff_core_Option.Option_all(mustContain_, ((s_) => {
|
|
358
|
-
|
|
359
|
-
|
|
357
|
+
return (((ff_core_Path.Path_extension(file_) === ".ff") && (!ff_core_Set.Set_contains(skipFiles_, ff_core_Path.Path_absolute(file_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))) && (ff_core_Path.Path_endsWith(file_, [".firefly", "package.ff"]) || ff_core_Option.Option_all(mustContain_, ((s_) => {
|
|
358
|
+
const code_ = ff_core_Option.Option_else(ff_core_Map.Map_get(virtualFiles_, ff_core_Path.Path_absolute(file_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
359
|
+
return ff_core_Path.Path_readText(file_)
|
|
360
|
+
}));
|
|
361
|
+
return ff_core_String.String_contains(code_, s_)
|
|
362
|
+
}))))
|
|
360
363
|
}));
|
|
361
364
|
return [...fireflyFiles_, ...ff_core_List.List_flatMap(relevantDirectories_, ((_w1) => {
|
|
362
|
-
return ff_compiler_Builder.findFireflyFiles_(_w1, mustContain_, skipFiles_)
|
|
365
|
+
return ff_compiler_Builder.findFireflyFiles_(_w1, virtualFiles_, mustContain_, skipFiles_)
|
|
363
366
|
}))]
|
|
364
367
|
}
|
|
365
368
|
|
|
@@ -493,7 +496,7 @@ if(!_1 && (await ff_core_Path.Path_endsWith$(path_, [".firefly", "package.ff"],
|
|
|
493
496
|
return [ff_compiler_Builder.PackageFiles(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task))), ff_core_Option.Some(path_), [])]
|
|
494
497
|
}
|
|
495
498
|
if(_1) {
|
|
496
|
-
return (await ff_compiler_Builder.findPackageFilesForDirectory_$(path_, mustContain_, skipFiles_, $task))
|
|
499
|
+
return (await ff_compiler_Builder.findPackageFilesForDirectory_$(path_, virtualFiles_, mustContain_, skipFiles_, $task))
|
|
497
500
|
}
|
|
498
501
|
{
|
|
499
502
|
return ff_core_Option.Option_toList((await ff_compiler_Builder.findPackageFilesForFile_$(path_, $task)))
|
|
@@ -594,8 +597,8 @@ return ff_compiler_Builder.PackageFiles(projectRoot_, packageFile_, [file_])
|
|
|
594
597
|
} else return ff_core_Option.None()
|
|
595
598
|
}
|
|
596
599
|
|
|
597
|
-
export async function findPackageFilesForDirectory_$(directory_, mustContain_, skipFiles_, $task) {
|
|
598
|
-
const files_ = (await ff_compiler_Builder.findFireflyFiles_$(directory_, mustContain_, skipFiles_, $task));
|
|
600
|
+
export async function findPackageFilesForDirectory_$(directory_, virtualFiles_, mustContain_, skipFiles_, $task) {
|
|
601
|
+
const files_ = (await ff_compiler_Builder.findFireflyFiles_$(directory_, virtualFiles_, mustContain_, skipFiles_, $task));
|
|
599
602
|
const split_ = (await ff_core_List.List_partition$(files_, (async (_w1, $task) => {
|
|
600
603
|
return (await ff_core_Path.Path_endsWith$(_w1, [".firefly", "package.ff"], $task))
|
|
601
604
|
}), $task));
|
|
@@ -617,7 +620,7 @@ return ff_compiler_Builder.PackageFiles(projectRoot_, ff_core_Option.None(), [fi
|
|
|
617
620
|
return [...multiFileProjects_, ...singleFileProjects_]
|
|
618
621
|
}
|
|
619
622
|
|
|
620
|
-
export async function findFireflyFiles_$(path_, mustContain_, skipFiles_, $task) {
|
|
623
|
+
export async function findFireflyFiles_$(path_, virtualFiles_, mustContain_, skipFiles_, $task) {
|
|
621
624
|
const split_ = (await ff_core_List.List_partition$((await ff_core_Stream.Stream_toList$((await ff_core_Path.Path_entries$(path_, $task)), $task)), (async (_w1, $task) => {
|
|
622
625
|
return (await ff_core_Path.PathEntry_isDirectory$(_w1, $task))
|
|
623
626
|
}), $task));
|
|
@@ -633,12 +636,15 @@ return (((c_ === 46) || ff_core_Char.Char_isAsciiLower(c_)) || ff_core_Char.Char
|
|
|
633
636
|
const fireflyFiles_ = (await ff_core_List.List_filter$((await ff_core_List.List_map$(files_, (async (_w1, $task) => {
|
|
634
637
|
return (await ff_core_Path.PathEntry_path$(_w1, $task))
|
|
635
638
|
}), $task)), (async (file_, $task) => {
|
|
636
|
-
return ((((await ff_core_Path.Path_extension$(file_, $task)) === ".ff") && (!ff_core_Set.Set_contains(skipFiles_, (await ff_core_Path.Path_absolute$(file_, $task)), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))) && (await ff_core_Option.Option_all$(mustContain_, (async (s_, $task) => {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
+
return ((((await ff_core_Path.Path_extension$(file_, $task)) === ".ff") && (!ff_core_Set.Set_contains(skipFiles_, (await ff_core_Path.Path_absolute$(file_, $task)), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))) && ((await ff_core_Path.Path_endsWith$(file_, [".firefly", "package.ff"], $task)) || (await ff_core_Option.Option_all$(mustContain_, (async (s_, $task) => {
|
|
640
|
+
const code_ = (await ff_core_Option.Option_else$(ff_core_Map.Map_get(virtualFiles_, (await ff_core_Path.Path_absolute$(file_, $task)), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (async ($task) => {
|
|
641
|
+
return (await ff_core_Path.Path_readText$(file_, $task))
|
|
642
|
+
}), $task));
|
|
643
|
+
return ff_core_String.String_contains(code_, s_)
|
|
644
|
+
}), $task))))
|
|
639
645
|
}), $task));
|
|
640
646
|
return [...fireflyFiles_, ...(await ff_core_List.List_flatMap$(relevantDirectories_, (async (_w1, $task) => {
|
|
641
|
-
return (await ff_compiler_Builder.findFireflyFiles_$(_w1, mustContain_, skipFiles_, $task))
|
|
647
|
+
return (await ff_compiler_Builder.findFireflyFiles_$(_w1, virtualFiles_, mustContain_, skipFiles_, $task))
|
|
642
648
|
}), $task))]
|
|
643
649
|
}
|
|
644
650
|
|
|
@@ -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_();
|
|
@@ -252,8 +252,8 @@ export function String_startsWith(self_, prefix_, offset_ = 0) {
|
|
|
252
252
|
return self_.startsWith(prefix_, offset_)
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
export function String_endsWith(self_,
|
|
256
|
-
return self_.endsWith(
|
|
255
|
+
export function String_endsWith(self_, suffix_) {
|
|
256
|
+
return self_.endsWith(suffix_)
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
export function String_removeFirst(self_, prefix_) {
|
|
@@ -514,8 +514,8 @@ export async function String_startsWith$(self_, prefix_, offset_ = 0, $task) {
|
|
|
514
514
|
return self_.startsWith(prefix_, offset_)
|
|
515
515
|
}
|
|
516
516
|
|
|
517
|
-
export async function String_endsWith$(self_,
|
|
518
|
-
return self_.endsWith(
|
|
517
|
+
export async function String_endsWith$(self_, suffix_, $task) {
|
|
518
|
+
return self_.endsWith(suffix_)
|
|
519
519
|
}
|
|
520
520
|
|
|
521
521
|
export async function String_removeFirst$(self_, prefix_, $task) {
|
package/package.json
CHANGED
package/vscode/package.json
CHANGED