Skip to content

Commit

Permalink
Work around "missing function body" errors.
Browse files Browse the repository at this point in the history
A failed build would sometimes leave broken types in the cache, causing the next build to fail even though no real errors exist. To work around this, we invalidate all `ComponentStorage` subclasses
before each build, on the off chance that one or two might be broken.
  • Loading branch information
player-03 committed Jan 5, 2024
1 parent 7c320eb commit e606843
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions extraParams.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--macro echoes.macro.ComponentStorageBuilder.invalidate()
9 changes: 7 additions & 2 deletions src/echoes/macro/ComponentStorageBuilder.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package echoes.macro;

#if macro

import haxe.macro.CompilationServer;
import haxe.macro.Expr;
import haxe.macro.Printer;
import haxe.PosInfos;

using echoes.macro.MacroTools;
using haxe.macro.Context;
Expand Down Expand Up @@ -39,8 +41,6 @@ class ComponentStorageBuilder {
var def:TypeDefinition = macro class $storageTypeName extends echoes.ComponentStorage<$componentComplexType> {
public static final instance:$storageType = new $storageTypePath();

//Known issue: after a failed build, this line may produce "Missing
//function body" errors. Workaround: restart the language server.
private function new() {
super($v{ componentTypeName });
}
Expand All @@ -57,6 +57,11 @@ class ComponentStorageBuilder {

return storageTypeName;
}

public static function invalidate():Void {
final filePath:String = ((?infos:PosInfos) -> infos.fileName)();
CompilationServer.invalidateFiles([filePath]);
}
}

#end

0 comments on commit e606843

Please sign in to comment.