-
Notifications
You must be signed in to change notification settings - Fork 93
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
Using String as return type for Hover participants #582
Conversation
There was a problem hiding this 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 = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a StringBuilder
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 could you merge your 3 commits please in one. |
StringBuilder retValue = new StringBuilder(); | ||
for (String value : values) { | ||
retValue.append(value); | ||
retValue.append("___"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR has been updated.
31f83d9
to
46d9018
Compare
if (kind.equals(MarkupKind.MARKDOWN)) { | ||
for (String value : values) { | ||
retValue.append(value); | ||
retValue.append("___"); |
There was a problem hiding this comment.
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)) {
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this code
46d9018
to
fbc8099
Compare
@@ -0,0 +1,93 @@ | |||
/** | |||
* Copyright (c) 2018 Angelo ZERR. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
fbc8099
to
2f2dab0
Compare
Thanks @Seiphon ! |
No description provided.