From a31a0c3cc9502128dffb27df78f94b61ebc3c1d4 Mon Sep 17 00:00:00 2001 From: Chris K Wensel Date: Tue, 7 Nov 2023 17:29:29 -0800 Subject: [PATCH] remove slf4j dependency from main classes --- mini-parsers-core/build.gradle | 2 +- .../heretical/parser/common/ParserSyntaxException.java | 10 +++++----- mini-parsers-temporal/build.gradle | 1 - .../parser/temporal/BaseTemporalExpressionParser.java | 8 -------- .../parser/temporal/format/DateTimeFormats.java | 7 +------ 5 files changed, 7 insertions(+), 21 deletions(-) diff --git a/mini-parsers-core/build.gradle b/mini-parsers-core/build.gradle index ddd8497..90454e9 100644 --- a/mini-parsers-core/build.gradle +++ b/mini-parsers-core/build.gradle @@ -9,7 +9,7 @@ dependencies { implementation group: 'org.parboiled', name: 'parboiled-java', version: parboiledVersion - implementation group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion + testCompile group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion testRuntime group: 'org.slf4j', name: 'slf4j-log4j12', version: slf4jVersion } diff --git a/mini-parsers-core/src/main/java/heretical/parser/common/ParserSyntaxException.java b/mini-parsers-core/src/main/java/heretical/parser/common/ParserSyntaxException.java index 9ceede4..bb89a18 100644 --- a/mini-parsers-core/src/main/java/heretical/parser/common/ParserSyntaxException.java +++ b/mini-parsers-core/src/main/java/heretical/parser/common/ParserSyntaxException.java @@ -21,11 +21,11 @@ public class ParserSyntaxException extends RuntimeException { public static final String SEARCH_PARSE_ERROR = "parser syntax error"; - private Result result; - private List errorMessages; + private final Result result; + private final List errorMessages; private static final DefaultInvalidInputErrorFormatter formatter = new DefaultInvalidInputErrorFormatter(); - public ParserSyntaxException( Result result ) + public ParserSyntaxException( Result result ) { super( makeMessage( result ) ); this.result = result; @@ -35,7 +35,7 @@ public ParserSyntaxException( Result result ) public ParserSyntaxException( List errorMessages ) { super( makeMessage( errorMessages ) ); - + this.result = null; this.errorMessages = errorMessages; } @@ -81,7 +81,7 @@ private static String makeMessage( Result result ) return String.format( "%s: %s", SEARCH_PARSE_ERROR, errors ); } - private static String getSyntaxError( Result result ) + private static String getSyntaxError( Result result ) { return ErrorUtils.printParseErrors( result.getParsingResult() ); } diff --git a/mini-parsers-temporal/build.gradle b/mini-parsers-temporal/build.gradle index db3b5d0..c1522ff 100644 --- a/mini-parsers-temporal/build.gradle +++ b/mini-parsers-temporal/build.gradle @@ -11,7 +11,6 @@ dependencies { api project( ':mini-parsers-core' ) implementation group: 'org.parboiled', name: 'parboiled-java', version: parboiledVersion - implementation group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion testCompile project( path: ':mini-parsers-core', configuration: 'testArtifacts' ) diff --git a/mini-parsers-temporal/src/main/java/heretical/parser/temporal/BaseTemporalExpressionParser.java b/mini-parsers-temporal/src/main/java/heretical/parser/temporal/BaseTemporalExpressionParser.java index f35cc4c..8b33c2e 100644 --- a/mini-parsers-temporal/src/main/java/heretical/parser/temporal/BaseTemporalExpressionParser.java +++ b/mini-parsers-temporal/src/main/java/heretical/parser/temporal/BaseTemporalExpressionParser.java @@ -18,16 +18,12 @@ import org.parboiled.parserunners.ParseRunner; import org.parboiled.parserunners.ReportingParseRunner; import org.parboiled.support.ParsingResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * */ public abstract class BaseTemporalExpressionParser> { - private static final Logger LOG = LoggerFactory.getLogger( BaseTemporalExpressionParser.class ); - private final Context context; private Rule grammar; @@ -86,11 +82,7 @@ public TemporalResult parseOrFail( String string ) throws ParserSyntaxExce TemporalResult parseResult = parse( string ); if( parseResult.hasErrors() ) - { - LOG.warn( parseResult.prettyPrintErrors() ); - throw new ParserSyntaxException( parseResult ); - } return parseResult; } diff --git a/mini-parsers-temporal/src/main/java/heretical/parser/temporal/format/DateTimeFormats.java b/mini-parsers-temporal/src/main/java/heretical/parser/temporal/format/DateTimeFormats.java index 67e70db..189e0a6 100644 --- a/mini-parsers-temporal/src/main/java/heretical/parser/temporal/format/DateTimeFormats.java +++ b/mini-parsers-temporal/src/main/java/heretical/parser/temporal/format/DateTimeFormats.java @@ -24,8 +24,6 @@ import org.parboiled.parserunners.BasicParseRunner; import org.parboiled.parserunners.ParseRunner; import org.parboiled.support.ParsingResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import static java.time.format.DateTimeFormatter.ISO_LOCAL_DATE; import static java.time.format.DateTimeFormatter.ISO_LOCAL_TIME; @@ -82,8 +80,6 @@ */ public class DateTimeFormats { - private static final Logger LOG = LoggerFactory.getLogger( DateTimeFormats.class ); - public enum Char { text, @@ -357,8 +353,7 @@ private static DateTimeFormatter insensitive( String format ) } catch( RuntimeException exception ) { - LOG.error( "failed on pattern: {}", pattern, exception ); - throw exception; + throw new RuntimeException( "failed on pattern: " + pattern, exception ); } }