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

Autocompletion of attribute values won't display documentation #736

Closed
bimimicah opened this issue Jul 13, 2022 · 12 comments · Fixed by eclipse/lemminx#1260
Closed

Autocompletion of attribute values won't display documentation #736

bimimicah opened this issue Jul 13, 2022 · 12 comments · Fixed by eclipse/lemminx#1260
Labels
bug Something isn't working completion hover
Milestone

Comments

@bimimicah
Copy link

Documentation appears properly when autocompleting attribute names:
image
But when autocompleting attribute values (xs:enumeration), the documentation does not appear:
image

I think it used to work, but I'm not entirely certain. Has anyone else noticed this issue? Is it working for anyone?

@fbricon
Copy link
Collaborator

fbricon commented Jul 13, 2022

can you provide a self contained sample reproducing this issue?

@bimimicah
Copy link
Author

Ok. So it looks like when one or more <xs:enumeration> do not have documentation, it breaks the documentation for all enums for that attribute.

Example Document:

<?xml version="1.0" encoding="utf-8"?>
<root attribute="value1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd" />

Example Schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:element name="root">
		<xs:annotation>
			<xs:documentation>Documentation for root element</xs:documentation>
		</xs:annotation>
		<xs:complexType>
			<xs:attribute name="attribute">
				<xs:annotation>
					<xs:documentation>Documentation for attribute</xs:documentation>
				</xs:annotation>
				<xs:simpleType>
					<xs:restriction base="xs:string">
						<xs:enumeration value="value1">
							<xs:annotation>
								<xs:documentation>Documentation for attribute value1</xs:documentation>
							</xs:annotation>
						</xs:enumeration>
						<xs:enumeration value="value2" /> <!-- this one has no documentation. if you delete this line, documentation displays properly for 'value1' -->
					</xs:restriction>
				</xs:simpleType>
			</xs:attribute>
		</xs:complexType>
	</xs:element>
</xs:schema>

@bimimicah bimimicah changed the title Autocompletion of attribute values is missing documentation Autocompletion of attribute values won't display documentation Jul 15, 2022
@bimimicah
Copy link
Author

So it looks like there are 2 problems:

  1. If you have multiple <xs:enumeration> elements, but one (or more) do not have a <xs:documentation> sub-element, then documentation will not pop up for any of that attribute's enumerated values, even the ones which have documentation. This applies to the autocomplete dropdown as well as hover documentation over the attribute value in the source code.
  2. If you create the attribute (instead of typing manually) by typing a space, the first letter, then choose the attribute name from the dropdown, the attribute will be autocompleted, and the enumerated attribute values will appear in a dropdown, as expected. However, none of them will display documentation, even if all of them have documentation in the xsd.

@bimimicah
Copy link
Author

@fbricon Were you able to reproduce the issues with the sample I provided? Thanks for looking into this.

@angelozerr
Copy link
Contributor

I can reproduce the problem @bimimicah.

Many thanks for your sample. Let us investigate the problem.

@angelozerr angelozerr added bug Something isn't working completion hover labels Jul 26, 2022
angelozerr pushed a commit to angelozerr/lemminx that referenced this issue Jul 26, 2022
angelozerr pushed a commit to angelozerr/lemminx that referenced this issue Jul 26, 2022
angelozerr pushed a commit to angelozerr/lemminx that referenced this issue Jul 26, 2022
@angelozerr
Copy link
Contributor

angelozerr commented Jul 26, 2022

@bimimicah I created a PR which should fix your issue, see demo at:

eclipse/lemminx#1260 (comment)

angelozerr pushed a commit to eclipse/lemminx that referenced this issue Jul 29, 2022
@angelozerr angelozerr added this to the 0.22.0 milestone Jul 29, 2022
@bimimicah
Copy link
Author

I tried the pre-release build of lemminx built 6 days ago, and it looks like problem # 1 has been solved completely! Thank you!

However, it looks like that didn't solve the second problem:

  • If you create the attribute (instead of typing manually) by typing a space, the first letter, then choose the attribute name from the dropdown, the attribute will be autocompleted, and the enumerated attribute values will appear in a dropdown, as expected. However, none of them will display documentation, even if all of them have documentation in the xsd.

For illustration:

image

  • Type <space>, then 'a'

image

  • Press <tab>

image

Thank you again for your quick solution to the first problem!

@bimimicah
Copy link
Author

@angelozerr should I make a new issue for the second part that hasn't been solved yet, since this issue is closed?

@angelozerr
Copy link
Contributor

I fear that it is not possible to support the second problem because it is not supported by the lsp specification. In otherwise when completion item is applied you can define a simple list of string value called choice but without specifying à documentation.

@bimimicah
Copy link
Author

I may be misunderstanding, since I am not very familiar with the details of LSP implementations, but shouldn't the process I illustrated above work like this?:

  1. user types 'a', triggers a textDocument/completion call to the LSP server (for the attributes beginning with 'a'), returning a list of completion items including documentation
  2. user selects the item from the list and presses <tab>, choosing the completion item, and triggering a second textDocument/completion call to the LSP server (for the chosen attribute's values), which should also return a list of completion items including documentation?

@angelozerr
Copy link
Contributor

I see your idea but it will require some hack on client side so it will require to do this Hack for vscode eclipe sublime etc wuich is not the goal of lsp.

Please create an issue for this problem. Perhaps there is a solution that I miss with lsp . We should study in détail the mroblem.

@bimimicah
Copy link
Author

Thanks. I created #760 to track the second problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working completion hover
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants