Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.16.9.qualifier
Bundle-Version: 0.16.10.qualifier
Fragment-Host: org.eclipse.lsp4e
Bundle-Vendor: Eclipse LSP4E
Bundle-RequiredExecutionEnvironment: JavaSE-21
Expand Down
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.16.9-SNAPSHOT</version>
<version>0.16.10-SNAPSHOT</version>

<properties>
<os-jvm-flags /> <!-- for the default case -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@
import org.junit.jupiter.params.provider.EnumSource.Mode;

public class LSPImagesTest {

@ParameterizedTest
@EnumSource(SymbolKind.class)
public void testAllImagesForSymbolKindAvailable(SymbolKind kind) {
Image img = LSPImages.imageFromSymbolKind(kind);

assertNotNull(img);
}

@ParameterizedTest
@EnumSource(SymbolTag.class)
public void testAllOverlayImagesForSymbolTagAvailable(SymbolTag tag) {
ImageDescriptor descriptor = LSPImages.imageDescriptorOverlayFromSymbolTag(tag);
Image img = LSPImages.imageOverlayFromSymbolTag(tag);

assertNotNull(descriptor);
assertNotNull(img);
}
Expand All @@ -54,22 +54,23 @@ public void testAllOverlayImagesForSymbolTagAvailable(SymbolTag tag) {
public void testVisibilityOverlayImagesForFieldsAndMethodsAvailable(SymbolTag tag) {
var symbolTags = List.of(tag);
SymbolIconProvider labelProvider = new SymbolIconProvider();

Image fieldImage = labelProvider.getImageFor(SymbolKind.Field, symbolTags);
Image methodImage = labelProvider.getImageFor(SymbolKind.Method, symbolTags);


// we do not need a symbol for this test, so the last argument is null
Image fieldImage = labelProvider.getImageFor(SymbolKind.Field, symbolTags, null);
Image methodImage = labelProvider.getImageFor(SymbolKind.Method, symbolTags, null);

assertNotNull(fieldImage);
assertNotNull(methodImage);
}

@ParameterizedTest
@EnumSource(value=CompletionItemKind.class, mode=Mode.EXCLUDE, names= { "Color", "Event", "Operator" })
public void testAllImagesForCompletionItemKindAvailable(CompletionItemKind kind) {
CompletionItem item = new CompletionItem();
item.setKind(kind);

Image img = LSPImages.imageFromCompletionItem(item);

assertNotNull(img);
}

Expand Down
1 change: 1 addition & 0 deletions org.eclipse.lsp4e/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<?eclipse version="3.4"?>
<plugin>
<extension-point id="languageServer" name="Language Server" schema="schema/languageServer.exsd" />
<extension-point id="symbolIconsProvider" name="Symbol Icons Provider" schema="schema/symbolIconsProvider.exsd"/>

<!-- ===================================== -->
<!-- Setup Text Doc To LS Connection -->
Expand Down
126 changes: 126 additions & 0 deletions org.eclipse.lsp4e/schema/symbolIconsProvider.exsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.lsp4e" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="org.eclipse.lsp4e" id="symbolIconsProvider" name="Symbol Icons Provider"/>
</appinfo>
<documentation>
This extension point allows for customizing the (document) symbol icons with their overlays, their placing and filtering for certain language servers. This way, clients can use other images, adapt overlay icon placing and decide wich symbol details to show or hide in the outline view, call hierarchy, or type hierarchy.
</documentation>
</annotation>

<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<sequence minOccurs="1" maxOccurs="unbounded">
<element ref="iconProvider"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
The fully qualified identifier of the extension point.

This extension point offers client plug-ins options to adapt placement and selection of overlay icons for document symbols and other related elements.
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>

</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>

</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

<element name="iconProvider">
<complexType>
<sequence minOccurs="1" maxOccurs="unbounded">
<element ref="contentType"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
A string uniquely identifying this symbol icon provider extension.
</documentation>
</annotation>
</attribute>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
The fully qualified name of the class implementing this symbol icon provider. The class must extend &lt;code&gt;org.eclipse.lsp4e.ui.SymbolIconProvider&lt;/code&gt;. Clients can override individual methods to customize overlay icons and their placement (top-left, top-right, bottom-left, bottom-right, underlay).
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn="org.eclipse.lsp4e.ui.SymbolIconProvider:"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

<element name="contentType">
<complexType>
<attribute name="contentTypeId" type="string" use="required">
<annotation>
<documentation>
The unique identifier of a content type (as registered with the &lt;code&gt;org.eclipse.core.contenttype.contentTypes&lt;/code&gt; extension point) for which this icon provider should be used. The provider is also used for all derived content types that do not have a more specific provider registered.
</documentation>
<appinfo>
<meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
0.19.10
</documentation>
</annotation>



<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
LSP4E provides a default implementation via &lt;code&gt;org.eclipse.lsp4e.ui.SymbolIconProvider&lt;/code&gt;. It is used automatically for all content types that have no specific provider registered through this extension point. It renders symbol icons based on the LSP &lt;code&gt;SymbolKind&lt;/code&gt; and up to four overlay icons derived from &lt;code&gt;SymbolTag&lt;/code&gt;s (visibility, static/final/abstract/etc., marker severity) plus a deprecation underlay.
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="copyright"/>
</appinfo>
<documentation>
Copyright (c) 2024 Advantest GmbH and others.
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
</documentation>
</annotation>

</schema>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*******************************************************************************/
package org.eclipse.lsp4e;

import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.charset.StandardCharsets.*;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
Expand Down Expand Up @@ -91,6 +91,16 @@ protected void initializeImageRegistry(ImageRegistry registry) {
LSPImages.initalize(registry);
}

/**
* Utility method to log errors.
*
* @param message
* User comprehensible message
*/
public static void logError(final String message) {
logError(message, null);
}

/**
* Utility method to log errors.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.lsp4e.operations.symbols.internal.SymbolIconProviderRegistry;
import org.eclipse.lsp4e.ui.SymbolIconProvider;
import org.eclipse.lsp4j.CallHierarchyItem;
import org.eclipse.swt.graphics.Image;
Expand All @@ -25,21 +26,12 @@
*/
public class CallHierarchyLabelProvider extends LabelProvider implements IStyledLabelProvider {

private final SymbolIconProvider symbolIconProvider;

public CallHierarchyLabelProvider() {
this(new SymbolIconProvider());
}

public CallHierarchyLabelProvider(SymbolIconProvider symbolIconProvider) {
this.symbolIconProvider = symbolIconProvider;
}

@Override
public @Nullable Image getImage(final @Nullable Object element) {
if (element instanceof CallHierarchyViewTreeNode treeNode) {
CallHierarchyItem callContainer = treeNode.getCallContainer();
Image res = symbolIconProvider.getImageFor(callContainer.getKind(), callContainer.getTags());
SymbolIconProvider symbolIconProvider = SymbolIconProviderRegistry.getSymbolIconProviderFor(callContainer);
Image res = symbolIconProvider.getImageFor(callContainer.getKind(), callContainer.getTags(), callContainer);
if (res != null) {
return res;
}
Expand Down
Loading
Loading