|
| 1 | +package cases.issues; |
| 2 | + |
| 3 | +import haxe.Json; |
| 4 | +import haxe.display.FsPath; |
| 5 | +import haxe.display.Server; |
| 6 | + |
| 7 | +class Issue8004 extends TestCase { |
| 8 | + @:variant("Js", "js", "test.js") |
| 9 | + @:variant("Jvm", "jvm", "test.jar") |
| 10 | + @:variant("Neko", "neko", "test.n") |
| 11 | + @:variant("Lua", "lua", "test.lua") |
| 12 | + @:variant("Python", "python", "test.py") |
| 13 | + @:variant("Swf", "swf", "test.swf") |
| 14 | + @:variant("Hashlink", "hl", "test.hl") |
| 15 | + @:variant("CPP", "cpp", "cpp") |
| 16 | + @:variant("PHP", "php", "php") |
| 17 | + @:variant("Eval", "--interp", null) |
| 18 | + function test(target:String, output:Null<String>) { |
| 19 | + vfs.putContent("Empty.hx", getTemplate("Empty.hx")); |
| 20 | + var args = output == null ? ["-main", "Empty", target] : ["-main", "Empty", '-$target', 'bin/$output', "--no-output"]; |
| 21 | + |
| 22 | + runHaxe(args); |
| 23 | + runHaxeJson(args, ServerMethods.ReadClassPaths, null); |
| 24 | + runHaxe(args.concat(["--display", "?@0@workspace-symbols@uint"])); |
| 25 | + |
| 26 | + var result:Array<SymbolReply> = Json.parse(lastResult.stderr); |
| 27 | + var found = false; |
| 28 | + for (module in result) { |
| 29 | + for (symbol in module.symbols) { |
| 30 | + if (symbol.name == "UInt" && symbol.kind == Abstract) { |
| 31 | + found = true; |
| 32 | + break; |
| 33 | + } |
| 34 | + } |
| 35 | + } |
| 36 | + Assert.isTrue(found); |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +// From Haxe LSP; should be moved to haxe.display package when workspace symbols |
| 41 | +// are added as Json RPC |
| 42 | +private enum abstract ModuleSymbolKind(Int) { |
| 43 | + final Class = 1; |
| 44 | + final Interface; |
| 45 | + final Enum; |
| 46 | + final TypeAlias; |
| 47 | + final Abstract; |
| 48 | + final Field; |
| 49 | + final Property; |
| 50 | + final Method; |
| 51 | + final Constructor; |
| 52 | + final Function; |
| 53 | + final Variable; |
| 54 | + final Struct; |
| 55 | + final EnumAbstract; |
| 56 | + final Operator; |
| 57 | + final EnumMember; |
| 58 | + final Constant; |
| 59 | + final Module; |
| 60 | +} |
| 61 | + |
| 62 | +private typedef ModuleSymbolEntry = { |
| 63 | + final name:String; |
| 64 | + final kind:ModuleSymbolKind; |
| 65 | + final range:Range; |
| 66 | + final ?containerName:String; |
| 67 | + final ?isDeprecated:Bool; |
| 68 | +} |
| 69 | + |
| 70 | +private typedef SymbolReply = { |
| 71 | + final file:FsPath; |
| 72 | + final symbols:Array<ModuleSymbolEntry>; |
| 73 | +} |
| 74 | + |
| 75 | +// From Haxe server protocol |
| 76 | +private typedef Position = { |
| 77 | + var line:Int; |
| 78 | + var character:Int; |
| 79 | +} |
| 80 | + |
| 81 | +private typedef Range = { |
| 82 | + var start:Position; |
| 83 | + var end:Position; |
| 84 | +} |
0 commit comments