Skip to content

Fixed golang language server hover bug#9874

Merged
dkulieshov merged 1 commit intomasterfrom
che#9781
Jun 4, 2018
Merged

Fixed golang language server hover bug#9874
dkulieshov merged 1 commit intomasterfrom
che#9781

Conversation

@dkulieshov
Copy link
Copy Markdown

Related issue #9781

Added default hover and occurrences provider initialization, moved default extension to mime type mappings to a separate class.

Signed-off-by: Dmytro Kulieshov <dkuliesh@redhat.com>
@dkulieshov dkulieshov requested a review from vparfonov May 30, 2018 13:12
@dkulieshov dkulieshov requested a review from evidolob as a code owner May 30, 2018 13:12
@dkulieshov
Copy link
Copy Markdown
Author

ci-test

@ghost
Copy link
Copy Markdown

ghost commented May 30, 2018

Everything works as expected - hovers do appear and display info they should display - type, docs etc

@codenvy-ci
Copy link
Copy Markdown

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

@dkulieshov dkulieshov requested a review from musienko-maxim May 31, 2018 08:20
@tsmaeder
Copy link
Copy Markdown
Contributor

tsmaeder commented May 31, 2018

Could you please state what the problem was and how this PR fixes it? I'd like to evaluate the potential impact on jdt.ls work.

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.

I think this PR uses the wrong approach. We should configure hovers, etc. based on contributions. We have the possibility to contribute through configuration and through injection. Let's get rid of the default mappings.

/** @author Dmytro Kulieshov */
@Singleton
public class DefaultExtensionToMimeTypeMappings {
private final Map<String, Set<String>> mappings =
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.

We can make this static, it's immutable for the lifetime of the class. Lazy initialization/dependency injection gives no advantage here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We can make this static, it's immutable for the lifetime of the class. Lazy initialization/dependency injection gives no advantage here.

Besides the fact that it preserves architectural homogeneity of the system and simplifies unit tests composition.

/** The known extensions registry. */
Map<String, List<String>> mappings = new HashMap<>();

public ExtensionFileTypeIdentifier() {
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.

It would have been a much simpler fix to simply register the mime types for hover here instead of refactoring stuff.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

As I remember we have already discussed this in another pull request, in general my attitude stays the same - my preference is to do it the most appropriate and simple way, not just simple way. If you experience difficulties in understanding I would recommend you to become more familiar with such concepts as decomposition, code refactoring and single responsibility principle. In our case there are several quite different components and their corresponding responsibilities: file type identification, default mime types registration, hover configuration initialization. Please just ping me if you need any other assistance.

@dkulieshov
Copy link
Copy Markdown
Author

I think this PR uses the wrong approach. We should configure hovers, etc. based on contributions. We have the possibility to contribute through configuration and through injection. Let's get rid of the default mappings.

@tsmaeder I find it strange that you've missed that during your review, but actually this pull request does not take away ability to configure hovers, it simply adds the default set of configurations for hovers, which may be (and for most supported languages is) overriden by contributed configurations (e.g. through injection). So when you say "we should configure hovers" and imply that this pull request disables that feature I find myself confused and puzzled.

@vparfonov
Copy link
Copy Markdown
Contributor

@tsmaeder I think this PR doesn't have any influence to the jdt.ls. Proposal provided by @dkuleshov just work and I don't see any technical mistake on it. We discus this solution internal before start implementation. If you have idea how to implement it in better way you can provide own PR

@musienko-maxim
Copy link
Copy Markdown
Contributor

We did not find regression in the functionality that is covered by selenium tests. Also we checked LS features according to manual testplan: https://github.com/eclipse/che/wiki/Test-plan-for-checking-Language-servers. The main features worked properly.

@tsmaeder
Copy link
Copy Markdown
Contributor

What I was commenting on is that the default mime types were introduced as a workaround for the fact that we could not contribute mime types for language servers defined in the workspace config only. What I propose is that it would be more useful to remove the original limitation instead of fixing the workaround.

@tsmaeder
Copy link
Copy Markdown
Contributor

tsmaeder commented Jun 1, 2018

Thinking about it overnight, I am wondering why we have a special entity for the default mime types. Why are we not simply contributing default LanguageDescription instances? Then all the hover-, etc. registration would be in one place. Methinks that would make the code simpler.

@dkulieshov
Copy link
Copy Markdown
Author

dkulieshov commented Jun 1, 2018

@tsmaeder

Thinking about it overnight, I am wondering why we have a special entity for the default mime types. Why are we not simply contributing default LanguageDescription instances? Then all the hover-, etc. registration would be in one place. Methinks that would make the code simpler.

That's a reasonable suggestion, my only concern is how we will distinguish the default LanguageDescription and the custom one. Actually @vparfonov and I discussed exactly the same idea to be the first viable solution. However we assumed that addition of a dozen of default language descriptions along with the mechanism that will allow us to set priorities for language descriptions (to make possible to override default descriptions by custom ones) would have larger impact on the code base. So we decided just to add a hover provider initializer for default mime types and keep the rest of the algorithms untouched.

Ideal solution I believe is to move language description to some configuration (like workspace configuration) so we could configure languages on demand w/o recompilation, however I have not clear vision on how we can do that now.

WDYT @vparfonov

@vparfonov
Copy link
Copy Markdown
Contributor

vparfonov commented Jun 4, 2018

For now i prefer current proposal in future will se maybe we will found better solution. Anyone can propose new PR. So goto merge this one

@dkulieshov dkulieshov merged commit af39ba2 into master Jun 4, 2018
@dkulieshov dkulieshov deleted the che#9781 branch June 4, 2018 13:15
@benoitf benoitf added the kind/bug Outline of a bug - must adhere to the bug report template. label Jun 4, 2018
@benoitf benoitf added this to the 6.7.0 milestone Jun 4, 2018
hbhargav pushed a commit to hbhargav/che that referenced this pull request Dec 5, 2018
Signed-off-by: Dmytro Kulieshov <dkuliesh@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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants