use of com.github._1c_syntax.mdclasses.mdo.support.MDOReference in project bsl-language-server by 1c-syntax.
the class ModuleSymbolComputerTest method testModuleName.
@Test
void testModuleName() {
// given
var documentContext = spy(TestUtils.getDocumentContextFromFile("./src/test/resources/context/symbol/ModuleSymbol.bsl"));
var computer = new ModuleSymbolComputer(documentContext);
MDOReference mdoReference = mock(MDOReference.class);
when(mdoReference.getMdoRef()).thenReturn("Document.Document1");
AbstractMDObjectBase mdObject = mock(AbstractMDObjectBase.class);
when(mdObject.getMdoReference()).thenReturn(mdoReference);
doReturn(Optional.of(mdObject)).when(documentContext).getMdObject();
// when-then pairs:
// when
doReturn(ModuleType.UNKNOWN).when(documentContext).getModuleType();
var moduleSymbol = computer.compute();
// then
assertThat(moduleSymbol.getName()).isEqualTo("Document.Document1");
// when
doReturn(ModuleType.ObjectModule).when(documentContext).getModuleType();
moduleSymbol = computer.compute();
// then
assertThat(moduleSymbol.getName()).isEqualTo("Document.Document1.ObjectModule");
// when
doReturn(ModuleType.ManagerModule).when(documentContext).getModuleType();
moduleSymbol = computer.compute();
// then
assertThat(moduleSymbol.getName()).isEqualTo("Document.Document1.ManagerModule");
}
use of com.github._1c_syntax.mdclasses.mdo.support.MDOReference in project mdclasses by 1c-syntax.
the class PairConverter method unmarshal.
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
if ("languages".equals(reader.getNodeName())) {
var uuid = reader.getAttribute("uuid");
var language = (MDLanguage) context.convertAnother(new MDLanguage(), MDLanguage.class);
language.setUuid(uuid);
language.setMdoReference(new MDOReference(language));
return Either.right(language);
} else if (reader.getValue().contains(".")) {
// уже лежит имя
return Either.left(reader.getValue());
} else {
var type = MDOType.fromValue(reader.getNodeName());
return type.map(mdoType -> Either.left(mdoType.getName() + "." + reader.getValue())).orElseGet(() -> Either.left(reader.getNodeName() + "." + reader.getValue()));
}
}
Aggregations