Skip to content

Don't throw an exception if none LS was found#11094

Merged
svor merged 1 commit into5730_java_ls_pocfrom
11091
Sep 12, 2018
Merged

Don't throw an exception if none LS was found#11094
svor merged 1 commit into5730_java_ls_pocfrom
11091

Conversation

@svor
Copy link
Copy Markdown
Contributor

@svor svor commented Sep 6, 2018

Signed-off-by: Valeriy Svydenko vsvydenk@redhat.com

What does this PR do?

  1. Add a way to check if jdt.ls installer exists in workspace's configuration;
  2. Add initialization methods which is called when workspace is ready;
  3. Don't ask for Java compiler options when workspace is running.

What issues does this PR fix or reference?

#11091

Release Notes

Docs PR

@svor svor added kind/bug Outline of a bug - must adhere to the bug report template. status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. target/branch Indicates that a PR will be merged into a branch other than master. team/languages labels Sep 6, 2018
@svor svor self-assigned this Sep 6, 2018
@svor svor requested review from tolusha and tsmaeder September 6, 2018 09:17
@svor svor requested a review from vparfonov as a code owner September 6, 2018 09:17
Copy link
Copy Markdown
Contributor

@tsmaeder tsmaeder left a comment

Choose a reason for hiding this comment

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

Generally, I think we should do most of the work in the back end.

e -> {
subscribe();
hasJDTLSInstallerAdded = checkJDTLSInstaller();
initializeJDTLS();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we want to start jdt.ls as soon as the workspace starts, we should do so in wsagent. For example, the current approach would try to initialize jdt.ls from ever open IDE. If we handle immediate startup on the back end, we don't have any such problems.

WorkspaceReadyEvent.getType(),
e -> {
subscribe();
hasJDTLSInstallerAdded = checkJDTLSInstaller();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the workspace is restarted, this might not be true anymore. You can restart the workspace without restarting the IDE:


@Override
public Promise<Map<String, String>> loadPreferences() {
if (!service.hasJDTLSInstallerAdded()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you follow the call hierarachy from here, this is only called early to populate CurrentUser#getPreferences(). But that method is never called at all. Maybe we can remove that method?

if (!service.hasJDTLSInstallerAdded()) {
return promiseProvider.resolve(newHashMap());
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are we not ensuring jdt.ls is enabled in the back end like we do for JavaLanguageServerExtensionService#executeCommand()? That would have the same effect, basically and be a one-liner.

@tsmaeder tsmaeder mentioned this pull request Sep 11, 2018
19 tasks
@svor svor requested a review from dkulieshov as a code owner September 12, 2018 11:30
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
@svor svor changed the title Rework initialisation of JDT.LS Don't throw an exception if none LS was found Sep 12, 2018
@svor
Copy link
Copy Markdown
Contributor Author

svor commented Sep 12, 2018

@tsmaeder I've updated the PR. Please take another look at it.

return doGetOne(Commands.GET_JAVA_CORE_OPTIONS_СOMMAND, new ArrayList<>(filter), type);
JavaCoreOptions result =
doGetOne(Commands.GET_JAVA_CORE_OPTIONS_СOMMAND, new ArrayList<>(filter), type);
return result == null ? new JavaCoreOptions() : result;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need the null check? Shoudn't this return a result or throw an exception?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's better to return empty map of java compiler options than null, if jdt.ls wasn't initialized

@svor svor merged commit db8cb38 into 5730_java_ls_poc Sep 12, 2018
@svor svor deleted the 11091 branch September 12, 2018 17:02
tsmaeder pushed a commit that referenced this pull request Sep 13, 2018
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
@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 Sep 18, 2018
tsmaeder pushed a commit that referenced this pull request Sep 20, 2018
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
tsmaeder pushed a commit that referenced this pull request Sep 26, 2018
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
tsmaeder pushed a commit that referenced this pull request Oct 1, 2018
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
@tsmaeder tsmaeder mentioned this pull request Oct 2, 2018
15 tasks
tsmaeder pushed a commit that referenced this pull request Oct 5, 2018
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
tsmaeder pushed a commit that referenced this pull request Oct 12, 2018
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
tsmaeder pushed a commit that referenced this pull request Oct 16, 2018
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
tsmaeder pushed a commit that referenced this pull request Oct 17, 2018
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
tsmaeder pushed a commit that referenced this pull request Oct 17, 2018
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
tsmaeder pushed a commit that referenced this pull request Oct 17, 2018
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
tsmaeder pushed a commit that referenced this pull request Oct 17, 2018
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
tsmaeder pushed a commit that referenced this pull request Oct 17, 2018
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Outline of a bug - must adhere to the bug report template. target/branch Indicates that a PR will be merged into a branch other than master.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants