Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
mcimadamore committed Dec 2, 2024
1 parent c4b890e commit 5526220
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

package propertiesparser.parser;

import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected Preview(Context context) {
lint = Lint.instance(context);
source = Source.instance(context);
this.previewHandler =
new MandatoryWarningHandler(log, source, lint.isEnabled(LintCategory.PREVIEW), true, "preview", LintCategory.PREVIEW);
new MandatoryWarningHandler(log, source, lint.isEnabled(LintCategory.PREVIEW), true, "preview");
forcePreview = options.isSet("forcePreview");
majorVersionToSource = initMajorVersionToSourceMap();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ protected Check(Context context) {
boolean enforceMandatoryWarnings = true;

deprecationHandler = new MandatoryWarningHandler(log, null, verboseDeprecated,
enforceMandatoryWarnings, "deprecated", LintCategory.DEPRECATION);
enforceMandatoryWarnings, "deprecated");
removalHandler = new MandatoryWarningHandler(log, null, verboseRemoval,
enforceMandatoryWarnings, "removal", LintCategory.REMOVAL);
enforceMandatoryWarnings, "removal");
uncheckedHandler = new MandatoryWarningHandler(log, null, verboseUnchecked,
enforceMandatoryWarnings, "unchecked", LintCategory.UNCHECKED);
enforceMandatoryWarnings, "unchecked");
sunApiHandler = new MandatoryWarningHandler(log, null, false,
enforceMandatoryWarnings, "sunapi", null);
enforceMandatoryWarnings, "sunapi");

deferredLintHandler = DeferredLintHandler.instance(context);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,10 @@ protected void lexError(DiagnosticFlag flags, int pos, JCDiagnostic.Error key) {
/**
* Report an error at the given position using the provided arguments.
*
* @param lc lint category.
* @param pos position in input buffer.
* @param key error key to report.
*/
protected void lexWarning(LintCategory lc, int pos, JCDiagnostic.Warning key) {
protected void lexWarning(int pos, JCDiagnostic.Warning key) {
DiagnosticPosition dp = new SimpleDiagnosticPosition(pos) ;
log.warning(dp, key);
}
Expand Down Expand Up @@ -1073,11 +1072,11 @@ public Token readToken() {
Set<TextBlockSupport.WhitespaceChecks> checks =
TextBlockSupport.checkWhitespace(string);
if (checks.contains(TextBlockSupport.WhitespaceChecks.INCONSISTENT)) {
lexWarning(LintCategory.TEXT_BLOCKS, pos,
lexWarning(pos,
Warnings.InconsistentWhiteSpaceIndentation);
}
if (checks.contains(TextBlockSupport.WhitespaceChecks.TRAILING)) {
lexWarning(LintCategory.TEXT_BLOCKS, pos,
lexWarning(pos,
Warnings.TrailingWhiteSpaceWillBeRemoved);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,14 @@ private enum DeferredDiagnosticKind {
* True if mandatory warnings and notes are being enforced.
* @param prefix A common prefix for the set of message keys for
* the messages that may be generated.
* @param lc An associated lint category for the warnings, or null if none.
*/
public MandatoryWarningHandler(Log log, Source source, boolean verbose,
boolean enforceMandatory, String prefix,
LintCategory lc) {
boolean enforceMandatory, String prefix) {
this.log = log;
this.source = source;
this.verbose = verbose;
this.prefix = prefix;
this.enforceMandatory = enforceMandatory;
this.lintCategory = lc;
}

/**
Expand Down Expand Up @@ -246,12 +243,6 @@ public void reportDeferredDiagnostic() {
*/
private final boolean enforceMandatory;

/**
* A LintCategory to be included in point-of-use diagnostics to indicate
* how messages might be suppressed (i.e. with @SuppressWarnings).
*/
private final LintCategory lintCategory;

/**
* Reports a mandatory warning to the log. If mandatory warnings
* are not being enforced, treat this as an ordinary warning.
Expand Down

0 comments on commit 5526220

Please sign in to comment.