Skip to content

Commit 9fe66a3

Browse files
Update Typescript Language Server to 4.4.3
- Update typescript to 5.6.2 (implies minimal node version 10) - Update typescript-language-server to 4.4.3 - 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
1 parent 180b3f7 commit 9fe66a3

47 files changed

Lines changed: 627 additions & 925 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@
5353
import java.util.stream.Collectors;
5454
import javax.swing.event.ChangeListener;
5555
import org.eclipse.lsp4j.ClientCapabilities;
56+
import org.eclipse.lsp4j.DiagnosticWorkspaceCapabilities;
5657
import org.eclipse.lsp4j.DocumentSymbolCapabilities;
5758
import org.eclipse.lsp4j.InitializeParams;
5859
import org.eclipse.lsp4j.InitializeResult;
5960
import org.eclipse.lsp4j.InitializedParams;
61+
import org.eclipse.lsp4j.PublishDiagnosticsCapabilities;
6062
import org.eclipse.lsp4j.ResourceOperationKind;
6163
import org.eclipse.lsp4j.SemanticTokens;
6264
import org.eclipse.lsp4j.SemanticTokensCapabilities;
@@ -427,6 +429,8 @@ private static InitializeResult initServer(Process p, LanguageServer server, Fil
427429
wcc.getWorkspaceEdit().setResourceOperations(Arrays.asList(ResourceOperationKind.Create, ResourceOperationKind.Delete, ResourceOperationKind.Rename));
428430
SymbolCapabilities sc = new SymbolCapabilities(new SymbolKindCapabilities(Arrays.asList(SymbolKind.values())));
429431
wcc.setSymbol(sc);
432+
PublishDiagnosticsCapabilities publishDiagnostics = new PublishDiagnosticsCapabilities();
433+
tdcc.setPublishDiagnostics(publishDiagnostics);
430434
initParams.setCapabilities(new ClientCapabilities(wcc, tdcc, null));
431435
CompletableFuture<InitializeResult> initResult = server.initialize(initParams);
432436
while (true) {

ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/SemanticHighlight.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public void run(LSPBindings bindings, FileObject file) {
8787
int lastColumn = 0;
8888
int offset = 0;
8989
for (int i = 0; i < data.size(); i += 5) {
90-
int deltaLine = data.get(i).intValue();
91-
int deltaColumn = data.get(i + 1).intValue();
90+
int deltaLine = data.get(i);
91+
int deltaColumn = data.get(i + 1);
9292
if (deltaLine == 0) {
9393
lastColumn += deltaColumn;
9494
offset += deltaColumn;
@@ -97,11 +97,11 @@ public void run(LSPBindings bindings, FileObject file) {
9797
lastColumn = deltaColumn;
9898
offset = Utils.getOffset(doc, new Position(lastLine, lastColumn));
9999
}
100-
if (data.get(i + 2).intValue() <= 0) {
100+
if (data.get(i + 2) <= 0) {
101101
continue; //XXX!
102102
}
103-
AttributeSet tokenHighlight = fcs == null ? EMPTY : tokenHighlight(bindings, fcs, data.get(i + 3).intValue(), data.get(i + 4).intValue());
104-
target.addHighlight(offset, offset + data.get(i + 2).intValue(), tokenHighlight);
103+
AttributeSet tokenHighlight = fcs == null ? EMPTY : tokenHighlight(bindings, fcs, data.get(i + 3), data.get(i + 4));
104+
target.addHighlight(offset, offset + data.get(i + 2), tokenHighlight);
105105
}
106106
getBag(doc).setHighlights(target);
107107
} catch (InterruptedException | ExecutionException ex) {
@@ -111,6 +111,7 @@ public void run(LSPBindings bindings, FileObject file) {
111111

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

114+
@SuppressWarnings("AssignmentToMethodParameter")
114115
private AttributeSet tokenHighlight(final LSPBindings bindings, final FontColorSettings fcs, int tokenId, int modifiers) {
115116
assert fcs != null;
116117
return tokenId2Highlight.computeIfAbsent(tokenId, s -> new HashMap<>())
@@ -121,7 +122,7 @@ private AttributeSet tokenHighlight(final LSPBindings bindings, final FontColorS
121122
//invalid token id
122123
return EMPTY;
123124
}
124-
String tokenName = tokenTypes.get(tokenId);
125+
String tokenName = tokenId >= 0 ? tokenTypes.get(tokenId) : null;
125126
boolean isStatic = false;
126127
boolean isDeclaration = false;
127128
while (mods != 0) {
@@ -134,7 +135,7 @@ private AttributeSet tokenHighlight(final LSPBindings bindings, final FontColorS
134135
mods &= ~mod;
135136
}
136137

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

161162
if (bag == null) {
162-
doc.putProperty(SemanticHighlight.class, bag = new OffsetsBag(doc));
163+
bag = new OffsetsBag(doc);
164+
doc.putProperty(SemanticHighlight.class, bag);
163165
}
164166

165167
return bag;
166168
}
167169

168170
private static AttributeSet adjustAttributes(AttributeSet as) {
169-
Collection<Object> attrs = new LinkedList<Object>();
171+
Collection<Object> attrs = new LinkedList<>();
170172

171173
for (Enumeration<?> e = as.getAttributeNames(); e.hasMoreElements(); ) {
172174
Object key = e.nextElement();

ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/TextDocumentSyncServerCapabilityHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ private void ensureDidOpenSent(Document doc) {
302302
}
303303
});
304304

305+
// @todo: the mimetype is not the language ID
305306
TextDocumentItem textDocumentItem = new TextDocumentItem(uri,
306307
FileUtil.getMIMEType(file),
307308
0,

nbbuild/licenses/Apache-2.0-typescript

Lines changed: 198 additions & 1 deletion
Large diffs are not rendered by default.

nbbuild/licenses/Apache-2.0-typescript-language-server

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1+
Parts of the code copied from the https://github.com/microsoft/vscode repository are licensed under the following license:
2+
3+
BEGIN LICENSE ----------------------------------------------------------------
4+
5+
MIT License
6+
7+
Copyright (c) 2015 - present Microsoft Corporation
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.
26+
27+
END LICESE -------------------------------------------------------------------
28+
29+
This applies to files that include the following license header:
30+
31+
/*---------------------------------------------------------------------------------------------
32+
* Copyright (c) Microsoft Corporation. All rights reserved.
33+
* Licensed under the MIT License. See License.txt in the project root for license information.
34+
*--------------------------------------------------------------------------------------------*/
35+
36+
37+
The rest of the code licensed under:
38+
39+
140
Apache License
241
Version 2.0, January 2004
342
http://www.apache.org/licenses/

nbbuild/licenses/ISC-graceful-fs

Lines changed: 0 additions & 15 deletions
This file was deleted.

nbbuild/licenses/MIT-command-exists

Lines changed: 0 additions & 22 deletions
This file was deleted.

nbbuild/licenses/MIT-commander

Lines changed: 0 additions & 22 deletions
This file was deleted.

nbbuild/licenses/MIT-fs-extra

Lines changed: 0 additions & 15 deletions
This file was deleted.

nbbuild/licenses/MIT-jsonfile

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)