@Test @DisplayName("Can replace a range of lexical elements between the start and the end.") void replacesRangeMiddle() { final var source = new TestSource("public final static var"); final String lexed; try(final var sut = new JavaLexed(source)) { sut.replace(2, 4, Arrays.asList(new LexicalElement.Identifier("static"), new LexicalElement.Spacing(" "))); lexed = toLexicalString(sut); } Assertions.assertEquals("IDENTIFIER[public]\n" + "SPACING[ ]\n" + "IDENTIFIER[static]\n" + "SPACING[ ]\n" + "IDENTIFIER[static]\n" + "SPACING[ ]\n" + "IDENTIFIER[var]\n", lexed); }
public int replace(MatchResult result, List<LexicalElement>... lists) { assertOpen(); if (result == null) { throw new IllegalArgumentException("Illegal sequence of invocation, there is no match result."); } if (result.matches) { return replace(result.start, result.end, lists); } return -1; }
JavaLexed implements AutoCloseable { public int replace(MatchResult result, List<LexicalElement>... lists) { assertOpen(); if (result == null) { throw new IllegalArgumentException("Illegal sequence of invocation, there is no match result."); } if (result.matches) { return replace(result.start, result.end, lists); } return -1; } }
JavaLexed implements AutoCloseable { public int replace(MatchResult result, List<LexicalElement>... lists) { assertOpen(); if (result == null) { throw new IllegalArgumentException("Illegal sequence of invocation, there is no match result."); } if (result.matches) { return replace(result.start, result.end, lists); } return -1; } JavaLexed(Source source); }
JavaLexed implements AutoCloseable { public int replace(MatchResult result, List<LexicalElement>... lists) { assertOpen(); if (result == null) { throw new IllegalArgumentException("Illegal sequence of invocation, there is no match result."); } if (result.matches) { return replace(result.start, result.end, lists); } return -1; } JavaLexed(Source source); @Override void close(); Iterable<LexicalElement> lexicalElements(); LexicalElement get(int i); LexicalElement remove(int i); void removeRange(int start, int end); int replaceWith(List<LexicalElement>... lists); int replace(MatchResult result, List<LexicalElement>... lists); int replace(int start, int end, List<LexicalElement>... lists); void add(int index, LexicalElement le); int size(); JavaLexed match(BiFunction<JavaLexed, Lexpression, LexMatcher> expression); JavaLexed find(BiFunction<JavaLexed, Lexpression, LexMatcher> expression); JavaLexed sensitivity(int sensitivity); JavaLexed fromStart(); JavaLexed fromIndex(int i); Optional<java.util.regex.MatchResult> regexGroups(final String name); List<javax0.geci.javacomparator.LexicalElement> group(final String name); MatchResult result(); }
JavaLexed implements AutoCloseable { public int replace(MatchResult result, List<LexicalElement>... lists) { assertOpen(); if (result == null) { throw new IllegalArgumentException("Illegal sequence of invocation, there is no match result."); } if (result.matches) { return replace(result.start, result.end, lists); } return -1; } JavaLexed(Source source); @Override void close(); Iterable<LexicalElement> lexicalElements(); LexicalElement get(int i); LexicalElement remove(int i); void removeRange(int start, int end); int replaceWith(List<LexicalElement>... lists); int replace(MatchResult result, List<LexicalElement>... lists); int replace(int start, int end, List<LexicalElement>... lists); void add(int index, LexicalElement le); int size(); JavaLexed match(BiFunction<JavaLexed, Lexpression, LexMatcher> expression); JavaLexed find(BiFunction<JavaLexed, Lexpression, LexMatcher> expression); JavaLexed sensitivity(int sensitivity); JavaLexed fromStart(); JavaLexed fromIndex(int i); Optional<java.util.regex.MatchResult> regexGroups(final String name); List<javax0.geci.javacomparator.LexicalElement> group(final String name); MatchResult result();  }