Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code warnings #435

Merged
merged 6 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package org.xhtmlrenderer.css.extend;

import com.google.errorprone.annotations.CheckReturnValue;
import org.w3c.dom.Node;

/**
Expand Down Expand Up @@ -62,6 +63,7 @@ public interface TreeResolver {
* @param element The node
* @return -1 in case of error, 0 indexed position otherwise
*/
@CheckReturnValue
int getPositionOfElement(Node element);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ private static class OddChildCondition extends Condition {
@Override
boolean matches(Node e, AttributeResolver attRes, TreeResolver treeRes) {
int position = treeRes.getPositionOfElement(e);
return position >= 0 && position % 2 == 1;
return position % 2 == 1;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
public class CSSParseException extends RuntimeException {
@Nullable
private final Token _found;
@Nullable
private final Token[] _expected;
private final Token @Nullable [] _expected;
private int _line;

@Nullable
Expand All @@ -52,7 +51,7 @@ public CSSParseException(Token found, Token expected, int line) {
_genericMessage = null;
}

public CSSParseException(Token found, @Nullable Token[] expected, int line) {
public CSSParseException(Token found, Token @Nullable [] expected, int line) {
_found = found;
_expected = expected == null ? new Token[]{} : expected.clone();
_line = line;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ public List<PropertyDeclaration> buildDeclarations(

String text = concat(normalized, ',');
PropertyValue result = new PropertyValue(
CSSPrimitiveValue.CSS_STRING, text, text, normalized.toArray(new String[normalized.size()]), null); // HACK cssText can be wrong
CSSPrimitiveValue.CSS_STRING, text, text, normalized.toArray(new String[0]), null); // HACK cssText can be wrong

return singletonList(
new PropertyDeclaration(cssName, result, important, origin));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import static java.util.Objects.requireNonNull;

public final class BrowserPanel extends JPanel implements DocumentListener {
private static final org.slf4j.Logger log = LoggerFactory.getLogger(BrowserPanel.class);
private static final Logger logger = Logger.getLogger("app.browser");
Expand Down Expand Up @@ -145,7 +147,7 @@ private void loadCustomFonts() {
SharedContext rc = view.getSharedContext();
try {
rc.setFontMapping("Fuzz", Font.createFont(Font.TRUETYPE_FONT,
new DemoMarker().getClass().getResourceAsStream("/demos/fonts/fuzz.ttf")));
requireNonNull(DemoMarker.class.getResourceAsStream("/demos/fonts/fuzz.ttf"))));
} catch (Exception ex) {
Uu.p(ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public void setStroke(Stroke s) {
case BasicStroke.CAP_BUTT -> SWT.CAP_FLAT;
case BasicStroke.CAP_ROUND -> SWT.CAP_ROUND;
case BasicStroke.CAP_SQUARE -> SWT.CAP_SQUARE;
default -> SWT.CAP_SQUARE;
default -> throw new IllegalArgumentException("Unsupported CAP value: " + bs.getEndCap());
};
_gc.setLineCap(gcCap);

Expand All @@ -308,7 +308,7 @@ public void setStroke(Stroke s) {
case BasicStroke.JOIN_BEVEL -> SWT.JOIN_BEVEL;
case BasicStroke.JOIN_MITER -> SWT.JOIN_MITER;
case BasicStroke.JOIN_ROUND -> SWT.JOIN_ROUND;
default -> SWT.JOIN_MITER;
default -> throw new IllegalArgumentException("Unsupported line join: " + bs.getLineJoin());
};
_gc.setLineJoin(gcJoin);

Expand Down