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

Add support for quick doc hovers (support for opening files) #149

Merged

Conversation

gayanper
Copy link
Contributor

@gayanper gayanper commented Oct 13, 2019

  • enabled HTML formatting for all content since LSP spec is now sending
    markup content
  • use a textpane with JB html kit to style the documentation
  • add support for lanuguage like java which doesn't inherit from plain
    text language.
  • add support for open source files from links in quick doc hover

quick-docs

});
}
} catch (MalformedURLException | URISyntaxException ex) {
LOGGER.error("Error opening doc link", ex);
Copy link
Contributor

@NipunaRanasinghe NipunaRanasinghe Oct 14, 2019

Choose a reason for hiding this comment

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

Shall we log this as a warning and prompt a message to the user instead of logging as an error? (AFAIR error logs will also be shown as fatal errors, which might make this library looks unstable.. so currently I have to log the exceptions as warnings and I'm not sure whether we have alternatives) WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure may be we can log this as a debug message and show a notification which will be shown in the event log. WDYT ?

Copy link
Contributor

@NipunaRanasinghe NipunaRanasinghe Oct 14, 2019

Choose a reason for hiding this comment

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

I'm afraid that the event log will be noisy if we continue prompting these kind of exceptions since it's shared by all the tools for prompting critical events :/ How about using the IntelliJ Messages API?

Messages.showErrorDialog(message, title);

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 meant to just show a info event in the event log. I don't see that we will get lot of such errors ?
Of cause we can use the Message API but then user will need to close the popup right ? Will that be better from UX point of view ?.

Copy link
Contributor

Choose a reason for hiding this comment

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

@gayanper @NipunaRanasinghe my suggestion is also to move ahead with the Messages API. If we are going to add this into event log; we need to treat & add all error messages in other places in same level and I am afraid that will flood the events log. IMO since this action is user-initiated (clicking the hyperlink); showing error message in a failure won't harm the UX. WDYT?

@nixel2007
Copy link
Contributor

Sorry for offtopic... Could you post some screenshots or gifs with $subject?

@NipunaRanasinghe
Copy link
Contributor

Sorry for offtopic... Could you post some screenshots or gifs with $subject?

Yeah that would be nice

@gayanper
Copy link
Contributor Author

Do you want a gif on the quick doc with clickable links ?

@NipunaRanasinghe
Copy link
Contributor

NipunaRanasinghe commented Oct 28, 2019

@gayanper Hopefully now you can proceed with this by resolving the conflicts as I've merged the other PRs. :) And as @nixel2007 requested, it would be great if you can update the PR description with an sample image/GIF so that the others can see the styling changes, if there are any.

@gayanper
Copy link
Contributor Author

@nixel2007 @NipunaRanasinghe i have update the PR description with a gif.

@nixel2007
Copy link
Contributor

nixel2007 commented Oct 28, 2019

@gayanper sorry, i can't get the idea. what's the difference with regular hovers sent from LS? html support with hrefs as actions? or...?

@gayanper
Copy link
Contributor Author

This is a regular hover, but in this the hyperlinks can be actually clicked and navigate to Files. For example if you click the Type link it will open that class file in java editor. if you click the http link it will be opened in the browser etc.

@nixel2007
Copy link
Contributor

nixel2007 commented Oct 28, 2019

ah, and you open files via URI parsing and VFS. Understood, thanks. Cool!

if ((!LanguageDocumentation.INSTANCE.allForLanguage(language).isEmpty() && !language
.equals(PlainTextLanguage.INSTANCE)) || (!getIsCtrlDown() && !EditorSettingsExternalizable
.getInstance().isShowQuickDocOnMouseOverElement())) {
if ((!LanguageDocumentation.INSTANCE.allForLanguage(language).isEmpty() && !isPlainTextLanguage(language))
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please explain the reason behind this cache based new check?
language.equals(PlainTextLanguage.INSTANCE) isn't working for you?

Copy link
Contributor Author

@gayanper gayanper Oct 29, 2019

Choose a reason for hiding this comment

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

Languages like java doesn't inherit the plain text language. Thats why this new check is added.

Copy link
Contributor

@NipunaRanasinghe NipunaRanasinghe Oct 31, 2019

Choose a reason for hiding this comment

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

Is it not working only for java? how about using a isFileSupported() check from our FileUtils instead, because you are registering a server definition for the java file extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@NipunaRanasinghe i think this is a really good suggestion. I have changed the code now to use FileUtils check.

Copy link
Contributor

Choose a reason for hiding this comment

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

@gayanper great :)

@gayanper gayanper force-pushed the pr/enhance-quick-doc branch 2 times, most recently from 79bb96a to a67af8a Compare October 31, 2019 16:35
@@ -297,6 +296,11 @@ public void mouseMoved(EditorMouseEvent e) {
}
}

private boolean isPlainTextLanguageFile(PsiFile file) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private boolean isPlainTextLanguageFile(PsiFile file) {
private boolean isSupportedLanguageFile(PsiFile file) {

Copy link
Contributor

@NipunaRanasinghe NipunaRanasinghe Nov 7, 2019

Choose a reason for hiding this comment

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

@gayanper WDYT since now we check for the registered server definitions as well?

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 think thats a good suggestion. I made the change and pushed it

@gayanper gayanper force-pushed the pr/enhance-quick-doc branch from a67af8a to 1a95390 Compare November 9, 2019 03:25
- enabled HTML formatting for all content since LSP spec is now sending
markup content
- use a textpane with JB html kit to style the documentation
- add support for lanuguage like java which doesn't inherit from plain
text language.
- add support for open source files from links in quick doc hover
- add support for http urls
@gayanper gayanper force-pushed the pr/enhance-quick-doc branch from 1a95390 to 644ab73 Compare November 9, 2019 03:27
Copy link
Contributor

@NipunaRanasinghe NipunaRanasinghe left a comment

Choose a reason for hiding this comment

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

Looks good!

@NipunaRanasinghe NipunaRanasinghe merged commit 32ea08f into ballerina-platform:master Nov 13, 2019
@gayanper gayanper deleted the pr/enhance-quick-doc branch May 19, 2020 16:35
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.

4 participants