Skip to content

Commit 78a3277

Browse files
travkin79rubenporras
authored andcommitted
feat: Use symbol tags in views to display visibility and other details
Affected views - Outline view - Call hierarchy view - Type hierachy view (and quick type hierarchy dialog) This change is an implementation of the proposal from microsoft/language-server-protocol#2003 See also #977 and llvm/llvm-project#167536
1 parent 1168eb4 commit 78a3277

35 files changed

+11423
-106
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 Advantest GmbH and others.
3+
* This program and the accompanying materials are made
4+
* available under the terms of the Eclipse Public License 2.0
5+
* which is available at https://www.eclipse.org/legal/epl-2.0/
6+
*
7+
* SPDX-License-Identifier: EPL-2.0
8+
*
9+
* Contributors:
10+
* Dietrich Travkin (Solunar GmbH) - initial implementation
11+
*******************************************************************************/
12+
package org.eclipse.lsp4e.test.symbols;
13+
14+
import static org.junit.jupiter.api.Assertions.*;
15+
16+
import java.util.Arrays;
17+
import java.util.List;
18+
19+
import org.eclipse.lsp4e.operations.symbols.SymbolsUtil;
20+
import org.eclipse.lsp4j.DocumentSymbol;
21+
import org.eclipse.lsp4j.SymbolInformation;
22+
import org.eclipse.lsp4j.SymbolTag;
23+
import org.eclipse.lsp4j.WorkspaceSymbol;
24+
import org.junit.jupiter.api.Test;
25+
26+
public class SymbolsUtilTest {
27+
28+
private static final List<SymbolTag> symbolTagsWithDeprecated = Arrays.asList(
29+
SymbolTag.Package, SymbolTag.Deprecated, SymbolTag.ReadOnly);
30+
private static final List<SymbolTag> symbolTagsWithoutDeprecated = Arrays.asList(
31+
SymbolTag.Public, SymbolTag.Declaration, SymbolTag.Static);
32+
33+
@Test
34+
public void testDeprecatedCheckForSymbolInformation() {
35+
var symbolInformation = new SymbolInformation();
36+
37+
assertFalse(SymbolsUtil.isDeprecated(symbolInformation));
38+
39+
symbolInformation.setDeprecated(true);
40+
41+
assertTrue(SymbolsUtil.isDeprecated(symbolInformation));
42+
43+
symbolInformation = new SymbolInformation();
44+
symbolInformation.setTags(symbolTagsWithDeprecated);
45+
46+
assertTrue(SymbolsUtil.isDeprecated(symbolInformation));
47+
48+
symbolInformation.setTags(symbolTagsWithoutDeprecated);
49+
50+
assertFalse(SymbolsUtil.isDeprecated(symbolInformation));
51+
}
52+
53+
@Test
54+
public void testDeprecatedCheckForWorkspaceSymbol() {
55+
var workspaceSymbol = new WorkspaceSymbol();
56+
57+
assertFalse(SymbolsUtil.isDeprecated(workspaceSymbol));
58+
59+
workspaceSymbol.setTags(symbolTagsWithDeprecated);
60+
61+
assertTrue(SymbolsUtil.isDeprecated(workspaceSymbol));
62+
63+
workspaceSymbol.setTags(symbolTagsWithoutDeprecated);
64+
65+
assertFalse(SymbolsUtil.isDeprecated(workspaceSymbol));
66+
}
67+
68+
@Test
69+
public void testDeprecatedCheckForDocumentSymbol() {
70+
var documentSymbol = new DocumentSymbol();
71+
72+
assertFalse(SymbolsUtil.isDeprecated(documentSymbol));
73+
74+
documentSymbol.setDeprecated(true);
75+
76+
assertTrue(SymbolsUtil.isDeprecated(documentSymbol));
77+
78+
documentSymbol = new DocumentSymbol();
79+
documentSymbol.setTags(symbolTagsWithDeprecated);
80+
81+
assertTrue(SymbolsUtil.isDeprecated(documentSymbol));
82+
83+
documentSymbol.setTags(symbolTagsWithoutDeprecated);
84+
85+
assertFalse(SymbolsUtil.isDeprecated(documentSymbol));
86+
}
87+
88+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 Advantest GmbH and others.
3+
* This program and the accompanying materials are made
4+
* available under the terms of the Eclipse Public License 2.0
5+
* which is available at https://www.eclipse.org/legal/epl-2.0/
6+
*
7+
* SPDX-License-Identifier: EPL-2.0
8+
*
9+
* Contributors:
10+
* Dietrich Travkin (Solunar GmbH) - initial implementation
11+
*******************************************************************************/
12+
package org.eclipse.lsp4e.test.utils;
13+
14+
import static org.junit.jupiter.api.Assertions.*;
15+
16+
import org.eclipse.jface.resource.ImageDescriptor;
17+
import org.eclipse.lsp4e.ui.LSPImages;
18+
import org.eclipse.lsp4j.CompletionItem;
19+
import org.eclipse.lsp4j.CompletionItemKind;
20+
import org.eclipse.lsp4j.SymbolKind;
21+
import org.eclipse.lsp4j.SymbolTag;
22+
import org.eclipse.swt.graphics.Image;
23+
import org.junit.jupiter.params.ParameterizedTest;
24+
import org.junit.jupiter.params.provider.EnumSource;
25+
import org.junit.jupiter.params.provider.EnumSource.Mode;
26+
27+
public class LSPImagesTest {
28+
29+
@ParameterizedTest
30+
@EnumSource(SymbolKind.class)
31+
public void testAllImagesForSymbolKindAvailable(SymbolKind kind) {
32+
Image img = LSPImages.imageFromSymbolKind(kind);
33+
34+
assertNotNull(img);
35+
}
36+
37+
@ParameterizedTest
38+
@EnumSource(SymbolTag.class)
39+
public void testAllOverlayImagesForSymbolTagAvailable(SymbolTag tag) {
40+
ImageDescriptor descriptor = LSPImages.imageDescriptorOverlayFromSymbolTag(tag);
41+
Image img = LSPImages.imageOverlayFromSymbolTag(tag);
42+
43+
assertNotNull(descriptor);
44+
assertNotNull(img);
45+
}
46+
47+
@ParameterizedTest
48+
@EnumSource(value=CompletionItemKind.class, mode=Mode.EXCLUDE, names= { "Color", "Event", "Operator" })
49+
public void testAllImagesForCompletionItemKindAvailable(CompletionItemKind kind) {
50+
CompletionItem item = new CompletionItem();
51+
item.setKind(kind);
52+
53+
Image img = LSPImages.imageFromCompletionItem(item);
54+
55+
assertNotNull(img);
56+
}
57+
58+
}
5.05 KB
Loading

org.eclipse.lsp4e/icons/full/obj16/constructor.svg

Lines changed: 68 additions & 33 deletions
Loading
5.59 KB
Loading
Lines changed: 99 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)