Skip to content

Commit 12952c7

Browse files
committed
Log an error when no Semantic tokens service can be found
TypeFox/yang-vscode#74
1 parent 48cf6a9 commit 12952c7

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

yang-lsp/gradle/versions.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = '0.7.2-SNAPSHOT'
1+
version = '0.7.3-SNAPSHOT'
22

33
ext.versions = [
44
xtext: '2.26.0',

yang-lsp/io.typefox.yang.diagram/src/main/java/io/typefox/yang/diagram/YangSyncDiagramLanguageServer.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package io.typefox.yang.diagram;
22

3+
import java.util.Collections;
34
import java.util.concurrent.CompletableFuture;
45

6+
import org.apache.log4j.Logger;
57
import org.eclipse.emf.common.util.URI;
68
import org.eclipse.lsp4j.InitializeParams;
79
import org.eclipse.lsp4j.SemanticTokens;
@@ -20,6 +22,10 @@
2022

2123

2224
public class YangSyncDiagramLanguageServer extends SyncDiagramLanguageServer {
25+
26+
private static final Logger LOG = Logger.getLogger(YangSyncDiagramLanguageServer.class);
27+
private static final SemanticTokens EMPTY_SEMANTIC_TOKENS = new SemanticTokens(Collections.emptyList());
28+
2329
@Inject
2430
YangAdditionalServerCapabilities serverAdditions;
2531
@Inject
@@ -40,7 +46,8 @@ private SemanticTokens semanticTokensCompute(SemanticTokensParams params, Cancel
4046
URI uri = getURI(params.getTextDocument());
4147
ISemanticHighlightingCalculator highlightingCalculator = getService(uri, ISemanticHighlightingCalculator.class);
4248
if (highlightingCalculator == null) {
43-
throw new UnsupportedOperationException();
49+
LOG.error("Semantic Highlighting Calculator service is not registered for URI: " +uri.toString());
50+
return EMPTY_SEMANTIC_TOKENS;
4451
}
4552
return getWorkspaceManager().doRead(uri, (final Document doc, final XtextResource resource) -> {
4653
return semantikTokens.highlightedPositionsToSemanticTokens(doc, resource,

0 commit comments

Comments
 (0)