|
| 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 | +} |
0 commit comments