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

Side by Side Diff: lib/src/compiler.dart

Issue 11293285: Fixes #163 - small fix in the mangling logic, renames all expected test files (Closed) Base URL: git@github.com:dart-lang/dart-web-components.git@master
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « no previous file | lib/src/info.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 compiler; 5 library compiler;
6 6
7 import 'dart:collection' show SplayTreeMap; 7 import 'dart:collection' show SplayTreeMap;
8 import 'dart:coreimpl'; 8 import 'dart:coreimpl';
9 import 'package:html5lib/dom.dart'; 9 import 'package:html5lib/dom.dart';
10 import 'package:html5lib/parser.dart'; 10 import 'package:html5lib/parser.dart';
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 /** Information about source [files] given their href. */ 53 /** Information about source [files] given their href. */
54 final Map<Path, FileInfo> info = new SplayTreeMap<Path, FileInfo>(); 54 final Map<Path, FileInfo> info = new SplayTreeMap<Path, FileInfo>();
55 55
56 Compiler(this.filesystem, this.options, [String currentDir]) { 56 Compiler(this.filesystem, this.options, [String currentDir]) {
57 _mainPath = new Path(options.inputFile); 57 _mainPath = new Path(options.inputFile);
58 var mainDir = _mainPath.directoryPath; 58 var mainDir = _mainPath.directoryPath;
59 var basePath = 59 var basePath =
60 options.baseDir != null ? new Path(options.baseDir) : mainDir; 60 options.baseDir != null ? new Path(options.baseDir) : mainDir;
61 var outputPath = 61 var outputPath =
62 options.outputDir != null ? new Path(options.outputDir) : mainDir; 62 options.outputDir != null ? new Path(options.outputDir) : mainDir;
63 var _mangleFilenames = basePath != outputPath;
Siggi Cherem (dart-lang) 2012/11/14 22:01:31 I just realized this should be == instead of !=, a
justinfagnani 2012/11/14 22:07:13 d'oh. the tests don't cover both mangling and no-m
64 63
65 // Normalize paths - all should be relative or absolute paths. 64 // Normalize paths - all should be relative or absolute paths.
66 bool anyAbsolute = _mainPath.isAbsolute || basePath.isAbsolute || 65 bool anyAbsolute = _mainPath.isAbsolute || basePath.isAbsolute ||
67 outputPath.isAbsolute; 66 outputPath.isAbsolute;
68 bool allAbsolute = _mainPath.isAbsolute && basePath.isAbsolute && 67 bool allAbsolute = _mainPath.isAbsolute && basePath.isAbsolute &&
69 outputPath.isAbsolute; 68 outputPath.isAbsolute;
70 if (anyAbsolute && !allAbsolute) { 69 if (anyAbsolute && !allAbsolute) {
71 if (currentDir == null) { 70 if (currentDir == null) {
72 messages.error('internal error: could not normalize paths. Please make ' 71 messages.error('internal error: could not normalize paths. Please make '
73 'the input, base, and output paths all absolute or relative, or ' 72 'the input, base, and output paths all absolute or relative, or '
74 'specify "currentDir" to the Compiler constructor', null); 73 'specify "currentDir" to the Compiler constructor', null);
75 return; 74 return;
76 } 75 }
77 var currentPath = new Path(currentDir); 76 var currentPath = new Path(currentDir);
78 if (!_mainPath.isAbsolute) _mainPath = currentPath.join(_mainPath); 77 if (!_mainPath.isAbsolute) _mainPath = currentPath.join(_mainPath);
79 if (!basePath.isAbsolute) basePath = currentPath.join(basePath); 78 if (!basePath.isAbsolute) basePath = currentPath.join(basePath);
80 if (!outputPath.isAbsolute) outputPath = currentPath.join(outputPath); 79 if (!outputPath.isAbsolute) outputPath = currentPath.join(outputPath);
81 } 80 }
82 _pathInfo = new PathInfo(basePath, outputPath, _mangleFilenames); 81 _pathInfo = new PathInfo(basePath, outputPath);
83 } 82 }
84 83
85 /** Compile the application starting from the given [mainFile]. */ 84 /** Compile the application starting from the given [mainFile]. */
86 Future run() { 85 Future run() {
87 if (_mainPath.filename.endsWith('.dart')) { 86 if (_mainPath.filename.endsWith('.dart')) {
88 messages.error("Please provide an HTML file as your entry point.", 87 messages.error("Please provide an HTML file as your entry point.",
89 null, file: _mainPath); 88 null, file: _mainPath);
90 return new Future.immediate(null); 89 return new Future.immediate(null);
91 } 90 }
92 return _parseAndDiscover(_mainPath).transform((_) { 91 return _parseAndDiscover(_mainPath).transform((_) {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 if (doctype.tagName != 'html' || commentIndex != 1) { 280 if (doctype.tagName != 'html' || commentIndex != 1) {
282 messages.warning('file should start with <!DOCTYPE html> ' 281 messages.warning('file should start with <!DOCTYPE html> '
283 'to avoid the possibility of it being parsed in quirks mode in IE. ' 282 'to avoid the possibility of it being parsed in quirks mode in IE. '
284 'See http://www.w3.org/TR/html5-diff/#doctype', 283 'See http://www.w3.org/TR/html5-diff/#doctype',
285 doctype.span, file: file.path); 284 doctype.span, file: file.path);
286 } 285 }
287 } 286 }
288 document.nodes.insertAt(commentIndex, parseFragment( 287 document.nodes.insertAt(commentIndex, parseFragment(
289 '\n<!-- This file was auto-generated from template ${file.path}. -->\n')); 288 '\n<!-- This file was auto-generated from template ${file.path}. -->\n'));
290 } 289 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/info.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698