Skip to content

Commit

Permalink
Initial implementation of a semantic tokens reconciler
Browse files Browse the repository at this point in the history
Initial implementation of a semantic tokens reconciler which supports
only SemanticTokensFull.

The reconciler uses the theme defined for TM4E so that the same styles
are used for the same token types.

In addition to the tokens defined for TM4E, also the deprecated modifier
is supported by marking striking out the regions.
  • Loading branch information
pcr authored and pcr committed Oct 5, 2022
1 parent 114422a commit b282afe
Show file tree
Hide file tree
Showing 5 changed files with 407 additions and 0 deletions.
1 change: 1 addition & 0 deletions org.eclipse.lsp4e/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.12.0",
org.eclipse.debug.ui;bundle-version="3.11.200",
org.eclipse.swt,
org.eclipse.jdt.annotation;bundle-version="2.1.0";resolution:=optional,
org.eclipse.tm4e.ui,
org.eclipse.ui.editors,
org.eclipse.ui.navigator;bundle-version="3.6.100",
org.eclipse.lsp4j;bundle-version="[0.15.0,0.16.0)",
Expand Down
17 changes: 17 additions & 0 deletions org.eclipse.lsp4e/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -663,4 +663,21 @@
</enabledWhen>
</reconciler>
</extension>
<extension
point="org.eclipse.ui.genericeditor.reconcilers">
<reconciler
class="org.eclipse.lsp4e.operations.semanticTokens.SemanticHighlightReconciler"
contentType="org.eclipse.core.runtime.text">
<enabledWhen>
<or>
<with variable="editorInput">
<test property="org.eclipse.lsp4e.hasLanguageServer"/>
</with>
<with variable="viewer">
<test property="org.eclipse.lsp4e.hasLanguageServer"/>
</with>
</or>
</enabledWhen>
</reconciler>
</extension>
</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.eclipse.lsp4e.operations.semanticTokens;

import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.reconciler.MonoReconciler;


public class SemanticHighlightReconciler extends MonoReconciler {

public SemanticHighlightReconciler() {
super(new SemanticHighlightReconcilerStrategy(), false);
}

@Override
public void install(final ITextViewer textViewer) {
super.install(textViewer);
// no need to do that if https://bugs.eclipse.org/bugs/show_bug.cgi?id=521326 is accepted
((SemanticHighlightReconcilerStrategy) getReconcilingStrategy(IDocument.DEFAULT_CONTENT_TYPE)).install(textViewer);
}

@Override
public void uninstall() {
super.uninstall();
// no need to do that if https://bugs.eclipse.org/bugs/show_bug.cgi?id=521326 is accepted
((SemanticHighlightReconcilerStrategy) getReconcilingStrategy(IDocument.DEFAULT_CONTENT_TYPE)).uninstall();
}

}
Loading

0 comments on commit b282afe

Please sign in to comment.