8000 Consumes navto tsserver command. · angelozerr/typescript.java@60bd101 · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 60bd101

Browse files
committed
Consumes navto tsserver command.
1 parent 566e841 commit 60bd101

10 files changed

+263
-0
lines changed

core/ts.core/META-INF/MANIFEST.MF

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Export-Package: ts,
2121
ts.client.installtypes,
2222
ts.client.jsdoc,
2323
ts.client.navbar,
24+
ts.client.navto,
2425
ts.client.occurrences,
2526
ts.client.projectinfo,
2627
ts.client.quickinfo,

core/ts.core/src/ts/client/CommandNames.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public enum CommandNames implements ISupportable {
3636
Configure("configure"),
3737
ProjectInfo("projectInfo"),
3838
Rename("rename"),
39+
NavTo("navto"),
3940

4041
// 2.0.0
4142
SemanticDiagnosticsSync("semanticDiagnosticsSync", "2.0.0"),

core/ts.core/src/ts/client/ITypeScriptServiceClient.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import ts.client.installtypes.IInstallTypesListener;
2626
import ts.client.jsdoc.TextInsertion;
2727
import ts.client.navbar.NavigationBarItem;
28+
import ts.client.navto.NavtoItem;
2829
import ts.client.occurrences.OccurrencesResponseItem;
2930
import ts.client.projectinfo.ProjectInfo;
3031
import ts.client.quickinfo.QuickInfo;
@@ -207,6 +208,9 @@ CompletableFuture<List<OccurrencesResponseItem>> occurrences(String fileName, in
207208
CompletableFuture<RenameResponseBody> rename(String file, int line, int offset, Boolean findInComments,
208209
Boolean findInStrings) throws TypeScriptException;
209210

211+
CompletableFuture<List<NavtoItem>> navto(String fileName, String searchValue, Integer maxResultCount,
212+
Boolean currentFileOnly, String projectFileName) throws TypeScriptException;
213+
210214
CompletableFuture<List<NavigationBarItem>> navbar(String fileName, IPositionProvider positionProvider)
211215
throws TypeScriptException;
212216

core/ts.core/src/ts/client/TypeScriptServiceClient.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import ts.client.installtypes.IInstallTypesListener;
4242
import ts.client.jsdoc.TextInsertion;
4343
import ts.client.navbar.NavigationBarItem;
44+
import ts.client.navto.NavtoItem;
4445
import ts.client.occurrences.OccurrencesResponseItem;
4546
import ts.client.projectinfo.ProjectInfo;
4647
import ts.client.quickinfo.QuickInfo;
@@ -72,6 +73,7 @@
7273
import ts.internal.client.protocol.ImplementationRequest;
7374
import ts.internal.client.protocol.MessageType;
7475
import ts.internal.client.protocol.NavBarRequest;
76+
import ts.internal.client.protocol.NavToRequest;
7577
import ts.internal.client.protocol.NavTreeRequest;
7678
import ts.internal.client.protocol.OccurrencesRequest;
7779
import ts.internal.client.protocol.OpenRequest;
@@ -395,6 +397,12 @@ public CompletableFuture<RenameResponseBody> rename(String file, int line, int o
395397
return execute(new RenameRequest(file, line, offset, findInComments, findInStrings), true);
396398
}
397399

400+
@Override
401+
public CompletableFuture<List<NavtoItem>> navto(String fileName, String searchValue, Integer maxResultCount,
402+
Boolean currentFileOnly, String projectFileName) throws TypeScriptException {
403+
return execute(new NavToRequest(fileName, searchValue, maxResultCount, currentFileOnly, projectFileName), true);
404+
}
405+
398406
@Override
399407
public CompletableFuture<List<NavigationBarItem>> navbar(String fileName, IPositionProvider positionProvider)
400408
throws TypeScriptException {
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/**
2+
* Copyright (c) 2015-2017 Angelo ZERR.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
10+
*/
11+
package ts.client.navto;
12+
13+
import ts.client.Location;
14+
15+
/**
16+
* An item found in a navto response.
17+
*/
18+
public class NavtoItem {
19+
20+
/**
21+
* The symbol's name.
22+
*/
23+
private String name;
24+
25+
/**
26+
* The symbol's kind (such as 'className' or 'parameterName').
27+
*/
28+
private String kind;
29+
30+
/**
31+
* exact, substring, or prefix.
32+
*/
33+
private String matchKind;
34+
35+
/**
36+
* If this was a case sensitive or insensitive match.
37+
*/
38+
private Boolean isCaseSensitive;
39+
40+
/**
41+
* Optional modifiers for the kind (such as 'public').
42+
*/
43+
private String kindModifiers;
44+
45+
/**
46+
* The file in which the symbol is found.
47+
*/
48+
private String file;
49+
50+
/**
51+
* The location within file at which the symbol is found.
52+
*/
53+
private Location start;
54+
55+
/**
56+
* One past the last character of the symbol.
57+
*/
58+
private Location end;
59+
60+
/**
61+
* Name of symbol's container symbol (if any); for example, the class name if
62+
* symbol is a class member.
63+
*/
64+
private String containerName;
65+
66+
/**
67+
* Kind of symbol's container symbol (if any).
68+
*/
69+
private String containerKind;
70+
71+
public String getName() {
72+
return name;
73+
}
74+
75+
public String getKind() {
76+
return kind;
77+
}
78+
79+
public String getMatchKind() {
80+
return matchKind;
81+
}
82+
83+
public Boolean getIsCaseSensitive() {
84+
return isCaseSensitive;
85+
}
86+
87+
public String getKindModifiers() {
88+
return kindModifiers;
89+
}
90+
91+
public String getFile() {
92+
return file;
93+
}
94+
95+
public Location getStart() {
96+
return start;
97+
}
98+
99+
public Location getEnd() {
100+
return end;
101+
}
102+
103+
public String getContainerName() {
104+
return containerName;
105+
}
106+
107+
public String getContainerKind() {
108+
return containerKind;
109+
}
110+
111+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Copyright (c) 2015-2017 Angelo ZERR.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
10+
*/
11+
package ts.internal.client.protocol;
12+
13+
import java.util.List;
14+
15+
import com.google.gson.Gson;
16+
import com.google.gson.JsonObject;
17+
18+
import ts.client.CommandNames;
19+
import ts.client.navto.NavtoItem;
20+
21+
/**
22+
* Navto request message; value of command field is "navto". Return list of
23+
* objects giving file locations and symbols that match the search term given in
24+
* argument 'searchTerm'. The context for the search is given by the named file.
25+
*
26+
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
27+
*/
28+
public class NavToRequest extends FileRequest<NavtoRequestArgs> {
29+
30+
public NavToRequest(String fileName, String searchValue, Integer maxResultCount, Boolean currentFileOnly,
31+
String projectFileName) {
32+
super(CommandNames.NavTo.getName(),
33+
new NavtoRequestArgs(fileName, searchValue, maxResultCount, currentFileOnly, projectFileName));
34+
}
35+
36+
@Override
37+
public Response<List<NavtoItem>> parseResponse(JsonObject json) {
38+
Gson gson = GsonHelper.DEFAULT_GSON;
39+
return gson.fromJson(json, NavtoResponse.class);
40+
}
41+
42+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* Copyright (c) 2015-2017 Angelo ZERR.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
10+
*/
11+
package ts.internal.client.protocol;
12+
13+
/**
14+
* Arguments for CompileOnSaveEmitFileRequest
15+
*
16+
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
17+
*
18+
*/
19+
public class NavtoRequestArgs extends FileRequestArgs {
20+
21+
/**
22+
* Search term to navigate to from current location; term can be '.*' or an
23+
* identifier prefix.
24+
*/
25+
private final String searchValue;
26+
27+
/**
28+
* Optional limit on the number of items to return.
29+
*/
30+
private Integer maxResultCount;
31+
/**
32+
* Optional flag to indicate we want results for just the current file or the
33+
* entire project.
34+
*/
35+
private final Boolean currentFileOnly;
36+
37+
public NavtoRequestArgs(String file, String searchValue, Integer maxResultCount, Boolean currentFileOnly,
38+
String projectFileName) {
39+
super(file, projectFileName);
40+
this.searchValue = searchValue;
41+
this.maxResultCount = maxResultCount;
42+
this.currentFileOnly = currentFileOnly;
43+
}
44+
45+
public String getSearchValue() {
46+
return searchValue;
47+
}
48+
49+
public Integer getMaxResultCount() {
50+
return maxResultCount;
51+
}
52+
53+
public Boolean getCurrentFileOnly() {
54+
return curr F438 entFileOnly;
55+
}
56+
57+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright (c) 2015-2017 Angelo ZERR.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
10+
*/
11+
package ts.internal.client.protocol;
12+
13+
import java.util.List;
14+
15+
import ts.client.navto.NavtoItem;
16+
17+
/**
18+
* Navto response message. Body is an array of navto items. Each item gives a
19+
* symbol that matched the search term.
20+
*
21+
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
22+
*/
23+
public class NavtoResponse extends Response<List<NavtoItem>> {
24+
25+
}

core/ts.core/src/ts/resources/AbstractTypeScriptFile.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import ts.client.format.FormatCodeSettings;
3131
import ts.client.jsdoc.TextInsertion;
3232
import ts.client.navbar.NavigationBarItemRoot;
33+
import ts.client.navto.NavtoItem;
3334
import ts.client.occurrences.OccurrencesResponseItem;
3435
import ts.client.quickinfo.QuickInfo;
3536
import ts.client.refactors.ApplicableRefactorInfo;
@@ -256,6 +257,15 @@ public CompletableFuture<RenameResponseBody> rename(int position, Boolean findIn
256257
return client.rename(this.getName(), line, offset, findInComments, findInStrings);
257258
}
258259

260+
@Override
261+
public CompletableFuture<List<NavtoItem>> navto(String searchValue, Integer maxResultCount,
262+
Boolean currentFileOnly, String projectFileName)
263+
throws TypeScriptException {
264+
this.synch();
265+
ITypeScriptServiceClient client = tsProject.getClient();
266+
return client.navto(getName(), searchValue, maxResultCount, currentFileOnly, projectFileName);
267+
}
268+
259269
@Override
260270
public CompletableFuture<List<FileSpan>> implementation(int position) throws TypeScriptException {
261271
this.synch();

core/ts.core/src/ts/resources/ITypeScriptFile.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import ts.client.format.FormatCodeSettings;
2727
import ts.client.jsdoc.TextInsertion;
2828
import ts.client.navbar.NavigationBarItemRoot;
29+
import ts.client.navto.NavtoItem;
2930
import ts.client.occurrences.OccurrencesResponseItem;
3031
import ts.client.quickinfo.QuickInfo;
3132
import ts.client.refactors.ApplicableRefactorInfo;
@@ -201,6 +202,9 @@ CompletableFuture<DiagnosticEventBody> syntacticDiagnosticsSync(Boolean includeL
201202
CompletableFuture<RenameResponseBody> rename(int position, Boolean findInComments, Boolean findInStrings)
202203
throws TypeScriptException;
203204

205+
CompletableFuture<List<NavtoItem>> navto(String searchValue, Integer maxResultCount, Boolean currentFileOnly,
206+
String projectFileName) throws TypeScriptException;
207+
204208
/**
205209
* Call implementation from the tsserver.
206210
*

0 commit comments

Comments
 (0)
0