Skip to content

Commit fc3d75f

Browse files
authored
Merge pull request #160 from webratio/pr/keep-open-project
Keep projects open on tsserver via OpenExternalProject
2 parents d0129a1 + d807513 commit fc3d75f

File tree

10 files changed

+459
-191
lines changed

10 files changed

+459
-191
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* Contributors:
99
* Angelo Zerr <[email protected]> - initial API and implementation
10+
* Lorenzo Dalla Vecchia <[email protected]> - openExternalProject
1011
*/
1112
package ts.client;
1213

@@ -36,6 +37,7 @@ public enum CommandNames {
3637
Configure("configure"),
3738
ProjectInfo("projectInfo"),
3839
Rename("rename"),
40+
OpenExternalProject("openExternalProject"),
3941

4042
// 2.0.3
4143
SemanticDiagnosticsSync("semanticDiagnosticsSync", "2.0.3"),

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

Lines changed: 37 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* Contributors:
99
* Angelo Zerr <[email protected]> - initial API and implementation
10+
* Lorenzo Dalla Vecchia <[email protected]> - adjusted usage of CompletableFuture, openExternalProject
1011
*/
1112
package ts.client;
1213

@@ -77,8 +78,8 @@ public interface ITypeScriptServiceClient {
7778
* @param insertString
7879
* @throws TypeScriptException
7980
*/
80-
// void changeFile(String fileName, int position, int endPosition, String
81-
// insertString) throws TypeScriptException;
81+
// void changeFile(String fileName, int position, int
82+
// endPosition, String insertString) throws TypeScriptException;
8283

8384
/**
8485
* Change file content at the given lines/offsets.
@@ -102,10 +103,9 @@ void changeFile(String fileName, int line, int offset, int endLine, int endOffse
102103
* @param fileName
103104
* @param position
104105
* @return completion for the given fileName at the given position.
105-
* @throws TypeScriptException
106106
*/
107107
// CompletableFuture<List<CompletionEntry>> completions(String fileName, int
108-
// position) throws TypeScriptException;
108+
// position);
109109

110110
/**
111111
* Completion for the given fileName at the given line/offset.
@@ -114,16 +114,14 @@ void changeFile(String fileName, int line, int offset, int endLine, int endOffse
114114
* @param line
115115
* @param offset
116116
* @return completion for the given fileName at the given line/offset
117-
* @throws TypeScriptException
118117
*/
119-
CompletableFuture<List<CompletionEntry>> completions(String fileName, int line, int offset)
120-
throws TypeScriptException;
118+
CompletableFuture<List<CompletionEntry>> completions(String fileName, int line, int offset);
121119

122120
CompletableFuture<List<CompletionEntry>> completions(String name, int line, int offset,
123-
ICompletionEntryFactory instanceCreator) throws TypeScriptException;
121+
ICompletionEntryFactory instanceCreator);
124122

125123
CompletableFuture<List<CompletionEntryDetails>> completionEntryDetails(String fileName, int line, int offset,
126-
String[] entryNames, CompletionEntry completionEntry) throws TypeScriptException;
124+
String[] entryNames, CompletionEntry completionEntry);
127125

128126
/**
129127
* Definition for the given fileName at the given line/offset.
@@ -132,9 +130,8 @@ CompletableFuture<List<CompletionEntryDetails>> completionEntryDetails(String fi
132130
* @param line
133131
* @param offset
134132
* @return
135-
* @throws TypeScriptException
136133
*/
137-
CompletableFuture<List<FileSpan>> definition(String fileName, int line, int offset) throws TypeScriptException;
134+
CompletableFuture<List<FileSpan>> definition(String fileName, int line, int offset);
138135

139136
/**
140137
* Signature help for the given fileName at the given line/offset.
@@ -143,10 +140,8 @@ CompletableFuture<List<CompletionEntryDetails>> completionEntryDetails(String fi
143140
* @param line
144141
* @param offset
145142
* @return
146-
* @throws TypeScriptException
147143
*/
148-
CompletableFuture<SignatureHelpItems> signatureHelp(String fileName, int line, int offset)
149-
throws TypeScriptException;
144+
CompletableFuture<SignatureHelpItems> signatureHelp(String fileName, int line, int offset);
150145

151146
/**
152147
* Quick info for the given fileName at the given line/offset.
@@ -155,14 +150,12 @@ CompletableFuture<SignatureHelpItems> signatureHelp(String fileName, int line, i
155150
* @param line
156151
* @param offset
157152
* @return
158-
* @throws TypeScriptException
159153
*/
160-
CompletableFuture<QuickInfo> quickInfo(String fileName, int line, int offset) throws TypeScriptException;
154+
CompletableFuture<QuickInfo> quickInfo(String fileName, int line, int offset);
161155

162-
CompletableFuture<List<DiagnosticEvent>> geterr(String[] files, int delay) throws TypeScriptException;
156+
CompletableFuture<List<DiagnosticEvent>> geterr(String[] files, int delay);
163157

164-
CompletableFuture<List<DiagnosticEvent>> geterrForProject(String file, int delay, ProjectInfo projectInfo)
165-
throws TypeScriptException;
158+
CompletableFuture<List<DiagnosticEvent>> geterrForProject(String file, int delay, ProjectInfo projectInfo);
166159

167160
/**
168161
* Format for the given fileName at the given line/offset.
@@ -173,10 +166,8 @@ CompletableFuture<List<DiagnosticEvent>> geterrForProject(String file, int delay
173166
* @param endLine
174167
* @param endOffset
175168
* @return
176-
* @throws TypeScriptException
177169
*/
178-
CompletableFuture<List<CodeEdit>> format(String fileName, int line, int offset, int endLine, int endOffset)
179-
throws TypeScriptException;
170+
CompletableFuture<List<CodeEdit>> format(String fileName, int line, int offset, int endLine, int endOffset);
180171

181172
/**
182173
* Find references for the given fileName at the given line/offset.
@@ -185,10 +176,8 @@ CompletableFuture<List<CodeEdit>> format(String fileName, int line, int offset,
185176
* @param line
186177
* @param offset
187178
* @return
188-
* @throws TypeScriptException
189179
*/
190-
CompletableFuture<ReferencesResponseBody> references(String fileName, int line, int offset)
191-
throws TypeScriptException;
180+
CompletableFuture<ReferencesResponseBody> references(String fileName, int line, int offset);
192181

193182
/**
194183
* Find occurrences for the given fileName at the given line/offset.
@@ -197,21 +186,27 @@ CompletableFuture<ReferencesResponseBody> references(String fileName, int line,
197186
* @param line
198187
* @param offset
199188
* @return
200-
* @throws TypeScriptException
201189
*/
202-
CompletableFuture<List<OccurrencesResponseItem>> occurrences(String fileName, int line, int offset)
203-
throws TypeScriptException;
190+
CompletableFuture<List<OccurrencesResponseItem>> occurrences(String fileName, int line, int offset);
204191

205192
CompletableFuture<RenameResponseBody> rename(String file, int line, int offset, Boolean findInComments,
206-
Boolean findInStrings) throws TypeScriptException;
193+
Boolean findInStrings);
207194

208-
CompletableFuture<List<NavigationBarItem>> navbar(String fileName, IPositionProvider positionProvider)
209-
throws TypeScriptException;
195+
CompletableFuture<List<NavigationBarItem>> navbar(String fileName, IPositionProvider positionProvider);
210196

211197
void configure(ConfigureRequestArguments arguments) throws TypeScriptException;
212198

213-
CompletableFuture<ProjectInfo> projectInfo(String file, String projectFileName, boolean needFileNameList)
214-
throws TypeScriptException;
199+
CompletableFuture<ProjectInfo> projectInfo(String file, String projectFileName, boolean needFileNameList);
200+
201+
/**
202+
* Defines a TypeScript project that is "handled by the client" and
203+
* therefore never closed automatically by the server.
204+
*
205+
* @param projectFileName
206+
* @param rootFileNames
207+
* @return
208+
*/
209+
CompletableFuture<Void> openExternalProject(String projectFileName, List<String> rootFileNames);
215210

216211
// Since 2.0.3
217212

@@ -220,42 +215,35 @@ CompletableFuture<ProjectInfo> projectInfo(String file, String projectFileName,
220215
*
221216
* @param includeLinePosition
222217
* @return
223-
* @throws TypeScriptException
224218
*/
225-
CompletableFuture<DiagnosticEventBody> semanticDiagnosticsSync(String file, Boolean includeLinePosition)
226-
throws TypeScriptException;
219+
CompletableFuture<DiagnosticEventBody> semanticDiagnosticsSync(String file, Boolean includeLinePosition);
227220

228221
/**
229222
* Execute syntactic diagnostics for the given file.
230223
*
231224
* @param includeLinePosition
232225
* @return
233-
* @throws TypeScriptException
234226
*/
235-
CompletableFuture<DiagnosticEventBody> syntacticDiagnosticsSync(String file, Boolean includeLinePosition)
236-
throws TypeScriptException;
227+
CompletableFuture<DiagnosticEventBody> syntacticDiagnosticsSync(String file, Boolean includeLinePosition);
237228

238229
// Since 2.0.5
239230

240-
CompletableFuture<Boolean> compileOnSaveEmitFile(String fileName, Boolean forced) throws TypeScriptException;
231+
CompletableFuture<Boolean> compileOnSaveEmitFile(String fileName, Boolean forced);
241232

242-
CompletableFuture<List<CompileOnSaveAffectedFileListSingleProject>> compileOnSaveAffectedFileList(String fileName)
243-
throws TypeScriptException;
233+
CompletableFuture<List<CompileOnSaveAffectedFileListSingleProject>> compileOnSaveAffectedFileList(String fileName);
244234

245235
// Since 2.0.6
246236

247-
CompletableFuture<NavigationBarItem> navtree(String fileName, IPositionProvider positionProvider)
248-
throws TypeScriptException;
237+
CompletableFuture<NavigationBarItem> navtree(String fileName, IPositionProvider positionProvider);
249238

250-
CompletableFuture<TextInsertion> docCommentTemplate(String fileName, int line, int offset)
251-
throws TypeScriptException;
239+
CompletableFuture<TextInsertion> docCommentTemplate(String fileName, int line, int offset);
252240

253241
// Since 2.1.0
254242

255243
CompletableFuture<List<CodeAction>> getCodeFixes(String fileName, IPositionProvider positionProvider, int startLine,
256-
int startOffset, int endLine, int endOffset, List<Integer> errorCodes) throws TypeScriptException;
244+
int startOffset, int endLine, int endOffset, List<Integer> errorCodes);
257245

258-
CompletableFuture<List<String>> getSupportedCodeFixes() throws TypeScriptException;
246+
CompletableFuture<List<String>> getSupportedCodeFixes();
259247

260248
//
261249
/**
@@ -265,9 +253,8 @@ CompletableFuture<List<CodeAction>> getCodeFixes(String fileName, IPositionProvi
265253
* @param line
266254
* @param offset
267255
* @return
268-
* @throws TypeScriptException
269256
*/
270-
CompletableFuture<List<FileSpan>> implementation(String fileName, int line, int offset) throws TypeScriptException;
257+
CompletableFuture<List<FileSpan>> implementation(String fileName, int line, int offset);
271258

272259
void addClientListener(ITypeScriptClientListener listener);
273260

0 commit comments

Comments
 (0)