Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Обновление версии mdclasses и восстановление работы диагностики #3218

Merged
merged 2 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ dependencies {
exclude("org.glassfish", "javax.json")
}
api("com.github.1c-syntax", "utils", "0.5.1")
api("io.github.1c-syntax", "mdclasses", "0.12.0-rc.5")
api("io.github.1c-syntax", "mdclasses", "0.12.0")
api("io.github.1c-syntax", "bsl-common-library", "0.5.0")
api("io.github.1c-syntax", "supportconf", "0.12.1")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import com.github._1c_syntax.bsl.languageserver.utils.Ranges;
import com.github._1c_syntax.bsl.mdo.Form;
import com.github._1c_syntax.bsl.mdo.MD;
import com.github._1c_syntax.bsl.mdo.storage.form.FormItem;
import com.github._1c_syntax.bsl.mdo.support.ScriptVariant;
import com.github._1c_syntax.bsl.types.ModuleType;
import com.github._1c_syntax.mdclasses.mdo.children.form.FormItem;
import org.eclipse.lsp4j.Range;

import java.util.function.Predicate;
Expand All @@ -57,16 +57,15 @@ public class WrongDataPathForFormElementsDiagnostic extends AbstractDiagnostic {

@Override
protected void check() {

var range = documentContext.getSymbolTree().getModule().getSelectionRange();
if (!Ranges.isEmpty(range)) {
checkCurrentModule(range);
}
}

// private static boolean wrongDataPath(FormItem formItem) {
// return formItem.getDataPath().getSegment().startsWith("~");
// }
private static boolean wrongDataPath(FormItem formItem) {
return formItem.getDataPath().getSegments().startsWith("~");
}

private static boolean haveFormModules(Form form) {
return !form.getModules().isEmpty();
Expand All @@ -84,13 +83,11 @@ private void checkCurrentModule(Range range) {
}

private void checkAllFormsWithoutModules() {
// todo формы не доделаны
// checkMdoObjectStream(form -> !haveFormModules(form),
// documentContext.getServerContext().getConfiguration().getChildrenByMdoRef().values().stream());
checkMdoObjectStream(form -> !haveFormModules(form),
documentContext.getServerContext().getConfiguration().getPlainChildren().stream());
}

private void checkMdoObjectStream(Predicate<Form> formFilter, Stream<MD> stream) {

stream
.filter(Form.class::isInstance)
.map(Form.class::cast)
Expand All @@ -99,17 +96,15 @@ private void checkMdoObjectStream(Predicate<Form> formFilter, Stream<MD> stream)
}

private void checkForm(Form form) {

var formData = form.getData();
if (formData.isEmpty()) {
return;
}
// todo формы не доделаны
// formData.getPlainChildren()
// .stream()
// .filter(WrongDataPathForFormElementsDiagnostic::wrongDataPath)
// .forEach(formItem -> diagnosticStorage.addDiagnostic(diagnosticRange,
// info.getMessage(formItem.getName(), getMdoRef(form))));
formData.getPlainItems()
.stream()
.filter(WrongDataPathForFormElementsDiagnostic::wrongDataPath)
.forEach(formItem -> diagnosticStorage.addDiagnostic(diagnosticRange,
info.getMessage(formItem.getName(), getMdoRef(form))));
}

private String getMdoRef(Form form) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@

import com.github._1c_syntax.bsl.languageserver.util.TestUtils;
import com.github._1c_syntax.bsl.mdclasses.CF;
import com.github._1c_syntax.bsl.mdo.Form;
import com.github._1c_syntax.utils.Absolute;
import org.eclipse.lsp4j.Diagnostic;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.test.annotation.DirtiesContext;

import java.nio.file.Paths;
import java.util.Collections;
import java.util.List;

import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat;
Expand All @@ -55,16 +56,14 @@ void setUp() {
}

@Test
@Disabled
void testNoFormModule() {

final var pathToManagedApplicationModuleFile = "/Ext/ManagedApplicationModule.bsl";

context = spy(context);
final var configuration = spy(context.getConfiguration());
when(context.getConfiguration()).thenReturn(configuration);

fillConfigChildrenByFormsWithoutModule(configuration);
when(context.getConfiguration()).thenReturn(configuration);

List<Diagnostic> diagnostics = getDiagnosticListForMockedFile(pathToManagedApplicationModuleFile);

Expand All @@ -76,7 +75,6 @@ void testNoFormModule() {
}

@Test
@Disabled
void testFormModule() {

List<Diagnostic> diagnostics = getDiagnosticListForMockedFile(PATH_TO_ELEMENT_MODULE_FILE);
Expand All @@ -88,7 +86,6 @@ void testFormModule() {
}

@Test
@Disabled
void testDynamicListFormModule() {

final var pathToDynamicListModuleFile = "/Catalogs/Справочник1/Forms/ФормаВыбора/Ext/Form/Module.bsl";
Expand All @@ -101,20 +98,23 @@ void testDynamicListFormModule() {
}

private void fillConfigChildrenByFormsWithoutModule(CF configuration) {
// final var childrenByMdoRefFromConfig = configuration.getChildrenByMdoRef();
// var childrenByMdoRef = childrenByMdoRefFromConfig.entrySet().stream()
// .filter(entry -> entry.getValue() instanceof Form)
// .collect(Collectors.toMap(Map.Entry::getKey, entry -> {
// ((Form) entry.getValue()).setModules(Collections.emptyList());
// return entry.getValue();
// }));
// when(configuration.getChildrenByMdoRef()).thenReturn(childrenByMdoRef);
var plainChildren = configuration.getPlainChildren().stream()
.filter(md -> md instanceof Form)
.map(md -> {
var mockMD = spy(md);
when(((Form) mockMD).getModules()).thenReturn(Collections.emptyList());
return mockMD;
})
.toList();

when(configuration.getPlainChildren()).thenReturn(plainChildren);
}

private List<Diagnostic> getDiagnosticListForMockedFile(String pathToDynamicListModuleFile) {
var testFile = Paths.get(PATH_TO_METADATA + pathToDynamicListModuleFile).toAbsolutePath();

var documentContext = TestUtils.getDocumentContext(testFile.toUri(), getText());
var documentContext = spy(TestUtils.getDocumentContext(testFile.toUri(), getText()));
when(documentContext.getServerContext()).thenReturn(context);

return getDiagnostics(documentContext);
}
Expand Down
Loading