Skip to content

Commit

Permalink
Don't cache/run filters for find reference/implementation requests (#…
Browse files Browse the repository at this point in the history
…11226)

* Only run filters and save cache on diagnostics, not usage requests

* [tests] Update test for 11184
  • Loading branch information
kLabz authored May 17, 2023
1 parent e9f34b0 commit 494f514
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 32 deletions.
7 changes: 6 additions & 1 deletion src/compiler/compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,12 @@ let compile ctx actx callbacks =
end;
DisplayProcessing.handle_display_after_typing ctx tctx display_file_dot_path;
finalize_typing ctx tctx;
filter ctx tctx (fun () -> DisplayProcessing.handle_display_after_finalization ctx tctx display_file_dot_path);
if is_diagnostics com then
filter ctx tctx (fun () -> DisplayProcessing.handle_display_after_finalization ctx tctx display_file_dot_path)
else begin
DisplayProcessing.handle_display_after_finalization ctx tctx display_file_dot_path;
filter ctx tctx (fun () -> ());
end;
if ctx.has_error then raise Abort;
Generate.check_auxiliary_output com actx;
com.stage <- CGenerationStart;
Expand Down
1 change: 0 additions & 1 deletion src/core/displayTypes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ module DisplayMode = struct
| DMDefault | DMDefinition | DMTypeDefinition | DMPackage | DMHover | DMSignature -> settings
| DMUsage _ | DMImplementation -> { settings with
dms_full_typing = true;
dms_populate_cache = !ServerConfig.populate_cache_from_display;
dms_force_macro_typing = true;
dms_display_file_policy = DFPAlso;
dms_exit_during_typing = false
Expand Down
31 changes: 2 additions & 29 deletions tests/server/src/cases/issues/Issue11184.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package cases.issues;

class Issue11184 extends TestCase {
function testDiagnostics(_) {
final content = getTemplate("issues/Issue11184/Main.hx");
final transform = Marker.extractMarkers(content);

vfs.putContent("Main.hx", transform.source);
vfs.putContent("Main.hx", getTemplate("issues/Issue11184/Main.hx"));
var args = ["-main", "Main", "-js", "bin/test.js"];

runHaxe(args.concat(["--display", "Main.hx@0@diagnostics"]));
Expand All @@ -18,32 +15,8 @@ class Issue11184 extends TestCase {
Assert.isTrue(hasErrorMessage("Cannot use Void as value"));
}

function testFindReferences(_) {
final content = getTemplate("issues/Issue11184/Main.hx");
final transform = Marker.extractMarkers(content);

vfs.putContent("Main.hx", transform.source);
var args = ["-main", "Main", "-js", "bin/test.js"];

runHaxeJson(args, DisplayMethods.FindReferences, {
file: new FsPath("Main.hx"),
offset: transform.markers.get(1),
contents: transform.source
});
final errors = haxe.Json.parse(lastResult.stderr).error?.data;
Assert.equals(errors[0].message, "Cannot use Void as value");

runHaxe(args);
Assert.isTrue(hasErrorMessage("Cannot use Void as value"));
runHaxe(args);
Assert.isTrue(hasErrorMessage("Cannot use Void as value"));
}

function testWithoutCacheFromDisplay(_) {
final content = getTemplate("issues/Issue11184/Main.hx");
final transform = Marker.extractMarkers(content);

vfs.putContent("Main.hx", transform.source);
vfs.putContent("Main.hx", getTemplate("issues/Issue11184/Main.hx"));
var args = ["-main", "Main", "-js", "bin/test.js"];
runHaxeJson([], ServerMethods.Configure, {populateCacheFromDisplay: false});
runHaxe(args.concat(["--display", "Main.hx@0@diagnostics"]));
Expand Down
2 changes: 1 addition & 1 deletion tests/server/test/templates/issues/Issue11184/Main.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Main {
static function main() {
function fo{-1-}o():Void {}
function foo():Void {}
final arr = [foo()];
}
}
Expand Down

0 comments on commit 494f514

Please sign in to comment.