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 39a508c9e..d2cae3e62 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 308b1939e..530932dfa 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/services/CompletionRequest.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/CompletionRequest.java index 2111dc0a3..f110a0325 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 970874632..28768f293 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 @@ -18,6 +18,7 @@ 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; /** * Hover request implementation. @@ -25,15 +26,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; } @@ -74,7 +78,9 @@ public T getComponent(Class clazz) { @Override public boolean canSupportMarkupKind(String kind) { - // FIXME : use the hover capability to know if the given kind is supported - return true; + return settings != null && settings.getCapabilities() != null + && settings.getCapabilities().getContentFormat() != null + && settings.getCapabilities().getContentFormat().contains(kind); + } } 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 625387eb7..ba9acf366 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 8ccf8bd43..82d7d68fa 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,10 +154,10 @@ 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. + LOGGER.log(Level.SEVERE, "Foldings received a StackOverflowError while scanning the document", e); } return ranges; } 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 0f42fadb8..a0746f545 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 bbbb666e9..ccfdeaabf 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 dfd437efe..6c058863e 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; import org.eclipse.lsp4xml.utils.MarkupContentFactory.IMarkupKindSupport; @@ -26,7 +27,7 @@ public interface ICompletionRequest extends IPositionRequest, IMarkupKindSupport 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 1f349691d..be98bcb1c 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 @@ -22,5 +22,4 @@ public interface IHoverRequest extends IPositionRequest, IMarkupKindSupport { Range getTagRange(); boolean isOpen(); - } 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 25afd4ea3..c593a8889 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 d7ca08298..b4ce127fa 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 000000000..bf7d4bfcc --- /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 b36f69e8a..4ed643d69 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 000000000..7995de4d2 --- /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 7ac965ae1..000000000 --- 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 e7dfea284..daff3e0b6 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 @@ -35,6 +35,7 @@ import org.eclipse.lsp4j.DocumentLink; import org.eclipse.lsp4j.DocumentSymbol; import org.eclipse.lsp4j.Hover; +import org.eclipse.lsp4j.HoverCapabilities; import org.eclipse.lsp4j.Location; import org.eclipse.lsp4j.LocationLink; import org.eclipse.lsp4j.MarkedString; @@ -61,12 +62,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; @@ -127,19 +129,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); @@ -553,7 +555,10 @@ public static void assertHover(XMLLanguageService xmlLanguageService, String val } xmlLanguageService.doSave(new SettingsSaveContext(settings)); - Hover hover = xmlLanguageService.doHover(htmlDoc, position); + XMLHoverSettings hoverSettings = new XMLHoverSettings(); + HoverCapabilities capabilities = new HoverCapabilities(Arrays.asList(MarkupKind.MARKDOWN), false); + hoverSettings.setCapabilities(capabilities); + 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 94ae043cc..c1d0ec2b1 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 @@ -10,7 +10,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 { @@ -180,7 +180,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/contentmodel/XMLSchemaCompletionExtensionsTest.java b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/XMLSchemaCompletionExtensionsTest.java index b3ae2f540..0c682f355 100644 --- a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/XMLSchemaCompletionExtensionsTest.java +++ b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/XMLSchemaCompletionExtensionsTest.java @@ -24,11 +24,10 @@ import org.eclipse.lsp4j.CompletionItem; import org.eclipse.lsp4j.CompletionItemCapabilities; import org.eclipse.lsp4j.MarkupKind; -import org.eclipse.lsp4j.Range; 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; /** @@ -379,8 +378,7 @@ public void completionWithXMLSchemaContentChanged() throws Exception { // Update resources.xsd, Schema doesn't define variant attribute -> no // completion - schema = "\r\n" - + "\r\n" + schema = "\r\n" + "\r\n" + "\r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" @@ -403,7 +401,7 @@ public void completionWithXMLSchemaContentChanged() throws Exception { * @see https://github.com/angelozerr/lsp4xml/issues/214 * * @throws BadLocationException - * @throws MalformedURIException + * @throws MalformedURIException */ @Test public void issue214() throws BadLocationException, MalformedURIException { @@ -496,102 +494,82 @@ public void issue311() throws BadLocationException { @Test public void xsiCompletionTestAllItems() throws BadLocationException { - String xml = - "\r\n" + - ""; - XMLAssert.testCompletionFor(xml, 4, c("xsi:nil", "xsi:nil=\"true\""), c("xsi:type", "xsi:type=\"\""), c("xsi:noNamespaceSchemaLocation", "xsi:noNamespaceSchemaLocation=\"\""), c("xsi:schemaLocation", "xsi:schemaLocation=\"\"")); + String xml = "\r\n" + ""; + XMLAssert.testCompletionFor(xml, 4, c("xsi:nil", "xsi:nil=\"true\""), c("xsi:type", "xsi:type=\"\""), + c("xsi:noNamespaceSchemaLocation", "xsi:noNamespaceSchemaLocation=\"\""), + c("xsi:schemaLocation", "xsi:schemaLocation=\"\"")); } @Test public void xsiCompletionNonRootElement() throws BadLocationException { - String xml = - "\r\n" + - " \r\n" + - ""; + String xml = "\r\n" + + " \r\n" + ""; XMLAssert.testCompletionFor(xml, 2, c("xsi:nil", "xsi:nil=\"true\""), c("xsi:type", "xsi:type=\"\"")); } @Test public void xsiCompletionNonRootElement2() throws BadLocationException { - String xml = - "\r\n" + - " \r\n" + - ""; + String xml = "\r\n" + + " \r\n" + ""; XMLAssert.testCompletionFor(xml, 1, c("xsi:type", "xsi:type=\"\"")); } @Test public void xsiCompletionNotUsingXSIName() throws BadLocationException { - String xml = - "\r\n" + - " \r\n" + - ""; + String xml = "\r\n" + + " \r\n" + ""; - XMLAssert.testCompletionFor(xml, 4, c("XXY:nil", "XXY:nil=\"true\""), c("XXY:type", "XXY:type=\"\""), c("XXY:noNamespaceSchemaLocation", "XXY:noNamespaceSchemaLocation=\"\"")); + XMLAssert.testCompletionFor(xml, 4, c("XXY:nil", "XXY:nil=\"true\""), c("XXY:type", "XXY:type=\"\""), + c("XXY:noNamespaceSchemaLocation", "XXY:noNamespaceSchemaLocation=\"\"")); } @Test public void xmlnsXSICompletion() throws BadLocationException { - String xml = - "\r\n" + - " \r\n" + - ""; + String xml = "\r\n" + + " \r\n" + ""; XMLAssert.testCompletionFor(xml, 1, c("xmlns:xsi", "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"")); } @Test public void xmlnsXSIValueCompletion() throws BadLocationException { - String xml = - "\r\n" + - " \r\n" + - ""; + String xml = "\r\n" + + " \r\n" + ""; - XMLAssert.testCompletionFor(xml, 1, c("http://www.w3.org/2001/XMLSchema-instance", "\"http://www.w3.org/2001/XMLSchema-instance\"")); + XMLAssert.testCompletionFor(xml, 1, + c("http://www.w3.org/2001/XMLSchema-instance", "\"http://www.w3.org/2001/XMLSchema-instance\"")); } @Test public void xsiCompletionSchemaLocationExists() throws BadLocationException { - String xml = - "\r\n" + - " \r\n" + - ""; + String xml = "\r\n" + + " \r\n" + ""; - XMLAssert.testCompletionFor(xml, 4, c("xsi:nil", "xsi:nil=\"true\""), c("xsi:type", "xsi:type=\"\""), c("xsi:noNamespaceSchemaLocation", "xsi:noNamespaceSchemaLocation=\"\"")); + XMLAssert.testCompletionFor(xml, 4, c("xsi:nil", "xsi:nil=\"true\""), c("xsi:type", "xsi:type=\"\""), + c("xsi:noNamespaceSchemaLocation", "xsi:noNamespaceSchemaLocation=\"\"")); } @Test public void xsiCompletionNoNamespaceSchemaLocationExists() throws BadLocationException { - String xml = - "\r\n" + // <- completion - " \r\n" + - ""; + String xml = "\r\n" + + // <- completion + " \r\n" + ""; - XMLAssert.testCompletionFor(xml, 3, c("xsi:nil", "xsi:nil=\"true\""), c("xsi:type", "xsi:type=\"\""), c("xsi:schemaLocation", "xsi:schemaLocation=\"\"")); + XMLAssert.testCompletionFor(xml, 3, c("xsi:nil", "xsi:nil=\"true\""), c("xsi:type", "xsi:type=\"\""), + c("xsi:schemaLocation", "xsi:schemaLocation=\"\"")); } @Test @@ -609,8 +587,8 @@ public void choice() throws BadLocationException { + // " | "; // Completion only member or employee - XMLAssert.testCompletionFor(xml, null, "src/test/resources/choice.xml", null, c("member", ""), - c("employee", "")); + XMLAssert.testCompletionFor(xml, null, "src/test/resources/choice.xml", null, c("member", ""), + c("employee", "")); xml = "\r\n" + // "\r\n" @@ -621,7 +599,7 @@ public void choice() throws BadLocationException { // Completion only member or employee XMLAssert.testCompletionFor(xml, null, "src/test/resources/choice.xml", 2, c("member", ""), c("employee", "")); - + xml = "\r\n" + // "\r\n" + // @@ -630,60 +608,63 @@ public void choice() throws BadLocationException { " <| " + // ""; // maxOccurs = 3, completion should be empty - XMLAssert.testCompletionFor(xml, null, "src/test/resources/choice.xml", 0); + XMLAssert.testCompletionFor(xml, null, "src/test/resources/choice.xml", 0); } @Test public void sequence() throws BadLocationException { String xml = "\r\n" + // - "\r\n" + // " |"; XMLAssert.testCompletionFor(xml, null, "src/test/resources/sequence.xml", null, c("e1", ""), c("optional0", "")); - + xml = "\r\n" + // - "\r\n" + // " | "; XMLAssert.testCompletionFor(xml, null, "src/test/resources/sequence.xml", null, c("e2", ""), c("optional1", ""), c("optional11", "")); - + xml = "\r\n" + // - "\r\n" + // " |"; XMLAssert.testCompletionFor(xml, null, "src/test/resources/sequence.xml", null, c("e2", ""), c("optional1", ""), c("optional11", "")); xml = "\r\n" + // - "\r\n" + // " |"; XMLAssert.testCompletionFor(xml, null, "src/test/resources/sequence.xml", null, c("e3", ""), c("optional2", ""), c("optional22", "")); xml = "\r\n" + // - "\r\n" + // " |"; - XMLAssert.testCompletionFor(xml, null, "src/test/resources/sequence.xml", null, c("optional3", "")); + XMLAssert.testCompletionFor(xml, null, "src/test/resources/sequence.xml", null, + c("optional3", "")); xml = "\r\n" + // - "\r\n" + // " |"; - XMLAssert.testCompletionFor(xml, null, "src/test/resources/sequence.xml", null, c("optional3", "")); + XMLAssert.testCompletionFor(xml, null, "src/test/resources/sequence.xml", null, + c("optional3", "")); xml = "\r\n" + // - "\r\n" + // " |"; // optional3 is not return by completion since optional3 has a max=2 occurences - XMLAssert.testCompletionFor(xml, null, "src/test/resources/sequence.xml", 1, c("End with ''", "")); + XMLAssert.testCompletionFor(xml, null, "src/test/resources/sequence.xml", 1, + c("End with ''", "")); } - + @Test public void tag() throws BadLocationException { String xml = "\r\n" + // @@ -726,8 +707,7 @@ public void tag() throws BadLocationException { xml = "\r\n" + // "\r\n" + // - " |\r\n" + - ""; + " |\r\n" + ""; XMLAssert.testCompletionFor(xml, null, "src/test/resources/sequence.xml", 1, c("optional", "")); @@ -741,8 +721,7 @@ public void tag() throws BadLocationException { xml = "\r\n" + // "\r\n" + // - " <|\r\n" + - ""; + " <|\r\n" + ""; XMLAssert.testCompletionFor(xml, null, "src/test/resources/sequence.xml", 1, c("optional", "")); @@ -759,11 +738,10 @@ public void tag() throws BadLocationException { "\r\n" + // " \r\n" + // - "|r\n" + - ""; + "|r\n" + ""; XMLAssert.testCompletionFor(xml, null, "src/test/resources/sequence.xml", 3, - c("optional", ""), - c("#region", ""), c("#endregion", "")); + c("optional", ""), c("#region", ""), + c("#endregion", "")); xml = "\r\n" + // "\r\n" + // " \r\n" + // - "<|\r\n" + - ""; + "<|\r\n" + ""; XMLAssert.testCompletionFor(xml, null, "src/test/resources/sequence.xml", 1, c("optional", "")); @@ -860,16 +837,17 @@ public void documentationAsMarkdown() throws BadLocationException, MalformedURIE } private static String getXMLSchemaFileURI(String schemaURI) throws MalformedURIException { - return XMLEntityManager.expandSystemId("xsd/" + schemaURI, "src/test/resources/test.xml", true) - .replace("///", "/"); + return XMLEntityManager.expandSystemId("xsd/" + schemaURI, "src/test/resources/test.xml", true).replace("///", + "/"); } private void testCompletionFor(String xml, CompletionItem... expectedItems) throws BadLocationException { XMLAssert.testCompletionFor(xml, "src/test/resources/catalogs/catalog.xml", expectedItems); } - - private void testCompletionMarkdownSupporytFor(String xml, CompletionItem... expectedItems) throws BadLocationException { - CompletionSettings completionSettings = new CompletionSettings(); + + private void testCompletionMarkdownSupporytFor(String xml, CompletionItem... expectedItems) + throws BadLocationException { + XMLCompletionSettings completionSettings = new XMLCompletionSettings(); CompletionCapabilities completionCapabilities = new CompletionCapabilities(); CompletionItemCapabilities completionItem = new CompletionItemCapabilities(false); completionItem.setDocumentationFormat(Arrays.asList(MarkupKind.MARKDOWN)); 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 ffa51d887..5a9efb49d 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 b1b30f6dd..c5e9b2c48 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 d66b5a1b4..caba7798d 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 8014910e3..069014415 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) {