-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for semanticTokens #446
Merged
spoenemann
merged 4 commits into
eclipse-lsp4j:master
from
ericdallo:semantic-tokens-support
Oct 7, 2020
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
424 changes: 421 additions & 3 deletions
424
org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend
Large diffs are not rendered by default.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/SemanticTokenModifiers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright (c) 2020 Eric Dallo. | ||
* | ||
* 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; | ||
|
||
/** | ||
* @since 3.16.0 | ||
*/ | ||
@Beta | ||
public final class SemanticTokenModifiers { | ||
private SemanticTokenModifiers() { | ||
} | ||
|
||
public static final String Declaration = "declaration"; | ||
|
||
public static final String Definition = "definition"; | ||
|
||
public static final String Readonly = "readonly"; | ||
|
||
public static final String Static = "static"; | ||
|
||
public static final String Deprecated = "deprecated"; | ||
|
||
public static final String Abstract = "abstract"; | ||
|
||
public static final String Async = "async"; | ||
|
||
public static final String Modification = "modification"; | ||
|
||
public static final String Documentation = "documentation"; | ||
|
||
public static final String DefaultLibrary = "defaultLibrary"; | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/SemanticTokenTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* Copyright (c) 2020 Eric Dallo. | ||
* | ||
* 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; | ||
|
||
/** | ||
* @since 3.16.0 | ||
*/ | ||
@Beta | ||
public final class SemanticTokenTypes { | ||
private SemanticTokenTypes() { | ||
} | ||
|
||
public static final String Namespace = "namespace"; | ||
|
||
public static final String Type = "type"; | ||
|
||
public static final String Class = "class"; | ||
|
||
public static final String Enum = "enum"; | ||
|
||
public static final String Interface = "interface"; | ||
|
||
public static final String Struct = "struct"; | ||
|
||
public static final String TypeParameter = "typeParameter"; | ||
|
||
public static final String Parameter = "parameter"; | ||
|
||
public static final String Variable = "variable"; | ||
|
||
public static final String Property = "property"; | ||
|
||
public static final String EnumMember = "enumMember"; | ||
|
||
public static final String Event = "event"; | ||
|
||
public static final String Function = "function"; | ||
|
||
public static final String Member = "member"; | ||
|
||
public static final String Macro = "macro"; | ||
|
||
public static final String Keyword = "keyword"; | ||
|
||
public static final String Modifier = "modifier"; | ||
|
||
public static final String Comment = "comment"; | ||
|
||
public static final String String = "string"; | ||
|
||
public static final String Number = "number"; | ||
|
||
public static final String Regexp = "regexp"; | ||
|
||
public static final String Operator = "operator"; | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/TokenFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright (c) 2020 Eric Dallo. | ||
* | ||
* 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; | ||
|
||
/** | ||
* @since 3.16.0 | ||
*/ | ||
@Beta | ||
public final class TokenFormat { | ||
private TokenFormat() { | ||
} | ||
|
||
public static final String Relative = "relative"; | ||
|
||
} |
127 changes: 127 additions & 0 deletions
127
org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/SemanticTokens.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/** | ||
* 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.jsonrpc.validation.NonNull; | ||
import org.eclipse.lsp4j.util.Preconditions; | ||
import org.eclipse.xtext.xbase.lib.Pure; | ||
import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; | ||
|
||
/** | ||
* @since 3.16.0 | ||
*/ | ||
@Beta | ||
@SuppressWarnings("all") | ||
public class SemanticTokens { | ||
/** | ||
* An optional result id. If provided and clients support delta updating | ||
* the client will include the result id in the next semantic token request. | ||
* A server can then instead of computing all semantic tokens again simply | ||
* send a delta. | ||
*/ | ||
private String resultId; | ||
|
||
/** | ||
* The actual tokens. | ||
*/ | ||
@NonNull | ||
private List<Integer> data; | ||
|
||
public SemanticTokens(@NonNull final List<Integer> data) { | ||
this.data = Preconditions.<List<Integer>>checkNotNull(data, "data"); | ||
} | ||
|
||
public SemanticTokens(final String resultId, @NonNull final List<Integer> data) { | ||
this(data); | ||
this.resultId = resultId; | ||
} | ||
|
||
/** | ||
* An optional result id. If provided and clients support delta updating | ||
* the client will include the result id in the next semantic token request. | ||
* A server can then instead of computing all semantic tokens again simply | ||
* send a delta. | ||
*/ | ||
@Pure | ||
public String getResultId() { | ||
return this.resultId; | ||
} | ||
|
||
/** | ||
* An optional result id. If provided and clients support delta updating | ||
* the client will include the result id in the next semantic token request. | ||
* A server can then instead of computing all semantic tokens again simply | ||
* send a delta. | ||
*/ | ||
public void setResultId(final String resultId) { | ||
this.resultId = resultId; | ||
} | ||
|
||
/** | ||
* The actual tokens. | ||
*/ | ||
@Pure | ||
@NonNull | ||
public List<Integer> getData() { | ||
return this.data; | ||
} | ||
|
||
/** | ||
* The actual tokens. | ||
*/ | ||
public void setData(@NonNull final List<Integer> data) { | ||
this.data = Preconditions.checkNotNull(data, "data"); | ||
} | ||
|
||
@Override | ||
@Pure | ||
public String toString() { | ||
ToStringBuilder b = new ToStringBuilder(this); | ||
b.add("resultId", this.resultId); | ||
b.add("data", this.data); | ||
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; | ||
SemanticTokens other = (SemanticTokens) obj; | ||
if (this.resultId == null) { | ||
if (other.resultId != null) | ||
return false; | ||
} else if (!this.resultId.equals(other.resultId)) | ||
return false; | ||
if (this.data == null) { | ||
if (other.data != null) | ||
return false; | ||
} else if (!this.data.equals(other.data)) | ||
return false; | ||
return true; | ||
} | ||
|
||
@Override | ||
@Pure | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((this.resultId== null) ? 0 : this.resultId.hashCode()); | ||
return prime * result + ((this.data== null) ? 0 : this.data.hashCode()); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for pinging closed PR, but shouldn't we migrate
List<Integer>
toint[]
? It's a huge list/array with a lot ofInteger
boxing/unboxing operations. Yes,List
is more comfortable class with all itsCollection
methods. But is it fast enough?@ericdallo @spoenemann WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think it makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would do some profiling before optimizing something like that. Java ArrayList and Integer boxing/unboxing is super optimized in the JVM, I don't know whether you'll notice any difference for real-world array sizes.