Skip to content

Commit

Permalink
fix IDEA warnings "Unneeded initialisation"
Browse files Browse the repository at this point in the history
  • Loading branch information
asolntsev committed Sep 16, 2023
1 parent f9e10d6 commit 67432ba
Show file tree
Hide file tree
Showing 61 changed files with 178 additions and 295 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ protected Font resolveFont(SharedContext ctx, String font, float size, IdentValu
if (available_fonts_hash.containsKey(font)) {
Object value = available_fonts_hash.get(font);
// have we actually allocated the root font object yet?
Font root_font = null;
Font root_font;
if (value instanceof Font) {
root_font = (Font) value;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public java.util.Map getCascadedPropertiesMap(Element e) {
* @return The pseudoElementStyle value
*/
public CascadedStyle getPseudoElementStyle(Node node, String pseudoElement) {
Element e = null;
Element e;
if (node.getNodeType() == Node.ELEMENT_NODE) {
e = (Element) node;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,16 @@ public final class ValueConstants {
* @return Returns
*/
public static String cssType(int cssType, int primitiveValueType) {
String desc = null;
if (cssType == CSSValue.CSS_PRIMITIVE_VALUE) {
if (primitiveValueType >= TYPE_DESCRIPTIONS.size()) {
desc = "{unknown: " + primitiveValueType + "}";
return "{unknown: " + primitiveValueType + "}";
} else {
desc = (String) TYPE_DESCRIPTIONS.get(primitiveValueType);
if (desc == null) {
desc = "{UNKNOWN VALUE TYPE}";
}
String desc = (String) TYPE_DESCRIPTIONS.get(primitiveValueType);
return desc == null ? "{UNKNOWN VALUE TYPE}" : desc;
}
} else {
desc = "{value list}";
return "{value list}";
}
return desc;
}

/**
Expand Down Expand Up @@ -126,8 +122,7 @@ public static String stringForSACPrimitiveType(short type) {
*/
//TODO: method may be unnecessary (tobe)
public static boolean isAbsoluteUnit(CSSPrimitiveValue primitive) {
short type = 0;
type = ((CSSPrimitiveValue) primitive).getPrimitiveType();
short type = ((CSSPrimitiveValue) primitive).getPrimitiveType();
return isAbsoluteUnit(type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ private static String[] split(String s, char ch) {
List result = new ArrayList();

int last = 0;
int next = 0;
int next;

while ((next = s.indexOf(ch, last)) != -1) {
if (next != last) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,7 @@ public PageInfo getPageCascadedStyle(String pageName, String pseudoPage) {
}
}

CascadedStyle style = null;
if (props.isEmpty()) {
style = CascadedStyle.emptyCascadedStyle;
} else {
style = new CascadedStyle(props.iterator());
}

CascadedStyle style = props.isEmpty() ? CascadedStyle.emptyCascadedStyle : new CascadedStyle(props.iterator());
return new PageInfo(props, style, marginBoxes);
}

Expand Down Expand Up @@ -407,9 +401,7 @@ Mapper mapChild(Object e) {
}

CascadedStyle getCascadedStyle(Object e) {
CascadedStyle result;
synchronized (e) {
CascadedStyle cs = null;
org.xhtmlrenderer.css.sheet.Ruleset elementStyling = getElementStyle(e);
org.xhtmlrenderer.css.sheet.Ruleset nonCssStyling = getNonCssStyle(e);
List propList = new LinkedList();
Expand All @@ -426,15 +418,8 @@ CascadedStyle getCascadedStyle(Object e) {
if (elementStyling != null) {
propList.addAll(elementStyling.getPropertyDeclarations());
}
if (propList.size() == 0)
cs = CascadedStyle.emptyCascadedStyle;
else {
cs = new CascadedStyle(propList.iterator());
}

result = cs;
return propList.isEmpty() ? CascadedStyle.emptyCascadedStyle : new CascadedStyle(propList.iterator());
}
return result;
}

/**
Expand All @@ -446,7 +431,6 @@ public CascadedStyle getPECascadedStyle(Object e, String pseudoElement) {
if (!si.hasNext()) {
return null;
}
CascadedStyle cs = null;
java.util.List pe = (java.util.List) pseudoSelectors.get(pseudoElement);
if (pe == null) return null;

Expand All @@ -455,12 +439,12 @@ public CascadedStyle getPECascadedStyle(Object e, String pseudoElement) {
org.xhtmlrenderer.css.sheet.Ruleset rs = (org.xhtmlrenderer.css.sheet.Ruleset) i.next();
propList.addAll(rs.getPropertyDeclarations());
}

if (propList.size() == 0)
cs = CascadedStyle.emptyCascadedStyle;//already internalized
return CascadedStyle.emptyCascadedStyle; // already internalized
else {
cs = new CascadedStyle(propList.iterator());
return new CascadedStyle(propList.iterator());
}
return cs;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,18 +350,17 @@ private void namespace() throws IOException {
try {
Token t = next();
if (t == Token.TK_NAMESPACE_SYM) {
String prefix = null;
String url = null;

skip_whitespace();
t = next();

String prefix = null;
if (t == Token.TK_IDENT) {
prefix = getTokenValue(t);
skip_whitespace();
t = next();
}

String url;
if (t == Token.TK_STRING || t == Token.TK_URI) {
url = getTokenValue(t);
} else {
Expand Down Expand Up @@ -459,16 +458,15 @@ private void media(Stylesheet stylesheet) throws IOException {
// ;
private String medium() throws IOException {
//System.out.println("medium()");
String result = null;
Token t = next();
if (t == Token.TK_IDENT) {
result = getTokenValue(t);
String result = getTokenValue(t);
skip_whitespace();
return result;
} else {
push(t);
throw new CSSParseException(t, Token.TK_IDENT, getCurrentLine());
}
return result;
}

// font_face
Expand Down Expand Up @@ -629,15 +627,15 @@ private void margin(Stylesheet stylesheet, PageRule pageRule) throws IOException
// ;
private String pseudo_page() throws IOException {
//System.out.println("pseudo_page()");
String result = null;
Token t = next();
if (t == Token.TK_COLON) {
t = next();
if (t == Token.TK_IDENT) {
result = getTokenValue(t);
String result = getTokenValue(t);
if (! (result.equals("first") || result.equals("left") || result.equals("right"))) {
throw new CSSParseException("Pseudo page must be one of first, left, or right", getCurrentLine());
}
return result;
} else {
push(t);
throw new CSSParseException(t, Token.TK_IDENT, getCurrentLine());
Expand All @@ -646,7 +644,6 @@ private String pseudo_page() throws IOException {
push(t);
throw new CSSParseException(t, Token.TK_COLON, getCurrentLine());
}
return result;
}
// operator
// : '/' S* | COMMA S* | /* empty */
Expand Down Expand Up @@ -1482,7 +1479,7 @@ private PropertyValue term(boolean literal) throws IOException {
sign = unary_operator();
t = la();
}
PropertyValue result = null;
PropertyValue result;
switch (t.getType()) {
case Token.ANGLE:
case Token.TIME:
Expand Down Expand Up @@ -1617,7 +1614,7 @@ private PropertyValue term(boolean literal) throws IOException {
// ;
private PropertyValue function() throws IOException {
//System.out.println("function()");
PropertyValue result = null;
PropertyValue result;
Token t = next();
if (t == Token.TK_FUNCTION) {
String f = getTokenValue(t);
Expand Down Expand Up @@ -1745,15 +1742,15 @@ private FSRGBColor createRGBColorFromFunction(List params) {
// ;
private PropertyValue hexcolor() throws IOException {
//System.out.println("hexcolor()");
PropertyValue result = null;
PropertyValue result;
Token t = next();
if (t == Token.TK_HASH) {
String s = getTokenValue(t);
if ((s.length() != 3 && s.length() != 6) || ! isHexString(s)) {
push(t);
throw new CSSParseException('#' + s + " is not a valid color definition", getCurrentLine());
}
FSRGBColor color = null;
FSRGBColor color;
if (s.length() == 3) {
color = new FSRGBColor(
convertToInteger(s.charAt(0), s.charAt(0)),
Expand Down

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 @@ -39,8 +39,8 @@ public List buildDeclarations(CSSName cssName, List values, int origin, boolean

checkValueCount(CSSName.BORDER_SPACING, 1, 2, values.size());

PropertyDeclaration horizontalSpacing = null;
PropertyDeclaration verticalSpacing = null;
PropertyDeclaration horizontalSpacing;
PropertyDeclaration verticalSpacing;

if (values.size() == 1) {
PropertyValue value = (PropertyValue)values.get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
* @author Patrick Wright
*/
public class Ruleset {
private int _origin;
private java.util.List _props;
private final int _origin;
private final java.util.List _props;

private List _fsSelectors = new ArrayList();
private final List _fsSelectors;

public Ruleset(int orig) {
_origin = orig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ public BorderRadiusCorner() {
public BorderRadiusCorner(float left, float right) {
this._left = left;
this._right = right;
this._rightPercent = false;
this._rightPercent = false;
}
public BorderRadiusCorner(CSSName fromVal, CalculatedStyle style, CssContext ctx) {
FSDerivedValue value = style.valueByName(fromVal);
PropertyValue first = null, second = null;
PropertyValue first, second;
if(value instanceof ListValue) {
ListValue lValues = (ListValue)value;
first = (PropertyValue)lValues.getValues().get(0);
Expand Down Expand Up @@ -82,7 +80,6 @@ private void setLeft(CSSName fromVal, CalculatedStyle style, PropertyValue value
}
private void setRight(CSSName fromVal, CalculatedStyle style, PropertyValue value, CssContext ctx) {
if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_PERCENTAGE) {
float percent = value.getFloatValue() / 100.0f;
_rightPercent = true;
_right = value.getFloatValue() / 100.0f;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public void setDefaultValue(CSSName cssName, FSDerivedValue fsDerivedValue) {

// TODO: doc
public boolean hasAbsoluteUnit(CSSName cssName) {
boolean isAbs = false;
boolean isAbs;
try {
isAbs = valueByName(cssName).hasAbsoluteUnit();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ private static void rebalanceInlineContent(List content) {

private static void stripAllWhitespace(List content) {
int start = 0;
int current = 0;
int current;
boolean started = false;
for (current = 0; current < content.size(); current++) {
Styleable styleable = (Styleable) content.get(current);
Expand Down Expand Up @@ -690,9 +690,8 @@ public static boolean isElementFunction(FSFunction function) {
if (params.size() < 1 || params.size() > 2) {
return false;
}
boolean ok = true;
PropertyValue value1 = (PropertyValue) params.get(0);
ok = value1.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT;
boolean ok = value1.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT;
if (ok && params.size() == 2) {
PropertyValue value2 = (PropertyValue) params.get(1);
ok = value2.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ public static void layoutContent(LayoutContext c, BlockBox box, int initialY, in
int remainingWidth = maxAvailableWidth;

LineBox currentLine = newLine(c, initialY, box);
LineBox previousLine = null;

InlineLayoutBox currentIB = null;
InlineLayoutBox previousIB = null;
InlineLayoutBox previousIB;

int contentStart = 0;

Expand Down Expand Up @@ -117,7 +116,6 @@ public static void layoutContent(LayoutContext c, BlockBox box, int initialY, in

boolean needFirstLetter = c.getFirstLettersTracker().hasStyles();
boolean zeroWidthInlineBlock = false;

int lineOffset = 0;

for (Iterator i = box.getInlineContent().iterator(); i.hasNext(); ) {
Expand Down Expand Up @@ -263,7 +261,7 @@ public static void layoutContent(LayoutContext c, BlockBox box, int initialY, in
if (lbContext.isEndsOnNL()) {
currentLine.setEndsOnNL(true);
}
previousLine = currentLine;
LineBox previousLine = currentLine;
currentLine = newLine(c, previousLine, box);
currentIB = addOpenInlineBoxes(
c, currentLine, openInlineBoxes, maxAvailableWidth, iBMap);
Expand Down Expand Up @@ -325,7 +323,7 @@ public static void layoutContent(LayoutContext c, BlockBox box, int initialY, in
lineOffset++;
markerData = null;
contentStart = 0;
previousLine = currentLine;
LineBox previousLine = currentLine;
currentLine = newLine(c, previousLine, box);
currentIB = addOpenInlineBoxes(
c, currentLine, openInlineBoxes, maxAvailableWidth, iBMap);
Expand Down
Loading

0 comments on commit 67432ba

Please sign in to comment.