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

Using String as return type for Hover participants #582

Merged
merged 1 commit into from
Oct 23, 2019

Conversation

Seiphon
Copy link
Contributor

@Seiphon Seiphon commented Oct 22, 2019

No description provided.

Copy link
Contributor

@fbricon fbricon left a comment

Choose a reason for hiding this comment

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

Can you please provide tests checking hover aggregation

}
return new MarkupContent(MarkupKind.PLAINTEXT, values.get(0));
}
String retValue = "";
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use a StringBuilder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I will uddate

/**
* Hover participant API.
*
*/
public interface IHoverParticipant {

Hover onTag(IHoverRequest request) throws Exception;
String onTag(IHoverRequest request) throws Exception;
Copy link
Contributor

Choose a reason for hiding this comment

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

Add javadoc.


Hover onAttributeName(IHoverRequest request) throws Exception;
String onAttributeName(IHoverRequest request) throws Exception;
Copy link
Contributor

Choose a reason for hiding this comment

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

Add javadoc.


Hover onAttributeValue(IHoverRequest request) throws Exception;
String onAttributeValue(IHoverRequest request) throws Exception;
Copy link
Contributor

Choose a reason for hiding this comment

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

Add javadoc.

* of the client.
*/
public static MarkupContent creatMarkupContent(List<String> values, IMarkupKindSupport request) {
if (values.size() ==1) {
Copy link
Contributor

@angelozerr angelozerr Oct 22, 2019

Choose a reason for hiding this comment

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

MarkupKind kind = request.canSupportMarkupKind(MarkupKind.MARKDOWN) ?  MarkupKind.MARKDOWN : MarkupKind.PLAINTEXT;

and after that you use this kind variable in the next code

if (request.canSupportMarkupKind(MarkupKind.MARKDOWN)) {
return new MarkupContent(MarkupKind.MARKDOWN, values.get(0));
}
return new MarkupContent(MarkupKind.PLAINTEXT, values.get(0));
Copy link
Contributor

Choose a reason for hiding this comment

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

return new MarkupContent(kind, values.get(0));

if (request.canSupportMarkupKind(MarkupKind.MARKDOWN)) {
return new MarkupContent(MarkupKind.MARKDOWN, retValue);
}
return new MarkupContent(MarkupKind.PLAINTEXT, retValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

return new MarkupContent(kind, retValue);

}
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "While performing IHoverParticipant#onTag", e);
}
}
if (!contentValues.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

share this code in private static method createHover to use it with other on* method.

"Cannot process " + (e.isDTD() ? "DTD" : "XML Schema") + " hover: " + e.getMessage(),
MarkupKind.MARKDOWN, support);
return new Hover(content);
return MarkdownConverter.convert("Cannot process " + (e.isDTD() ? "DTD" : "XML Schema") + " hover: " + e.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to check if client support markdown to convert it to markdown.

String value = "Cannot process " + (e.isDTD() ? "DTD" : "XML Schema") + " hover: " + e.getMessage();
return support.canSupportMarkupKind(MarkupKind.MARKDOWN) ? MarkdownConverter.convert(value) : value;

}
String retValue = "";
for (String value : values) {
retValue = retValue + value + System.lineSeparator();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should separate several hover value (only in markdown?) with '___' like vscode does
microsoft/vscode-languageserver-node#417 (comment)

We need to see the result in Eclipse IDE and vscode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, got it. I will update this PR with all above problems resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, I am wandering if we use '___' to separate hover values, we need to handle it on LSP client, right? otherwise it will looks very ugly.

Copy link
Contributor

Choose a reason for hiding this comment

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

My idea was to generate line breaks (only if client can support markdown) https://www.markdownguide.org/basic-syntax/#horizontal-rules

@Seiphon Seiphon requested a review from fbricon October 23, 2019 07:30
@angelozerr
Copy link
Contributor

@Seiphon could you merge your 3 commits please in one.

StringBuilder retValue = new StringBuilder();
for (String value : values) {
retValue.append(value);
retValue.append("___");
Copy link
Contributor

Choose a reason for hiding this comment

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

What about with plaintext? I think we should generate that only for markdown and generate a System.lineSeparator() in another case.

Copy link
Contributor Author

@Seiphon Seiphon Oct 23, 2019

Choose a reason for hiding this comment

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

Sorry just saw your last reply. I will update this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR has been updated.

@Seiphon Seiphon force-pushed the hover-return-type-change branch from 31f83d9 to 46d9018 Compare October 23, 2019 07:50
if (kind.equals(MarkupKind.MARKDOWN)) {
for (String value : values) {
retValue.append(value);
retValue.append("___");
Copy link
Contributor

Choose a reason for hiding this comment

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

Do this test here if (kind.equals(MarkupKind.MARKDOWN)) {

Copy link
Contributor

Choose a reason for hiding this comment

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

I think retValue.append(System.lineSeparator() ); must be done for all kind, no?

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, you are right. I will modify it.
For the test, it only test when kind is markdown. should I add test for plaintext kind?

Copy link
Contributor

Choose a reason for hiding this comment

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

we have not this kind of test. I think it's fine now. But please merge your 3 commits in once and after that I think we will able to merge your PR

}
}
else {
for (String value : values) {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this code

@Seiphon Seiphon force-pushed the hover-return-type-change branch from 46d9018 to fbc8099 Compare October 23, 2019 08:28
@@ -0,0 +1,93 @@
/**
* Copyright (c) 2018 Angelo ZERR.
Copy link
Contributor

Choose a reason for hiding this comment

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

Add Liferay header or your name

Copy link
Contributor Author

@Seiphon Seiphon Oct 23, 2019

Choose a reason for hiding this comment

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

OK, @angelozerr , one more thing.
I found if we only use one System.lineSeparator(), it does'nt work(on Eclipse). And if I use two of them, it will looks much better.
Screenshot (24)
Screenshot (26)
1571823642(1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do you think, should we use two line separator?

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems LSP4E required that but what about with vscode?

Copy link
Contributor Author

@Seiphon Seiphon Oct 23, 2019

Choose a reason for hiding this comment

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

Sorry, just saw it. I believe it won't hurt anything on vscode. If someday we find some problems which caused by it on vscode, we can go back here, and discuss about it.

@Seiphon Seiphon force-pushed the hover-return-type-change branch from fbc8099 to 2f2dab0 Compare October 23, 2019 10:10
@angelozerr angelozerr changed the title Using String as return type for Hover paricipants Using String as return type for Hover participants Oct 23, 2019
@angelozerr angelozerr merged commit 0e09b21 into eclipse-lemminx:master Oct 23, 2019
@angelozerr
Copy link
Contributor

Thanks @Seiphon !

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.

3 participants