Skip to content
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

Asynchronous requests to Tern Server (Issue #171) #232

Merged
merged 3 commits into from
Jan 30, 2015

Conversation

piotrtomiak
Copy link
Contributor

This pull request covers following improvements:

  • asynchronous upload of files to Tern server
  • ensure synchronized is called when a JS or HTML editor is focused
  • content of JS file is uploaded to Tern server when JS editor looses focus
  • HTML files are removed from Tern server after HTML editor looses focus
  • refactoring of collectors API - code has been extracted from TernServers
  • refactoring of code completion code - a record objects were introduced to keep all the information related to completion proposal

Additional changes:
- refactoring of completion proposals collection - introduced a record
object to hold all information relevant to a completion item
- refactoring of collectors API - collection algorithms have been moved
out of *TernServer classes and placed in singletons

Genuitec bugs: 21189, 27330, 27532, 27560, 27606, 27639, 27747, 27900
@piotrtomiak
Copy link
Contributor Author

@angelozerr the code is not yet tested as I stumbled upon some troubles with launching eclipse with Tern. Really weird. Anyway, I wanted you to have a look at number of changes done, so that we can already talk about them and test a bit later. Most of the code related to synchronization has been copied from MyEclipse and that code was tested well. Collectors API refactoring is a new thing, not yet tested. I've made that change, as I don't like methods args to be so unstable, especially when we patch them a bit ;) I hope that you like it! I am sure it will work well for you as well, when adding new collectors.

@angelozerr
Copy link
Owner

Thanks @piotrtomiak ! Wow it's a big PR! I will integrate it for 0.9.0. I have few questions :

  • what is the benefit to synchronize tern file when editor is opened, have focus, etc? What is about performance? Do you do that on the background?
  • you have refactored collector API, because they change every time?
  • do you know if it's possible to unactivate with preferences the asynch completion (open completion with synch mode like today)?

@angelozerr
Copy link
Owner

@piotrtomiak do you know if there will have compilation problem with AngularJS Eclipse?

@piotrtomiak
Copy link
Contributor Author

@angelozerr

what is the benefit to synchronize tern file when editor is opened, have focus, etc? What is about performance? Do you do that on the background?

ensureSynchronized is using file uploader for uploading files, have a look at IDETernFileUploader. Uploader can work synchronously or asynchronously. IDE uploader is asynchronous, so ensureSynchronized exits very quickly. We have applied this technique in MyEclipse and haven't noticed any performance issue. The advantage of such a solution is that when user invokes content assist in the file, files are already synchronized and only the edited file has to be send to the server. Since synchronization is asynchronous, the file has to be attached directly to the request, so that is available to Tern when computing proposals. IDETernFileUploader uploads 20 files at once, and in between a completion request can be issued.

you have refactored collector API, because they change every time?

Mostly because I had to have a clear code for asynchronous collectors support. That support had to be done in a single method, not replicated in several request methods. Also, I felt that with so many collectors, making a separate request method for each of them wasn't elegant and resulted in a very unstable API. And it looks like you are going to add more collectors in a future ;)

do you know if it's possible to unactivate with preferences the asynch completion (open completion with synch mode like today)?

We can sure add such a functionality, though I don't see much point in it. It's like giving a user ability to freeze IDE for several seconds ;) Anyway, it shouldn't be a big deal to add it, so let me know if you want it.

do you know if there will have compilation problem with AngularJS Eclipse?

Yes, there are compilation problems with AngularJS and I have a commit to push as PR. I haven't pushed it yet, since this one is not done.

@angelozerr
Copy link
Owner

@piotrtomiak many thanks for your answer!

Anyway, it shouldn't be a big deal to add it, so let me know if you want it.

If you can do it, it should be very cool. By default this preference can be setted to asynch. If there are some bugs with asynch completion (even if I trust you in 100%), user could unactivate this feature by waiting a fix.

Yes, there are compilation problems with AngularJS and I have a commit to push as PR. I haven't pushed it yet, since this one is not done.

Could you create a PR please. I have tested AngularJS with your asynch compeltion by using your github and it seems that it works (I have tested quickly).

@piotrtomiak
Copy link
Contributor Author

If you can do it, it should be very cool. By default this preference can be setted to asynch. If there are some bugs with asynch completion (even if I trust you in 100%), user could unactivate this feature by waiting a fix.

Ok. I now have to take care of urgent stuff in MyEclipse, so I guess I will be able to finish on Friday along with some testing.

Could you create a PR please. I have tested AngularJS with your asynch compeltion by using your github and it seems that it works (I have tested quickly).

Well, I am surprised that it actually works. I have not been able to run it in eclipse yet (problems with launching), so this code is totally not tested and should have some bugs in it. I'll create the PR today. What I am concerned about is that HTML file is being removed from the server when you switch from HTML editor to other editor or view. That's cool, so that you don't get completion proposals in JS files from HTML files you've opened, however it may interfere with AngularJS, for which I am do not know how model is built. This thing is totally optional and can be commented out.

@angelozerr
Copy link
Owner

@piotrtomiak I would like to move the whole tern plugins in a project, so I must change some code.

What do you prefer?

  • I accept your PR and you do after some new PR?
  • or I'm waiting that you do several tests before creating PR and you will adjust your work with my work.

@piotrtomiak
Copy link
Contributor Author

Sounds like in this case accepting this PR would be better. I don't want to move so much of the code around ;) I will create PR for Angular immediatley

@angelozerr
Copy link
Owner

Sounds like in this case accepting this PR would be better.

I understand :)

As it's a big PR, are you OK to help me to fix problem if they have a problem and improve angular?

@piotrtomiak
Copy link
Contributor Author

As it's a big PR, are you OK to help me to fix problem if they have a problem and improve angular?

Definitely yes :) And of course, if there is any bug resulting from this contribution I will fix it. I will be able to get into this again on Friday.

@piotrtomiak
Copy link
Contributor Author

All right, it looks like everything works as it should be. Once you merge the PR, I will integrate this code with MyEclipse and we will perform tests in MyEclipse. If we find out any problems related to this contribution we will provide you with the fixes.

I will now add that preference for synchronous content assist invocation.

@piotrtomiak
Copy link
Contributor Author

@angelozerr as I think of it now... Where would you put such a preference? It is common to all servers and all request types, that is, if you have AngularJS requests, if collector implements appropriate interface it can also run asynch. So the only location I can think of is the "Tern" main page. Would you agree?

@angelozerr
Copy link
Owner

I can think of is the "Tern" main page. Would you agree?

Yes I think it's the best place.

I would liek to tell you 2 things :

@piotrtomiak
Copy link
Contributor Author

It seems that you track editor and I have done the same thing for use tern lint. See https://github.com/angelozerr/tern.java/blob/master/eclipse/tern.eclipse.ide.ui/src/tern/eclipse/ide/internal/ui/validation/JavaEditorTracker.java I tell me if we could just have one tracker. What do you think about that?

Yes, I saw your JavaEditorTracker. If you feel it's ok, you can later on integrate it with mine; I wouldn't feel sure enough to do it myself, though I can do it of course if you want. The other way is not possible as through our tests it turned out that the listener has to be installed only if workbench is initialized and there are already windows, otherwise a workbench window might appear too fast.

when you have a lot of JS files and you execute completion, it post JS files to tern server with asynch mode (that's very cool), but if you try to stop it (you can do that if you hava activated tern console), it continues to post JS files). It should be cool if we could stop the posting of JS files.

Right! This is something I kept forgetting about adding to ME code. I'll add it.

@angelozerr
Copy link
Owner

Ok @piotrtomiak thanks for your answer.

Tell me when I can accept this PR.

@piotrtomiak
Copy link
Contributor Author

@angelozerr I have added the changes you wanted. As for me, you can merge it :D

angelozerr added a commit that referenced this pull request Jan 30, 2015
Asynchronous requests to Tern Server (Issue #171)
@angelozerr angelozerr merged commit b3aed80 into angelozerr:master Jan 30, 2015
@angelozerr
Copy link
Owner

We will see if users (and me) will find problems. Anyway Thanks @piotrtomiak for your great PR!

@piotrtomiak
Copy link
Contributor Author

You're welcome :) MyEclipse QA team will start testing this on Monday or Tuesday, so we will have more input. I don't expect any issues though :) Thanks!

@angelozerr
Copy link
Owner

MyEclipse QA team will start testing this on Monday or Tuesday, so we will have more input.

Cool!

For your information, I will try to integrate ESLint #234

I will see if we could merge our tracker.

@angelozerr angelozerr added this to the 0.9.0 milestone Jan 30, 2015
vrubezhny pushed a commit to vrubezhny/tern.java that referenced this pull request Feb 18, 2015
vrubezhny pushed a commit to vrubezhny/tern.java that referenced this pull request Feb 18, 2015
vrubezhny pushed a commit to vrubezhny/tern.java that referenced this pull request Feb 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants