Skip to content

Commit c987ab9

Browse files
committed
Wire navto tests
1 parent 4a44b74 commit c987ab9

3 files changed

Lines changed: 49 additions & 11 deletions

File tree

src/server/client.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ module ts.server {
8080
return this.host.getScriptSnapshot(fileName).getLength();
8181
}
8282

83+
getFileNames(): string[] {
84+
return this.host.getScriptFileNames();
85+
}
86+
8387
close(): void {
8488
}
8589

@@ -107,6 +111,7 @@ module ts.server {
107111
private sequence: number = 0;
108112
private host: SessionClientHostProxy;
109113
private expantionTable: ts.Map<string>;
114+
private fileMapping: ts.Map<string> = {};
110115

111116
constructor(host: SessionClientHost, abbreviate: boolean) {
112117
this.sequence = 0;
@@ -177,14 +182,14 @@ module ts.server {
177182
};
178183
}
179184

180-
private getFileNameFromEncodedFile(fileId: ServerProtocol.EncodedFile, fileMapping: ts.Map<string>): string {
185+
private getFileNameFromEncodedFile(fileId: ServerProtocol.EncodedFile): string {
181186
var fileName: string;
182187
if (typeof fileId === "object") {
183188
fileName = (<ServerProtocol.IdFile>fileId).file;
184-
fileMapping[(<ServerProtocol.IdFile>fileId).id] = fileName;
189+
this.fileMapping[(<ServerProtocol.IdFile>fileId).id] = fileName;
185190
}
186191
else if (typeof fileId === "number") {
187-
fileName = ts.lookUp(fileMapping, fileId.toString());
192+
fileName = ts.lookUp(this.fileMapping, fileId.toString());
188193
Debug.assert(!!fileName, "Did not find filename in previous fileID mappings.");
189194
}
190195
else {
@@ -330,21 +335,23 @@ module ts.server {
330335
};
331336
}
332337

333-
getNavigateToItems(seatchTerm: string): NavigateToItem[] {
334-
var request = this.processRequest("navto", { seatchTerm });
338+
getNavigateToItems(searchTerm: string): NavigateToItem[] {
339+
var request = this.processRequest("navto", {
340+
searchTerm,
341+
file: this.host.getFileNames()[0]
342+
});
335343

336344
var response = this.processResponse<ServerProtocol.NavtoResponse>(request);
337-
var fileMapping: ts.Map<string> = {};
338345

339346
return response.body.map(entry => {
340-
var fileName = this.getFileNameFromEncodedFile(entry.file, fileMapping);
341-
var start = this.lineColToPosition(entry.file.toString(), entry.start);
342-
var end = this.lineColToPosition(entry.file.toString(), entry.end);
347+
var fileName = this.getFileNameFromEncodedFile(entry.file);
348+
var start = this.lineColToPosition(fileName, entry.start);
349+
var end = this.lineColToPosition(fileName, entry.end);
343350

344351
return {
345352
name: entry.name,
346-
containerName: entry.containerName,
347-
containerKind: entry.containerKind,
353+
containerName: entry.containerName || "",
354+
containerKind: entry.containerKind || "",
348355
kind: entry.kind,
349356
kindModifiers: entry.kindModifiers,
350357
matchKind: entry.matchKind,

src/server/protocol.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,9 @@ module ts.server {
10511051
this.output(undefined, CommandNames.Navto, reqSeq, "no nav items");
10521052
}
10531053
}
1054+
else {
1055+
this.output(undefined, CommandNames.Navto, reqSeq, "no nav items");
1056+
}
10541057
}
10551058

10561059
executeJSONcmd(cmd: string) {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
/////// Module
4+
////{| "itemName": "Shapes", "kind": "module", "parentName": "", "matchKind": "substring" |}module Shapes {
5+
////
6+
//// // Class
7+
//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes", "matchKind": "substring" |}export class Point {
8+
//// // Instance member
9+
//// {| "itemName": "originPointAttheHorizon", "kind": "property", "parentName": "Point", "matchKind": "substring"|}private originPointAttheHorizon = 0.0;
10+
////
11+
//// // Getter
12+
//// {| "itemName": "distanceFromOrigin", "kind": "getter", "parentName": "Point", "matchKind": "substring" |}get distanceFromOrigin(): number { return 0; }
13+
////
14+
//// }
15+
////}
16+
////
17+
////// Local variables
18+
////{| "itemName": "myPointThatIJustInitiated", "kind": "var", "parentName": "", "matchKind": "substring"|}var myPointThatIJustInitiated = new Shapes.Point();
19+
20+
//// Testing for substring matching of navigationItems
21+
//var searchValue = "FromOrigin horizon INITIATED Shape Point";
22+
23+
test.markers().forEach((marker) => {
24+
if (marker.data) {
25+
var name = marker.data.itemName;
26+
verify.navigationItemsListContains(name, marker.data.kind, name.substr(1), marker.data.matchKind, marker.fileName, marker.data.parentName);
27+
}
28+
});

0 commit comments

Comments
 (0)