Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

HTTP Interface #495

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

HTTP Interface #495

wants to merge 4 commits into from

Conversation

lukroth
Copy link
Contributor

@lukroth lukroth commented Dec 19, 2016

Content of the pull request:

  • added an new HTTP Interface
  • added a new 'file_save', 'file_list', and 'file_delete' command
  • added a new 'add_dependency' and 'remove_dependency' command
  • added new test cases for the new commands and the HTTP Interface

Reason for our pull request:

We are creating an online editor (we took codemirror as a base editor) which provides code completion functionality for groovy code. To achieve this, we run an eclipse instance in the background. To get the completion proposals out of eclipse we selected the eclim plug-in. Since eclipse should run in a docker image we do not want to use the “command line interface”, but would prefer a HTTP interface which provides the functionality of eclim.

We need the additional commands to control eclim completely over the HTTP Interface.
With the file_save command we can

  • save code files and
  • save jar dependencies (which we later add to the .classpath file of eclipse over the add_dependency command)

- added an new HTTP Interface
- added a new 'file_save', 'file_list', and 'file_delete' command
- added a new 'add_dependency' and 'remove_dependency' command
- added new test cases for the new commands and the HTTP Interface
ant.classpath{ant.pathelement(path: '${build.classes}/org.eclim')}
ant.classpath{
ant.pathelement(path: '${build.classes}/org.eclim')
ant.pathelement(path: '${build.classes}/org.eclim.jdt')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be changed to to use ${pluginName} rather than hardcoding in jdt, which not all users may be able to compile (they may only be interested in running/testing cdt for example).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, thanks for the comment!
See changes in the next commit.

@@ -1130,6 +1133,7 @@ junit = { pluginName ->
ant.path(refid: 'junit')
ant.pathelement(path: "build/test/junit/classes/${pluginName}")
ant.pathelement(path: '${build.classes}/org.eclim')
ant.pathelement(path: '${build.classes}/org.eclim.jdt')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this shouldn't be hardcoded as jdt.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also done in the next commit.

int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this code and replace it with org.eclim.util.IOUtils.copy(in, out).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I did not see this Utility class.
I changed it -> See changes in the next commit.

* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.eclim.plugin.jdt.command.dependency;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a package for .classpath commands at jdt.command.classpath. Can you move your new commands there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - i moved all my classes from the dependency package including the test cases to the classpath package.
See changes in the next commit.

import org.eclim.plugin.core.util.PathUtilException;

@Command(
name = "add_dependency",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency and to prevent collisions, all language specific commands have a common prefix. Since this is a jdt (java) command, this should have a java_ prefix. For consistency with the existing classpath commands I'd call this java_classpath_add_entry.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - Changed the add_dependency and also the remove_dependency to java_classpath_add_entry and java_classpath_remove_entry.
See changes in the next commit.

@@ -1,4 +1,7 @@
pluginVersion=${eclim.version}
nailgun.server.host=127.0.0.1
nailgun.server.port=9091
http.server.enabled=true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please disable this by default. Currently no other users will be using this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense - this was the initial reason why I introduced this flag -> I just forgot to set it to false by default.
Now changed -> See changes in the next commit.

@ervandew
Copy link
Owner

I scanned through this and left some comments. I'll need to spend more time looking at this more closely and testing, but for the most part it looks good.

Please run $ ant checkstyle for this and address any failures (Note: i fixed the jdt SearchCommand failures on master).

…iew round' of ervandew

- build.gant: use ${pluginName} instead of hard coding
- use IOUtils in FileSaveCommand
- move org.eclim.plugin.jdt.command.dependency to jdt.command.classpath
- disable http server by default
- rename add_dependency and remove_dependency commands to java_classpath_add_entry and java_classpath_remove_entry
@lukroth
Copy link
Contributor Author

lukroth commented Jan 3, 2017

First: Thanks for your comments and your time you took to look at the code!

  • I changed everything accordingly to your suggestions.

  • I ran the $ ant checkstyle command already :) -> it should be fine?
    (I just realized that the checkstyle command does not check the junit test classes?, is there any reason for this?)

@lukroth
Copy link
Contributor Author

lukroth commented Jan 3, 2017

Note: Before you merge the code: Please run the junit tests on your machine to ensure all tests pass - i had to comment some tests out which did never run on my system (https://groups.google.com/forum/#!msg/eclim-dev/O8dqcvOEFWI/_VSC3ncmDwAJ)

Please do so also for #496 and #497
Thanks!

- changed wrong logging call (tried to log an object which is no instance of exception in an error logging call)
The HTTP Server returned an error message if a command returns null. Since there exist commands which return null when they succeed (e.g. project_refresh_file) we changed this. The HTTP Server now returns an empty string in the message if a command returns null.
lukroth added a commit to lukroth/eclim that referenced this pull request Jan 11, 2017
…iew round' of ervandew

- build.gant: use ${pluginName} instead of hard coding
- use IOUtils in FileSaveCommand
- move org.eclim.plugin.jdt.command.dependency to jdt.command.classpath
- disable http server by default
- rename add_dependency and remove_dependency commands to java_classpath_add_entry and java_classpath_remove_entry
lukroth added a commit to lukroth/eclim that referenced this pull request Jan 11, 2017
- changed wrong logging call (tried to log an object which is no instance of exception in an error logging call)
lukroth added a commit to lukroth/eclim that referenced this pull request Jan 11, 2017
The HTTP Server returned an error message if a command returns null. Since there exist commands which return null when they succeed (e.g. project_refresh_file) we changed this. The HTTP Server now returns an empty string in the message if a command returns null.
@ervandew
Copy link
Owner

I just wanted to leave a note that I haven't forgotten about these pull requests. I've just haven't had the time to fully review them yet (I was hoping to tackle a couple the past weekend, but my internet went out friday afternoon and wasn't back until monday afternoon).

@vitkoczi
Copy link

hi @ervandew

do you plan to have a look?
we would need the rest interface

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants