firefly-compiler 0.5.71 → 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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "editor.suggest.showWords": false,
3
- "firefly.trace.server": "verbose",
3
+ "firefly.trace.server": "messages",
4
4
  "editor.trimAutoWhitespace": false
5
5
  }
@@ -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()) && mustContain.all {s =>
250
- file.readText().contains(s)
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/core/String.ff CHANGED
@@ -150,8 +150,8 @@ extend self: String {
150
150
  self!->startsWith(prefix, offset)?
151
151
  }
152
152
 
153
- endsWith(prefix: String): Bool {
154
- self!->endsWith(prefix)?
153
+ endsWith(suffix: String): Bool {
154
+ self!->endsWith(suffix)?
155
155
  }
156
156
 
157
157
  removeFirst(prefix: String): Option[String] {
@@ -1,10 +1,3 @@
1
- import a.A
2
-
3
- nodeMain(system: NodeSystem) {
4
- Log.trace("Hello Root")
5
- A.functionA()
1
+ foo(abe: Int): Int {
2
+ bb
6
3
  }
7
-
8
- functionRoot() {
9
- Log.trace("function Root")
10
- }
@@ -0,0 +1,3 @@
1
+ myFunction2(xxx: Int): Int {
2
+ xxx
3
+ }
package/lsp/Handler.ff CHANGED
@@ -316,7 +316,9 @@ extend self: Handler {
316
316
  let files = if(rootPath.isFile()) {
317
317
  [rootPath]
318
318
  } else {
319
- self.printTime(system.mainTask(), "findFireflyFiles") {Builder.findFireflyFiles(rootPath, None, Set.new())}
319
+ self.printTime(system.mainTask(), "findFireflyFiles") {
320
+ Builder.findFireflyFiles(rootPath, self.virtualFiles, None, Set.new())
321
+ }
320
322
  }
321
323
  let root = if(rootPath.isFile()) {rootPath.parent().grab()} else {rootPath}
322
324
  let query = parameters.grab("query").grabString()
@@ -489,7 +491,6 @@ extend self: Handler {
489
491
  | Some([]) => Result(Json.null().write())
490
492
  | Some([first, ...] @ tokens) =>
491
493
  let oldName = first.raw
492
- Log.trace("Rename '" + oldName + "' to '" + newName + "'")
493
494
 
494
495
  // TODO findReferences returns some bad tokens
495
496
  let goodTokens = tokens.filter {_.raw == oldName}
@@ -519,8 +520,8 @@ extend self: Handler {
519
520
  version: Int
520
521
  ): Option[List[TokenLocation]] {
521
522
  let temporaryLspHook = LspHook.new(at = Some(targetAt), definedAt = None, insertIdentifier = False, trackSymbols = False)
522
- let path = system.path(targetAt.file)
523
- let errors = self.check(system, self.fireflyPath, path, None, Set.new(), self.virtualFiles, version, temporaryLspHook, True)
523
+ let targetPath = system.path(targetAt.file)
524
+ let errors = self.check(system, self.fireflyPath, targetPath, None, Set.new(), self.virtualFiles, version, temporaryLspHook, True)
524
525
  errors.each {| CompileError(at, message) =>
525
526
  Log.trace("findReferences first check error: " + message + " in " + at.file + ":" + at.line + ":" + at.column)
526
527
  }
@@ -548,6 +549,9 @@ extend self: Handler {
548
549
  | h => None
549
550
  }.filter {pair => !pair.at.file.endsWith(">")}
550
551
 
552
+ Log.trace("findReferences("+Show.show(targetAt)+")")
553
+ Log.trace("definedAtList: " + Show.show(definedAtList))
554
+
551
555
  function unqualify(qualifiedName: String): String {
552
556
  qualifiedName.split('.').grabLast().split('_').grabLast()
553
557
  }
@@ -566,10 +570,8 @@ extend self: Handler {
566
570
  | Some(definition) =>
567
571
  let lspHook = LspHook.new(at = None, definedAt = Some(definition.at), insertIdentifier = False, trackSymbols = False)
568
572
  let localCheck = local || definition.local
569
- let path = if(localCheck) {system.path(targetAt.file)} else {self.rootPath.else {system.path(targetAt.file)}}
573
+ let checkPath = if(localCheck) {targetPath} else {self.rootPath.else {targetPath}}
570
574
  let mustContain = Some(definition.name).filter {_ => !localCheck}.map(unqualify)
571
- Log.trace("findReferences definition: " + Show.show(definition))
572
- mustContain.each {Log.trace("mustContain: " + _)}
573
575
 
574
576
  let skipFiles = if(definition.name.contains(":")) {
575
577
  let list = self.moduleCache.filesNotImporting(extractModuleKey(definition.name))
@@ -582,8 +584,8 @@ extend self: Handler {
582
584
  Log.trace("No skip list due to unqualified definition.name: " + definition.name)
583
585
  Set.new()
584
586
  }
585
- }
586
- let errors = self.check(system, self.fireflyPath, path, mustContain, skipFiles, self.virtualFiles, version, lspHook, True)
587
+ }.remove(targetPath.absolute())
588
+ let errors = self.check(system, self.fireflyPath, checkPath, mustContain, skipFiles, self.virtualFiles, version, lspHook, True)
587
589
  errors.each {| CompileError(at, message) =>
588
590
  Log.trace("findReferences second check error: " + message + " in " + at.file + ":" + at.line + ":" + at.column)
589
591
  }
@@ -604,8 +606,6 @@ extend self: Handler {
604
606
  !at.file.endsWith(">") &&
605
607
  (includeDeclaration || at != definition.at)
606
608
  }
607
-
608
- //referencesResult.each {Log.trace(Show.show(_))}
609
609
 
610
610
  let clientLocations = referencesResult.addAll(
611
611
  if(includeDeclaration) {[definition.at]} else {[]}
@@ -640,7 +640,7 @@ extend self: Handler {
640
640
  }.toOption()
641
641
  }
642
642
  let symbols = nonCore.flatMap {| Pair(packagePair, packagePath) =>
643
- let packageFiles = Builder.findPackageFilesForDirectory(packagePath, None, Set.new())
643
+ let packageFiles = Builder.findPackageFilesForDirectory(packagePath, self.virtualFiles, None, Set.new())
644
644
  packageFiles.flatMap {_.files.collect {file =>
645
645
  parseModule(packagePair, file).map: module =>
646
646
  let typeNames = module.types.map {_.name}
@@ -794,3 +794,7 @@ extend self: Handler {
794
794
  }
795
795
 
796
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
- return ff_core_String.String_contains(ff_core_Path.Path_readText(file_), s_)
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
- return ff_core_String.String_contains((await ff_core_Path.Path_readText$(file_, $task)), s_)
638
- }), $task)))
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
 
@@ -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_, prefix_) {
256
- return self_.endsWith(prefix_)
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_, prefix_, $task) {
518
- return self_.endsWith(prefix_)
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
@@ -4,7 +4,7 @@
4
4
  "description": "Firefly compiler",
5
5
  "author": "Firefly team",
6
6
  "license": "MIT",
7
- "version": "0.5.71",
7
+ "version": "0.5.72",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"
@@ -4,7 +4,7 @@
4
4
  "description": "Firefly language support",
5
5
  "author": "Firefly team",
6
6
  "license": "MIT",
7
- "version": "0.5.71",
7
+ "version": "0.5.72",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"
@@ -1,3 +0,0 @@
1
- functionA() {
2
- Log.trace("function A")
3
- }
@@ -1,3 +0,0 @@
1
- nodeMain(system: NodeSystem) {
2
- Log.trace("Hello from a/MainA")
3
- }