Skip to content

Commit

Permalink
Semantic Tokens: Do not use default theme (#1029)
Browse files Browse the repository at this point in the history
Fix for #1028 - we requested the default theme if no TM mapping for the editor, but
this calls syncExec. Reconciler threads mustn't block on the UI thread as it is possible for the UI thread to be blocked
waiting for reconciliation; this deadlock was indeed observed.
  • Loading branch information
ahmedneilhussain authored Jun 21, 2024
1 parent 91f8365 commit 5f0770d
Show file tree
Hide file tree
Showing 7 changed files with 746 additions and 12 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.lsp4e.test/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tests for language server bundle (Incubation)
Bundle-SymbolicName: org.eclipse.lsp4e.test;singleton:=true
Bundle-Version: 0.15.13.qualifier
Bundle-Version: 0.15.14.qualifier
Fragment-Host: org.eclipse.lsp4e
Bundle-Vendor: Eclipse.org
Bundle-RequiredExecutionEnvironment: JavaSE-17
Expand Down
30 changes: 30 additions & 0 deletions org.eclipse.lsp4e.test/fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
contentType="org.eclipse.lsp4e.test.content-type"
id="org.eclipse.lsp4e.test.server">
</contentTypeMapping>
<contentTypeMapping
contentType="org.eclipse.lsp4e.test.content-type.tm"
id="org.eclipse.lsp4e.test.server">
</contentTypeMapping>
<contentTypeMapping
contentType="org.eclipse.lsp4e.test.content-type-multi-ls"
id="org.eclipse.lsp4e.test.server">
Expand Down Expand Up @@ -125,6 +129,13 @@
id="org.eclipse.lsp4e.test.content-type"
name="Test Content Type"
priority="normal">
</content-type>
<content-type
base-type="org.eclipse.core.runtime.text"
file-extensions="lsptm"
id="org.eclipse.lsp4e.test.content-type.tm"
name="Test Content Type With TM Grammar"
priority="normal">
</content-type>
<content-type
base-type="org.eclipse.core.runtime.text"
Expand Down Expand Up @@ -277,4 +288,23 @@
class="org.eclipse.lsp4e.test.references.FindReferencesTest$UiFreezeEventLogger">
</logger>
</extension>

<extension
point="org.eclipse.tm4e.registry.grammars">
<grammar
path="org/eclipse/lsp4e/test/semanticTokens/rust.tmLanguage.json"
scopeName="source.lsptm">
</grammar>
<scopeNameContentTypeBinding
contentTypeId="org.eclipse.lsp4e.test.content-type.tm"
scopeName="source.lsptm">
</scopeNameContentTypeBinding>
</extension>
<extension
point="org.eclipse.ui.genericeditor.presentationReconcilers">
<presentationReconciler
class="org.eclipse.tm4e.ui.text.TMPresentationReconciler"
contentType="org.eclipse.lsp4e.test.content-type.tm">
</presentationReconciler>
</extension>
</fragment>
2 changes: 1 addition & 1 deletion org.eclipse.lsp4e.test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>
<artifactId>org.eclipse.lsp4e.test</artifactId>
<packaging>eclipse-test-plugin</packaging>
<version>0.15.13-SNAPSHOT</version>
<version>0.15.14-SNAPSHOT</version>

<properties>
<os-jvm-flags /> <!-- for the default case -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void testKeyword() throws CoreException {

MockLanguageServer.INSTANCE.getTextDocumentService().setSemanticTokens(semanticTokens);

IFile file = TestUtils.createUniqueTestFile(project, "lspt", SemanticTokensTestUtil.keywordText);
IFile file = TestUtils.createUniqueTestFile(project, "lsptm", SemanticTokensTestUtil.keywordText);
ITextViewer textViewer = TestUtils.openTextViewer(file);

Display display = shell.getDisplay();
Expand All @@ -58,18 +58,30 @@ public void testKeyword() throws CoreException {
StyleRange[] styleRanges = textViewer.getTextWidget().getStyleRanges();
var backgroundColor = textViewer.getTextWidget().getBackground();

assertEquals(3, styleRanges.length);
assertEquals(6, styleRanges.length);

assertEquals(0, styleRanges[0].start);
assertEquals(4, styleRanges[0].length);
assertNotEquals(styleRanges[0].foreground, backgroundColor);

assertEquals(15, styleRanges[1].start);
assertEquals(4, styleRanges[1].length);
assertEquals(4, styleRanges[1].start);
assertEquals(11, styleRanges[1].length);
assertNotEquals(styleRanges[1].foreground, backgroundColor);

assertEquals(24, styleRanges[2].start);
assertEquals(7, styleRanges[2].length);
assertEquals(15, styleRanges[2].start);
assertEquals(4, styleRanges[2].length);
assertNotEquals(styleRanges[2].foreground, backgroundColor);

assertEquals(19, styleRanges[3].start);
assertEquals(5, styleRanges[3].length);
assertNotEquals(styleRanges[3].foreground, backgroundColor);

assertEquals(24, styleRanges[4].start);
assertEquals(7, styleRanges[4].length);
assertNotEquals(styleRanges[4].foreground, backgroundColor);

assertEquals(31, styleRanges[5].start);
assertEquals(11, styleRanges[5].length);
assertNotEquals(styleRanges[5].foreground, backgroundColor);
}
}
Loading

0 comments on commit 5f0770d

Please sign in to comment.