-
Notifications
You must be signed in to change notification settings - Fork 770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[READY] Allow switching to a different JavaScript project with RestartServer #875
[READY] Allow switching to a different JavaScript project with RestartServer #875
Conversation
Codecov Report
@@ Coverage Diff @@
## master #875 +/- ##
==========================================
+ Coverage 94.81% 95.01% +0.19%
==========================================
Files 79 79
Lines 5440 5455 +15
Branches 171 171
==========================================
+ Hits 5158 5183 +25
+ Misses 233 225 -8
+ Partials 49 47 -2 |
bb33265
to
727d162
Compare
Start Tern on the FileReadyToParse event. Make sure there is only one attempt to start the server. Add Tern configuration path to debugging information.
727d162
to
e587501
Compare
I did some refactoring in the tests by introducing an utility function to start the Tern server. Also, similarly to the recent changes in PR #857, I slightly changed the logic so that we only try to start the Tern server once. PR is ready. Reviewed 6 of 6 files at r1, 4 of 4 files at r2, 1 of 1 files at r3, 1 of 1 files at r4. Comments from Reviewable |
Makes me wonder if we should start all semantic completers on Reviewed 2 of 6 files at r1, 3 of 4 files at r2, 1 of 1 files at r4. Comments from Reviewable |
Thanks! Review status: all files reviewed at latest revision, 1 unresolved discussion. ycmd/completers/javascript/tern_completer.py, line 391 at r4 (raw file):
This PR adds 10+ lines of code to a function with a TODO of "this function is too long". :( Doesn't block this PR, but we should consider refactoring this sooner rather than later. Comments from Reviewable |
So is it time to merge this? Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. Comments from Reviewable |
Reviewed 1 of 1 files at r5. ycmd/completers/javascript/tern_completer.py, line 391 at r4 (raw file): Previously, Valloric (Val Markovic) wrote…
Did some simplifications and moved the new code to a separate function. It's now 54 lines instead of 74. ycmd/completers/javascript/tern_completer.py, line 442 at r4 (raw file):
Removed this Comments from Reviewable |
Review status: all files reviewed at latest revision, 8 unresolved discussions. ycmd/completers/javascript/tern_completer.py, line 157 at r5 (raw file):
should this be a dir name rather than file name? totally optional. i'm ambivalent. ycmd/completers/javascript/tern_completer.py, line 268 at r5 (raw file):
should we call it "Tern project file", as that is a little clearer that it is specific to Tern rather than YCM ? I theory at least editors and ycmd itself might have "configuration files". Again, optional. ycmd/completers/javascript/tern_completer.py, line 386 at r5 (raw file):
I think this might be a slight regression, but I'm not sure. Previously in this scenario we would use Vim's working dir, which might turn out a better choice than the file's directory. Example might be:
I don't know for certain if this would or would not have previously just about worked based on the wd of the term server being I guess the key question for discussion is: if we can't find a tern project file, should we really use the dirname of the file, or revert to the previous behaviour of using the WD of the client. I suspect that we should do the latter, for safety unless there's a good reason not to... or I totally missed the point, which is of course also possible! ycmd/completers/javascript/tern_completer.py, line 442 at r5 (raw file):
should these be %d ? just being pedantic, you can ignore. ycmd/completers/javascript/tern_completer.py, line 489 at r5 (raw file):
should we reset ycmd/tests/javascript/event_notification_test.py, line 160 at r5 (raw file):
should we test that if we restart it in some other directory (which doesn't have a .tern-project) that we do get another error (as mentioned, I think we don't, but i'm not 100% sure). Comments from Reviewable |
Reviewed 1 of 1 files at r6. ycmd/completers/javascript/tern_completer.py, line 157 at r5 (raw file): Previously, puremourning (Ben Jackson) wrote…
It's simpler to put the filepath here. ycmd/completers/javascript/tern_completer.py, line 268 at r5 (raw file): Previously, puremourning (Ben Jackson) wrote…
No need because this item is added in the ycmd/completers/javascript/tern_completer.py, line 386 at r5 (raw file): Previously, puremourning (Ben Jackson) wrote…
I did some tests and Tern doesn't seem to rely at all on the working directory to resolve modules path (I tried with ycmd/completers/javascript/tern_completer.py, line 442 at r5 (raw file): Previously, puremourning (Ben Jackson) wrote…
Done. ycmd/completers/javascript/tern_completer.py, line 489 at r5 (raw file): Previously, puremourning (Ben Jackson) wrote…
When restarting the server, the ycmd/tests/javascript/event_notification_test.py, line 160 at r5 (raw file):
Comments from Reviewable |
Reviewed 2 of 6 files at r1, 3 of 4 files at r2, 1 of 1 files at r5. ycmd/completers/javascript/tern_completer.py, line 386 at r5 (raw file): Previously, micbou wrote…
Like i said i wasn't sure if it would work before, or if there are other Tern behaviours that use relative paths in some sense. I should have said "something like Thanks for testing anyway, let's assume this is grand. In any event the solution is to add a ycmd/completers/javascript/tern_completer.py, line 489 at r5 (raw file): Previously, micbou wrote…
Great, thanks. ycmd/tests/javascript/event_notification_test.py, line 160 at r5 (raw file): Previously, micbou wrote…
Heh ok sorry :) Comments from Reviewable |
Reviewed 2 of 2 files at r7. Comments from Reviewable |
Let's merge. @zzbot r+ Reviewed 2 of 2 files at r7. Comments from Reviewable |
📌 Commit 4ebb5da has been approved by |
… r=micbou [READY] Allow switching to a different JavaScript project with RestartServer Contrarily to what the YCM docs say, issuing the `:YcmCompleter RestartServer` command to switch to a different JavaScript project doesn't work. The reason is that we don't set the working directory when starting the Tern server. Same issue if the user starts the client outside a project and then open a file in that project. It's even worse in that case because no warning will be displayed to the user. I considered passing the `request_data` object when initializing the completer but that doesn't work because the request is not always available. I also considered adding support for multiple projects similarly to what the C# completer does but I felt it was too much work. Finally, I went for starting the server on the `FileReadyToParse` event. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/ycmd/875) <!-- Reviewable:end -->
☀️ Test successful - status-appveyor, status-travis |
[READY] Update ycmd Include the following changes: - PR ycm-core/ycmd#856: update JediHTTP; - PR ycm-core/ycmd#860: improve diagnostics location in C-family languages; - PR ycm-core/ycmd#865: use Objective-C triggers for Objective-C++; - PR ycm-core/ycmd#869: support TypeScript 2.6.1; - PR ycm-core/ycmd#875: allow switching to a different JavaScript project with `RestartServer`; - PR ycm-core/ycmd#877: support `-idirafter` include flag in C-family languages. Update the JavaScript documentation on how to switch to a different project. We only mention the `:YcmCompleter RestartServer` way as other methods involve restarting ycmd and losing all its data like stored identifiers. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2839) <!-- Reviewable:end -->
Include the following changes: - PR ycm-core/ycmd#856: update JediHTTP; - PR ycm-core/ycmd#860: improve diagnostics location in C-family languages; - PR ycm-core/ycmd#865: use Objective-C triggers for Objective-C++; - PR ycm-core/ycmd#869: support TypeScript 2.6.1; - PR ycm-core/ycmd#875: allow switching to a different JavaScript project with `RestartServer`; - PR ycm-core/ycmd#877: support `-idirafter` include flag in C-family languages.
Contrarily to what the YCM docs say, issuing the
:YcmCompleter RestartServer
command to switch to a different JavaScript project doesn't work. The reason is that we don't set the working directory when starting the Tern server. Same issue if the user starts the client outside a project and then open a file in that project. It's even worse in that case because no warning will be displayed to the user.I considered passing the
request_data
object when initializing the completer but that doesn't work because the request is not always available. I also considered adding support for multiple projects similarly to what the C# completer does but I felt it was too much work. Finally, I went for starting the server on theFileReadyToParse
event.This change is