-
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
DTD hover/completion support for documentation #592
Conversation
cfae425
to
503bf4e
Compare
if (documentation != null) { | ||
return documentation; | ||
} | ||
Map<String, String> commentsMap = document.getCommentsMap(); |
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 CMDTDElementDeclaration should provide a new method CMDTDElementDeclaration#getDocumentation(String attrName)
which uses the DTDElementInfo (see next comment)
Replace with
this.documentation = elementDecl.getDocumentation(getName())
@@ -124,6 +127,12 @@ public void startContentModel(String elementName, Augmentations augs) throws XNI | |||
if (hierarchiesMap == null) { | |||
hierarchiesMap = new HashMap<>(); | |||
} | |||
if (commentsMap == null) { |
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 have just one Map hierarchiesMap which stores comment and hierarchies both (as value). To do that, I suggest that you create a private class which holds those information like:
static class DTDElementInfo {
private final Set<String> hierarchies;
private String comment;
public DTDElementInfo() {
this.hierarchies = new LinkedHashSet<String>();
this.comment = null;
}
public Set<String> getHierarchies() {
return hierarchies;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
}
hierarchiesMap should store String as key (like today) and DTDElementInfo as value.
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 @angelozerr , by this way, we can collect the elements' comments and their child elements' comments. But how to collect attributes' commets? We can not just put attributes and its commet to hierarchiesMap, because there are some attributes have same 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.
I forget the attribute case that you could manage like this:
static class DTDNodeInfo {
private String comment;
public DTDNodeInfo() {
this.comment = null;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
}
static class DTDElementInfo extends DTDNodeInfo {
private final Set<String> hierarchies;
private final Map<String, DTDNodeInfo> attributes;
public DTDElementInfo() {
this.hierarchies = new LinkedHashSet<String>();
this.attributes = new HashMap<>();
}
public Set<String> getHierarchies() {
return hierarchies;
}
public String getComment(String attrName) {
DTDNodeInfo attr = attributes.get(attrName);
return attr != null ? attr.getComment() : null;
}
}
commentsMap = new HashMap<>(); | ||
} | ||
if (comment != null) { | ||
commentsMap.put(elementName, comment); |
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.
use DTDElementInfo #setComment
@Seiphon your PR looks promising but I think we should avoir creating a new Map for comments. I think we should have a map which contains information of DTDElementInfo (hierachies + comments) for each element name. See my comment with DTDElementInfo. The second thing is that you support comments for attribute declaration but nor for element delclaration. Please support it too. |
503bf4e
to
1e75d53
Compare
@@ -200,4 +250,46 @@ public LocationLink findTypeLocation(DOMNode node) { | |||
public boolean isDirty() { | |||
return tracker != null ? tracker.isDirty() : null; | |||
} | |||
|
|||
static class DTDNodeInfo { |
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 move those 2 classes on the top of the CMDTDDocument class.
1e75d53
to
d6a6269
Compare
|
||
private static void assertHover(String value, String expectedHoverLabel, Integer expectedHoverOffset) | ||
throws BadLocationException { | ||
XMLAssert.assertHover(new XMLLanguageService(), value, "src/test/resources/catalogs/service.xml", null, |
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.
service.xml doesn't exist as catalog. Please rename service.xml to catalog-liferay.xml and create this file catalog-liferay.xml to references your liferay-service-builder_7_2_0.dtd
For me I think it's a good start, perhaps we will improve it in an another PR (add title, format as markdown etc). Please
|
d6a6269
to
c4e2b1d
Compare
@@ -0,0 +1,51 @@ | |||
<?xml version="1.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.
It's not a XML catalog. Please update this file with
<?xml version="1.0"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<system
systemId="http://www.liferay.com/dtd/liferay-service-builder_7_2_0.dtd"
uri="../dtd/liferay-service-builder_7_2_0.dtd" />
</catalog>
To check that the XML catalog is working and uses the local liferay-service-builder_7_2_0.dtd, disconnect your Internet and try to execute your test.
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 got it. the pr has been updated.
c4e2b1d
to
1bddb88
Compare
2dae487
to
296f9d1
Compare
Fixes eclipse-lemminx#585 Signed-off-by: Seiphon Wang <seiphon.wang@liferay.com>
296f9d1
to
9286aa0
Compare
Hi @angelozerr, is that ok if I use commit description as follows:
Is the title of the commit not corrent? or should I use |
yes it's perfect! |
Thanks a lot @Seiphon for your great PR! |
No description provided.