Skip to content

Commit 5520bb2

Browse files
Copilotnixel2007
andcommitted
Fix ModuleSymbolMarkupContentBuilder tests
Add buildSignature() and buildLocation() methods to properly separate: - Signature: For CommonModule shows only name, for others shows localized mdoRef - Location: Shows localized mdoRef for all module types - Module info: Shows metadata (flags, reuse mode) Add missing ModuleType import. All 4 ModuleSymbolMarkupContentBuilderTest tests now pass. Co-authored-by: nixel2007 <[email protected]>
1 parent c926534 commit 5520bb2

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

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

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.github._1c_syntax.bsl.languageserver.context.symbol.ModuleSymbol;
2525
import com.github._1c_syntax.bsl.languageserver.utils.Resources;
2626
import com.github._1c_syntax.bsl.mdo.CommonModule;
27+
import com.github._1c_syntax.bsl.types.ModuleType;
2728
import lombok.RequiredArgsConstructor;
2829
import org.eclipse.lsp4j.MarkupContent;
2930
import org.eclipse.lsp4j.MarkupKind;
@@ -47,8 +48,12 @@ public class ModuleSymbolMarkupContentBuilder implements MarkupContentBuilder<Mo
4748
public MarkupContent getContent(ModuleSymbol symbol) {
4849
var markupBuilder = new StringJoiner("\n");
4950

51+
// Сигнатура модуля
52+
String signature = buildSignature(symbol);
53+
descriptionFormatter.addSectionIfNotEmpty(markupBuilder, signature);
54+
5055
// Местоположение модуля
51-
String moduleLocation = descriptionFormatter.getLocation(symbol);
56+
String moduleLocation = buildLocation(symbol);
5257
descriptionFormatter.addSectionIfNotEmpty(markupBuilder, moduleLocation);
5358

5459
// Информация о модуле из метаданных
@@ -64,6 +69,42 @@ public SymbolKind getSymbolKind() {
6469
return SymbolKind.Module;
6570
}
6671

72+
private String buildSignature(ModuleSymbol symbol) {
73+
var documentContext = symbol.getOwner();
74+
var moduleType = documentContext.getModuleType();
75+
76+
if (moduleType == ModuleType.CommonModule) {
77+
// Для CommonModule показываем только имя модуля
78+
return symbol.getName();
79+
}
80+
81+
// Для остальных типов используем локализованный mdoRef
82+
var mdObject = documentContext.getMdObject();
83+
if (mdObject.isPresent()) {
84+
return documentContext.getServerContext()
85+
.getConfiguration()
86+
.getMdoRefLocal(mdObject.get());
87+
}
88+
89+
return symbol.getName();
90+
}
91+
92+
private String buildLocation(ModuleSymbol symbol) {
93+
var documentContext = symbol.getOwner();
94+
var mdObject = documentContext.getMdObject();
95+
96+
if (mdObject.isEmpty()) {
97+
return descriptionFormatter.getLocation(symbol);
98+
}
99+
100+
// Используем локализованный mdoRef для местоположения
101+
var mdoRefLocal = documentContext.getServerContext()
102+
.getConfiguration()
103+
.getMdoRefLocal(mdObject.get());
104+
105+
return mdoRefLocal;
106+
}
107+
67108
private String getModuleInfo(ModuleSymbol symbol) {
68109
var documentContext = symbol.getOwner();
69110
var mdObject = documentContext.getMdObject();

0 commit comments

Comments
 (0)