Skip to content

Commit

Permalink
Fix warnings in GSS.
Browse files Browse the repository at this point in the history
Change-Id: I224e0514aed74e987188a57da39f562363a76257
  • Loading branch information
dankurka committed Jan 8, 2015
1 parent d981f2f commit c37e6ec
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 22 deletions.
7 changes: 4 additions & 3 deletions user/src/com/google/gwt/resources/converter/Css2Gss.java
Expand Up @@ -58,10 +58,11 @@ public Css2Gss(String filePath) throws MalformedURLException {
} }


public Css2Gss(URL resource, boolean lenient) { public Css2Gss(URL resource, boolean lenient) {
this(resource, lenient, Predicates.alwaysFalse()); this(resource, lenient, Predicates.<String>alwaysFalse());
} }


public Css2Gss(URL resource, boolean lenient, Predicate simpleBooleanConditionPredicate) { public Css2Gss(URL resource, boolean lenient,
Predicate<String> simpleBooleanConditionPredicate) {
cssFile = resource; cssFile = resource;
printWriter = new PrintWriter(System.err); printWriter = new PrintWriter(System.err);
this.treeLogger = new PrintWriterTreeLogger(printWriter); this.treeLogger = new PrintWriterTreeLogger(printWriter);
Expand All @@ -70,7 +71,7 @@ public Css2Gss(URL resource, boolean lenient, Predicate simpleBooleanConditionPr
} }


public Css2Gss(URL fileUrl, TreeLogger treeLogger, boolean lenient, public Css2Gss(URL fileUrl, TreeLogger treeLogger, boolean lenient,
Predicate simpleBooleanConditionPredicate) { Predicate<String> simpleBooleanConditionPredicate) {
cssFile = fileUrl; cssFile = fileUrl;
this.treeLogger = treeLogger; this.treeLogger = treeLogger;
this.lenient = lenient; this.lenient = lenient;
Expand Down
Expand Up @@ -397,7 +397,6 @@ public boolean visit(CssProperty x, Context ctx) {
* } * }
* } * }
* @param cssProperty * @param cssProperty
* @return
*/ */
private String quoteFontFamilyWithWhiteSpace(String cssProperty) { private String quoteFontFamilyWithWhiteSpace(String cssProperty) {
StringBuilder valueBuilder = new StringBuilder(); StringBuilder valueBuilder = new StringBuilder();
Expand Down
Expand Up @@ -29,31 +29,25 @@
/** /**
* Visitor that collects the simple boolean conditions that are mapped to configuration * Visitor that collects the simple boolean conditions that are mapped to configuration
* properties. * properties.
* <p/> * <p>
* <code> * <code>
* *
* &#064;if (MY_PROPERTY) { * &#064;if (MY_PROPERTY) {
* ... * ...
* } * }
* </code> * </code>
* <p/>
* <p>will be evaluated to true if and only if a configuration property with the same name is set * <p>will be evaluated to true if and only if a configuration property with the same name is set
* to the value "true": * to the value "true":
* <p/> * {@code
* <code>
* <set-configuration-property name="MY_PROPERTY" value="true" /> * <set-configuration-property name="MY_PROPERTY" value="true" />
* </code> * }
* <p/>
* <p/>
*/ */
public class BooleanConditionCollector extends ExtendedConditionalNodeVisitor public class BooleanConditionCollector extends ExtendedConditionalNodeVisitor
implements CssCompilerPass { implements CssCompilerPass {
private final MutatingVisitController delegate; private final MutatingVisitController delegate;
private final Set<String> booleanConditions; private final Set<String> booleanConditions;


public BooleanConditionCollector(MutatingVisitController delegate) { public BooleanConditionCollector(MutatingVisitController delegate) {
super(delegate);

this.delegate = delegate; this.delegate = delegate;
booleanConditions = new HashSet<String>(); booleanConditions = new HashSet<String>();
} }
Expand Down
Expand Up @@ -20,7 +20,6 @@
import com.google.gwt.thirdparty.common.css.compiler.ast.CssConditionalRuleNode; import com.google.gwt.thirdparty.common.css.compiler.ast.CssConditionalRuleNode;
import com.google.gwt.thirdparty.common.css.compiler.ast.CssValueNode; import com.google.gwt.thirdparty.common.css.compiler.ast.CssValueNode;
import com.google.gwt.thirdparty.common.css.compiler.ast.DefaultTreeVisitor; import com.google.gwt.thirdparty.common.css.compiler.ast.DefaultTreeVisitor;
import com.google.gwt.thirdparty.common.css.compiler.ast.VisitController;


import java.util.Stack; import java.util.Stack;


Expand All @@ -29,11 +28,10 @@
* is to implement this behavior. * is to implement this behavior.
*/ */
public class ExtendedConditionalNodeVisitor extends DefaultTreeVisitor { public class ExtendedConditionalNodeVisitor extends DefaultTreeVisitor {
private final VisitController delegate;
private final Stack<CssBooleanExpressionNode> childrenStack; private final Stack<CssBooleanExpressionNode> childrenStack;


public ExtendedConditionalNodeVisitor(VisitController delegate) { public ExtendedConditionalNodeVisitor() {
this.delegate = delegate;
childrenStack = new Stack<CssBooleanExpressionNode>(); childrenStack = new Stack<CssBooleanExpressionNode>();
} }


Expand Down
Expand Up @@ -40,8 +40,6 @@ public class PermutationsCollector extends ExtendedConditionalNodeVisitor
private final Set<String> permutationAxesSet; private final Set<String> permutationAxesSet;


public PermutationsCollector(MutatingVisitController delegate) { public PermutationsCollector(MutatingVisitController delegate) {
super(delegate);

this.delegate = delegate; this.delegate = delegate;
permutationAxesSet = new HashSet<String>(); permutationAxesSet = new HashSet<String>();
} }
Expand Down
Expand Up @@ -467,6 +467,7 @@ public void init(TreeLogger logger, ResourceContext context) throws UnableToComp
initReplacement(context); initReplacement(context);
} }


@SuppressWarnings("unchecked")
private void initReplacement(ResourceContext context) { private void initReplacement(ResourceContext context) {
if (context.getCachedData(KEY_HAS_CACHED_DATA, Boolean.class) != Boolean.TRUE) { if (context.getCachedData(KEY_HAS_CACHED_DATA, Boolean.class) != Boolean.TRUE) {


Expand Down Expand Up @@ -854,7 +855,7 @@ private CssParsingResult parseResources(List<URL> resources, ResourceContext con
Charset charset = Charsets.UTF_8; Charset charset = Charsets.UTF_8;


// check if the stylesheet doesn't include a @charset at-rule // check if the stylesheet doesn't include a @charset at-rule
String styleSheetCharset = extractCharset(byteSource, logger); String styleSheetCharset = extractCharset(byteSource);
if (styleSheetCharset != null) { if (styleSheetCharset != null) {
try { try {
charset = Charset.forName(styleSheetCharset); charset = Charset.forName(styleSheetCharset);
Expand Down Expand Up @@ -913,7 +914,7 @@ private CssParsingResult parseResources(List<URL> resources, ResourceContext con
booleanConditionCollector.getBooleanConditions(), constantNameMappingBuilder.build()); booleanConditionCollector.getBooleanConditions(), constantNameMappingBuilder.build());
} }


private String extractCharset(ByteSource byteSource, TreeLogger logger) throws IOException { private String extractCharset(ByteSource byteSource) throws IOException {
String firstLine = byteSource.asCharSource(Charsets.UTF_8).readFirstLine(); String firstLine = byteSource.asCharSource(Charsets.UTF_8).readFirstLine();
Matcher matcher = CHARSET.matcher(firstLine); Matcher matcher = CHARSET.matcher(firstLine);


Expand Down Expand Up @@ -1184,7 +1185,6 @@ private boolean writeUserMethod(TreeLogger logger, JMethod userMethod,
* Transform a camel case string to upper case. Each word is separated by a '_' * Transform a camel case string to upper case. Each word is separated by a '_'
* *
* @param camelCase * @param camelCase
* @return
*/ */
private String toUpperCase(String camelCase) { private String toUpperCase(String camelCase) {
return CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, camelCase); return CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, camelCase);
Expand Down

0 comments on commit c37e6ec

Please sign in to comment.