Skip to content

Commit

Permalink
feat(#3744): fix some code offences
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Jan 10, 2025
1 parent 40c0c4d commit 70faa33
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
25 changes: 15 additions & 10 deletions eo-parser/src/main/java/org/eolang/parser/XeEoListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ private static String trimMargin(final String text, final int indent) {
* Create parsing exception from given context.
* @param ctx Context
* @param msg Error message
* @return Parsing exception from current context
* @return Parsing exception from the current context
*/
private static ParsingException error(final ParserRuleContext ctx, final String msg) {
return new ParsingException(
Expand All @@ -1286,23 +1286,28 @@ private static ParsingException error(final ParserRuleContext ctx, final String
);
}

private static ParsingException error(final TerminalNode ctx, final String msg) {
/**
* Create parsing exception from given terminal node.
* @param terminal Terminal node
* @param msg Error message
* @return Parsing exception from the current terminal node
*/
private static ParsingException error(final TerminalNode terminal, final String msg) {
return new ParsingException(
ctx.getSymbol().getLine(),
terminal.getSymbol().getLine(),
new MsgLocated(
ctx.getSymbol().getLine(),
ctx.getSymbol().getCharPositionInLine(),
terminal.getSymbol().getLine(),
terminal.getSymbol().getCharPositionInLine(),
msg
).formatted(),
new MsgUnderlined(
XeEoListener.line(ctx.getSymbol()),
ctx.getSymbol().getCharPositionInLine(),
ctx.getText().length()
XeEoListener.line(terminal.getSymbol()),
terminal.getSymbol().getCharPositionInLine(),
terminal.getText().length()
).formatted()
);
}


/**
* Get line from context.
* @param ctx Context
Expand All @@ -1313,7 +1318,7 @@ private static String line(final ParserRuleContext ctx) {
}

/**
* Get line from context.
* Get line from token.
* @param token Token
* @return Line
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Set;
import java.util.stream.Collectors;
import org.cactoos.io.InputOf;
import org.cactoos.io.ResourceOf;
import org.cactoos.iterable.Mapped;
Expand Down

0 comments on commit 70faa33

Please sign in to comment.