From 8c410026b0a957501846f2069f8daec2935e51f7 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Fri, 27 May 2022 17:29:30 -0700 Subject: [PATCH] [tests] Repair LSP tests. --- .../src/org/lflang/tests/lsp/ErrorInserter.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/org.lflang.tests/src/org/lflang/tests/lsp/ErrorInserter.java b/org.lflang.tests/src/org/lflang/tests/lsp/ErrorInserter.java index 69f7736ae8..c200010ae9 100644 --- a/org.lflang.tests/src/org/lflang/tests/lsp/ErrorInserter.java +++ b/org.lflang.tests/src/org/lflang/tests/lsp/ErrorInserter.java @@ -78,7 +78,7 @@ private boolean get() { /** * Initialize a possibly altered copy of {@code originalTest}. * @param originalTest A path to an LF file that serves as a test. - * @param insertCondition Whether the error inserter is permitted to insert a line after a given line. + * @param insertCondition Whether the error inserter is permitted to insert a line between two given lines. * @throws IOException if the content of {@code originalTest} cannot be read. */ private AlteredTest(Path originalTest, BiPredicate insertCondition) throws IOException { @@ -86,15 +86,7 @@ private AlteredTest(Path originalTest, BiPredicate insertConditi this.path = originalTest; this.lines = new LinkedList<>(); // Constant-time insertion during iteration is desired. this.lines.addAll(Files.readAllLines(originalTest)); - this.insertCondition = it -> { - boolean ret = true; - it.previous(); - if (it.hasPrevious()) { - ret = insertCondition.test(it.previous(), it.next()); - } - it.next(); - return ret; - }; + this.insertCondition = it -> insertCondition.test(it.previous(), it.hasNext() ? it.next() : ";"); } /** Return the location where the content of {@code this} lives. */ @@ -172,9 +164,7 @@ public void insert(String line, Random random) { OnceTrue onceTrue = new OnceTrue(random); alter((it, current) -> { if (insertCondition.test(it) && onceTrue.get()) { - it.remove(); it.add(line); - it.add(current); return true; } return false;