From 20c3819eff2f40b1b231cc753989c7296886d0de Mon Sep 17 00:00:00 2001 From: azerr Date: Mon, 22 Jul 2019 12:18:36 +0200 Subject: [PATCH] Hover markup kind response ignores the hover client capability Fix #525 Signed-off-by: azerr --- .../eclipse/lsp4xml/XMLLanguageServer.java | 4 +- .../lsp4xml/XMLTextDocumentService.java | 10 +++-- .../ContentModelHoverParticipant.java | 44 ++++++++----------- .../lsp4xml/services/CompletionRequest.java | 6 +-- .../lsp4xml/services/HoverRequest.java | 32 +++++++++++++- .../lsp4xml/services/XMLCompletions.java | 4 +- .../eclipse/lsp4xml/services/XMLFoldings.java | 8 ++-- .../eclipse/lsp4xml/services/XMLHover.java | 20 +++++---- .../lsp4xml/services/XMLLanguageService.java | 21 +++++---- .../extensions/ICompletionRequest.java | 3 +- .../services/extensions/IHoverRequest.java | 4 ++ .../lsp4xml/settings/SharedSettings.java | 20 +++++---- .../XMLCompletionSettings.java} | 10 ++--- .../lsp4xml/settings/XMLFoldingSettings.java | 33 ++++++++++++++ .../settings/XMLGeneralClientSettings.java | 7 ++- .../lsp4xml/settings/XMLHoverSettings.java | 30 +++++++++++++ .../XMLIncrementalSupportSettings.java | 32 -------------- .../java/org/eclipse/lsp4xml/XMLAssert.java | 12 ++--- .../DTDCompletionExtensionsTest.java | 4 +- .../PrologCompletionExtensionsTest.java | 10 ++--- .../xsi/XSICompletionExtensionsTest.java | 4 +- .../lsp4xml/services/XMLCompletionTest.java | 6 +-- .../lsp4xml/services/XMLFoldingsTest.java | 5 ++- 23 files changed, 200 insertions(+), 129 deletions(-) rename org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/{services/extensions/CompletionSettings.java => settings/XMLCompletionSettings.java} (86%) create mode 100644 org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLFoldingSettings.java create mode 100644 org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLHoverSettings.java delete mode 100644 org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLIncrementalSupportSettings.java diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/XMLLanguageServer.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/XMLLanguageServer.java index 39a508c9e4..d2cae3e62c 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/XMLLanguageServer.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/XMLLanguageServer.java @@ -41,8 +41,8 @@ import org.eclipse.lsp4xml.logs.LogHelper; import org.eclipse.lsp4xml.services.IXMLDocumentProvider; import org.eclipse.lsp4xml.services.XMLLanguageService; -import org.eclipse.lsp4xml.services.extensions.CompletionSettings; import org.eclipse.lsp4xml.settings.AllXMLSettings; +import org.eclipse.lsp4xml.settings.XMLCompletionSettings; import org.eclipse.lsp4xml.settings.InitializationOptionsSettings; import org.eclipse.lsp4xml.settings.LogsSettings; import org.eclipse.lsp4xml.settings.ServerSettings; @@ -141,7 +141,7 @@ public synchronized void updateSettings(Object initializationOptionsSettings) { xmlTextDocumentService.getSharedFormattingSettings().merge(formatterSettings); } - CompletionSettings newCompletions = xmlClientSettings.getCompletion(); + XMLCompletionSettings newCompletions = xmlClientSettings.getCompletion(); if (newCompletions != null) { xmlTextDocumentService.updateCompletionSettings(newCompletions); } diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/XMLTextDocumentService.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/XMLTextDocumentService.java index 308b1939e1..530932dfa4 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/XMLTextDocumentService.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/XMLTextDocumentService.java @@ -73,10 +73,10 @@ import org.eclipse.lsp4xml.dom.DOMParser; import org.eclipse.lsp4xml.extensions.contentmodel.settings.XMLValidationSettings; import org.eclipse.lsp4xml.services.XMLLanguageService; -import org.eclipse.lsp4xml.services.extensions.CompletionSettings; import org.eclipse.lsp4xml.services.extensions.save.AbstractSaveContext; import org.eclipse.lsp4xml.settings.SharedSettings; import org.eclipse.lsp4xml.settings.XMLCodeLensSettings; +import org.eclipse.lsp4xml.settings.XMLCompletionSettings; import org.eclipse.lsp4xml.settings.XMLFormattingOptions; import org.eclipse.lsp4xml.settings.XMLSymbolSettings; import org.eclipse.lsp4xml.utils.XMLPositionUtility; @@ -148,8 +148,9 @@ public void updateClientCapabilities(ClientCapabilities capabilities, ExtendedClientCapabilities extendedClientCapabilities) { TextDocumentClientCapabilities textDocumentClientCapabilities = capabilities.getTextDocument(); if (textDocumentClientCapabilities != null) { - // Completion settings sharedSettings.getCompletionSettings().setCapabilities(textDocumentClientCapabilities.getCompletion()); + sharedSettings.getFoldingSettings().setCapabilities(textDocumentClientCapabilities.getFoldingRange()); + sharedSettings.getHoverSettings().setCapabilities(textDocumentClientCapabilities.getHover()); codeActionLiteralSupport = textDocumentClientCapabilities.getCodeAction() != null && textDocumentClientCapabilities.getCodeAction().getCodeActionLiteralSupport() != null; hierarchicalDocumentSymbolSupport = textDocumentClientCapabilities.getDocumentSymbol() != null @@ -180,7 +181,8 @@ public CompletableFuture, CompletionList>> completio @Override public CompletableFuture hover(TextDocumentPositionParams params) { return computeDOMAsync(params.getTextDocument(), (cancelChecker, xmlDocument) -> { - return getXMLLanguageService().doHover(xmlDocument, params.getPosition(), cancelChecker); + return getXMLLanguageService().doHover(xmlDocument, params.getPosition(), sharedSettings.getHoverSettings(), + cancelChecker); }); } @@ -438,7 +440,7 @@ private XMLLanguageService getXMLLanguageService() { return xmlLanguageServer.getXMLLanguageService(); } - public void updateCompletionSettings(CompletionSettings newCompletion) { + public void updateCompletionSettings(XMLCompletionSettings newCompletion) { sharedSettings.getCompletionSettings().merge(newCompletion); } diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/extensions/contentmodel/participants/ContentModelHoverParticipant.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/extensions/contentmodel/participants/ContentModelHoverParticipant.java index 37453c616e..81785cb4aa 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/extensions/contentmodel/participants/ContentModelHoverParticipant.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/extensions/contentmodel/participants/ContentModelHoverParticipant.java @@ -22,7 +22,6 @@ import org.eclipse.lsp4xml.services.extensions.HoverParticipantAdapter; import org.eclipse.lsp4xml.services.extensions.IHoverRequest; import org.eclipse.lsp4xml.uriresolver.CacheResourceDownloadingException; -import org.eclipse.lsp4xml.utils.MarkdownConverter; /** * Extension to support XML hover based on content model (XML Schema completion, @@ -39,22 +38,19 @@ public Hover onTag(IHoverRequest hoverRequest) throws Exception { if (cmElement != null) { String doc = cmElement.getDocumentation(); if (doc != null && doc.length() > 0) { - String markdown = MarkdownConverter.convert(doc); - MarkupContent content = new MarkupContent(); - content.setKind(MarkupKind.MARKDOWN); - content.setValue(markdown); + MarkupContent content = hoverRequest.createMarkupContent(doc, MarkupKind.MARKDOWN); return new Hover(content, hoverRequest.getTagRange()); } } } catch (CacheResourceDownloadingException e) { - return getCacheWarningHover(e); + return getCacheWarningHover(e, hoverRequest); } return null; } @Override public Hover onAttributeName(IHoverRequest hoverRequest) throws Exception { - + DOMAttr attribute = (DOMAttr) hoverRequest.getNode(); try { @@ -66,15 +62,13 @@ public Hover onAttributeName(IHoverRequest hoverRequest) throws Exception { if (cmAttribute != null) { String doc = cmAttribute.getDocumentation(); if (doc != null && doc.length() > 0) { - MarkupContent content = new MarkupContent(); - content.setKind(MarkupKind.PLAINTEXT); - content.setValue(doc); + MarkupContent content = hoverRequest.createMarkupContent(doc, MarkupKind.MARKDOWN); return new Hover(content); } } } } catch (CacheResourceDownloadingException e) { - return getCacheWarningHover(e); + return getCacheWarningHover(e, hoverRequest); } return null; } @@ -83,44 +77,42 @@ public Hover onAttributeName(IHoverRequest hoverRequest) throws Exception { public Hover onAttributeValue(IHoverRequest hoverRequest) throws Exception { DOMAttr attribute = (DOMAttr) hoverRequest.getNode(); - //Attempts to compute specifically for XSI related attributes since - //the XSD itself does not have enough information. Should create a mock XSD eventually. + // Attempts to compute specifically for XSI related attributes since + // the XSD itself does not have enough information. Should create a mock XSD + // eventually. Hover temp = XSISchemaModel.computeHoverResponse(attribute, hoverRequest); - if(temp != null) { + if (temp != null) { return temp; } - + try { ContentModelManager contentModelManager = hoverRequest.getComponent(ContentModelManager.class); - + CMElementDeclaration cmElement = contentModelManager.findCMElement(attribute.getOwnerElement()); if (cmElement != null) { String attributeName = attribute.getName(); CMAttributeDeclaration cmAttribute = cmElement.findCMAttribute(attributeName); - + String attributeValue = attribute.getValue(); if (cmAttribute != null) { String doc = cmAttribute.getValueDocumentation(attributeValue); if (doc != null && doc.length() > 0) { - String markdown = MarkdownConverter.convert(doc); - MarkupContent content = new MarkupContent(); - content.setKind(MarkupKind.MARKDOWN); - content.setValue(markdown); + MarkupContent content = hoverRequest.createMarkupContent(doc, MarkupKind.MARKDOWN); return new Hover(content); } } } } catch (CacheResourceDownloadingException e) { - return getCacheWarningHover(e); + return getCacheWarningHover(e, hoverRequest); } return null; } - private Hover getCacheWarningHover(CacheResourceDownloadingException e) { + private static Hover getCacheWarningHover(CacheResourceDownloadingException e, IHoverRequest hoverRequest) { // Here cache is enabled and some XML Schema, DTD, etc are loading - MarkupContent content = new MarkupContent(); - content.setKind(MarkupKind.MARKDOWN); - content.setValue("Cannot process " + (e.isDTD() ? "DTD" : "XML Schema") + " hover: " + e.getMessage()); + MarkupContent content = hoverRequest.createMarkupContent( + "Cannot process " + (e.isDTD() ? "DTD" : "XML Schema") + " hover: " + e.getMessage(), + MarkupKind.MARKDOWN); return new Hover(content); } } diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/CompletionRequest.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/CompletionRequest.java index 56403b8cda..9625ef7891 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/CompletionRequest.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/CompletionRequest.java @@ -16,9 +16,9 @@ import org.eclipse.lsp4xml.dom.DOMDocument; import org.eclipse.lsp4xml.dom.DOMNode; import org.eclipse.lsp4xml.extensions.contentmodel.utils.XMLGenerator; -import org.eclipse.lsp4xml.services.extensions.CompletionSettings; import org.eclipse.lsp4xml.services.extensions.ICompletionRequest; import org.eclipse.lsp4xml.services.extensions.XMLExtensionsRegistry; +import org.eclipse.lsp4xml.settings.XMLCompletionSettings; import org.eclipse.lsp4xml.settings.SharedSettings; import org.eclipse.lsp4xml.settings.XMLFormattingOptions; import org.eclipse.lsp4xml.utils.StringUtils; @@ -29,7 +29,7 @@ */ class CompletionRequest extends AbstractPositionRequest implements ICompletionRequest { - private final CompletionSettings completionSettings; + private final XMLCompletionSettings completionSettings; private final XMLFormattingOptions formattingSettings; @@ -62,7 +62,7 @@ public XMLFormattingOptions getFormattingSettings() { } @Override - public CompletionSettings getCompletionSettings() { + public XMLCompletionSettings getCompletionSettings() { return completionSettings; } diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/HoverRequest.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/HoverRequest.java index 1d02d1e606..54d2005a4f 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/HoverRequest.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/HoverRequest.java @@ -10,6 +10,8 @@ */ package org.eclipse.lsp4xml.services; +import org.eclipse.lsp4j.MarkupContent; +import org.eclipse.lsp4j.MarkupKind; import org.eclipse.lsp4j.Position; import org.eclipse.lsp4j.Range; import org.eclipse.lsp4xml.commons.BadLocationException; @@ -18,6 +20,8 @@ import org.eclipse.lsp4xml.dom.DOMNode; import org.eclipse.lsp4xml.services.extensions.IHoverRequest; import org.eclipse.lsp4xml.services.extensions.XMLExtensionsRegistry; +import org.eclipse.lsp4xml.settings.XMLHoverSettings; +import org.eclipse.lsp4xml.utils.MarkdownConverter; /** * Hover request implementation. @@ -25,15 +29,18 @@ */ class HoverRequest extends AbstractPositionRequest implements IHoverRequest { + private final XMLHoverSettings settings; + private final XMLExtensionsRegistry extensionsRegistry; private Range tagRange; private boolean open; - public HoverRequest(DOMDocument xmlDocument, Position position, XMLExtensionsRegistry extensionsRegistry) - throws BadLocationException { + public HoverRequest(DOMDocument xmlDocument, Position position, XMLHoverSettings settings, + XMLExtensionsRegistry extensionsRegistry) throws BadLocationException { super(xmlDocument, position); + this.settings = settings; this.extensionsRegistry = extensionsRegistry; } @@ -71,4 +78,25 @@ public void setOpen(boolean open) { public T getComponent(Class clazz) { return extensionsRegistry.getComponent(clazz); } + + @Override + public boolean canSupportMarkupKind(String kind) { + return settings != null && settings.getCapabilities() != null + && settings.getCapabilities().getContentFormat() != null + && settings.getCapabilities().getContentFormat().contains(kind); + } + + @Override + public MarkupContent createMarkupContent(String value, String kind) { + MarkupContent content = new MarkupContent(); + if (MarkupKind.MARKDOWN.equals(kind) && canSupportMarkupKind(kind)) { + String markdown = MarkdownConverter.convert(value); + content.setValue(markdown); + content.setKind(MarkupKind.MARKDOWN); + } else { + content.setValue(value); + content.setKind(MarkupKind.PLAINTEXT); + } + return content; + } } diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLCompletions.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLCompletions.java index 625387eb7f..ba9acf3663 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLCompletions.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLCompletions.java @@ -41,11 +41,11 @@ import org.eclipse.lsp4xml.dom.parser.TokenType; import org.eclipse.lsp4xml.dom.parser.XMLScanner; import org.eclipse.lsp4xml.extensions.prolog.PrologModel; -import org.eclipse.lsp4xml.services.extensions.CompletionSettings; import org.eclipse.lsp4xml.services.extensions.ICompletionParticipant; import org.eclipse.lsp4xml.services.extensions.ICompletionRequest; import org.eclipse.lsp4xml.services.extensions.ICompletionResponse; import org.eclipse.lsp4xml.services.extensions.XMLExtensionsRegistry; +import org.eclipse.lsp4xml.settings.XMLCompletionSettings; import org.eclipse.lsp4xml.settings.SharedSettings; import org.eclipse.lsp4xml.utils.StringUtils; @@ -513,7 +513,7 @@ private void collectOpenTagSuggestions(boolean hasOpenBracket, Range replaceRang xml.append(" />"); } else { xml.append(">"); - CompletionSettings completionSettings = completionRequest.getCompletionSettings(); + XMLCompletionSettings completionSettings = completionRequest.getCompletionSettings(); if (completionSettings.isCompletionSnippetsSupported()) { xml.append("$0"); diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLFoldings.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLFoldings.java index 8ccf8bd433..fe4e9bdd00 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLFoldings.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLFoldings.java @@ -23,7 +23,6 @@ import java.util.regex.Pattern; import org.eclipse.lsp4j.FoldingRange; -import org.eclipse.lsp4j.FoldingRangeCapabilities; import org.eclipse.lsp4j.FoldingRangeKind; import org.eclipse.lsp4j.jsonrpc.CancelChecker; import org.eclipse.lsp4xml.commons.BadLocationException; @@ -32,6 +31,7 @@ import org.eclipse.lsp4xml.dom.parser.TokenType; import org.eclipse.lsp4xml.dom.parser.XMLScanner; import org.eclipse.lsp4xml.services.extensions.XMLExtensionsRegistry; +import org.eclipse.lsp4xml.settings.XMLFoldingSettings; /** * XML folding support. @@ -59,7 +59,8 @@ public TagInfo(int startLine, String tagName) { } } - public List getFoldingRanges(TextDocument document, FoldingRangeCapabilities context, CancelChecker cancelChecker) { + public List getFoldingRanges(TextDocument document, XMLFoldingSettings context, + CancelChecker cancelChecker) { Scanner scanner = XMLScanner.createScanner(document.getText()); TokenType token = scanner.scan(); List ranges = new ArrayList<>(); @@ -153,8 +154,7 @@ public List getFoldingRanges(TextDocument document, FoldingRangeCa } } catch (BadLocationException e) { LOGGER.log(Level.SEVERE, "Foldings received a BadLocation while scanning the document", e); - } - catch(StackOverflowError e) { + } catch (StackOverflowError e) { // This exception occurs with large file, why? // For the moment we catch it. } diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLHover.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLHover.java index 0f42fadb83..a0746f5452 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLHover.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLHover.java @@ -27,6 +27,7 @@ import org.eclipse.lsp4xml.dom.parser.XMLScanner; import org.eclipse.lsp4xml.services.extensions.IHoverParticipant; import org.eclipse.lsp4xml.services.extensions.XMLExtensionsRegistry; +import org.eclipse.lsp4xml.settings.XMLHoverSettings; /** * XML hover support. @@ -42,10 +43,11 @@ public XMLHover(XMLExtensionsRegistry extensionsRegistry) { this.extensionsRegistry = extensionsRegistry; } - public Hover doHover(DOMDocument xmlDocument, Position position, CancelChecker cancelChecker) { + public Hover doHover(DOMDocument xmlDocument, Position position, XMLHoverSettings settings, + CancelChecker cancelChecker) { HoverRequest hoverRequest = null; try { - hoverRequest = new HoverRequest(xmlDocument, position, extensionsRegistry); + hoverRequest = new HoverRequest(xmlDocument, position, settings, extensionsRegistry); } catch (BadLocationException e) { LOGGER.log(Level.SEVERE, "Failed creating HoverRequest", e); return null; @@ -72,7 +74,7 @@ public Hover doHover(DOMDocument xmlDocument, Position position, CancelChecker c } } else if (node.isAttribute()) { DOMAttr attr = (DOMAttr) node; - if(attr.valueContainsOffset(offset)) { + if (attr.valueContainsOffset(offset)) { return getAttrValueHover(hoverRequest, null); } // Attribute is hover @@ -129,12 +131,12 @@ private Range getTagNameRange(TokenType tokenType, int startOffset, int offset, * Returns the LSP hover from the hovered attribute. * * @param hoverRequest the hover request. - * @param attrRange the attribute range + * @param attrRange the attribute range * @return the LSP hover from the hovered attribute. */ private Hover getAttrNameHover(HoverRequest hoverRequest, Range attrRange) { - //hoverRequest.setTagRange(tagRange); - //hoverRequest.setOpen(open); + // hoverRequest.setTagRange(tagRange); + // hoverRequest.setOpen(open); for (IHoverParticipant participant : extensionsRegistry.getHoverParticipants()) { try { Hover hover = participant.onAttributeName(hoverRequest); @@ -152,12 +154,12 @@ private Hover getAttrNameHover(HoverRequest hoverRequest, Range attrRange) { * Returns the LSP hover from the hovered attribute. * * @param hoverRequest the hover request. - * @param attrRange the attribute range + * @param attrRange the attribute range * @return the LSP hover from the hovered attribute. */ private Hover getAttrValueHover(HoverRequest hoverRequest, Range attrRange) { - //hoverRequest.setTagRange(tagRange); - //hoverRequest.setOpen(open); + // hoverRequest.setTagRange(tagRange); + // hoverRequest.setOpen(open); for (IHoverParticipant participant : extensionsRegistry.getHoverParticipants()) { try { Hover hover = participant.onAttributeValue(hoverRequest); diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLLanguageService.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLLanguageService.java index bbbb666e98..ccfdeaabf6 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLLanguageService.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLLanguageService.java @@ -26,7 +26,6 @@ import org.eclipse.lsp4j.DocumentLink; import org.eclipse.lsp4j.DocumentSymbol; import org.eclipse.lsp4j.FoldingRange; -import org.eclipse.lsp4j.FoldingRangeCapabilities; import org.eclipse.lsp4j.Hover; import org.eclipse.lsp4j.Location; import org.eclipse.lsp4j.LocationLink; @@ -47,7 +46,9 @@ import org.eclipse.lsp4xml.services.extensions.XMLExtensionsRegistry; import org.eclipse.lsp4xml.settings.SharedSettings; import org.eclipse.lsp4xml.settings.XMLCodeLensSettings; +import org.eclipse.lsp4xml.settings.XMLFoldingSettings; import org.eclipse.lsp4xml.settings.XMLFormattingOptions; +import org.eclipse.lsp4xml.settings.XMLHoverSettings; import org.eclipse.lsp4xml.uriresolver.CacheResourceDownloadingException; import org.eclipse.lsp4xml.utils.XMLPositionUtility; @@ -135,12 +136,13 @@ public CompletionList doComplete(DOMDocument xmlDocument, Position position, Sha return completions.doComplete(xmlDocument, position, settings, cancelChecker); } - public Hover doHover(DOMDocument xmlDocument, Position position) { - return doHover(xmlDocument, position, NULL_CHECKER); + public Hover doHover(DOMDocument xmlDocument, Position position, XMLHoverSettings settings) { + return doHover(xmlDocument, position, settings, NULL_CHECKER); } - public Hover doHover(DOMDocument xmlDocument, Position position, CancelChecker cancelChecker) { - return hover.doHover(xmlDocument, position, cancelChecker); + public Hover doHover(DOMDocument xmlDocument, Position position, XMLHoverSettings settings, + CancelChecker cancelChecker) { + return hover.doHover(xmlDocument, position, settings, cancelChecker); } public List doDiagnostics(DOMDocument xmlDocument, CancelChecker monitor, @@ -193,11 +195,11 @@ private static void publishOneDiagnosticInRoot(DOMDocument document, String mess publishDiagnostics.accept(new PublishDiagnosticsParams(uri, diagnostics)); } - public List getFoldingRanges(DOMDocument xmlDocument, FoldingRangeCapabilities context) { + public List getFoldingRanges(DOMDocument xmlDocument, XMLFoldingSettings context) { return getFoldingRanges(xmlDocument, context, NULL_CHECKER); } - public List getFoldingRanges(DOMDocument xmlDocument, FoldingRangeCapabilities context, + public List getFoldingRanges(DOMDocument xmlDocument, XMLFoldingSettings context, CancelChecker cancelChecker) { return foldings.getFoldingRanges(xmlDocument.getTextDocument(), context, cancelChecker); } @@ -219,13 +221,14 @@ public List findTypeDefinition(DOMDocument xmlDocument, CancelChecker cancelChecker) { return typeDefinition.findTypeDefinition(xmlDocument, position, cancelChecker); } - + public List findReferences(DOMDocument xmlDocument, Position position, ReferenceContext context, CancelChecker cancelChecker) { return reference.findReferences(xmlDocument, position, context, cancelChecker); } - public List getCodeLens(DOMDocument xmlDocument, XMLCodeLensSettings settings, CancelChecker cancelChecker) { + public List getCodeLens(DOMDocument xmlDocument, XMLCodeLensSettings settings, + CancelChecker cancelChecker) { return codelens.getCodelens(xmlDocument, settings, cancelChecker); } diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/extensions/ICompletionRequest.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/extensions/ICompletionRequest.java index f962d04a84..6ab4a3efa1 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/extensions/ICompletionRequest.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/extensions/ICompletionRequest.java @@ -13,6 +13,7 @@ import org.eclipse.lsp4j.Range; import org.eclipse.lsp4xml.commons.BadLocationException; import org.eclipse.lsp4xml.extensions.contentmodel.utils.XMLGenerator; +import org.eclipse.lsp4xml.settings.XMLCompletionSettings; import org.eclipse.lsp4xml.settings.XMLFormattingOptions; /** @@ -25,7 +26,7 @@ public interface ICompletionRequest extends IPositionRequest { XMLFormattingOptions getFormattingSettings(); - CompletionSettings getCompletionSettings(); + XMLCompletionSettings getCompletionSettings(); XMLGenerator getXMLGenerator() throws BadLocationException; diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/extensions/IHoverRequest.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/extensions/IHoverRequest.java index ef3147240f..de57a26dbd 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/extensions/IHoverRequest.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/extensions/IHoverRequest.java @@ -10,6 +10,7 @@ */ package org.eclipse.lsp4xml.services.extensions; +import org.eclipse.lsp4j.MarkupContent; import org.eclipse.lsp4j.Range; /** @@ -22,4 +23,7 @@ public interface IHoverRequest extends IPositionRequest { boolean isOpen(); + boolean canSupportMarkupKind(String kind); + + MarkupContent createMarkupContent(String value, String kind); } diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/SharedSettings.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/SharedSettings.java index 25afd4ea34..c593a88892 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/SharedSettings.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/SharedSettings.java @@ -10,36 +10,36 @@ package org.eclipse.lsp4xml.settings; -import org.eclipse.lsp4j.FoldingRangeCapabilities; import org.eclipse.lsp4xml.extensions.contentmodel.settings.XMLValidationSettings; -import org.eclipse.lsp4xml.services.extensions.CompletionSettings; /** * SharedSettings */ public class SharedSettings { - private final CompletionSettings completionSettings; - private final FoldingRangeCapabilities foldingSettings; + private final XMLCompletionSettings completionSettings; + private final XMLFoldingSettings foldingSettings; private final XMLFormattingOptions formattingSettings; private final XMLValidationSettings validationSettings; private final XMLSymbolSettings symbolSettings; private final XMLCodeLensSettings codeLensSettings; + private final XMLHoverSettings hoverSettings; public SharedSettings() { - this.completionSettings = new CompletionSettings(); - this.foldingSettings = new FoldingRangeCapabilities(); + this.completionSettings = new XMLCompletionSettings(); + this.foldingSettings = new XMLFoldingSettings(); this.formattingSettings = new XMLFormattingOptions(true); this.validationSettings = new XMLValidationSettings(); this.symbolSettings = new XMLSymbolSettings(); this.codeLensSettings = new XMLCodeLensSettings(); + this.hoverSettings = new XMLHoverSettings(); } - public CompletionSettings getCompletionSettings() { + public XMLCompletionSettings getCompletionSettings() { return completionSettings; } - public FoldingRangeCapabilities getFoldingSettings() { + public XMLFoldingSettings getFoldingSettings() { return foldingSettings; } @@ -59,4 +59,8 @@ public XMLCodeLensSettings getCodeLensSettings() { return codeLensSettings; } + public XMLHoverSettings getHoverSettings() { + return hoverSettings; + } + } \ No newline at end of file diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/extensions/CompletionSettings.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLCompletionSettings.java similarity index 86% rename from org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/extensions/CompletionSettings.java rename to org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLCompletionSettings.java index d7ca082980..b4ce127fa6 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/extensions/CompletionSettings.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLCompletionSettings.java @@ -8,7 +8,7 @@ * Contributors: * Angelo Zerr - initial API and implementation */ -package org.eclipse.lsp4xml.services.extensions; +package org.eclipse.lsp4xml.settings; import org.eclipse.lsp4j.CompletionCapabilities; @@ -16,17 +16,17 @@ * A wrapper around LSP {@link CompletionCapabilities}. * */ -public class CompletionSettings { +public class XMLCompletionSettings { private CompletionCapabilities completionCapabilities; private boolean autoCloseTags; - public CompletionSettings(boolean autoCloseTags) { + public XMLCompletionSettings(boolean autoCloseTags) { this.autoCloseTags = autoCloseTags; } - public CompletionSettings() { + public XMLCompletionSettings() { this(true); } @@ -75,7 +75,7 @@ public boolean isCompletionSnippetsSupported() { * * @param newCompletion the new settings to merge. */ - public void merge(CompletionSettings newCompletion) { + public void merge(XMLCompletionSettings newCompletion) { this.setAutoCloseTags(newCompletion.isAutoCloseTags()); } } diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLFoldingSettings.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLFoldingSettings.java new file mode 100644 index 0000000000..bf7d4bfcce --- /dev/null +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLFoldingSettings.java @@ -0,0 +1,33 @@ +/******************************************************************************* +* Copyright (c) 2019 Red Hat Inc. and others. +* All rights reserved. This program and the accompanying materials +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v20.html +* +* Contributors: +* Red Hat Inc. - initial API and implementation +*******************************************************************************/ +package org.eclipse.lsp4xml.settings; + +import org.eclipse.lsp4j.FoldingRangeCapabilities; + +/** + * A wrapper around LSP {@link FoldingRangeCapabilities}. + * + */ +public class XMLFoldingSettings { + + private FoldingRangeCapabilities capabilities; + + public void setCapabilities(FoldingRangeCapabilities capabilities) { + this.capabilities = capabilities; + } + + public FoldingRangeCapabilities getCapabilities() { + return capabilities; + } + + public Integer getRangeLimit() { + return capabilities != null ? capabilities.getRangeLimit() : null; + } +} diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLGeneralClientSettings.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLGeneralClientSettings.java index b36f69e8ad..4ed643d69a 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLGeneralClientSettings.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLGeneralClientSettings.java @@ -10,7 +10,6 @@ */ package org.eclipse.lsp4xml.settings; -import org.eclipse.lsp4xml.services.extensions.CompletionSettings; import org.eclipse.lsp4xml.utils.JSONUtility; /** @@ -38,7 +37,7 @@ public class XMLGeneralClientSettings { private XMLFormattingOptions format; - private CompletionSettings completion; + private XMLCompletionSettings completion; private ServerSettings server; @@ -93,7 +92,7 @@ public XMLFormattingOptions getFormat() { * * @param completion */ - public void setCompletion(CompletionSettings completion) { + public void setCompletion(XMLCompletionSettings completion) { this.completion = completion; } @@ -102,7 +101,7 @@ public void setCompletion(CompletionSettings completion) { * * @param completion */ - public CompletionSettings getCompletion() { + public XMLCompletionSettings getCompletion() { return completion; } diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLHoverSettings.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLHoverSettings.java new file mode 100644 index 0000000000..7995de4d26 --- /dev/null +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLHoverSettings.java @@ -0,0 +1,30 @@ +/******************************************************************************* +* Copyright (c) 2019 Red Hat Inc. and others. +* All rights reserved. This program and the accompanying materials +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v20.html +* +* Contributors: +* Red Hat Inc. - initial API and implementation +*******************************************************************************/ +package org.eclipse.lsp4xml.settings; + +import org.eclipse.lsp4j.HoverCapabilities; + +/** + * A wrapper around LSP {@link HoverCapabilities}. + * + */ +public class XMLHoverSettings { + + private HoverCapabilities capabilities; + + public void setCapabilities(HoverCapabilities capabilities) { + this.capabilities = capabilities; + } + + public HoverCapabilities getCapabilities() { + return capabilities; + } + +} diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLIncrementalSupportSettings.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLIncrementalSupportSettings.java deleted file mode 100644 index 7ac965ae1c..0000000000 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLIncrementalSupportSettings.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2018 Angelo ZERR - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v2.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * Contributors: - * Angelo Zerr - initial API and implementation - */ -package org.eclipse.lsp4xml.settings; - -/** - * XML experimental incremental support capabilities. - * - */ -public class XMLIncrementalSupportSettings { - - private Boolean enabled; - - public Boolean getEnabled() { - if(enabled == null) { - enabled = true; // default on - } - return enabled; - } - - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } - -} diff --git a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/XMLAssert.java b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/XMLAssert.java index 72707d8970..a11830b9c1 100644 --- a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/XMLAssert.java +++ b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/XMLAssert.java @@ -60,12 +60,13 @@ import org.eclipse.lsp4xml.extensions.contentmodel.settings.ContentModelSettings; import org.eclipse.lsp4xml.extensions.contentmodel.settings.XMLValidationSettings; import org.eclipse.lsp4xml.services.XMLLanguageService; -import org.eclipse.lsp4xml.services.extensions.CompletionSettings; import org.eclipse.lsp4xml.services.extensions.diagnostics.IXMLErrorCode; import org.eclipse.lsp4xml.services.extensions.save.AbstractSaveContext; import org.eclipse.lsp4xml.settings.SharedSettings; import org.eclipse.lsp4xml.settings.XMLCodeLensSettings; +import org.eclipse.lsp4xml.settings.XMLCompletionSettings; import org.eclipse.lsp4xml.settings.XMLFormattingOptions; +import org.eclipse.lsp4xml.settings.XMLHoverSettings; import org.eclipse.lsp4xml.utils.StringUtils; import org.junit.Assert; @@ -126,19 +127,19 @@ public static void testCompletionFor(XMLLanguageService xmlLanguageService, Stri Consumer customConfiguration, String fileURI, Integer expectedCount, boolean autoCloseTags, CompletionItem... expectedItems) throws BadLocationException { testCompletionFor(xmlLanguageService, value, catalogPath, customConfiguration, fileURI, expectedCount, - new CompletionSettings(autoCloseTags), expectedItems); + new XMLCompletionSettings(autoCloseTags), expectedItems); } public static void testCompletionFor(XMLLanguageService xmlLanguageService, String value, String catalogPath, Consumer customConfiguration, String fileURI, Integer expectedCount, - CompletionSettings completionSettings, CompletionItem... expectedItems) throws BadLocationException { + XMLCompletionSettings completionSettings, CompletionItem... expectedItems) throws BadLocationException { testCompletionFor(xmlLanguageService, value, catalogPath, customConfiguration, fileURI, expectedCount, completionSettings, new XMLFormattingOptions(4, true), expectedItems); } public static void testCompletionFor(XMLLanguageService xmlLanguageService, String value, String catalogPath, Consumer customConfiguration, String fileURI, Integer expectedCount, - CompletionSettings completionSettings, XMLFormattingOptions formattingSettings, + XMLCompletionSettings completionSettings, XMLFormattingOptions formattingSettings, CompletionItem... expectedItems) throws BadLocationException { int offset = value.indexOf('|'); value = value.substring(0, offset) + value.substring(offset + 1); @@ -543,7 +544,8 @@ public static void assertHover(XMLLanguageService xmlLanguageService, String val } xmlLanguageService.doSave(new SettingsSaveContext(settings)); - Hover hover = xmlLanguageService.doHover(htmlDoc, position); + XMLHoverSettings hoverSettings = new XMLHoverSettings(); + Hover hover = xmlLanguageService.doHover(htmlDoc, position, hoverSettings); if (expectedHoverLabel == null) { Assert.assertNull(hover); } else { diff --git a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/DTDCompletionExtensionsTest.java b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/DTDCompletionExtensionsTest.java index 1cccbddc1d..c148b644d8 100644 --- a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/DTDCompletionExtensionsTest.java +++ b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/DTDCompletionExtensionsTest.java @@ -9,7 +9,7 @@ import org.eclipse.lsp4xml.XMLAssert; import org.eclipse.lsp4xml.commons.BadLocationException; import org.eclipse.lsp4xml.services.XMLLanguageService; -import org.eclipse.lsp4xml.services.extensions.CompletionSettings; +import org.eclipse.lsp4xml.settings.XMLCompletionSettings; import org.junit.Test; public class DTDCompletionExtensionsTest { @@ -179,7 +179,7 @@ private void testCompletionFor(String xml, CompletionItem... expectedItems) thro } private void testCompletionFor(String xml, boolean isSnippetsSupported, Integer expectedCount, CompletionItem... expectedItems) throws BadLocationException { - CompletionSettings completionSettings = new CompletionSettings(); + XMLCompletionSettings completionSettings = new XMLCompletionSettings(); CompletionCapabilities completionCapabilities = new CompletionCapabilities(); CompletionItemCapabilities completionItem = new CompletionItemCapabilities(isSnippetsSupported); // activate snippets completionCapabilities.setCompletionItem(completionItem); diff --git a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/prolog/PrologCompletionExtensionsTest.java b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/prolog/PrologCompletionExtensionsTest.java index ffa51d887e..5a9efb49de 100644 --- a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/prolog/PrologCompletionExtensionsTest.java +++ b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/prolog/PrologCompletionExtensionsTest.java @@ -19,7 +19,7 @@ import org.eclipse.lsp4xml.XMLAssert; import org.eclipse.lsp4xml.commons.BadLocationException; import org.eclipse.lsp4xml.services.XMLLanguageService; -import org.eclipse.lsp4xml.services.extensions.CompletionSettings; +import org.eclipse.lsp4xml.settings.XMLCompletionSettings; import org.eclipse.lsp4xml.settings.XMLFormattingOptions; import org.junit.BeforeClass; import org.junit.Test; @@ -252,7 +252,7 @@ private void testCompletionFor(String xml, String fileURI, boolean autoCloseTags } private void testCompletionFor(String xml, String fileURI, XMLFormattingOptions formattingSettings, - CompletionSettings completionSettings, CompletionItem... expectedItems) throws BadLocationException { + XMLCompletionSettings completionSettings, CompletionItem... expectedItems) throws BadLocationException { XMLAssert.testCompletionFor(new XMLLanguageService(), xml, null, null, fileURI, null, completionSettings, formattingSettings, expectedItems); } @@ -264,13 +264,13 @@ private void testCompletionFor(String xml, boolean autoCloseTags, boolean isSnip } private void testCompletionFor(String xml, XMLFormattingOptions formattingSettings, - CompletionSettings completionSettings, CompletionItem... expectedItems) throws BadLocationException { + XMLCompletionSettings completionSettings, CompletionItem... expectedItems) throws BadLocationException { XMLAssert.testCompletionFor(new XMLLanguageService(), xml, null, null, null, null, completionSettings, formattingSettings, expectedItems); } - private CompletionSettings createCompletionSettings(boolean autoCloseTags, boolean isSnippetsSupported) { - CompletionSettings completionSettings = new CompletionSettings(autoCloseTags); + private XMLCompletionSettings createCompletionSettings(boolean autoCloseTags, boolean isSnippetsSupported) { + XMLCompletionSettings completionSettings = new XMLCompletionSettings(autoCloseTags); CompletionCapabilities capabilities = new CompletionCapabilities(); CompletionItemCapabilities itemCapabilities = new CompletionItemCapabilities(isSnippetsSupported); capabilities.setCompletionItem(itemCapabilities); diff --git a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/xsi/XSICompletionExtensionsTest.java b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/xsi/XSICompletionExtensionsTest.java index b1b30f6dd7..c5e9b2c483 100644 --- a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/xsi/XSICompletionExtensionsTest.java +++ b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/xsi/XSICompletionExtensionsTest.java @@ -17,7 +17,7 @@ import org.eclipse.lsp4xml.XMLAssert; import org.eclipse.lsp4xml.commons.BadLocationException; import org.eclipse.lsp4xml.services.XMLLanguageService; -import org.eclipse.lsp4xml.services.extensions.CompletionSettings; +import org.eclipse.lsp4xml.settings.XMLCompletionSettings; import org.eclipse.lsp4xml.settings.XMLFormattingOptions; import org.junit.BeforeClass; import org.junit.Test; @@ -154,6 +154,6 @@ private void testCompletionFor(String xml, CompletionItem... expectedItems) thro } private void testCompletionFor(String xml, XMLFormattingOptions formattingSettings, CompletionItem... expectedItems) throws BadLocationException { - XMLAssert.testCompletionFor(new XMLLanguageService(), xml, null, null, null, null, new CompletionSettings(true), formattingSettings, expectedItems); + XMLAssert.testCompletionFor(new XMLLanguageService(), xml, null, null, null, null, new XMLCompletionSettings(true), formattingSettings, expectedItems); } } diff --git a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/services/XMLCompletionTest.java b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/services/XMLCompletionTest.java index d66b5a1b47..caba7798d4 100644 --- a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/services/XMLCompletionTest.java +++ b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/services/XMLCompletionTest.java @@ -29,7 +29,7 @@ import org.eclipse.lsp4xml.customservice.AutoCloseTagResponse; import org.eclipse.lsp4xml.dom.DOMDocument; import org.eclipse.lsp4xml.dom.DOMParser; -import org.eclipse.lsp4xml.services.extensions.CompletionSettings; +import org.eclipse.lsp4xml.settings.XMLCompletionSettings; import org.eclipse.lsp4xml.settings.SharedSettings; import org.eclipse.lsp4xml.settings.XMLFormattingOptions; import org.junit.Before; @@ -42,12 +42,12 @@ public class XMLCompletionTest { private XMLLanguageService languageService; - private CompletionSettings sharedCompletionSettings; + private XMLCompletionSettings sharedCompletionSettings; @Before public void initializeLanguageService() { languageService = new XMLLanguageService(); - sharedCompletionSettings = new CompletionSettings(); + sharedCompletionSettings = new XMLCompletionSettings(); } diff --git a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/services/XMLFoldingsTest.java b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/services/XMLFoldingsTest.java index 8014910e32..0690144150 100644 --- a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/services/XMLFoldingsTest.java +++ b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/services/XMLFoldingsTest.java @@ -19,6 +19,7 @@ import org.eclipse.lsp4xml.commons.TextDocument; import org.eclipse.lsp4xml.dom.DOMDocument; import org.eclipse.lsp4xml.dom.DOMParser; +import org.eclipse.lsp4xml.settings.XMLFoldingSettings; import org.junit.Assert; import org.junit.Test; @@ -229,7 +230,9 @@ private static void assertRanges(String[] lines, ExpectedIndentRange[] expected, FoldingRangeCapabilities context = new FoldingRangeCapabilities(); context.setRangeLimit(nRanges); - List actual = languageService.getFoldingRanges(xmlDocument, context); + XMLFoldingSettings settings = new XMLFoldingSettings(); + settings.setCapabilities(context); + List actual = languageService.getFoldingRanges(xmlDocument, settings); List actualRanges = new ArrayList<>(); for (FoldingRange f : actual) {