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
rubenporras committed Nov 21, 2022
1 parent 6905f41 commit 6816201
Show file tree
Hide file tree
Showing 5 changed files with 434 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.18.0,0.19.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 @@ -657,4 +657,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,36 @@
/*******************************************************************************
* Copyright (c) 2022 Avaloq Evolution AG.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
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 6816201

Please sign in to comment.