Cleanup some ambiguous and incorrect types and disable a case that in analyzer.dart that seems like it is broken.
BUG=
R=kevmoo@google.com
Review URL: https://codereview.chromium.org//873313003
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7c044aa..df9123c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.11.0+4
+
+* Cleanup some ambiguous and some incorrect type signatures.
+
## 0.11.0+3
* Improve the speed and memory efficiency of parsing.
diff --git a/lib/parser.dart b/lib/parser.dart
index 6060166..dce31b6 100644
--- a/lib/parser.dart
+++ b/lib/parser.dart
@@ -130,7 +130,7 @@
if (input is String) {
source = input;
- } else if (input is List<int>) {
+ } else if (input is List) {
// TODO(terry): The parse function needs an "encoding" argument and will
// default to whatever encoding CSS defaults to.
//
@@ -145,7 +145,7 @@
// See encoding helpers at: package:html5lib/lib/src/char_encodings.dart
// These helpers can decode in different formats given an encoding name
// (mostly unicode, ascii, windows-1252 which is html5 default encoding).
- source = new String.fromCharCodes(input);
+ source = new String.fromCharCodes(input as List<int>);
} else {
// TODO(terry): Support RandomAccessFile using console.
throw new ArgumentError("'source' must be a String or "
diff --git a/lib/src/analyzer.dart b/lib/src/analyzer.dart
index 6758a2d..da1a9fa 100644
--- a/lib/src/analyzer.dart
+++ b/lib/src/analyzer.dart
@@ -595,7 +595,7 @@
* Given a mixin's defined arguments return a cloned mixin defintion that has
* replaced all defined arguments with user's supplied VarUsages.
*/
- MixinDefinition transform(List<TreeNode> callArgs) {
+ MixinDefinition transform(List callArgs) {
// TODO(terry): Handle default arguments and varArgs.
// Transform mixin with callArgs.
var index = 0;
diff --git a/lib/src/polyfill.dart b/lib/src/polyfill.dart
index ef3c7b9..95749b9 100644
--- a/lib/src/polyfill.dart
+++ b/lib/src/polyfill.dart
@@ -144,7 +144,7 @@
} else if (node.defaultValues.any((e) => e is VarUsage)) {
// Don't have a VarDefinition need to use default values resolve all
// default values.
- var terminalDefaults = [];
+ var terminalDefaults = <Expression>[];
for (var defaultValue in node.defaultValues) {
terminalDefaults.addAll(resolveUsageTerminal(defaultValue));
}
@@ -199,7 +199,7 @@
return result;
}
- _resolveVarUsage(List<Expressions> expressions, int index,
+ _resolveVarUsage(List<Expression> expressions, int index,
VarDefinition def) {
var defExpressions = (def.expression as Expressions).expressions;
expressions.replaceRange(index, index + 1, defExpressions);
diff --git a/lib/src/property.dart b/lib/src/property.dart
index 777288a..5219c25 100644
--- a/lib/src/property.dart
+++ b/lib/src/property.dart
@@ -184,7 +184,7 @@
int get argbValue => Color.hexToInt(_argb);
- bool operator ==(Object other) => Color.equal(this, other);
+ bool operator ==(other) => Color.equal(this, other);
String toHexArgbString() => _argb;
@@ -198,7 +198,7 @@
return new Color.hex("${newRgba.toHexArgbString()}");
}
- static bool equal(ColorBase curr, Object other) {
+ static bool equal(ColorBase curr, other) {
if (other is Color) {
Color o = other;
return o.toHexArgbString() == curr.toHexArgbString();
@@ -601,7 +601,7 @@
return v1;
}
- bool operator ==(Object other) => Color.equal(this, other);
+ bool operator ==(other) => Color.equal(this, other);
String get cssExpression {
if (a == null) {
@@ -763,7 +763,7 @@
*/
num get alpha => _a;
- bool operator ==(Object other) => Color.equal(this, other);
+ bool operator ==(other) => Color.equal(this, other);
String get cssExpression => (_a == null) ?
"hsl($hueDegrees,$saturationPercentage,$lightnessPercentage)" :
@@ -1099,7 +1099,7 @@
return size.toInt() % family[0].hashCode;
}
- bool operator ==(Object other) {
+ bool operator ==(other) {
if (other is! Font) return false;
Font o = other;
return o.size == size && o.family == family && o.weight == weight &&
diff --git a/lib/src/tree.dart b/lib/src/tree.dart
index 53a5f9f..37d0741 100644
--- a/lib/src/tree.dart
+++ b/lib/src/tree.dart
@@ -1206,11 +1206,10 @@
lineHeight: lineHeight),
super(DartStyleExpression.fontStyle, span);
- FontExpression merged(FontExpression newFontExpr) {
- if (this.isFont && newFontExpr.isFont) {
+ FontExpression merged(DartStyleExpression newFontExpr) {
+ if (newFontExpr is FontExpression && this.isFont && newFontExpr.isFont) {
return new FontExpression.merge(this, newFontExpr);
}
-
return null;
}
@@ -1222,8 +1221,8 @@
}
FontExpression._merge(FontExpression x, FontExpression y, SourceSpan span)
- : super(DartStyleExpression.fontStyle, span),
- font = new Font.merge(x.font, y.font);
+ : font = new Font.merge(x.font, y.font),
+ super(DartStyleExpression.fontStyle, span);
FontExpression clone() =>
new FontExpression(span, size: font.size, family: font.family,
@@ -1239,13 +1238,6 @@
BoxExpression(int styleType, SourceSpan span, this.box)
: super(styleType, span);
- /*
- * Merges give 2 DartStyleExpression (or derived from DartStyleExpression,
- * e.g., FontExpression, etc.) will merge if the two expressions are of the
- * same property name (implies same exact type e.g, FontExpression).
- */
- merged(BoxExpression newDartExpr);
-
visit(VisitorBase visitor) => visitor.visitBoxExpression(this);
String get formattedBoxEdge {
@@ -1272,8 +1264,9 @@
MarginExpression.boxEdge(SourceSpan span, BoxEdge box)
: super(DartStyleExpression.marginStyle, span, box);
- merged(MarginExpression newMarginExpr) {
- if (this.isMargin && newMarginExpr.isMargin) {
+ merged(DartStyleExpression newMarginExpr) {
+ if (newMarginExpr is MarginExpression && this.isMargin &&
+ newMarginExpr.isMargin) {
return new MarginExpression.merge(this, newMarginExpr);
}
@@ -1307,8 +1300,8 @@
BorderExpression.boxEdge(SourceSpan span, BoxEdge box)
: super(DartStyleExpression.borderStyle, span, box);
- merged(BorderExpression newBorderExpr) {
- if (this.isBorder && newBorderExpr.isBorder) {
+ merged(DartStyleExpression newBorderExpr) {
+ if (newBorderExpr is BorderExpression && this.isBorder && newBorderExpr.isBorder) {
return new BorderExpression.merge(this, newBorderExpr);
}
@@ -1340,8 +1333,8 @@
HeightExpression(SourceSpan span, this.height)
: super(DartStyleExpression.heightStyle, span);
- merged(HeightExpression newHeightExpr) {
- if (this.isHeight && newHeightExpr.isHeight) {
+ merged(DartStyleExpression newHeightExpr) {
+ if (newHeightExpr is DartStyleExpression && this.isHeight && newHeightExpr.isHeight) {
return newHeightExpr;
}
@@ -1358,8 +1351,9 @@
WidthExpression(SourceSpan span, this.width)
: super(DartStyleExpression.widthStyle, span);
- merged(WidthExpression newWidthExpr) {
- if (this.isWidth && newWidthExpr.isWidth) {
+ merged(DartStyleExpression newWidthExpr) {
+ if (newWidthExpr is WidthExpression && this.isWidth &&
+ newWidthExpr.isWidth) {
return newWidthExpr;
}
@@ -1379,8 +1373,9 @@
PaddingExpression.boxEdge(SourceSpan span, BoxEdge box)
: super(DartStyleExpression.paddingStyle, span, box);
- merged(PaddingExpression newPaddingExpr) {
- if (this.isPadding && newPaddingExpr.isPadding) {
+ merged(DartStyleExpression newPaddingExpr) {
+ if (newPaddingExpr is PaddingExpression && this.isPadding &&
+ newPaddingExpr.isPadding) {
return new PaddingExpression.merge(this, newPaddingExpr);
}
diff --git a/lib/visitor.dart b/lib/visitor.dart
index aac7242..154d235 100644
--- a/lib/visitor.dart
+++ b/lib/visitor.dart
@@ -40,7 +40,7 @@
void visitRuleSet(RuleSet node);
void visitDeclarationGroup(DeclarationGroup node);
- void visitMarginGroup(DeclarationGroup node);
+ void visitMarginGroup(MarginGroup node);
void visitDeclaration(Declaration node);
void visitVarDefinition(VarDefinition node);
void visitIncludeMixinAtDeclaration(IncludeMixinAtDeclaration node);
diff --git a/pubspec.yaml b/pubspec.yaml
index 462fde0..7bb6317 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: csslib
-version: 0.11.0+3
+version: 0.11.0+4
author: Polymer.dart Team <web-ui-dev@dartlang.org>
description: A library for parsing CSS.
homepage: https://github.com/dart-lang/csslib