From 45627ff583eed3c72403c7a49ea8e53d3a3dba54 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Sun, 27 Dec 2020 17:39:21 -0500 Subject: [PATCH] Remove Semantic Highlighting Signed-off-by: Matthew Brown --- .../java/org/eclipse/lsp4j/Protocol.xtend | 138 ---------- .../lsp4j/services/LanguageClient.java | 25 -- .../util/SemanticHighlightingTokens.java | 241 ------------------ .../SemanticHighlightingCapabilities.java | 90 ------- .../SemanticHighlightingInformation.java | 118 --------- .../lsp4j/SemanticHighlightingParams.java | 124 --------- ...emanticHighlightingServerCapabilities.java | 100 -------- .../org/eclipse/lsp4j/ServerCapabilities.java | 38 --- .../lsp4j/TextDocumentClientCapabilities.java | 38 --- .../util/SemanticHighlightingTokensTest.java | 145 ----------- 10 files changed, 1057 deletions(-) delete mode 100644 org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/util/SemanticHighlightingTokens.java delete mode 100644 org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingCapabilities.java delete mode 100644 org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingInformation.java delete mode 100644 org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingParams.java delete mode 100644 org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingServerCapabilities.java delete mode 100644 org.eclipse.lsp4j/src/test/java/org/eclipse/lsp4j/test/util/SemanticHighlightingTokensTest.java diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend index 8e9740b5..b1165f43 100644 --- a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend @@ -1262,34 +1262,6 @@ class FoldingRangeCapabilities extends DynamicRegistrationCapabilities { Boolean lineFoldingOnly } -/** - * Capabilities specific to {@code textDocument/semanticHighlighting}. - * - *

- * Note: the {@code textDocument/semanticHighlighting} - * language feature is not yet part of the official LSP specification. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ -@Beta -@Deprecated -@JsonRpcData -class SemanticHighlightingCapabilities { - - /** - * The client supports semantic highlighting. - */ - Boolean semanticHighlighting - - new() { - } - - new(Boolean semanticHighlighting) { - this.semanticHighlighting = semanticHighlighting - } -} - /** * Capabilities specific to the {@code textDocument/typeHierarchy}. * @@ -1797,15 +1769,6 @@ class TextDocumentClientCapabilities { */ FoldingRangeCapabilities foldingRange - /** - * Capabilities specific to {@code textDocument/semanticHighlighting}. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ - @Beta - @Deprecated - SemanticHighlightingCapabilities semanticHighlightingCapabilities - /** * Capabilities specific to {@code textDocument/typeHierarchy}. */ @@ -4929,15 +4892,6 @@ class ServerCapabilities { */ WorkspaceServerCapabilities workspace - /** - * Semantic highlighting server capabilities. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ - @Beta - @Deprecated - SemanticHighlightingServerCapabilities semanticHighlighting - /** * Server capability for calculating super- and subtype hierarchies. * The LS supports the type hierarchy language feature, if this capability is set to {@code true}. @@ -5013,38 +4967,6 @@ class WorkspaceServerCapabilities { } } -/** - * Semantic highlighting server capabilities. - * - *

- * Note: the {@code textDocument/semanticHighlighting} - * language feature is not yet part of the official LSP specification. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ -@Beta -@Deprecated -@JsonRpcData -class SemanticHighlightingServerCapabilities { - - /** - * A "lookup table" of semantic highlighting TextMate scopes - * supported by the language server. If not defined or empty, then the server does not support the semantic highlighting - * feature. Otherwise, clients should reuse this "lookup table" when receiving semantic highlighting notifications from - * the server. - */ - List> scopes - - new() { - } - - new(List> scopes) { - this.scopes = scopes - } - -} - /** * The show message request is sent from a server to a client to ask the client to display a particular message in the * user class. In addition to the show message notification the request allows to pass actions and to wait for an @@ -7130,66 +7052,6 @@ class FoldingRange { } } -/** - * Parameters for the semantic highlighting (server-side) push notification. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ -@Beta -@Deprecated -@JsonRpcData -class SemanticHighlightingParams { - /** - * The text document that has to be decorated with the semantic highlighting information. - */ - @NonNull - VersionedTextDocumentIdentifier textDocument - - /** - * An array of semantic highlighting information. - */ - @NonNull - List lines - - new() { - } - - new(@NonNull VersionedTextDocumentIdentifier textDocument, @NonNull List lines) { - this.textDocument = Preconditions.checkNotNull(textDocument, 'textDocument') - this.lines = Preconditions.checkNotNull(lines, 'lines') - } -} - -/** - * Represents a semantic highlighting information that has to be applied on a specific line of the text document. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ -@Beta -@Deprecated -@JsonRpcData -class SemanticHighlightingInformation { - /** - * The zero-based line position in the text document. - */ - int line - - /** - * A base64 encoded string representing every single highlighted ranges in the line with its start position, length - * and the "lookup table" index of of the semantic highlighting - * TextMate scopes. If the {@code tokens} is empty or not defined, then no highlighted positions are available for the line. - */ - String tokens - - new() { - } - - new(int line, String tokens) { - this.line = line - this.tokens = tokens - } -} - /** * The parameter of a `textDocument/prepareCallHierarchy` request. * diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/LanguageClient.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/LanguageClient.java index 32e64a34..7d125450 100644 --- a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/LanguageClient.java +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/LanguageClient.java @@ -23,7 +23,6 @@ import org.eclipse.lsp4j.ProgressParams; import org.eclipse.lsp4j.PublishDiagnosticsParams; import org.eclipse.lsp4j.RegistrationParams; -import org.eclipse.lsp4j.SemanticHighlightingParams; import org.eclipse.lsp4j.SetTraceParams; import org.eclipse.lsp4j.ShowDocumentParams; import org.eclipse.lsp4j.ShowDocumentResult; @@ -142,30 +141,6 @@ default CompletableFuture> configuration(ConfigurationParams config throw new UnsupportedOperationException(); } - /** - * The {@code textDocument/semanticHighlighting} notification is pushed from the server to the client - * to inform the client about additional semantic highlighting information that has to be applied - * on the text document. It is the server's responsibility to decide which lines are included in - * the highlighting information. In other words, the server is capable of sending only a delta - * information. For instance, after opening the text document ({@code DidOpenTextDocumentNotification}) - * the server sends the semantic highlighting information for the entire document, but if the server - * receives a {@code DidChangeTextDocumentNotification}, it pushes the information only about - * the affected lines in the document. - * - *

- * Note: the {@code textDocument/semanticHighlighting} - * language feature is not yet part of the official LSP specification. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ - @Beta - @Deprecated - @JsonNotification("textDocument/semanticHighlighting") - default void semanticHighlighting(SemanticHighlightingParams params) { - throw new UnsupportedOperationException(); - } - /** * This request is sent from the server to the client to ask the client to create a work done progress. * diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/util/SemanticHighlightingTokens.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/util/SemanticHighlightingTokens.java deleted file mode 100644 index 675a0e38..00000000 --- a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/util/SemanticHighlightingTokens.java +++ /dev/null @@ -1,241 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, - * or the Eclipse Distribution License v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - ******************************************************************************/ -package org.eclipse.lsp4j.util; - -import static java.util.Collections.emptyList; - -import java.nio.ByteBuffer; -import java.util.Base64; -import java.util.List; - -import org.eclipse.xtext.xbase.lib.IterableExtensions; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ComparisonChain; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; -import com.google.common.collect.Iterables; - -/** - * Utility class for encoding and decoding semantic highlighting tokens into a - * compact, {@code base64} representation. - */ -public final class SemanticHighlightingTokens { - - private static int LENGTH_SHIFT = 0x0000010; - private static int SCOPES_MASK = 0x0000FFFF; - - /** - * Encodes the iterable of tokens into a compact, {@code base64} string. Returns - * with an empty string if the {@code tokens} argument is {@code null} or empty. - */ - public static String encode(Iterable tokens) { - if (IterableExtensions.isNullOrEmpty(tokens)) { - return ""; - } - // 2 stands for: number of elements for the output; the "character" and the - // "length and scope". - // 4 stands for: 4 byte for a primitive integer. - ByteBuffer buffer = ByteBuffer.allocate(Iterables.size(tokens) * 2 * 4); - for (Token token : tokens) { - int character = token.character; - int length = token.length; - int scope = token.scope; - - int lengthAndScope = length; - lengthAndScope = lengthAndScope << LENGTH_SHIFT; - lengthAndScope |= scope; - - buffer.putInt(character); - buffer.putInt(lengthAndScope); - } - return Base64.getEncoder().encodeToString(buffer.array()); - } - - /** - * Decodes the tokens string and returns with a list of semantic highlighting - * tokens. Returns with an empty list if the argument is {@code null} or empty. - */ - public static List decode(String tokens) { - if (tokens == null || tokens.length() == 0) { - return emptyList(); - } - ByteBuffer buffer = ByteBuffer.wrap(Base64.getDecoder().decode(tokens)); - Builder builder = ImmutableList.builder(); - while (buffer.hasRemaining()) { - int character = buffer.getInt(); - - int lengthAndScope = buffer.getInt(); - int length = lengthAndScope >>> LENGTH_SHIFT; - int scope = lengthAndScope & SCOPES_MASK; - - builder.add(new Token(character, length, scope)); - } - return builder.build(); - } - - /** - * The bare minimum representation of a semantic highlighting token. - * - *

- * Semantic highlighting tokens are not part of the protocol, as they're - * sent through the wire as an encoded string. The purpose of this data type is - * to help working with them. - */ - public static class Token implements Comparable { - - private static int[] EMPTY_ARRAY = new int[0]; - private static int MAX_UINT_16 = 65_535; // 2^16 - 1 - - /** - * Converts an iterable of tokens into an array of primitive integers. Returns - * with an empty array if the argument is {@code null} or empty. - * - *

- *

- */ - public static int[] toIntArray(Iterable tokens) { - if (IterableExtensions.isNullOrEmpty(tokens)) { - return EMPTY_ARRAY; - } - int[] array = new int[Iterables.size(tokens) * 3]; - int i = 0; - for (Token token : tokens) { - array[i++] = token.character; - array[i++] = token.length; - array[i++] = token.scope; - } - return array; - } - - /** - * Counter-part of the {@link Token#toIntArray}. Converts an array of primitive - * integers into a list of tokens. If the input is {@code null}, returns with an - * empty list. Throws an exception if the length of the arguments is not a - * modulo of {@code 3}. - * - * The elements of the input will be used to create new {@link Token} instances, - * hence they must comply the requirements described - * {@link #SemanticHighlightingTokens.Token(int, int, int) here}. - */ - public static List fromIntArray(int... input) { - if (input == null) { - return emptyList(); - } - int inputLength = input.length; - Preconditions.checkArgument(inputLength % 3 == 0, - "Invalid input. 'input.length % 3 != 0' Input length was: " + inputLength + "."); - Builder builder = ImmutableList.builder(); - for (int i = 0; i < inputLength; i = i + 3) { - builder.add(new Token( - input[i], // character - input[i + 1], // length - input[i + 2] // scope - )); - } - return builder.build(); - } - - /** - * The zero-based character offset of the token in the line. - */ - public final int character; - - /** - * The length of the token. - */ - public final int length; - - /** - * The internal index of the - * TextMate - * scope. - */ - public final int scope; - - /** - * Creates a new highlighting token. - * - * @param character - * the character offset of the token. Must not be a negative integer. - * @param length - * the length of the token. Must be an integer between {@code 0} and - * {@code 2}16{@code -1} (inclusive). - * @param scope - * the scope. Must be an integer between {@code 0} and - * {@code 2}16{@code -1} (inclusive). - */ - public Token(int character, int length, int scope) { - Preconditions.checkArgument(character >= 0, "Expected 'character' >= 0. Was: " + character + "."); - this.character = character; - this.length = assertUint16(length, "length"); - this.scope = assertUint16(scope, "scope"); - } - - /** - * Asserts the argument. It must be in a range of {@code 0} and - * {@code 2}16{@code -1} (inclusive). Returns with the argument if - * valid. Otherwise throws an {@link IllegalArgumentException}. - */ - private static int assertUint16(int i, String prefix) { - Preconditions.checkArgument(i >= 0, "Expected: '" + prefix + "' >= 0. '" + prefix + "' was: " + i + "."); - Preconditions.checkArgument(i <= MAX_UINT_16, - "Expected: '" + prefix + "' <= " + MAX_UINT_16 + ". '" + prefix + "' was: " + i + "."); - return i; - } - - @Override - public int compareTo(Token o) { - return ComparisonChain.start().compare(character, o.character).compare(length, o.length) - .compare(scope, o.scope).result(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + character; - result = prime * result + length; - result = prime * result + scope; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Token other = (Token) obj; - if (character != other.character) - return false; - if (length != other.length) - return false; - if (scope != other.scope) - return false; - return true; - } - - } - - private SemanticHighlightingTokens() { - } - -} diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingCapabilities.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingCapabilities.java deleted file mode 100644 index 71885a81..00000000 --- a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingCapabilities.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright (c) 2016-2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, - * or the Eclipse Distribution License v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -package org.eclipse.lsp4j; - -import com.google.common.annotations.Beta; -import org.eclipse.xtext.xbase.lib.Pure; -import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; - -/** - * Capabilities specific to {@code textDocument/semanticHighlighting}. - * - *

- * Note: the {@code textDocument/semanticHighlighting} - * language feature is not yet part of the official LSP specification. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ -@Beta -@Deprecated -@SuppressWarnings("all") -public class SemanticHighlightingCapabilities { - /** - * The client supports semantic highlighting. - */ - private Boolean semanticHighlighting; - - public SemanticHighlightingCapabilities() { - } - - public SemanticHighlightingCapabilities(final Boolean semanticHighlighting) { - this.semanticHighlighting = semanticHighlighting; - } - - /** - * The client supports semantic highlighting. - */ - @Pure - public Boolean getSemanticHighlighting() { - return this.semanticHighlighting; - } - - /** - * The client supports semantic highlighting. - */ - public void setSemanticHighlighting(final Boolean semanticHighlighting) { - this.semanticHighlighting = semanticHighlighting; - } - - @Override - @Pure - public String toString() { - ToStringBuilder b = new ToStringBuilder(this); - b.add("semanticHighlighting", this.semanticHighlighting); - return b.toString(); - } - - @Override - @Pure - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SemanticHighlightingCapabilities other = (SemanticHighlightingCapabilities) obj; - if (this.semanticHighlighting == null) { - if (other.semanticHighlighting != null) - return false; - } else if (!this.semanticHighlighting.equals(other.semanticHighlighting)) - return false; - return true; - } - - @Override - @Pure - public int hashCode() { - return 31 * 1 + ((this.semanticHighlighting== null) ? 0 : this.semanticHighlighting.hashCode()); - } -} diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingInformation.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingInformation.java deleted file mode 100644 index c1ddcaf7..00000000 --- a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingInformation.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Copyright (c) 2016-2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, - * or the Eclipse Distribution License v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -package org.eclipse.lsp4j; - -import com.google.common.annotations.Beta; -import org.eclipse.xtext.xbase.lib.Pure; -import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; - -/** - * Represents a semantic highlighting information that has to be applied on a specific line of the text document. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ -@Beta -@Deprecated -@SuppressWarnings("all") -public class SemanticHighlightingInformation { - /** - * The zero-based line position in the text document. - */ - private int line; - - /** - * A base64 encoded string representing every single highlighted ranges in the line with its start position, length - * and the "lookup table" index of of the semantic highlighting - * TextMate scopes. If the {@code tokens} is empty or not defined, then no highlighted positions are available for the line. - */ - private String tokens; - - public SemanticHighlightingInformation() { - } - - public SemanticHighlightingInformation(final int line, final String tokens) { - this.line = line; - this.tokens = tokens; - } - - /** - * The zero-based line position in the text document. - */ - @Pure - public int getLine() { - return this.line; - } - - /** - * The zero-based line position in the text document. - */ - public void setLine(final int line) { - this.line = line; - } - - /** - * A base64 encoded string representing every single highlighted ranges in the line with its start position, length - * and the "lookup table" index of of the semantic highlighting - * TextMate scopes. If the {@code tokens} is empty or not defined, then no highlighted positions are available for the line. - */ - @Pure - public String getTokens() { - return this.tokens; - } - - /** - * A base64 encoded string representing every single highlighted ranges in the line with its start position, length - * and the "lookup table" index of of the semantic highlighting - * TextMate scopes. If the {@code tokens} is empty or not defined, then no highlighted positions are available for the line. - */ - public void setTokens(final String tokens) { - this.tokens = tokens; - } - - @Override - @Pure - public String toString() { - ToStringBuilder b = new ToStringBuilder(this); - b.add("line", this.line); - b.add("tokens", this.tokens); - return b.toString(); - } - - @Override - @Pure - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SemanticHighlightingInformation other = (SemanticHighlightingInformation) obj; - if (other.line != this.line) - return false; - if (this.tokens == null) { - if (other.tokens != null) - return false; - } else if (!this.tokens.equals(other.tokens)) - return false; - return true; - } - - @Override - @Pure - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + this.line; - return prime * result + ((this.tokens== null) ? 0 : this.tokens.hashCode()); - } -} diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingParams.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingParams.java deleted file mode 100644 index 7ebb7466..00000000 --- a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingParams.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Copyright (c) 2016-2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, - * or the Eclipse Distribution License v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -package org.eclipse.lsp4j; - -import com.google.common.annotations.Beta; -import java.util.List; -import org.eclipse.lsp4j.SemanticHighlightingInformation; -import org.eclipse.lsp4j.VersionedTextDocumentIdentifier; -import org.eclipse.lsp4j.jsonrpc.validation.NonNull; -import org.eclipse.lsp4j.util.Preconditions; -import org.eclipse.xtext.xbase.lib.Pure; -import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; - -/** - * Parameters for the semantic highlighting (server-side) push notification. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ -@Beta -@Deprecated -@SuppressWarnings("all") -public class SemanticHighlightingParams { - /** - * The text document that has to be decorated with the semantic highlighting information. - */ - @NonNull - private VersionedTextDocumentIdentifier textDocument; - - /** - * An array of semantic highlighting information. - */ - @NonNull - private List lines; - - public SemanticHighlightingParams() { - } - - public SemanticHighlightingParams(@NonNull final VersionedTextDocumentIdentifier textDocument, @NonNull final List lines) { - this.textDocument = Preconditions.checkNotNull(textDocument, "textDocument"); - this.lines = Preconditions.>checkNotNull(lines, "lines"); - } - - /** - * The text document that has to be decorated with the semantic highlighting information. - */ - @Pure - @NonNull - public VersionedTextDocumentIdentifier getTextDocument() { - return this.textDocument; - } - - /** - * The text document that has to be decorated with the semantic highlighting information. - */ - public void setTextDocument(@NonNull final VersionedTextDocumentIdentifier textDocument) { - this.textDocument = Preconditions.checkNotNull(textDocument, "textDocument"); - } - - /** - * An array of semantic highlighting information. - */ - @Pure - @NonNull - public List getLines() { - return this.lines; - } - - /** - * An array of semantic highlighting information. - */ - public void setLines(@NonNull final List lines) { - this.lines = Preconditions.checkNotNull(lines, "lines"); - } - - @Override - @Pure - public String toString() { - ToStringBuilder b = new ToStringBuilder(this); - b.add("textDocument", this.textDocument); - b.add("lines", this.lines); - return b.toString(); - } - - @Override - @Pure - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SemanticHighlightingParams other = (SemanticHighlightingParams) obj; - if (this.textDocument == null) { - if (other.textDocument != null) - return false; - } else if (!this.textDocument.equals(other.textDocument)) - return false; - if (this.lines == null) { - if (other.lines != null) - return false; - } else if (!this.lines.equals(other.lines)) - return false; - return true; - } - - @Override - @Pure - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((this.textDocument== null) ? 0 : this.textDocument.hashCode()); - return prime * result + ((this.lines== null) ? 0 : this.lines.hashCode()); - } -} diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingServerCapabilities.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingServerCapabilities.java deleted file mode 100644 index 4042e95a..00000000 --- a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticHighlightingServerCapabilities.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Copyright (c) 2016-2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, - * or the Eclipse Distribution License v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -package org.eclipse.lsp4j; - -import com.google.common.annotations.Beta; -import java.util.List; -import org.eclipse.xtext.xbase.lib.Pure; -import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; - -/** - * Semantic highlighting server capabilities. - * - *

- * Note: the {@code textDocument/semanticHighlighting} - * language feature is not yet part of the official LSP specification. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ -@Beta -@Deprecated -@SuppressWarnings("all") -public class SemanticHighlightingServerCapabilities { - /** - * A "lookup table" of semantic highlighting TextMate scopes - * supported by the language server. If not defined or empty, then the server does not support the semantic highlighting - * feature. Otherwise, clients should reuse this "lookup table" when receiving semantic highlighting notifications from - * the server. - */ - private List> scopes; - - public SemanticHighlightingServerCapabilities() { - } - - public SemanticHighlightingServerCapabilities(final List> scopes) { - this.scopes = scopes; - } - - /** - * A "lookup table" of semantic highlighting TextMate scopes - * supported by the language server. If not defined or empty, then the server does not support the semantic highlighting - * feature. Otherwise, clients should reuse this "lookup table" when receiving semantic highlighting notifications from - * the server. - */ - @Pure - public List> getScopes() { - return this.scopes; - } - - /** - * A "lookup table" of semantic highlighting TextMate scopes - * supported by the language server. If not defined or empty, then the server does not support the semantic highlighting - * feature. Otherwise, clients should reuse this "lookup table" when receiving semantic highlighting notifications from - * the server. - */ - public void setScopes(final List> scopes) { - this.scopes = scopes; - } - - @Override - @Pure - public String toString() { - ToStringBuilder b = new ToStringBuilder(this); - b.add("scopes", this.scopes); - return b.toString(); - } - - @Override - @Pure - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SemanticHighlightingServerCapabilities other = (SemanticHighlightingServerCapabilities) obj; - if (this.scopes == null) { - if (other.scopes != null) - return false; - } else if (!this.scopes.equals(other.scopes)) - return false; - return true; - } - - @Override - @Pure - public int hashCode() { - return 31 * 1 + ((this.scopes== null) ? 0 : this.scopes.hashCode()); - } -} diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/ServerCapabilities.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/ServerCapabilities.java index 5ba11a44..02070667 100644 --- a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/ServerCapabilities.java +++ b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/ServerCapabilities.java @@ -23,7 +23,6 @@ import org.eclipse.lsp4j.FoldingRangeProviderOptions; import org.eclipse.lsp4j.MonikerRegistrationOptions; import org.eclipse.lsp4j.RenameOptions; -import org.eclipse.lsp4j.SemanticHighlightingServerCapabilities; import org.eclipse.lsp4j.SemanticTokensWithRegistrationOptions; import org.eclipse.lsp4j.SignatureHelpOptions; import org.eclipse.lsp4j.StaticRegistrationOptions; @@ -169,15 +168,6 @@ public class ServerCapabilities { */ private WorkspaceServerCapabilities workspace; - /** - * Semantic highlighting server capabilities. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ - @Beta - @Deprecated - private SemanticHighlightingServerCapabilities semanticHighlighting; - /** * Server capability for calculating super- and subtype hierarchies. * The LS supports the type hierarchy language feature, if this capability is set to {@code true}. @@ -732,27 +722,6 @@ public void setWorkspace(final WorkspaceServerCapabilities workspace) { this.workspace = workspace; } - /** - * Semantic highlighting server capabilities. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ - @Pure - @Deprecated - public SemanticHighlightingServerCapabilities getSemanticHighlighting() { - return this.semanticHighlighting; - } - - /** - * Semantic highlighting server capabilities. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ - @Deprecated - public void setSemanticHighlighting(final SemanticHighlightingServerCapabilities semanticHighlighting) { - this.semanticHighlighting = semanticHighlighting; - } - /** * Server capability for calculating super- and subtype hierarchies. * The LS supports the type hierarchy language feature, if this capability is set to {@code true}. @@ -997,7 +966,6 @@ public String toString() { b.add("declarationProvider", this.declarationProvider); b.add("executeCommandProvider", this.executeCommandProvider); b.add("workspace", this.workspace); - b.add("semanticHighlighting", this.semanticHighlighting); b.add("typeHierarchyProvider", this.typeHierarchyProvider); b.add("callHierarchyProvider", this.callHierarchyProvider); b.add("selectionRangeProvider", this.selectionRangeProvider); @@ -1133,11 +1101,6 @@ public boolean equals(final Object obj) { return false; } else if (!this.workspace.equals(other.workspace)) return false; - if (this.semanticHighlighting == null) { - if (other.semanticHighlighting != null) - return false; - } else if (!this.semanticHighlighting.equals(other.semanticHighlighting)) - return false; if (this.typeHierarchyProvider == null) { if (other.typeHierarchyProvider != null) return false; @@ -1204,7 +1167,6 @@ public int hashCode() { result = prime * result + ((this.declarationProvider== null) ? 0 : this.declarationProvider.hashCode()); result = prime * result + ((this.executeCommandProvider== null) ? 0 : this.executeCommandProvider.hashCode()); result = prime * result + ((this.workspace== null) ? 0 : this.workspace.hashCode()); - result = prime * result + ((this.semanticHighlighting== null) ? 0 : this.semanticHighlighting.hashCode()); result = prime * result + ((this.typeHierarchyProvider== null) ? 0 : this.typeHierarchyProvider.hashCode()); result = prime * result + ((this.callHierarchyProvider== null) ? 0 : this.callHierarchyProvider.hashCode()); result = prime * result + ((this.selectionRangeProvider== null) ? 0 : this.selectionRangeProvider.hashCode()); diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/TextDocumentClientCapabilities.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/TextDocumentClientCapabilities.java index f239f57a..34e25b90 100644 --- a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/TextDocumentClientCapabilities.java +++ b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/TextDocumentClientCapabilities.java @@ -34,7 +34,6 @@ import org.eclipse.lsp4j.ReferencesCapabilities; import org.eclipse.lsp4j.RenameCapabilities; import org.eclipse.lsp4j.SelectionRangeCapabilities; -import org.eclipse.lsp4j.SemanticHighlightingCapabilities; import org.eclipse.lsp4j.SemanticTokensCapabilities; import org.eclipse.lsp4j.SignatureHelpCapabilities; import org.eclipse.lsp4j.SynchronizationCapabilities; @@ -163,15 +162,6 @@ public class TextDocumentClientCapabilities { */ private FoldingRangeCapabilities foldingRange; - /** - * Capabilities specific to {@code textDocument/semanticHighlighting}. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ - @Beta - @Deprecated - private SemanticHighlightingCapabilities semanticHighlightingCapabilities; - /** * Capabilities specific to {@code textDocument/typeHierarchy}. */ @@ -548,27 +538,6 @@ public void setFoldingRange(final FoldingRangeCapabilities foldingRange) { this.foldingRange = foldingRange; } - /** - * Capabilities specific to {@code textDocument/semanticHighlighting}. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ - @Pure - @Deprecated - public SemanticHighlightingCapabilities getSemanticHighlightingCapabilities() { - return this.semanticHighlightingCapabilities; - } - - /** - * Capabilities specific to {@code textDocument/semanticHighlighting}. - * - * @deprecated Use {@code SemanticTokens} API instead. - */ - @Deprecated - public void setSemanticHighlightingCapabilities(final SemanticHighlightingCapabilities semanticHighlightingCapabilities) { - this.semanticHighlightingCapabilities = semanticHighlightingCapabilities; - } - /** * Capabilities specific to {@code textDocument/typeHierarchy}. */ @@ -704,7 +673,6 @@ public String toString() { b.add("rename", this.rename); b.add("publishDiagnostics", this.publishDiagnostics); b.add("foldingRange", this.foldingRange); - b.add("semanticHighlightingCapabilities", this.semanticHighlightingCapabilities); b.add("typeHierarchyCapabilities", this.typeHierarchyCapabilities); b.add("callHierarchy", this.callHierarchy); b.add("selectionRange", this.selectionRange); @@ -829,11 +797,6 @@ public boolean equals(final Object obj) { return false; } else if (!this.foldingRange.equals(other.foldingRange)) return false; - if (this.semanticHighlightingCapabilities == null) { - if (other.semanticHighlightingCapabilities != null) - return false; - } else if (!this.semanticHighlightingCapabilities.equals(other.semanticHighlightingCapabilities)) - return false; if (this.typeHierarchyCapabilities == null) { if (other.typeHierarchyCapabilities != null) return false; @@ -893,7 +856,6 @@ public int hashCode() { result = prime * result + ((this.rename== null) ? 0 : this.rename.hashCode()); result = prime * result + ((this.publishDiagnostics== null) ? 0 : this.publishDiagnostics.hashCode()); result = prime * result + ((this.foldingRange== null) ? 0 : this.foldingRange.hashCode()); - result = prime * result + ((this.semanticHighlightingCapabilities== null) ? 0 : this.semanticHighlightingCapabilities.hashCode()); result = prime * result + ((this.typeHierarchyCapabilities== null) ? 0 : this.typeHierarchyCapabilities.hashCode()); result = prime * result + ((this.callHierarchy== null) ? 0 : this.callHierarchy.hashCode()); result = prime * result + ((this.selectionRange== null) ? 0 : this.selectionRange.hashCode()); diff --git a/org.eclipse.lsp4j/src/test/java/org/eclipse/lsp4j/test/util/SemanticHighlightingTokensTest.java b/org.eclipse.lsp4j/src/test/java/org/eclipse/lsp4j/test/util/SemanticHighlightingTokensTest.java deleted file mode 100644 index a6e3bf81..00000000 --- a/org.eclipse.lsp4j/src/test/java/org/eclipse/lsp4j/test/util/SemanticHighlightingTokensTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, - * or the Eclipse Distribution License v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - ******************************************************************************/ -package org.eclipse.lsp4j.test.util; - -import static com.google.common.collect.Lists.newArrayList; -import static java.util.Collections.emptyList; -import static org.eclipse.lsp4j.util.SemanticHighlightingTokens.decode; -import static org.eclipse.lsp4j.util.SemanticHighlightingTokens.encode; -import static org.eclipse.lsp4j.util.SemanticHighlightingTokens.Token.fromIntArray; -import static org.eclipse.lsp4j.util.SemanticHighlightingTokens.Token.toIntArray; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; - -import java.util.List; - -import org.eclipse.lsp4j.util.SemanticHighlightingTokens.Token; -import org.junit.Test; - -public class SemanticHighlightingTokensTest { - - private static int[] EMPTY_ARRAY = new int[0]; - - @Test(expected = IllegalArgumentException.class) - public void newToken_invalidCharacter() { - new Token(-1, 0, 0); - } - - @Test(expected = IllegalArgumentException.class) - public void newToken_invalidLengthSmaller() { - new Token(0, -1, 0); - } - - @Test(expected = IllegalArgumentException.class) - public void newToken_invalidLengthGreater() { - new Token(0, (int) Math.pow(2, 16), 0); - } - - @Test(expected = IllegalArgumentException.class) - public void newToken_invalidScopeSmaller() { - new Token(0, 0, -1); - } - - @Test(expected = IllegalArgumentException.class) - public void newToken_invalidScopeGreater() { - new Token(0, 0, (int) Math.pow(2, 16)); - } - - @Test - public void toIntArray_null() { - assertArrayEquals(EMPTY_ARRAY, toIntArray(null)); - } - - @Test - public void toIntArray_empty() { - assertArrayEquals(EMPTY_ARRAY, toIntArray(emptyList())); - } - - @Test(expected = NullPointerException.class) - public void toIntArray_invalid() { - toIntArray(newArrayList((Token) null)); - } - - @Test - public void toIntArray_() { - assertArrayEquals(new int[] { 2, 5, 0, 12, 15, 1, 7, 1000, 1 }, - toIntArray(newArrayList(new Token(2, 5, 0), new Token(12, 15, 1), new Token(7, 1000, 1)))); - } - - @Test - public void fromIntArray_null() { - assertEquals(emptyList(), fromIntArray(null)); - } - - @Test - public void fromIntArray_empty() { - assertEquals(emptyList(), fromIntArray(EMPTY_ARRAY)); - } - - @Test(expected = IllegalArgumentException.class) - public void fromIntArray_invalid() { - assertEquals(emptyList(), fromIntArray(new int[] { 1, 2 })); - } - - @Test - public void fromIntArray_() { - assertEquals(newArrayList(new Token(2, 5, 0), new Token(12, 15, 1), new Token(7, 1000, 1)), - fromIntArray(new int[] { 2, 5, 0, 12, 15, 1, 7, 1000, 1 })); - } - - @Test - public void encode_null() { - assertEquals("", encode(null)); - } - - @Test - public void encode_empty() { - assertEquals("", encode(emptyList())); - } - - @Test(expected = NullPointerException.class) - public void encode_invalid() { - encode(newArrayList((Token) null)); - } - - @Test - public void encode_() { - assertEquals("AAAAAgAFAAAAAAAMAA8AAQAAAAcD6AAB", - encode(newArrayList(new Token(2, 5, 0), new Token(12, 15, 1), new Token(7, 1000, 1)))); - } - - @Test - public void decode_null() { - assertEquals(emptyList(), decode(null)); - } - - @Test - public void decode_empty() { - assertEquals(emptyList(), decode("")); - } - - @Test - public void decode_() { - assertEquals(newArrayList(new Token(2, 5, 0), new Token(12, 15, 1), new Token(7, 1000, 1)), - decode("AAAAAgAFAAAAAAAMAA8AAQAAAAcD6AAB")); - } - - @Test - public void symmetric() { - List expected = newArrayList(); - for (int i = 0; i < 65536; i++) { - expected.add(new Token(i, i, i)); - } - assertEquals(expected, decode(encode(expected))); - } - -}