Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes based on review for #4 #8

Merged
merged 15 commits into from Mar 8, 2019
Merged
8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -9,7 +9,7 @@ cache:
directories:
- $HOME/.pub-cache

script:
- dartanalyzer --fatal-warnings ./
- dartfmt -n --set-exit-if-changed .
- pub run test
dart_task:
- dartanalyzer: --fatal-warnings ./
- dartfmt
- test
4 changes: 3 additions & 1 deletion README.md
@@ -1,7 +1,9 @@
# Sass Modules Migrator

This tool is designed to help migrate stylesheets from the old `@import`
functionality to the new module system.
functionality to [the new module system][module-spec].

This is still a work-in-progress, but should eventually implement everything
described in [sass/sass#2575](https://github.com/sass/sass/issues/2575).

[module-spec]: https://github.com/sass/language/blob/master/accepted/module-system.md
5 changes: 2 additions & 3 deletions bin/sass_module_migrator.dart
Expand Up @@ -26,15 +26,14 @@ void main(List<String> args) {
var argResults = argParser.parse(args);

if (argResults['help'] == true || argResults.rest.isEmpty) {
print('Migrates one or more .scss files to the new module system.\n\n'
print('Migrates one or more Sass files to the new module system.\n\n'
'Usage: sass_migrate_to_modules [options] <entrypoint.scss ...>\n\n'
'${argParser.usage}');
exitCode = 64;
return;
}

var migrated = Migrator().runMigrations(argResults.rest,
migrateDependencies: argResults['recursive']);
var migrated = migrateFiles(argResults.rest);

if (migrated.isEmpty) {
print('Nothing to migrate!');
Expand Down
310 changes: 0 additions & 310 deletions lib/src/base_visitor.dart

This file was deleted.

38 changes: 38 additions & 0 deletions lib/src/local_scope.dart
@@ -0,0 +1,38 @@
// Copyright 2019 Google LLC
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

import 'utils.dart';

/// Keeps track of the scope of any members declared at the current level of
/// the stylesheet.
class LocalScope {
/// The parent of this scope, or null if this scope is only nested one level
/// from the root of the file.
final LocalScope parent;

/// Variables defined in this scope.
final variables = normalizedSet();

/// Mixins defined in this scope.
final mixins = normalizedSet();

/// Functions defined in this scope.
final functions = normalizedSet();

LocalScope(this.parent);

/// Returns whether a variable [name] exists somewhere within this scope.
bool isLocalVariable(String name) =>
variables.contains(name) || (parent?.isLocalVariable(name) ?? false);

/// Returns whether a mixin [name] exists somewhere within this scope.
bool isLocalMixin(String name) =>
variables.contains(name) || (parent?.isLocalMixin(name) ?? false);

/// Returns whether a function [name] exists somewhere within this scope.
bool isLocalFunction(String name) =>
variables.contains(name) || (parent?.isLocalFunction(name) ?? false);
}