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

ClangD support for Eclipse Che #7516

Merged
merged 11 commits into from
Feb 15, 2018

Conversation

hkolvenbach
Copy link
Contributor

@hkolvenbach hkolvenbach commented Nov 22, 2017

What does this PR do?

This PR adds initial support for C/C++ Intellisense by using clangd as a language server. It supports starting the language server and connecting to the clangd in a hardcoded path within the docker image

There is still work to do, but I would like to use this PR to discuss how to best continue.
Open Questions:

  • Which clangd binary to integrate? Stable release (5.0.1) or latest svn (6.x)
  • How to provide the clangd binary? Who is maintaining the eclipse/cpp_gcc docker image and should we integrate clangd into it?
  • How should we handle the compile_commands.json? ClangD expects this to do proper "gotoDefinition" handling, however this file needs to be generated e.g. by cmake and passed as an argument to the language server

ToDo:

  • Che6 Integration

What issues does this PR fix or reference?

#4991

Release Notes

Docs PR

@benoitf benoitf added status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. kind/task Internal things, technical debt, and to-do tasks to be performed. labels Nov 22, 2017
@hkolvenbach
Copy link
Contributor Author

@AndrienkoAleksandr should i squash or rewrite your commits to fix the ip validation error?

@AndrienkoAleksandr
Copy link
Contributor

AndrienkoAleksandr commented Nov 23, 2017

@hkolvenbach ok. You can do all necessary
.

@tolusha
Copy link
Contributor

tolusha commented Nov 23, 2017

Hello. Here is my humble opinions.

Which clangd binary to integrate? Stable release (5.0.1) or latest svn (6.x)

It depends. If the latest version provides considerably more functionality then it make sense, otherwise I would prefer the stable version.

How to provide the clangd binary?

We can host them as we host other binaries for language servers.

Who is maintaining the eclipse/cpp_gcc docker image and should we integrate clangd into it?

I would say no.

How should we handle the compile_commands.json? ClangD expects this to do proper "gotoDefinition" handling, however this file needs to be generated e.g. by cmake and passed as an argument to the language server

@evidolob may be could help here.

@evidolob
Copy link
Contributor

How should we handle the compile_commands.json? ClangD expects this to do proper "gotoDefinition" handling, however this file needs to be generated e.g. by cmake and passed as an argument to the language server

I guess, we need to generate that file after project creation/clone.

@AndrienkoAleksandr
Copy link
Contributor

@hkolvenbach About generation json, we can try workaround. I think we can install cmake with help installation script org.eclipse.che.ls.clangd.sh. And than we can run command for generation json like we do it for csharp-ls: "dotnet restore on start csharp-ls" . For csharp we run command "dotnet restore" to restore dotnet dependencies, without them cshape intellisense doesn't work. For clangD we can run cmake command to generate compilation data-source json.
And as I know cmake support generation such json from some version. We should check installation cmake in the container and version cmake. In case if cmake was not installed than install this third-party program.
What do you think @tolusha ?

@tolusha
Copy link
Contributor

tolusha commented Nov 28, 2017

@AndrienkoAleksandr I don't mind.

@hkolvenbach hkolvenbach force-pushed the kolvenbach.clangd_v3 branch 3 times, most recently from f9a44e4 to b5c5681 Compare December 5, 2017 08:18
@hkolvenbach
Copy link
Contributor Author

hkolvenbach commented Dec 5, 2017

@tolusha @AndrienkoAleksandr @evidolob thanks for your responses, we are now continuing to work on it. just another question: what would be the most appropriate way to add the --compile-commands-dir=<compile_commands.json> parameter to the agent launch script? just write a new launch.sh script with the specific compile_commands.json parameter before https://github.com/eclipse/che/pull/7516/files#diff-b0a97402fc623235c7707c20684cfe61R75 for each project?

FYI @thierryk12

@tolusha
Copy link
Contributor

tolusha commented Dec 6, 2017

IMHO it is better choice:

just write a new launch.sh script with the specific compile_commands.json parameter before https://github.com/eclipse/che/pull/7516/files#diff-b0a97402fc623235c7707c20684cfe61R75 for each project?

@hkolvenbach
Copy link
Contributor Author

just a quick update: we have a working compile_commands.json integration internally, but noticed that clangd (or the communication from eclipse che to clangd) is crashing regularly after a few minutes. currently investigating if this is a clangd or eclipse che problem.

@hkolvenbach
Copy link
Contributor Author

by the way: am i correct that eclipse che is not restarting a crashed language server? the VSCode plugin for clangd restarts it once it crashes.

@tolusha
Copy link
Contributor

tolusha commented Dec 12, 2017

@hkolvenbach
You are right, LS won't be restarted in case of crashing.

@hkolvenbach
Copy link
Contributor Author

Quick update (as already told on the community call yesterday):
I will soon update the PR with a Che6 version of the clangd integration (we won't continue on che5)

What is currently working:

  • go to definition
    find_definition
  • autodetect compile_commands.json (clangd feature)
  • refactoring
  • code completion & templates like "for" loops
    for_autocomplete
  • warnings and errors

clangd very much depends on the compile_commands.json file, but if it is present, the results are generally very good. regarding #4991, a quick comparison to cquery also didn't show much differences (comparing latest clangd 6 svn).

There are some open issues regarding the languageserver implemention of che though, which I would like to discuss before we propose changes that break in other languages:

CC @thierryk12

@hkolvenbach
Copy link
Contributor Author

the PR is updated, to test it you need to enable the clangd language server under installers and use silexica/tools:nightly as a base image (it has an integrated clangd binary)

# }
#
## Red Hat Enterprise Linux 6
#############################
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we have to support all possible linux distributions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, i will think about a way to install it through the script

@tolusha
Copy link
Contributor

tolusha commented Jan 10, 2018

@hkolvenbach
I've tested the PR. It seems working well.

@gazarenkov gazarenkov added kind/enhancement A feature request - must adhere to the feature request template. and removed kind/task Internal things, technical debt, and to-do tasks to be performed. labels Jan 14, 2018
Hanno Kolvenbach added 2 commits January 23, 2018 12:25
Signed-off-by: Hanno Kolvenbach <kolvenbach@silexica.com>
};
private static final String MIME_TYPE = "text/x-cpp";

// @Override

Choose a reason for hiding this comment

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

I just would like to remind that we're trying to avoid having comments of such kind when we do merge to master, do you think this section could be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, i will go through it and remove those

import org.eclipse.che.plugin.cpp.projecttype.CppProjectType;
import org.eclipse.plugin.clangd.languageserver.ClangDLanguageServerLauncher;

/** @author Alexander Andrienko */

Choose a reason for hiding this comment

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

Seems like copy/pasted author?

Copy link
Contributor

Choose a reason for hiding this comment

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

No :)

Signed-off-by: Hanno Kolvenbach <kolvenbach@silexica.com>
@hkolvenbach hkolvenbach changed the title WIP: Initial ClangD support for Eclipse Che ClangD support for Eclipse Che Jan 29, 2018
@hkolvenbach
Copy link
Contributor Author

hkolvenbach commented Jan 29, 2018

@dkuleshov I removed the comments. I think the PR is ready to be merged, if there are no more suggestions from you or the Che team.

BTW: I picked clang 6 (will be released soon anyway), because clangD 5 was not working properly with the Che language protocol client

"description": "Clangd intellisense for C/C++ projects.",
"dependencies": [],
"properties": {}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It is supposed to be a new line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

command -v tar >/dev/null 2>&1 || { PACKAGES=${PACKAGES}" tar"; }
command -v curl >/dev/null 2>&1 || { PACKAGES=${PACKAGES}" curl"; }
command -v wget >/dev/null 2>&1 || { PACKAGES=${PACKAGES}" wget"; }
test "$(id -u)" = 0 || SUDO="sudo -E"
Copy link
Contributor

Choose a reason for hiding this comment

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

Have a look at
https://github.com/eclipse/che/blob/2c2bd6637c8169018e2b33397f9d738bbf82a0b1/agents/ls-csharp/src/main/resources/installers/1.0.1/org.eclipse.che.ls.csharp.script.sh#L12

The scripts have been modified. For instance

is_current_user_root() {
    test "$(id -u)" = 0
}

is_current_user_sudoer() {
    sudo -n true > /dev/null 2>&1
}

set_sudo_command() {
    if is_current_user_sudoer && ! is_current_user_root; then SUDO="sudo -E"; else unset SUDO; fi
}

have been added to test if user is sudo or isn't

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, i will take a look!

Signed-off-by: Hanno Kolvenbach <kolvenbach@silexica.com>
Signed-off-by: Hanno Kolvenbach <kolvenbach@silexica.com>
Copy link
Contributor

@tolusha tolusha left a comment

Choose a reason for hiding this comment

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

Pls, update pom.xml to set 6.1.0-SNAPSHOT version.

Signed-off-by: Hanno Kolvenbach <kolvenbach@silexica.com>
@hkolvenbach
Copy link
Contributor Author

done!

@tolusha
Copy link
Contributor

tolusha commented Feb 13, 2018

@vparfonov What are the next steps here?

pom.xml Outdated
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-clangd-lang-server</artifactId>

Copy link
Contributor

Choose a reason for hiding this comment

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

redundant line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Hanno Kolvenbach added 2 commits February 13, 2018 11:35
Signed-off-by: Hanno Kolvenbach <kolvenbach@silexica.com>
Signed-off-by: Hanno Kolvenbach <kolvenbach@silexica.com>
@vparfonov
Copy link
Contributor

ci-build

@codenvy-ci
Copy link

@skabashnyuk
Copy link
Contributor

ci-test

@codenvy-ci
Copy link

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:7516
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@musienko-maxim
Copy link
Contributor

The selenium tests passed without regressions

@vparfonov vparfonov merged commit 0a7cf2e into eclipse-che:master Feb 15, 2018
@hkolvenbach hkolvenbach deleted the kolvenbach.clangd_v3 branch February 16, 2018 08:32
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Feb 23, 2018
@benoitf benoitf added this to the 6.2.0 milestone Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A feature request - must adhere to the feature request template.
Projects
None yet
Development

Successfully merging this pull request may close these issues.