Skip to content

Commit

Permalink
lime display: if the project file is newer than an existing debug/rel…
Browse files Browse the repository at this point in the history
…ease/final.hxml file, don't consider the .hxml file valid anymore

Code intelligence should always use the newest hxml content, so the fallback mode where the hxml content is generated, instead of loaded from an existing .hxml file, should be used when the project file is newer.

For instance, if the user changes any file/dir paths in their project file, continuing to use the existing .hxml file could lead to confusing error messages that still reference the old/cached file paths. It should always use the latest paths or other values from the project file. It should be considered a bug to use the old cached paths.

Previously, as a workaround, the user would need to clean or build their project again to get updated .hxml files. It might also require restarting their editor/IDE too. Bad developer experience when we can detect this case automatically.
  • Loading branch information
joshtynjala committed Jan 5, 2024
1 parent 9b9faae commit b021dbe
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/lime/tools/HXProject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class HXProject extends Script
public var templatePaths:Array<String>;
@:isVar public var window(get, set):WindowData;
public var windows:Array<WindowData>;
public var projectFilePath:String;

private var needRerun:Bool;

Expand Down Expand Up @@ -740,6 +741,11 @@ class HXProject extends Script
launchStoryboard.merge(project.launchStoryboard);
}

if (projectFilePath == null)
{
projectFilePath = project.projectFilePath;
}

languages = ArrayTools.concatUnique(languages, project.languages, true);
libraries = ArrayTools.concatUnique(libraries, project.libraries, true);

Expand Down
5 changes: 5 additions & 0 deletions tools/CommandLineTools.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,11 @@ class CommandLineTools
return null;
}
}

if (project != null)
{
project.projectFilePath = projectFile;
}
}

if (project != null && project.needRerun && !project.targetFlags.exists("norerun"))
Expand Down
7 changes: 6 additions & 1 deletion tools/platforms/AndroidPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,12 @@ class AndroidPlatform extends PlatformTarget
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";

if (FileSystem.exists(path))
// try to use the existing .hxml file. however, if the project file was
// modified more recently than the .hxml, then the .hxml cannot be
// considered valid anymore. it may cause errors in editors like vscode.
if (FileSystem.exists(path)
&& (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath)
|| (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime())))
{
return File.getContent(path);
}
Expand Down
7 changes: 6 additions & 1 deletion tools/platforms/FlashPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,12 @@ class FlashPlatform extends PlatformTarget
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";

if (FileSystem.exists(path))
// try to use the existing .hxml file. however, if the project file was
// modified more recently than the .hxml, then the .hxml cannot be
// considered valid anymore. it may cause errors in editors like vscode.
if (FileSystem.exists(path)
&& (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath)
|| (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime())))
{
return File.getContent(path);
}
Expand Down
7 changes: 6 additions & 1 deletion tools/platforms/HTML5Platform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@ class HTML5Platform extends PlatformTarget
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";

if (FileSystem.exists(path))
// try to use the existing .hxml file. however, if the project file was
// modified more recently than the .hxml, then the .hxml cannot be
// considered valid anymore. it may cause errors in editors like vscode.
if (FileSystem.exists(path)
&& (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath)
|| (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime())))
{
return File.getContent(path);
}
Expand Down
7 changes: 6 additions & 1 deletion tools/platforms/IOSPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,12 @@ class IOSPlatform extends PlatformTarget
{
var path = targetDirectory + "/" + project.app.file + "/haxe/Build.hxml";

if (FileSystem.exists(path))
// try to use the existing .hxml file. however, if the project file was
// modified more recently than the .hxml, then the .hxml cannot be
// considered valid anymore. it may cause errors in editors like vscode.
if (FileSystem.exists(path)
&& (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath)
|| (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime())))
{
return File.getContent(path);
}
Expand Down
7 changes: 6 additions & 1 deletion tools/platforms/LinuxPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,12 @@ class LinuxPlatform extends PlatformTarget
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";

if (FileSystem.exists(path))
// try to use the existing .hxml file. however, if the project file was
// modified more recently than the .hxml, then the .hxml cannot be
// considered valid anymore. it may cause errors in editors like vscode.
if (FileSystem.exists(path)
&& (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath)
|| (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime())))
{
return File.getContent(path);
}
Expand Down
7 changes: 6 additions & 1 deletion tools/platforms/MacPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,12 @@ class MacPlatform extends PlatformTarget
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";

if (FileSystem.exists(path))
// try to use the existing .hxml file. however, if the project file was
// modified more recently than the .hxml, then the .hxml cannot be
// considered valid anymore. it may cause errors in editors like vscode.
if (FileSystem.exists(path)
&& (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath)
|| (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime())))
{
return File.getContent(path);
}
Expand Down
7 changes: 6 additions & 1 deletion tools/platforms/TVOSPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,12 @@ class TVOSPlatform extends PlatformTarget
{
var path = targetDirectory + "/" + project.app.file + "/haxe/Build.hxml";

if (FileSystem.exists(path))
// try to use the existing .hxml file. however, if the project file was
// modified more recently than the .hxml, then the .hxml cannot be
// considered valid anymore. it may cause errors in editors like vscode.
if (FileSystem.exists(path)
&& (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath)
|| (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime())))
{
return File.getContent(path);
}
Expand Down
7 changes: 6 additions & 1 deletion tools/platforms/WebAssemblyPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,12 @@ class WebAssemblyPlatform extends PlatformTarget
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";

if (FileSystem.exists(path))
// try to use the existing .hxml file. however, if the project file was
// modified more recently than the .hxml, then the .hxml cannot be
// considered valid anymore. it may cause errors in editors like vscode.
if (FileSystem.exists(path)
&& (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath)
|| (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime())))
{
return File.getContent(path);
}
Expand Down
7 changes: 6 additions & 1 deletion tools/platforms/WindowsPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,12 @@ class WindowsPlatform extends PlatformTarget
{
var path = targetDirectory + "/haxe/" + buildType + ".hxml";

if (FileSystem.exists(path))
// try to use the existing .hxml file. however, if the project file was
// modified more recently than the .hxml, then the .hxml cannot be
// considered valid anymore. it may cause errors in editors like vscode.
if (FileSystem.exists(path)
&& (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath)
|| (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime())))
{
return File.getContent(path);
}
Expand Down

0 comments on commit b021dbe

Please sign in to comment.