Skip to content

Commit

Permalink
added useLegacyDiagnostics config for opting out of Json RPC for Haxe…
Browse files Browse the repository at this point in the history
… 4.3.5+ (#129)

* added useLegacyDiagnostics config for opting out of Json RPC for Haxe 4.3.5+
see HaxeFoundation/haxe#11413
  • Loading branch information
AlexHaxe committed Aug 4, 2024
1 parent f4a7ca5 commit 9d56446
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/haxeLanguageServer/Configuration.hx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ typedef UserConfig = {
var buildCompletionCache:Bool;
var enableCompletionCacheWarning:Bool;
var useLegacyCompletion:Bool;
var useLegacyDiagnostics:Bool;
var codeGeneration:CodeGenerationConfig;
var exclude:Array<String>;
var postfixCompletion:PostfixCompletionConfig;
Expand Down Expand Up @@ -164,6 +165,7 @@ class Configuration {
buildCompletionCache: true,
enableCompletionCacheWarning: true,
useLegacyCompletion: false,
useLegacyDiagnostics: false,
codeGeneration: {
functions: {
anonymous: {
Expand Down
4 changes: 4 additions & 0 deletions src/haxeLanguageServer/features/haxe/DiagnosticsFeature.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import haxe.ds.BalancedTree;
import haxe.io.Path;
import haxeLanguageServer.LanguageServerMethods;
import haxeLanguageServer.helper.PathHelper;
import haxeLanguageServer.helper.SemVer;
import haxeLanguageServer.protocol.DisplayPrinter;
import haxeLanguageServer.server.DisplayResult;
import js.Node.clearImmediate;
Expand Down Expand Up @@ -45,6 +46,9 @@ class DiagnosticsFeature {
errorUri = new FsPath(Path.join([context.workspacePath.toString(), "Error"])).toUri();

useJsonRpc = context.haxeServer.supports(DisplayMethods.Diagnostics);
if (context.config.user.useLegacyDiagnostics) {
useJsonRpc = false;
}
timerName = useJsonRpc ? DisplayMethods.Diagnostics : "@diagnostics";

ChildProcess.exec(context.config.haxelib.executable + " config", (error, stdout, stderr) -> haxelibPath = new FsPath(stdout.trim()));
Expand Down
4 changes: 4 additions & 0 deletions src/haxeLanguageServer/helper/SemVer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ abstract SemVer(Version) from Version {
return isEqual(other) || isGreaterThan(other);
}

@:op(a < b) function isLessThan(other:SemVer):Bool {
return !isEqualOrGreaterThan(other);
}

@:op(a > b) function isGreaterThan(other:SemVer):Bool {
return (major > other.major)
|| (major == other.major && minor > other.minor)
Expand Down

0 comments on commit 9d56446

Please sign in to comment.