Skip to content

Commit 33b1365

Browse files
committed
Смена апи MarkupContentBuilder в сторону SymbolKind
1 parent c251a79 commit 33b1365

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/MarkupContentBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import com.github._1c_syntax.bsl.languageserver.context.symbol.Symbol;
2525
import org.eclipse.lsp4j.MarkupContent;
26+
import org.eclipse.lsp4j.SymbolKind;
2627

2728
/**
2829
* Интерфейс построителя контента для всплывающего окна на основе символа.
@@ -41,7 +42,7 @@ public interface MarkupContentBuilder<T extends Symbol> {
4142
/**
4243
* Тип символа, на основе которого работает данный построитель.
4344
*
44-
* @return тип символа (см. {@link Symbol})
45+
* @return тип символа.
4546
*/
46-
Class<T> getType();
47+
SymbolKind getSymbolKind();
4748
}

src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/MarkupContentBuilderConfiguration.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
package com.github._1c_syntax.bsl.languageserver.hover;
2323

2424
import com.github._1c_syntax.bsl.languageserver.context.symbol.Symbol;
25+
import org.eclipse.lsp4j.SymbolKind;
2526
import org.springframework.context.annotation.Bean;
2627
import org.springframework.context.annotation.Configuration;
2728

@@ -41,10 +42,10 @@ public class MarkupContentBuilderConfiguration {
4142
* @return Карта построителей контента для всплывающего окна и типов символов, для которых они предназначены.
4243
*/
4344
@Bean
44-
public <T extends Symbol> Map<Class<T>, MarkupContentBuilder<T>> markupContentBuilders(
45+
public <T extends Symbol> Map<SymbolKind, MarkupContentBuilder<T>> markupContentBuilders(
4546
Collection<MarkupContentBuilder<T>> builders
4647
) {
47-
return builders.stream().collect(Collectors.toMap(MarkupContentBuilder::getType, Function.identity()));
48+
return builders.stream().collect(Collectors.toMap(MarkupContentBuilder::getSymbolKind, Function.identity()));
4849
}
4950

5051
}

src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/MethodSymbolMarkupContentBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import lombok.RequiredArgsConstructor;
3333
import org.eclipse.lsp4j.MarkupContent;
3434
import org.eclipse.lsp4j.MarkupKind;
35+
import org.eclipse.lsp4j.SymbolKind;
3536
import org.springframework.stereotype.Component;
3637

3738
import java.util.Collections;
@@ -107,8 +108,8 @@ public MarkupContent getContent(MethodSymbol symbol) {
107108
}
108109

109110
@Override
110-
public Class<MethodSymbol> getType() {
111-
return MethodSymbol.class;
111+
public SymbolKind getSymbolKind() {
112+
return SymbolKind.Method;
112113
}
113114

114115
private static void addSectionIfNotEmpty(StringJoiner markupBuilder, String newContent) {

src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/VariableSymbolMarkupContentBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public MarkupContent getContent(VariableSymbol symbol) {
7575
}
7676

7777
@Override
78-
public Class<VariableSymbol> getType() {
79-
return VariableSymbol.class;
78+
public SymbolKind getSymbolKind() {
79+
return SymbolKind.Variable;
8080
}
8181

8282
private String getSignature(VariableSymbol symbol) {

src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/HoverProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.eclipse.lsp4j.Hover;
3131
import org.eclipse.lsp4j.HoverParams;
3232
import org.eclipse.lsp4j.Position;
33+
import org.eclipse.lsp4j.SymbolKind;
3334
import org.springframework.stereotype.Component;
3435

3536
import java.util.Map;
@@ -40,7 +41,7 @@
4041
public final class HoverProvider {
4142

4243
private final ReferenceResolver referenceResolver;
43-
private final Map<Class<Symbol>, MarkupContentBuilder<Symbol>> markupContentBuilders;
44+
private final Map<SymbolKind, MarkupContentBuilder<Symbol>> markupContentBuilders;
4445

4546
public Optional<Hover> getHover(DocumentContext documentContext, HoverParams params) {
4647
Position position = params.getPosition();
@@ -50,7 +51,7 @@ public Optional<Hover> getHover(DocumentContext documentContext, HoverParams par
5051
var symbol = reference.getSymbol();
5152
var range = reference.getSelectionRange();
5253

53-
return Optional.ofNullable(markupContentBuilders.get(symbol.getClass()))
54+
return Optional.ofNullable(markupContentBuilders.get(symbol.getSymbolKind()))
5455
.map(markupContentBuilder -> markupContentBuilder.getContent(symbol))
5556
.map(content -> new Hover(content, range));
5657
});

0 commit comments

Comments
 (0)