lib/sass/tree.rb in scss-lint-0.9.0 vs lib/sass/tree.rb in scss-lint-0.10.0
- old
+ new
@@ -8,14 +8,21 @@
# The `args` field of some Sass::Tree::Node classes returns
# Sass::Script::Variable nodes with no line numbers. This adds the line
# numbers back in so lint reporting works for those nodes.
def add_line_numbers_to_args(arg_list)
arg_list.each do |variable, default_expr|
- variable.line = line # Use line number of containing parse tree node
+ add_line_number(variable)
end
end
+ # The Sass parser sometimes doesn't assign line numbers in cases where it
+ # should. This is a helper to easily correct that.
+ def add_line_number(node)
+ node.line ||= line if node.is_a?(Sass::Script::Node)
+ node
+ end
+
# Sometimes the parse tree doesn't return a Sass::Script::Variable, but just
# the name of the variable. This helper takes that name and turns it back
# into a Sass::Script::Variable that supports lint reporting.
def create_variable(var_name)
Sass::Script::Variable.new(var_name).tap do |v|
@@ -115,10 +122,10 @@
end
end
class PropNode
def children
- concat_expr_lists super, extract_script_nodes(name), value
+ concat_expr_lists super, extract_script_nodes(name), add_line_number(value)
end
end
class ReturnNode
def children