Skip to content

Commit

Permalink
Update Typescript Language Server to 4.4.3
Browse files Browse the repository at this point in the history
- Update typescript to 5.5.4 (implies minimal node version 10)
- Update typescript-language-server to 5.5.4
- Add PublishDiagnosticsCapabilities to declared capabilities
- Added handling of SematicHighlighting for tokenTypeId -1: Assume this means "only consider modifier"
- Document update procedure
- Add @todo for handling mapping mimetype -> languageId
  • Loading branch information
matthiasblaesing committed Sep 4, 2024
1 parent 083226f commit bebc2eb
Show file tree
Hide file tree
Showing 45 changed files with 153 additions and 857 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@
import java.util.stream.Collectors;
import javax.swing.event.ChangeListener;
import org.eclipse.lsp4j.ClientCapabilities;
import org.eclipse.lsp4j.DiagnosticWorkspaceCapabilities;
import org.eclipse.lsp4j.DocumentSymbolCapabilities;
import org.eclipse.lsp4j.InitializeParams;
import org.eclipse.lsp4j.InitializeResult;
import org.eclipse.lsp4j.InitializedParams;
import org.eclipse.lsp4j.PublishDiagnosticsCapabilities;
import org.eclipse.lsp4j.ResourceOperationKind;
import org.eclipse.lsp4j.SemanticTokens;
import org.eclipse.lsp4j.SemanticTokensCapabilities;
Expand Down Expand Up @@ -427,6 +429,8 @@ private static InitializeResult initServer(Process p, LanguageServer server, Fil
wcc.getWorkspaceEdit().setResourceOperations(Arrays.asList(ResourceOperationKind.Create, ResourceOperationKind.Delete, ResourceOperationKind.Rename));
SymbolCapabilities sc = new SymbolCapabilities(new SymbolKindCapabilities(Arrays.asList(SymbolKind.values())));
wcc.setSymbol(sc);
PublishDiagnosticsCapabilities publishDiagnostics = new PublishDiagnosticsCapabilities();
tdcc.setPublishDiagnostics(publishDiagnostics);
initParams.setCapabilities(new ClientCapabilities(wcc, tdcc, null));
CompletableFuture<InitializeResult> initResult = server.initialize(initParams);
while (true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public void run(LSPBindings bindings, FileObject file) {
int lastColumn = 0;
int offset = 0;
for (int i = 0; i < data.size(); i += 5) {
int deltaLine = data.get(i).intValue();
int deltaColumn = data.get(i + 1).intValue();
int deltaLine = data.get(i);
int deltaColumn = data.get(i + 1);
if (deltaLine == 0) {
lastColumn += deltaColumn;
offset += deltaColumn;
Expand All @@ -97,11 +97,11 @@ public void run(LSPBindings bindings, FileObject file) {
lastColumn = deltaColumn;
offset = Utils.getOffset(doc, new Position(lastLine, lastColumn));
}
if (data.get(i + 2).intValue() <= 0) {
if (data.get(i + 2) <= 0) {
continue; //XXX!
}
AttributeSet tokenHighlight = fcs == null ? EMPTY : tokenHighlight(bindings, fcs, data.get(i + 3).intValue(), data.get(i + 4).intValue());
target.addHighlight(offset, offset + data.get(i + 2).intValue(), tokenHighlight);
AttributeSet tokenHighlight = fcs == null ? EMPTY : tokenHighlight(bindings, fcs, data.get(i + 3), data.get(i + 4));
target.addHighlight(offset, offset + data.get(i + 2), tokenHighlight);
}
getBag(doc).setHighlights(target);
} catch (InterruptedException | ExecutionException ex) {
Expand All @@ -111,6 +111,7 @@ public void run(LSPBindings bindings, FileObject file) {

private final Map<Integer, Map<Integer, AttributeSet>> tokenId2Highlight = new HashMap<>();

@SuppressWarnings("AssignmentToMethodParameter")
private AttributeSet tokenHighlight(final LSPBindings bindings, final FontColorSettings fcs, int tokenId, int modifiers) {
assert fcs != null;
return tokenId2Highlight.computeIfAbsent(tokenId, s -> new HashMap<>())
Expand All @@ -121,7 +122,7 @@ private AttributeSet tokenHighlight(final LSPBindings bindings, final FontColorS
//invalid token id
return EMPTY;
}
String tokenName = tokenTypes.get(tokenId);
String tokenName = tokenId >= 0 ? tokenTypes.get(tokenId) : null;
boolean isStatic = false;
boolean isDeclaration = false;
while (mods != 0) {
Expand All @@ -134,7 +135,7 @@ private AttributeSet tokenHighlight(final LSPBindings bindings, final FontColorS
mods &= ~mod;
}

String colorSet = "mod-" + tokenName + (isDeclaration ? "-declaration" : "");
String colorSet = "mod" + (tokenName != null ? ("-" + tokenName) : "") + (isDeclaration ? "-declaration" : "");
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "LSP Semantic coloring. token kind: {0}", colorSet);
}
Expand All @@ -159,14 +160,15 @@ private static OffsetsBag getBag(Document doc) {
OffsetsBag bag = (OffsetsBag) doc.getProperty(SemanticHighlight.class);

if (bag == null) {
doc.putProperty(SemanticHighlight.class, bag = new OffsetsBag(doc));
bag = new OffsetsBag(doc);
doc.putProperty(SemanticHighlight.class, bag);
}

return bag;
}

private static AttributeSet adjustAttributes(AttributeSet as) {
Collection<Object> attrs = new LinkedList<Object>();
Collection<Object> attrs = new LinkedList<>();

for (Enumeration<?> e = as.getAttributeNames(); e.hasMoreElements(); ) {
Object key = e.nextElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ private void ensureDidOpenSent(Document doc) {
}
});

// @todo: the mimetype is not the language ID
TextDocumentItem textDocumentItem = new TextDocumentItem(uri,
FileUtil.getMIMEType(file),
0,
Expand Down
39 changes: 39 additions & 0 deletions nbbuild/licenses/Apache-2.0-typescript-language-server
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
Parts of the code copied from the https://github.com/microsoft/vscode repository are licensed under the following license:

BEGIN LICENSE ----------------------------------------------------------------

MIT License

Copyright (c) 2015 - present Microsoft Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

END LICESE -------------------------------------------------------------------

This applies to files that include the following license header:

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/


The rest of the code licensed under:


Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down
15 changes: 0 additions & 15 deletions nbbuild/licenses/ISC-graceful-fs

This file was deleted.

22 changes: 0 additions & 22 deletions nbbuild/licenses/MIT-command-exists

This file was deleted.

22 changes: 0 additions & 22 deletions nbbuild/licenses/MIT-commander

This file was deleted.

15 changes: 0 additions & 15 deletions nbbuild/licenses/MIT-fs-extra

This file was deleted.

15 changes: 0 additions & 15 deletions nbbuild/licenses/MIT-jsonfile

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions nbbuild/licenses/MIT-tempy

This file was deleted.

20 changes: 0 additions & 20 deletions nbbuild/licenses/MIT-universalify

This file was deleted.

46 changes: 0 additions & 46 deletions nbbuild/licenses/MIT-vscode-jsonrpc

This file was deleted.

Loading

0 comments on commit bebc2eb

Please sign in to comment.