Skip to content

Commit

Permalink
Semantic Tokens: Do not use default theme
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 committed Jun 17, 2024
1 parent 11b81cf commit 1d5ef13
Show file tree
Hide file tree
Showing 5 changed files with 744 additions and 10 deletions.
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>
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 1d5ef13

Please sign in to comment.