Skip to content

Commit

Permalink
Fix build (see #214)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelozerr committed Nov 10, 2018
1 parent e567943 commit 1d83bea
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,24 @@ public void onTagOpen(ICompletionRequest request, ICompletionResponse response)
try {
Element parentElement = request.getParentElement();
if (parentElement == null) {
// XML is empty, in case of XML file associations, a XMl Schema/DTD can be bound
// check if it's root element (in the case of XML file associations, the link to
// XML Schema is done with pattern and not with XML root element)
CMDocument cmDocument = ContentModelManager.getInstance().findCMDocument(request.getXMLDocument(),
null);
if (cmDocument != null) {
fillWithChildrenElementDeclaration(null, cmDocument.getElements(), request, response);
fillWithChildrenElementDeclaration(null, cmDocument.getElements(), null, false, request, response);
}
return;
}
// Try to retrieve XML Schema/DTD element declaration for the parent element
// where completion was triggered.
CMElementDeclaration cmElement = ContentModelManager.getInstance().findCMElement(parentElement);
String defaultPrefix = null;
if (cmElement != null) {
defaultPrefix = parentElement.getPrefix();
fillWithChildrenElementDeclaration(parentElement, cmElement.getElements(), request, response);
fillWithChildrenElementDeclaration(parentElement, cmElement.getElements(), defaultPrefix, false,
request, response);
}
if (parentElement.isDocumentElement()) {
// root document element
Expand All @@ -66,7 +70,8 @@ public void onTagOpen(ICompletionRequest request, ICompletionResponse response)
CMDocument cmDocument = ContentModelManager.getInstance().findCMDocument(parentElement,
namespaceURI);
if (cmDocument != null) {
fillWithChildrenElementDeclaration(parentElement, cmDocument.getElements(), request, response);
fillWithChildrenElementDeclaration(parentElement, cmDocument.getElements(), prefix, true,
request, response);
}
}
}
Expand All @@ -76,10 +81,11 @@ public void onTagOpen(ICompletionRequest request, ICompletionResponse response)
}

private void fillWithChildrenElementDeclaration(Element element, Collection<CMElementDeclaration> cmElements,
ICompletionRequest request, ICompletionResponse response) throws BadLocationException {
String p, boolean forceUseOfPrefix, ICompletionRequest request, ICompletionResponse response)
throws BadLocationException {
XMLGenerator generator = request.getXMLGenerator();
for (CMElementDeclaration child : cmElements) {
String prefix = element != null ? element.getPrefix(child.getNamespace()) : null;
String prefix = forceUseOfPrefix ? p : (element != null ? element.getPrefix(child.getNamespace()) : null);
String label = child.getName(prefix);
CompletionItem item = new CompletionItem(label);
item.setFilterText(request.getFilterForStartTagName(label));
Expand Down

0 comments on commit 1d83bea

Please sign in to comment.