Skip to content

Commit

Permalink
GH-1163: fixed problem with content-assist not showing up for fully q…
Browse files Browse the repository at this point in the history
…ualified beans root element
  • Loading branch information
martinlippert committed Jan 18, 2024
1 parent 9784b2a commit b6d5e89
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ public Collection<ICompletionProposal> getCompletions(TextDocument doc, int offs
case AttributeName:
if (scanner.getTokenOffset() <= offset && offset < scanner.getTokenEnd()) {
if (node.getParentNode() != null && node.getParentNode() instanceof DOMDocument
&& namespace.equals("http://www.springframework.org/schema/beans") && node.getNodeName().equals("beans")) {
&& namespace.equals("http://www.springframework.org/schema/beans") && node.getLocalName().equals("beans")) {
return NamespaceCompletionProvider.createNamespaceCompletionProposals(doc, offset, token, node);
}
}
break;
case Whitespace:
if (scanner.getTokenOffset() <= offset && offset < scanner.getTokenEnd()) {
if (node.getParentNode() != null && node.getParentNode() instanceof DOMDocument
&& namespace.equals("http://www.springframework.org/schema/beans") && node.getNodeName().equals("beans")) {
&& namespace.equals("http://www.springframework.org/schema/beans") && node.getLocalName().equals("beans")) {
return NamespaceCompletionProvider.createNamespaceCompletionProposals(doc, offset, token, node);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,29 @@ void testAddNamespaceCompletion5() throws Exception {
editorContent);
}

@Test
void testAddNamespaceCompletionWhenBeansElementFullyQualified() throws Exception {
Editor editor = new Editor(harness, """
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
<*>
xsi:schemaLocation="http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
<!-- Root Context: defines shared resources visible to all other web components -->
<bean id="simpleObj" class="u.t.r.SimpleObj"></bean>
</beans>
""",
LanguageId.XML);

List<CompletionItem> completions = editor.getCompletions();
assertEquals(ALL_NAMESPACE_COMPLETIONS, completions.size());
}

@Test
void testNoNamespaceCompletionOutsideOfMainElement1() throws Exception {
Expand Down

0 comments on commit b6d5e89

Please sign in to comment.