Skip to content

Commit eec3214

Browse files
committed
Use symbol tags in outline view to display visibility and other details
1 parent ee645ca commit eec3214

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+652
-56
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: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.SymbolKind;
19+
import org.eclipse.lsp4j.SymbolTag;
20+
import org.eclipse.swt.graphics.Image;
21+
import org.junit.jupiter.api.Test;
22+
23+
public class LSPImagesTest {
24+
25+
@Test
26+
public void testAllImagesForSymbolKindAvailable() {
27+
for (SymbolKind kind : SymbolKind.values()) {
28+
Image img = LSPImages.imageFromSymbolKind(kind);
29+
30+
assertNotNull(img);
31+
}
32+
}
33+
34+
@Test
35+
public void testAllOverlayImagesForSymbolTagAvailable() {
36+
for (SymbolTag tag : SymbolTag.values()) {
37+
ImageDescriptor descriptor = LSPImages.imageDescriptorOverlayFromSymbolTag(tag);
38+
Image img = LSPImages.imageOverlayFromSymbolTag(tag);
39+
40+
assertNotNull(descriptor);
41+
assertNotNull(img);
42+
}
43+
}
44+
45+
}
5.05 KB
5.59 KB
257 Bytes
488 Bytes
252 Bytes
482 Bytes
4.35 KB
4.52 KB

0 commit comments

Comments
 (0)