Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't populate cache from legacy diagnostics #11696

Merged
merged 4 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/displayProcessing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let handle_display_argument_old com file_pos actx =
| "diagnostics" ->
com.report_mode <- RMLegacyDiagnostics [file_unique];
let dm = create DMNone in
{dm with dms_display_file_policy = DFPOnly; dms_per_file = true; dms_populate_cache = !ServerConfig.populate_cache_from_display}
{dm with dms_display_file_policy = DFPOnly; dms_per_file = true; dms_populate_cache = false}
| "statistics" ->
com.report_mode <- RMStatistics;
let dm = create DMNone in
Expand Down
4 changes: 1 addition & 3 deletions src/compiler/serverConfig.ml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
let do_not_check_modules = ref false
let populate_cache_from_display = ref true
let legacy_completion = ref false

let max_completion_items = ref 0

let reset () =
do_not_check_modules := false;
populate_cache_from_display := true;
legacy_completion := false;
max_completion_items := 0
max_completion_items := 0
8 changes: 1 addition & 7 deletions src/context/display/displayJson.ml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ let handler =

(match hctx.com.file_contents with
| [file, None] ->
hctx.com.display <- { hctx.com.display with dms_display_file_policy = DFPAlso; dms_per_file = true; dms_populate_cache = !ServerConfig.populate_cache_from_display};
hctx.com.display <- { hctx.com.display with dms_display_file_policy = DFPAlso; dms_per_file = true; dms_populate_cache = true };
| _ -> ());
);
"display/implementation", (fun hctx ->
Expand Down Expand Up @@ -464,12 +464,6 @@ let handler =
l := jstring ("Legacy completion " ^ (if b then "enabled" else "disabled")) :: !l;
()
) ();
hctx.jsonrpc#get_opt_param (fun () ->
let b = hctx.jsonrpc#get_bool_param "populateCacheFromDisplay" in
ServerConfig.populate_cache_from_display := b;
l := jstring ("Compilation cache refill from display " ^ (if b then "enabled" else "disabled")) :: !l;
()
) ();
hctx.send_result (jarray !l)
);
"server/memory",(fun hctx ->
Expand Down
1 change: 0 additions & 1 deletion std/haxe/display/Server.hx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ typedef ConfigurePrintParams = {

typedef ConfigureParams = {
final ?noModuleChecks:Bool;
final ?populateCacheFromDisplay:Bool;
final ?legacyCompletion:Bool;
final ?print:ConfigurePrintParams;
}
Expand Down
12 changes: 4 additions & 8 deletions tests/server/src/cases/issues/Issue11177.hx
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,16 @@ class Issue11177 extends TestCase {
});
}

function testWithoutCacheFromDisplay(_) {
function testLegacyDiagnostics(_) {
vfs.putContent("Main.hx", getTemplate("issues/Issue11177/Main.hx"));
vfs.putContent("Buttons.hx", getTemplate("issues/Issue11177/Buttons.hx"));
vfs.putContent("KeyCode.hx", getTemplate("issues/Issue11177/KeyCode.hx"));
var args = ["-main", "Main", "--interp"];
runHaxeJson([], ServerMethods.Configure, {populateCacheFromDisplay: false});
runHaxeJsonCb(args, DisplayMethods.Diagnostics, {file: new FsPath("Buttons.hx")}, res -> {
Assert.equals(0, res.length);
});
runHaxe(args.concat(["--display", "Buttons.hx@0@diagnostics"]));
vfs.putContent("Main.hx", getTemplate("issues/Issue11177/Main2.hx"));
runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("Main.hx")});
runHaxe(args);
runHaxeJsonCb(args, DisplayMethods.Diagnostics, {file: new FsPath("Buttons.hx")}, res -> {
Assert.equals(0, res.length);
});
runHaxe(args.concat(["--display", "Buttons.hx@0@diagnostics"]));
Assert.isTrue(lastResult.stderr.length == 2);
}
}
11 changes: 4 additions & 7 deletions tests/server/src/cases/issues/Issue11184.hx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@ class Issue11184 extends TestCase {
Assert.isTrue(hasErrorMessage("Cannot use Void as value"));
}

function testWithoutCacheFromDisplay(_) {
function testLegacyDiagnostics(_) {
vfs.putContent("Main.hx", getTemplate("issues/Issue11184/Main.hx"));
var args = ["-main", "Main", "-js", "bin/test.js"];
runHaxeJson([], ServerMethods.Configure, {populateCacheFromDisplay: false});
runHaxeJsonCb(args, DisplayMethods.Diagnostics, {file: new FsPath("Main.hx")}, res -> {
Assert.equals(1, res.length);
Assert.equals(1, res[0].diagnostics.length);
Assert.equals(res[0].diagnostics[0].args, "Cannot use Void as value");
});
runHaxe(args.concat(["--display", "Main.hx@0@diagnostics"]));
final diagnostics = haxe.Json.parse(lastResult.stderr)[0].diagnostics;
Assert.equals(diagnostics[0].args, "Cannot use Void as value");
runHaxe(args);
Assert.isTrue(hasErrorMessage("Cannot use Void as value"));
runHaxe(args);
Expand Down
39 changes: 39 additions & 0 deletions tests/server/src/cases/issues/Issue11695.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cases.issues;

class Issue11695 extends TestCase {
function test(_) {
vfs.putContent("Main.hx", getTemplate("issues/Issue11695/Main.hx"));
vfs.putContent("Macro.hx", getTemplate("issues/Issue11695/Macro1.hx"));
var args = ["-main", "Main", "--interp"];
runHaxe(args);
assertHasPrint("Macro.hx:1: before");

// Note: this is needed because modification time is currently checked with second precision
Sys.sleep(1);

vfs.putContent("Macro.hx", getTemplate("issues/Issue11695/Macro2.hx"));
runHaxeJsonCb(args, DisplayMethods.Diagnostics, {file: new FsPath("Macro.hx")}, res -> {
Assert.equals(0, res.length);
});

runHaxe(args);
assertHasPrint("Macro.hx:1: after");
}

function testLegacyDiagnostics(_) {
vfs.putContent("Main.hx", getTemplate("issues/Issue11695/Main.hx"));
vfs.putContent("Macro.hx", getTemplate("issues/Issue11695/Macro1.hx"));
var args = ["-main", "Main", "--interp"];
runHaxe(args);
assertHasPrint("Macro.hx:1: before");

// Note: this is needed because modification time is currently checked with second precision
Sys.sleep(1);

vfs.putContent("Macro.hx", getTemplate("issues/Issue11695/Macro2.hx"));
runHaxe(args.concat(["--display", "Macro.hx@0@diagnostics"]));

runHaxe(args);
assertHasPrint("Macro.hx:1: after");
}
}
1 change: 1 addition & 0 deletions tests/server/test/templates/issues/Issue11695/Macro1.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
macro function test() return macro trace("before");
1 change: 1 addition & 0 deletions tests/server/test/templates/issues/Issue11695/Macro2.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
macro function test() return macro trace("after");
3 changes: 3 additions & 0 deletions tests/server/test/templates/issues/Issue11695/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function main() {
Macro.test();
}
Loading