Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Side by Side Diff: pkg/csslib/lib/css.dart

Issue 426053003: Use source_span rather than source_maps in csslib. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add CHANGELOG Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/csslib/CHANGELOG.md ('k') | pkg/csslib/lib/parser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library css; 5 library css;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:path/path.dart' as path; 9 import 'package:path/path.dart' as path;
10 import 'package:source_maps/span.dart' show SourceFile; 10 import 'package:source_span/source_span.dart';
11 11
12 import 'parser.dart'; 12 import 'parser.dart';
13 import 'visitor.dart'; 13 import 'visitor.dart';
14 import 'src/messages.dart'; 14 import 'src/messages.dart';
15 import 'src/options.dart'; 15 import 'src/options.dart';
16 16
17 void main(List<String> arguments) { 17 void main(List<String> arguments) {
18 // TODO(jmesserly): fix this to return a proper exit code 18 // TODO(jmesserly): fix this to return a proper exit code
19 var options = PreprocessorOptions.parse(arguments); 19 var options = PreprocessorOptions.parse(arguments);
20 if (options == null) return; 20 if (options == null) return;
21 21
22 messages = new Messages(options: options); 22 messages = new Messages(options: options);
23 23
24 _time('Total time spent on ${options.inputFile}', () { 24 _time('Total time spent on ${options.inputFile}', () {
25 _compile(options.inputFile, options.verbose); 25 _compile(options.inputFile, options.verbose);
26 }, true); 26 }, true);
27 } 27 }
28 28
29 void _compile(String inputPath, bool verbose) { 29 void _compile(String inputPath, bool verbose) {
30 var ext = path.extension(inputPath); 30 var ext = path.extension(inputPath);
31 if (ext != '.css' && ext != '.scss') { 31 if (ext != '.css' && ext != '.scss') {
32 messages.error("Please provide a CSS/Sass file", null); 32 messages.error("Please provide a CSS/Sass file", null);
33 return; 33 return;
34 } 34 }
35 try { 35 try {
36 // Read the file. 36 // Read the file.
37 var filename = path.basename(inputPath); 37 var filename = path.basename(inputPath);
38 var contents = new File(inputPath).readAsStringSync(); 38 var contents = new File(inputPath).readAsStringSync();
39 var file = new SourceFile.text(inputPath, contents); 39 var file = new SourceFile(contents, url: path.toUri(inputPath));
40 40
41 // Parse the CSS. 41 // Parse the CSS.
42 var tree = _time('Parse $filename', 42 var tree = _time('Parse $filename',
43 () => new Parser(file, contents).parse(), verbose); 43 () => new Parser(file, contents).parse(), verbose);
44 44
45 _time('Analyzer $filename', 45 _time('Analyzer $filename',
46 () => new Analyzer([tree], messages), verbose).run(); 46 () => new Analyzer([tree], messages), verbose).run();
47 47
48 // Emit the processed CSS. 48 // Emit the processed CSS.
49 var emitter = new CssPrinter(); 49 var emitter = new CssPrinter();
(...skipping 22 matching lines...) Expand all
72 void _printMessage(String message, int duration) { 72 void _printMessage(String message, int duration) {
73 var buf = new StringBuffer(); 73 var buf = new StringBuffer();
74 buf.write(message); 74 buf.write(message);
75 for (int i = message.length; i < 60; i++) buf.write(' '); 75 for (int i = message.length; i < 60; i++) buf.write(' ');
76 buf.write(' -- '); 76 buf.write(' -- ');
77 if (duration < 10) buf.write(' '); 77 if (duration < 10) buf.write(' ');
78 if (duration < 100) buf.write(' '); 78 if (duration < 100) buf.write(' ');
79 buf..write(duration)..write(' ms'); 79 buf..write(duration)..write(' ms');
80 print(buf.toString()); 80 print(buf.toString());
81 } 81 }
OLDNEW
« no previous file with comments | « pkg/csslib/CHANGELOG.md ('k') | pkg/csslib/lib/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698