Skip to content

Commit

Permalink
Fixed Checkstyle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
oswetto authored and rbri committed Nov 1, 2023
1 parent 47086fa commit e3f97b4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
29 changes: 21 additions & 8 deletions src/main/java/org/htmlunit/cssparser/parser/CSSOMParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,20 @@
import java.util.Deque;
import java.util.List;

import org.htmlunit.cssparser.dom.*;
import org.htmlunit.cssparser.dom.AbstractCSSRuleImpl;
import org.htmlunit.cssparser.dom.CSSCharsetRuleImpl;
import org.htmlunit.cssparser.dom.CSSFontFaceRuleImpl;
import org.htmlunit.cssparser.dom.CSSImportRuleImpl;
import org.htmlunit.cssparser.dom.CSSMediaRuleImpl;
import org.htmlunit.cssparser.dom.CSSPageRuleImpl;
import org.htmlunit.cssparser.dom.CSSRuleListImpl;
import org.htmlunit.cssparser.dom.CSSStyleDeclarationImpl;
import org.htmlunit.cssparser.dom.CSSStyleRuleImpl;
import org.htmlunit.cssparser.dom.CSSStyleSheetImpl;
import org.htmlunit.cssparser.dom.CSSUnknownRuleImpl;
import org.htmlunit.cssparser.dom.CSSValueImpl;
import org.htmlunit.cssparser.dom.MediaListImpl;
import org.htmlunit.cssparser.dom.Property;
import org.htmlunit.cssparser.parser.javacc.CSS3Parser;
import org.htmlunit.cssparser.parser.media.MediaQueryList;
import org.htmlunit.cssparser.parser.selector.SelectorList;
Expand Down Expand Up @@ -100,7 +113,7 @@ public CSSStyleDeclarationImpl parseStyleDeclaration(final String styleDecl) thr
* @throws IOException if the underlying SAC parser throws an IOException
*/
public void parseStyleDeclaration(final CSSStyleDeclarationImpl sd, final String styleDecl) throws IOException {
try (final InputSource source = new InputSource(new StringReader(styleDecl))) {
try (InputSource source = new InputSource(new StringReader(styleDecl))) {
final Deque<Object> nodeStack = new ArrayDeque<>();
nodeStack.push(sd);
final CSSOMHandler handler = new CSSOMHandler(nodeStack);
Expand All @@ -117,7 +130,7 @@ public void parseStyleDeclaration(final CSSStyleDeclarationImpl sd, final String
* @throws IOException if the underlying SAC parser throws an IOException
*/
public CSSValueImpl parsePropertyValue(final String propertyValue) throws IOException {
try (final InputSource source = new InputSource(new StringReader(propertyValue))) {
try (InputSource source = new InputSource(new StringReader(propertyValue))) {
final CSSOMHandler handler = new CSSOMHandler();
parser_.setDocumentHandler(handler);
final LexicalUnit lu = parser_.parsePropertyValue(source);
Expand All @@ -136,7 +149,7 @@ public CSSValueImpl parsePropertyValue(final String propertyValue) throws IOExce
* @throws IOException if the underlying SAC parser throws an IOException
*/
public AbstractCSSRuleImpl parseRule(final String rule) throws IOException {
try (final InputSource source = new InputSource(new StringReader(rule))) {
try (InputSource source = new InputSource(new StringReader(rule))) {
final CSSOMHandler handler = new CSSOMHandler();
parser_.setDocumentHandler(handler);
parser_.parseRule(source);
Expand All @@ -152,7 +165,7 @@ public AbstractCSSRuleImpl parseRule(final String rule) throws IOException {
* @throws IOException if the underlying SAC parser throws an IOException
*/
public SelectorList parseSelectors(final String selectors) throws IOException {
try (final InputSource source = new InputSource(new StringReader(selectors))) {
try (InputSource source = new InputSource(new StringReader(selectors))) {
final HandlerBase handler = new HandlerBase();
parser_.setDocumentHandler(handler);
return parser_.parseSelectors(source);
Expand All @@ -167,7 +180,7 @@ public SelectorList parseSelectors(final String selectors) throws IOException {
* @throws IOException if the underlying SAC parser throws an IOException
*/
public MediaQueryList parseMedia(final String media) throws IOException {
try (final InputSource source = new InputSource(new StringReader(media))) {
try (InputSource source = new InputSource(new StringReader(media))) {
final HandlerBase handler = new HandlerBase();
parser_.setDocumentHandler(handler);
return parser_.parseMedia(source);
Expand Down Expand Up @@ -410,8 +423,8 @@ public void property(final String name, final LexicalUnit value, final boolean i

private AbstractCSSRuleImpl getParentRule() {
if (!nodeStack_.isEmpty() && nodeStack_.size() > 1) {
final List<Object> nodesStack_ = new ArrayList<>(nodeStack_);
final Object node = nodesStack_.get(nodesStack_.size() - 2);
final List<Object> nodesStack = new ArrayList<>(nodeStack_);
final Object node = nodesStack.get(nodesStack.size() - 2);
if (node instanceof AbstractCSSRuleImpl) {
return (AbstractCSSRuleImpl) node;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ public String toString() {
result.append(")");
return result.toString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ public String toString() {

return sb.toString();
}
}
}

0 comments on commit e3f97b4

Please sign in to comment.