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

[tests] Add server test for #8004 #11950

Merged
merged 1 commit into from
Jan 29, 2025
Merged
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
84 changes: 84 additions & 0 deletions tests/server/src/cases/issues/Issue8004.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package cases.issues;

import haxe.Json;
import haxe.display.FsPath;
import haxe.display.Server;

class Issue8004 extends TestCase {
@:variant("Js", "js", "test.js")
@:variant("Jvm", "jvm", "test.jar")
@:variant("Neko", "neko", "test.n")
@:variant("Lua", "lua", "test.lua")
@:variant("Python", "python", "test.py")
@:variant("Swf", "swf", "test.swf")
@:variant("Hashlink", "hl", "test.hl")
@:variant("CPP", "cpp", "cpp")
@:variant("PHP", "php", "php")
@:variant("Eval", "--interp", null)
function test(target:String, output:Null<String>) {
vfs.putContent("Empty.hx", getTemplate("Empty.hx"));
var args = output == null ? ["-main", "Empty", target] : ["-main", "Empty", '-$target', 'bin/$output', "--no-output"];

runHaxe(args);
runHaxeJson(args, ServerMethods.ReadClassPaths, null);
runHaxe(args.concat(["--display", "?@0@workspace-symbols@uint"]));

var result:Array<SymbolReply> = Json.parse(lastResult.stderr);
var found = false;
for (module in result) {
for (symbol in module.symbols) {
if (symbol.name == "UInt" && symbol.kind == Abstract) {
found = true;
break;
}
}
}
Assert.isTrue(found);
}
}

// From Haxe LSP; should be moved to haxe.display package when workspace symbols
// are added as Json RPC
private enum abstract ModuleSymbolKind(Int) {
final Class = 1;
final Interface;
final Enum;
final TypeAlias;
final Abstract;
final Field;
final Property;
final Method;
final Constructor;
final Function;
final Variable;
final Struct;
final EnumAbstract;
final Operator;
final EnumMember;
final Constant;
final Module;
}

private typedef ModuleSymbolEntry = {
final name:String;
final kind:ModuleSymbolKind;
final range:Range;
final ?containerName:String;
final ?isDeprecated:Bool;
}

private typedef SymbolReply = {
final file:FsPath;
final symbols:Array<ModuleSymbolEntry>;
}

// From Haxe server protocol
private typedef Position = {
var line:Int;
var character:Int;
}

private typedef Range = {
var start:Position;
var end:Position;
}
Loading