public void GetCompletionsAtPosition() { string script = @" class Greeter { greeting: string; constructor (message: string) { this.greeting = message; } greet() { return 'Hello, ' + this.greeting; } } var greeter = new Greeter('world'); var button = document.createElement('button') button.innerText = 'Say Hello' button.onclick = function() { alert(greeter.greet()) } document.body.appendChild(button) "; var shimHost = new TypeScriptLS (); var lsHost = new LanguageServiceShimHostAdapter (shimHost); var ls = new TypeScriptServicesFactory ().CreatePullLanguageService (lsHost); shimHost.AddScript ("foo.ts", script); for (int i = 0; i < 37; i++) { var lisst = ls.GetCompletionsAtPosition ("foo.ts", i, true); if (lisst == null) continue; // fine. if ((bool) lisst.MaybeInaccurate) continue; // fine // the number in general doesn't matter, only meaning that there are completions. Assert.AreEqual (54, lisst.Entries.Length, "#2." + i); } for (int i = 37; i < 76; i++) { var lisst = ls.GetCompletionsAtPosition ("foo.ts", i, true); if (lisst == null) continue; // fine. Assert.AreEqual (55, lisst.Entries.Length, "#2x2." + i); } var list = ls.GetCompletionsAtPosition ("foo.ts", 76, true); Assert.AreEqual (2, list.Entries.Length, "#1"); /* for (int i = 77; i < 132; i++) { var list = ls.GetCompletionsAtPosition ("foo.ts", i, true); Assert.AreEqual (0, list.Entries.Length, "#2." + i); } */ list = ls.GetCompletionsAtPosition ("foo.ts", 136, true); Assert.AreEqual (2, list.Entries.Length, "#3"); /* for (int i = 137; i < 307; i++) { var list = ls.GetCompletionsAtPosition ("foo.ts", i, true); Assert.AreEqual (0, list.Entries.Length, "#4." + i); } */ list = ls.GetCompletionsAtPosition ("foo.ts", 314, true); // reeter.greet() at line 17 Assert.AreEqual (2, list.Entries.Length, "#5"); /* for (int i = 315; i < script.Length; i++) { var list = ls.GetCompletionsAtPosition ("foo.ts", i, true); Assert.AreEqual (0, list.Entries.Length, "#6 " + i + " : " + script.Substring (i)); } */ }