Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nixel2007 committed Jan 28, 2020
2 parents e472db1 + 4036536 commit f1c335c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ private void addChildrenToRelatedInformation(
Integer... ruleIndex
) {
Trees.getChildren(ctx, ruleIndex).stream()
.filter(node ->
node.getStart() != null
&& node.getStop() != null
&& (node.getStart().getLine() <= node.getStop().getLine())) // todo исправить костыль
.filter(node -> !node.getTokens().isEmpty())
.map(node ->
RelatedInformation.create(
documentContext.getUri(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,18 @@

import com.ginsberg.junit.exit.ExpectSystemExitWithStatus;
import com.github._1c_syntax.bsl.languageserver.BSLLSPLauncher;
import com.github._1c_syntax.bsl.languageserver.configuration.LanguageServerConfiguration;
import com.github._1c_syntax.bsl.languageserver.providers.DiagnosticProvider;
import com.github._1c_syntax.bsl.languageserver.util.TestUtils;
import org.apache.commons.io.FileUtils;
import org.eclipse.lsp4j.Diagnostic;
import org.junit.jupiter.api.Test;

import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import static org.assertj.core.api.Assertions.assertThat;

public class SmokyTest {
Expand All @@ -38,6 +48,33 @@ void test() {
BSLLSPLauncher.main(args);

assertThat(true).isTrue(); // TODO что проверять?
}

@Test
void testIdenticalRanges() {

var configuration = LanguageServerConfiguration.create();
var diagnosticSupplier = new DiagnosticSupplier(configuration);
var srcDir = "./src/test/resources/";
List<Diagnostic> diagnostics = new ArrayList<>();
FileUtils.listFiles(Paths.get(srcDir).toAbsolutePath().toFile(), new String[]{"bsl", "os"}, true)
.forEach(filePath -> {
var documentContext = TestUtils.getDocumentContextFromFile(filePath.toString());
var diagnosticProvider = new DiagnosticProvider(diagnosticSupplier);
diagnosticProvider.computeDiagnostics(documentContext).stream()
.filter(diagnostic ->
(diagnostic.getRange() != null
&& diagnostic.getRange().getEnd().equals(diagnostic.getRange().getStart()))
|| (diagnostic.getRelatedInformation() != null
&& diagnostic.getRelatedInformation().stream()
.anyMatch(relation -> relation.getLocation() != null
&& relation.getLocation().getRange() != null
&& relation.getLocation().getRange().getEnd().equals(relation.getLocation().getRange().getStart())))
)
.collect(Collectors.toCollection(() -> diagnostics));
});

assertThat(diagnostics).isEmpty();
}

}

0 comments on commit f1c335c

Please sign in to comment.