From fd8aa2f39782072ffbc2ad07bd2a7dd00bfa7778 Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Tue, 15 Nov 2016 13:33:21 +0100 Subject: [PATCH] Updated coloring LSP extension service API. - Renamed semantic highlighting to coloring. - Updated abstract test class to provide coloring parameters. Signed-off-by: Akos Kitta --- org.eclipse.xtext.ide/META-INF/MANIFEST.MF | 2 +- .../ColoringInformation.xtend} | 8 +- .../ColoringParams.xtend} | 17 ++-- .../IColoringClient.java} | 18 ++--- .../IColoringService.java} | 36 ++++----- .../ColoringInformation.java} | 12 +-- .../ColoringParams.java} | 54 ++++++++++--- .../testing/AbstractLanguageServerTest.xtend | 25 +++++- .../testing/AbstractLanguageServerTest.java | 77 ++++++++++++++++++- .../xtext/testing/ColoringConfiguration.java | 27 +++++++ 10 files changed, 213 insertions(+), 63 deletions(-) rename org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/{syntaxColoring/SemanticHighlightInformation.xtend => coloring/ColoringInformation.xtend} (82%) rename org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/{syntaxColoring/SemanticHighlight.xtend => coloring/ColoringParams.xtend} (66%) rename org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/{syntaxColoring/ISemanticHighlightClient.java => coloring/IColoringClient.java} (69%) rename org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/{syntaxColoring/ISemanticHighlightService.java => coloring/IColoringService.java} (52%) rename org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/{syntaxColoring/SemanticHighlightInformation.java => coloring/ColoringInformation.java} (88%) rename org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/{syntaxColoring/SemanticHighlight.java => coloring/ColoringParams.java} (54%) create mode 100644 org.eclipse.xtext.testing/xtend-gen/org/eclipse/xtext/testing/ColoringConfiguration.java diff --git a/org.eclipse.xtext.ide/META-INF/MANIFEST.MF b/org.eclipse.xtext.ide/META-INF/MANIFEST.MF index 495d42365..5f24d3c1c 100644 --- a/org.eclipse.xtext.ide/META-INF/MANIFEST.MF +++ b/org.eclipse.xtext.ide/META-INF/MANIFEST.MF @@ -28,6 +28,7 @@ Export-Package: org.eclipse.xtext.ide;x-friends:="org.eclipse.xtend.ide", org.eclipse.xtext.ide.editor.syntaxcoloring, org.eclipse.xtext.ide.labels;x-friends:="org.eclipse.xtext.web", org.eclipse.xtext.ide.server, + org.eclipse.xtext.ide.server.coloring, org.eclipse.xtext.ide.server.concurrent, org.eclipse.xtext.ide.server.contentassist, org.eclipse.xtext.ide.server.findReferences, @@ -36,5 +37,4 @@ Export-Package: org.eclipse.xtext.ide;x-friends:="org.eclipse.xtend.ide", org.eclipse.xtext.ide.server.occurrences, org.eclipse.xtext.ide.server.signatureHelp, org.eclipse.xtext.ide.server.symbol, - org.eclipse.xtext.ide.server.syntaxColoring, org.eclipse.xtext.ide.util diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/syntaxColoring/SemanticHighlightInformation.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/coloring/ColoringInformation.xtend similarity index 82% rename from org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/syntaxColoring/SemanticHighlightInformation.xtend rename to org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/coloring/ColoringInformation.xtend index 4ae9681fe..15fdc8620 100644 --- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/syntaxColoring/SemanticHighlightInformation.xtend +++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/coloring/ColoringInformation.xtend @@ -5,20 +5,20 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.xtext.ide.server.syntaxColoring +package org.eclipse.xtext.ide.server.coloring import java.util.List import org.eclipse.lsp4j.Range -import org.eclipse.lsp4j.annotations.LanguageServerAPI +import org.eclipse.lsp4j.generator.LanguageServerAPI /** * Representation of a range and highlighting style identifiers that should be - * highlighted based on semantic information of the underlying model. + * highlighted based on the underlying model. * * @author akos.kitta - Initial contribution and API */ @LanguageServerAPI -class SemanticHighlightInformation { +class ColoringInformation { /** * The range that should be highlighted on the client-side. diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/syntaxColoring/SemanticHighlight.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/coloring/ColoringParams.xtend similarity index 66% rename from org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/syntaxColoring/SemanticHighlight.xtend rename to org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/coloring/ColoringParams.xtend index 0d2ebf20e..5757cd367 100644 --- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/syntaxColoring/SemanticHighlight.xtend +++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/coloring/ColoringParams.xtend @@ -5,10 +5,11 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.xtext.ide.server.syntaxColoring +package org.eclipse.xtext.ide.server.coloring import java.util.List -import org.eclipse.lsp4j.annotations.LanguageServerAPI +import org.eclipse.lsp4j.generator.LanguageServerAPI +import org.eclipse.lsp4j.jsonrpc.validation.NonNull /** * Representation of a computed mapping from ranges to the appropriate @@ -17,11 +18,17 @@ import org.eclipse.lsp4j.annotations.LanguageServerAPI * @author akos.kitta - Initial contribution and API */ @LanguageServerAPI -class SemanticHighlight { +class ColoringParams { /** - * A list of semantic highlight information. + * The URI for which coloring information is reported. */ - List infos; + @NonNull + String uri; + + /** + * A list of coloring information instances. + */ + List infos; } diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/syntaxColoring/ISemanticHighlightClient.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/coloring/IColoringClient.java similarity index 69% rename from org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/syntaxColoring/ISemanticHighlightClient.java rename to org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/coloring/IColoringClient.java index 0f21fe45f..730d1a19b 100644 --- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/syntaxColoring/ISemanticHighlightClient.java +++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/coloring/IColoringClient.java @@ -5,30 +5,30 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.xtext.ide.server.syntaxColoring; +package org.eclipse.xtext.ide.server.coloring; import org.eclipse.lsp4j.jsonrpc.services.JsonNotification; import org.eclipse.xtext.ide.server.ILanguageServerExtension; /** * Representation of a language-server client that can receive - * {@link SemanticHighlight semantic highlight} push notifications from the + * {@link ColoringParams coloring parameters} as push notifications from the * language-server as part of the * Language * Server Protocol {@link ILanguageServerExtension extension}. * * @author akos.kitta - Initial contribution and API */ -public interface ISemanticHighlightClient { +public interface IColoringClient { /** - * Pushes the {@link SemanticHighlight semantic highlight} to the client. + * Pushes the {@link ColoringParams coloring parameter} to the client. * - * @param highlight - * the information that should be pushed to the client side. Must - * not be {@code null}. + * @param params + * the information that should be pushed to the client side for + * coloring purposes. Must not be {@code null}. */ - @JsonNotification("lsp4j/pushSemanticHighlight") - void pushSemanticHighlight(SemanticHighlight highlight); + @JsonNotification("textDocument/updateColoring") + void updateColoring(ColoringParams params); } diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/syntaxColoring/ISemanticHighlightService.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/coloring/IColoringService.java similarity index 52% rename from org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/syntaxColoring/ISemanticHighlightService.java rename to org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/coloring/IColoringService.java index ce46814b4..8006f93d7 100644 --- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/syntaxColoring/ISemanticHighlightService.java +++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/coloring/IColoringService.java @@ -5,33 +5,28 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.xtext.ide.server.syntaxColoring; +package org.eclipse.xtext.ide.server.coloring; import static java.util.Collections.*; import org.eclipse.xtext.ide.server.Document; +import org.eclipse.xtext.ide.server.coloring.ColoringParams; import org.eclipse.xtext.resource.XtextResource; import com.google.inject.ImplementedBy; /** - * Representation of a generic, IDE independent semantic highlighting service. - * Provides coloring and semantic highlighting information for clients based on - * the underlying model. + * Representation of a generic, IDE independent coloring service. Provides + * coloring and highlighting information for clients based on the underlying + * model. * * @author akos.kitta - Initial contribution and API */ -@ImplementedBy(ISemanticHighlightService.Noop.class) -public interface ISemanticHighlightService { +@ImplementedBy(IColoringService.Noop.class) +public interface IColoringService { /** - * Shared, immutable empty instance. - */ - SemanticHighlight EMPTY = new SemanticHighlight(emptyList()); - - /** - * Provides semantic highlighting information based on the offset in the - * document. + * Provides all available coloring information for the resource. * * @param resource * the resource that will be highlighted. May be {@code null} in @@ -39,22 +34,21 @@ public interface ISemanticHighlightService { * @param document * the IDE and Xtext independent document that can be used to * convert the document based offsets to line based positions. - * @return the semantic highlight proposal for the resource. + * @return the coloring and highlighting proposal for the resource. */ - SemanticHighlight getSemanticHighlight(XtextResource resource, Document document); + ColoringParams getColoring(XtextResource resource, Document document); /** - * NOOP {@link ISemanticHighlightService semantic highlighting service} - * implementation. Always provides an {@link ISemanticHighlightService#EMPTY - * empty} instance. + * NOOP {@link IColoringService coloring service} implementation. Always + * provides an {@link IColoringService#EMPTY empty} instance. * * @author akos.kitta - Initial contribution and API */ - public static class Noop implements ISemanticHighlightService { + public static class Noop implements IColoringService { @Override - public SemanticHighlight getSemanticHighlight(final XtextResource resource, final Document document) { - return EMPTY; + public ColoringParams getColoring(final XtextResource resource, final Document document) { + return new ColoringParams(resource.getURI().toString(), emptyList()); } } diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/syntaxColoring/SemanticHighlightInformation.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/coloring/ColoringInformation.java similarity index 88% rename from org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/syntaxColoring/SemanticHighlightInformation.java rename to org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/coloring/ColoringInformation.java index 906672168..4972a2efa 100644 --- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/syntaxColoring/SemanticHighlightInformation.java +++ b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/coloring/ColoringInformation.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.xtext.ide.server.syntaxColoring; +package org.eclipse.xtext.ide.server.coloring; import java.util.List; import org.eclipse.lsp4j.Range; @@ -14,12 +14,12 @@ import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; /** * Representation of a range and highlighting style identifiers that should be - * highlighted based on semantic information of the underlying model. + * highlighted based on the underlying model. * * @author akos.kitta - Initial contribution and API */ @SuppressWarnings("all") -public class SemanticHighlightInformation { +public class ColoringInformation { /** * The range that should be highlighted on the client-side. */ @@ -66,11 +66,11 @@ public class SemanticHighlightInformation { this.ids = ids; } - public SemanticHighlightInformation() { + public ColoringInformation() { } - public SemanticHighlightInformation(final Range range, final List ids) { + public ColoringInformation(final Range range, final List ids) { this.range = range; this.ids = ids; } @@ -95,7 +95,7 @@ public class SemanticHighlightInformation { return false; if (!super.equals(obj)) return false; - SemanticHighlightInformation other = (SemanticHighlightInformation) obj; + ColoringInformation other = (ColoringInformation) obj; if (this.range == null) { if (other.range != null) return false; diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/syntaxColoring/SemanticHighlight.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/coloring/ColoringParams.java similarity index 54% rename from org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/syntaxColoring/SemanticHighlight.java rename to org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/coloring/ColoringParams.java index 51e43bb22..05b097cf4 100644 --- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/syntaxColoring/SemanticHighlight.java +++ b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/coloring/ColoringParams.java @@ -5,10 +5,11 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.xtext.ide.server.syntaxColoring; +package org.eclipse.xtext.ide.server.coloring; import java.util.List; -import org.eclipse.xtext.ide.server.syntaxColoring.SemanticHighlightInformation; +import org.eclipse.lsp4j.jsonrpc.validation.NonNull; +import org.eclipse.xtext.ide.server.coloring.ColoringInformation; import org.eclipse.xtext.xbase.lib.Pure; import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; @@ -19,32 +20,54 @@ import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; * @author akos.kitta - Initial contribution and API */ @SuppressWarnings("all") -public class SemanticHighlight { +public class ColoringParams { /** - * A list of semantic highlight information. + * The URI for which coloring information is reported. */ - private List infos; + @NonNull + private String uri; /** - * A list of semantic highlight information. + * A list of coloring information instances. + */ + private List infos; + + /** + * The URI for which coloring information is reported. */ @Pure - public List getInfos() { + public String getUri() { + return this.uri; + } + + /** + * The URI for which coloring information is reported. + */ + public void setUri(final String uri) { + this.uri = uri; + } + + /** + * A list of coloring information instances. + */ + @Pure + public List getInfos() { return this.infos; } /** - * A list of semantic highlight information. + * A list of coloring information instances. */ - public void setInfos(final List infos) { + public void setInfos(final List infos) { this.infos = infos; } - public SemanticHighlight() { + public ColoringParams() { } - public SemanticHighlight(final List infos) { + public ColoringParams(final String uri, final List infos) { + this.uri = uri; this.infos = infos; } @@ -52,6 +75,7 @@ public class SemanticHighlight { @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); + b.add("uri", this.uri); b.add("infos", this.infos); return b.toString(); } @@ -67,7 +91,12 @@ public class SemanticHighlight { return false; if (!super.equals(obj)) return false; - SemanticHighlight other = (SemanticHighlight) obj; + ColoringParams other = (ColoringParams) obj; + if (this.uri == null) { + if (other.uri != null) + return false; + } else if (!this.uri.equals(other.uri)) + return false; if (this.infos == null) { if (other.infos != null) return false; @@ -81,6 +110,7 @@ public class SemanticHighlight { public int hashCode() { final int prime = 31; int result = super.hashCode(); + result = prime * result + ((this.uri== null) ? 0 : this.uri.hashCode()); result = prime * result + ((this.infos== null) ? 0 : this.infos.hashCode()); return result; } diff --git a/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/AbstractLanguageServerTest.xtend b/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/AbstractLanguageServerTest.xtend index 4fd9d1495..a206221a8 100644 --- a/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/AbstractLanguageServerTest.xtend +++ b/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/AbstractLanguageServerTest.xtend @@ -19,6 +19,7 @@ import java.util.List import java.util.Map import java.util.concurrent.CompletableFuture import org.eclipse.lsp4j.CompletionItem +import org.eclipse.lsp4j.CompletionList import org.eclipse.lsp4j.Diagnostic import org.eclipse.lsp4j.DidChangeWatchedFilesParams import org.eclipse.lsp4j.DidCloseTextDocumentParams @@ -35,6 +36,7 @@ import org.eclipse.lsp4j.InitializeParams import org.eclipse.lsp4j.InitializeResult import org.eclipse.lsp4j.Location import org.eclipse.lsp4j.Position +import org.eclipse.lsp4j.PublishDiagnosticsParams import org.eclipse.lsp4j.Range import org.eclipse.lsp4j.ReferenceContext import org.eclipse.lsp4j.ReferenceParams @@ -55,6 +57,7 @@ import org.eclipse.xtext.ide.server.Document import org.eclipse.xtext.ide.server.LanguageServerImpl import org.eclipse.xtext.ide.server.ServerModule import org.eclipse.xtext.ide.server.UriExtensions +import org.eclipse.xtext.ide.server.coloring.ColoringParams import org.eclipse.xtext.ide.server.concurrent.RequestManager import org.eclipse.xtext.resource.IResourceServiceProvider import org.eclipse.xtext.util.CancelIndicator @@ -62,8 +65,7 @@ import org.eclipse.xtext.util.Files import org.eclipse.xtext.util.Modules2 import org.junit.Assert import org.junit.Before -import org.eclipse.lsp4j.PublishDiagnosticsParams -import org.eclipse.lsp4j.CompletionList +import org.eclipse.xtext.ide.server.coloring.ColoringInformation /** * @author Sven Efftinge - Initial contribution and API @@ -107,7 +109,7 @@ abstract class AbstractLanguageServerTest implements Endpoint { languageServer.supportedMethods() // create workingdir - root = new File("./test-data/test-project") + root = new File(new File("").absoluteFile, "/test-data/test-project") if (!root.mkdirs) { Files.cleanFolder(root, null, true, false) } @@ -256,6 +258,14 @@ abstract class AbstractLanguageServerTest implements Endpoint { protected dispatch def String toExpectation(DocumentHighlightKind kind) { return kind.toString.substring(0, 1).toUpperCase; } + + protected dispatch def String toExpectation(Map it) { + return '''«FOR entry : entrySet SEPARATOR '\n'»«entry.key.toExpectation» -> «IF entry.value instanceof Iterable»«FOR item : (entry.value as Iterable)»«"\n * "»«item.toExpectation»«ENDFOR»«ELSE»«entry.value.toExpectation»«ENDIF»«ENDFOR»'''; + } + + protected dispatch def String toExpectation(ColoringInformation it) { + return '''«range.toExpectation» -> [«ids.join(', ')»]'''; + } protected def void testCompletion((TestCompletionConfiguration)=>void configurator) { val extension configuration = new TestCompletionConfiguration @@ -465,6 +475,10 @@ abstract class AbstractLanguageServerTest implements Endpoint { } return result } + + protected def getColoringParams() { + return notifications.map[value].filter(ColoringParams).toMap([uri], [infos]); + } } @Data class FileInfo { @@ -539,6 +553,11 @@ class FormattingConfiguration extends TextDocumentConfiguration { String expectedText = '' } +@Accessors +class ColoringConfiguration extends TextDocumentConfiguration { + String expectedColoredRangesWithStyles = ''; +} + @Accessors class RangeFormattingConfiguration extends FormattingConfiguration { Range range = new Range => [ diff --git a/org.eclipse.xtext.testing/xtend-gen/org/eclipse/xtext/testing/AbstractLanguageServerTest.java b/org.eclipse.xtext.testing/xtend-gen/org/eclipse/xtext/testing/AbstractLanguageServerTest.java index cdbbb61b0..84aa788f6 100644 --- a/org.eclipse.xtext.testing/xtend-gen/org/eclipse/xtext/testing/AbstractLanguageServerTest.java +++ b/org.eclipse.xtext.testing/xtend-gen/org/eclipse/xtext/testing/AbstractLanguageServerTest.java @@ -70,6 +70,8 @@ import org.eclipse.xtext.ide.server.Document; import org.eclipse.xtext.ide.server.LanguageServerImpl; import org.eclipse.xtext.ide.server.ServerModule; import org.eclipse.xtext.ide.server.UriExtensions; +import org.eclipse.xtext.ide.server.coloring.ColoringInformation; +import org.eclipse.xtext.ide.server.coloring.ColoringParams; import org.eclipse.xtext.ide.server.concurrent.RequestManager; import org.eclipse.xtext.resource.IResourceServiceProvider; import org.eclipse.xtext.testing.DefinitionTestConfiguration; @@ -151,8 +153,10 @@ public abstract class AbstractLanguageServerTest implements Endpoint { LanguageClient _serviceObject = ServiceEndpoints.toServiceObject(this, LanguageClient.class); this.languageServer.connect(_serviceObject); this.languageServer.supportedMethods(); - File _file = new File("./test-data/test-project"); - this.root = _file; + File _file = new File(""); + File _absoluteFile = _file.getAbsoluteFile(); + File _file_1 = new File(_absoluteFile, "/test-data/test-project"); + this.root = _file_1; boolean _mkdirs = this.root.mkdirs(); boolean _not = (!_mkdirs); if (_not) { @@ -549,6 +553,56 @@ public abstract class AbstractLanguageServerTest implements Endpoint { return _substring.toUpperCase(); } + protected String _toExpectation(final Map it) { + StringConcatenation _builder = new StringConcatenation(); + { + Set> _entrySet = it.entrySet(); + boolean _hasElements = false; + for(final Map.Entry entry : _entrySet) { + if (!_hasElements) { + _hasElements = true; + } else { + _builder.appendImmediate("\n", ""); + } + Object _key = entry.getKey(); + String _expectation = this.toExpectation(_key); + _builder.append(_expectation, ""); + _builder.append(" -> "); + { + Object _value = entry.getValue(); + if ((_value instanceof Iterable)) { + { + Object _value_1 = entry.getValue(); + for(final Object item : ((Iterable) _value_1)) { + _builder.append("\n * ", ""); + String _expectation_1 = this.toExpectation(item); + _builder.append(_expectation_1, ""); + } + } + } else { + Object _value_2 = entry.getValue(); + String _expectation_2 = this.toExpectation(_value_2); + _builder.append(_expectation_2, ""); + } + } + } + } + return _builder.toString(); + } + + protected String _toExpectation(final ColoringInformation it) { + StringConcatenation _builder = new StringConcatenation(); + Range _range = it.getRange(); + String _expectation = this.toExpectation(_range); + _builder.append(_expectation, ""); + _builder.append(" -> ["); + List _ids = it.getIds(); + String _join = IterableExtensions.join(_ids, ", "); + _builder.append(_join, ""); + _builder.append("]"); + return _builder.toString(); + } + protected void testCompletion(final Procedure1 configurator) { try { @Extension @@ -960,6 +1014,21 @@ public abstract class AbstractLanguageServerTest implements Endpoint { return result; } + protected Map> getColoringParams() { + final Function1, Object> _function = (Pair it) -> { + return it.getValue(); + }; + List _map = ListExtensions., Object>map(this.notifications, _function); + Iterable _filter = Iterables.filter(_map, ColoringParams.class); + final Function1 _function_1 = (ColoringParams it) -> { + return it.getUri(); + }; + final Function1> _function_2 = (ColoringParams it) -> { + return it.getInfos(); + }; + return IterableExtensions.>toMap(_filter, _function_1, _function_2); + } + protected String toExpectation(final Object elements) { if (elements instanceof List) { return _toExpectation((List)elements); @@ -969,6 +1038,8 @@ public abstract class AbstractLanguageServerTest implements Endpoint { return _toExpectation((String)elements); } else if (elements == null) { return _toExpectation((Void)null); + } else if (elements instanceof Map) { + return _toExpectation((Map)elements); } else if (elements instanceof CompletionItem) { return _toExpectation((CompletionItem)elements); } else if (elements instanceof DocumentHighlight) { @@ -987,6 +1058,8 @@ public abstract class AbstractLanguageServerTest implements Endpoint { return _toExpectation((SymbolInformation)elements); } else if (elements instanceof TextEdit) { return _toExpectation((TextEdit)elements); + } else if (elements instanceof ColoringInformation) { + return _toExpectation((ColoringInformation)elements); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.asList(elements).toString()); diff --git a/org.eclipse.xtext.testing/xtend-gen/org/eclipse/xtext/testing/ColoringConfiguration.java b/org.eclipse.xtext.testing/xtend-gen/org/eclipse/xtext/testing/ColoringConfiguration.java new file mode 100644 index 000000000..b0c819638 --- /dev/null +++ b/org.eclipse.xtext.testing/xtend-gen/org/eclipse/xtext/testing/ColoringConfiguration.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.xtext.testing; + +import org.eclipse.xtend.lib.annotations.Accessors; +import org.eclipse.xtext.testing.TextDocumentConfiguration; +import org.eclipse.xtext.xbase.lib.Pure; + +@Accessors +@SuppressWarnings("all") +public class ColoringConfiguration extends TextDocumentConfiguration { + private String expectedColoredRangesWithStyles = ""; + + @Pure + public String getExpectedColoredRangesWithStyles() { + return this.expectedColoredRangesWithStyles; + } + + public void setExpectedColoredRangesWithStyles(final String expectedColoredRangesWithStyles) { + this.expectedColoredRangesWithStyles = expectedColoredRangesWithStyles; + } +}