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

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

Issue 11275029: Support for specifying an output directory (issue #106) (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
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 /** 5 /**
6 * Datatypes holding information extracted by the analyzer and used by later 6 * Datatypes holding information extracted by the analyzer and used by later
7 * phases of the compiler. 7 * phases of the compiler.
8 */ 8 */
9 library info; 9 library info;
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 /** 75 /**
76 * Returns the relative path to import the output library represented [info] 76 * Returns the relative path to import the output library represented [info]
77 * from a file at the top-level output directory. 77 * from a file at the top-level output directory.
78 */ 78 */
79 Path relativePathFromOutputDir(LibraryInfo info) { 79 Path relativePathFromOutputDir(LibraryInfo info) {
80 var relativeDir = info.inputPath.directoryPath.relativeTo(_baseDir); 80 var relativeDir = info.inputPath.directoryPath.relativeTo(_baseDir);
81 return relativeDir.append(info.outputFilename).canonicalize(); 81 return relativeDir.append(info.outputFilename).canonicalize();
82 } 82 }
83 83
84 /** 84 /**
85 * Returns a relative path to import [target] from the output library of 85 * Transforms an import, part, or export [url] seen in `src.inputPath` into a
86 * [src]. Unlike [relativePath], this returns a relative path from the output 86 * corresponding url from the output library of [src]. This will keep
87 * directory back to the input directory. An exception will be thrown if 87 * 'package:' and 'dart:' urls intact, but it will fix relative paths to walk
88 * [target] is not under [_baseDir]. 88 * from the output directory back to the input directory. An exception will be
89 * thrown if [target] is not under [_baseDir].
89 */ 90 */
90 Path relativePathToInput(LibraryInfo src, Path target) { 91 String transferDirectiveUrl(LibraryInfo src, String url) {
91 return target.relativeTo(outputLibraryPath(src)).canonicalize(); 92 if (url.startsWith('package:') || url.startsWith('dart:')) return url;
93 var pathFromBaseDir = src.inputPath.directoryPath.join(new Path(url));
94 var outputLibraryDir = _outputDirPath(src.inputPath);
95 return pathFromBaseDir.relativeTo(outputLibraryDir)
96 .canonicalize().toString();
92 } 97 }
93 } 98 }
94 99
95 /** 100 /**
96 * Information for any library-like input. We consider each HTML file a library, 101 * Information for any library-like input. We consider each HTML file a library,
97 * and each component declaration a library as well. Hence we use this as a base 102 * and each component declaration a library as well. Hence we use this as a base
98 * class for both [FileInfo] and [ComponentInfo]. Both HTML files and components 103 * class for both [FileInfo] and [ComponentInfo]. Both HTML files and components
99 * can have .dart code provided by the user for top-level user scripts and 104 * can have .dart code provided by the user for top-level user scripts and
100 * component-level behavior code. This code can either be inlined in the HTML 105 * component-level behavior code. This code can either be inlined in the HTML
101 * file or included in a `<script src='url'>` tag. 106 * file or included in a `<script src='url'>` tag.
102 */ 107 */
103 abstract class LibraryInfo { 108 abstract class LibraryInfo {
104 109
105 /** Whether there is any code associated with the page/component. */ 110 /** Whether there is any code associated with the page/component. */
106 bool get codeAttached => inlinedCode != null || externalFile != null; 111 bool get codeAttached => inlinedCode != null || externalFile != null;
107 112
108 /** 113 /**
109 * The actual code, either inlined or from an external file, or `null` if none 114 * The actual code, either inlined or from an external file, or `null` if none
110 * was defined. 115 * was defined.
111 */ 116 */
112 String get userCode { 117 DartCodeInfo userCode;
113 if (inlinedCode != null) return inlinedCode;
114 if (externalCode != null) return externalCode.userCode;
115 return null;
116 }
117 118
118 /** The inlined code, if any. */ 119 /** The inlined code, if any. */
119 String inlinedCode; 120 String inlinedCode;
120 121
121 /** The name of the file sourced in a script tag, if any. */ 122 /** The name of the file sourced in a script tag, if any. */
122 Path externalFile; 123 Path externalFile;
123 124
124 /** Info asscociated with [externalFile], if any. */ 125 /** Info asscociated with [externalFile], if any. */
125 FileInfo externalCode; 126 FileInfo externalCode;
126 127
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 425
425 /** 426 /**
426 * Specifies the action to take on a particular event. Some actions need to read 427 * Specifies the action to take on a particular event. Some actions need to read
427 * attributes from the DOM element that has the event listener (e.g. two way 428 * attributes from the DOM element that has the event listener (e.g. two way
428 * bindings do this). [elementVarName] stores a reference to this element, and 429 * bindings do this). [elementVarName] stores a reference to this element, and
429 * [eventArgName] stores a reference to the event parameter name. 430 * [eventArgName] stores a reference to the event parameter name.
430 * They are generated outside of the analyzer (in the emitter), so they are 431 * They are generated outside of the analyzer (in the emitter), so they are
431 * passed here as arguments. 432 * passed here as arguments.
432 */ 433 */
433 typedef String ActionDefinition(String elemVarName, String eventArgName); 434 typedef String ActionDefinition(String elemVarName, String eventArgName);
435
436 /** Information extracted from a source Dart file. */
437 class DartCodeInfo {
438 /** Library qualified identifier, if any. */
439 final String libraryName;
440
441 /** Library which the code is part-of, if any. */
442 final String partOf;
443
444 /** Declared imports, exports, and parts. */
445 final List<DartDirectiveInfo> directives;
446
447 /** The rest of the code. */
448 final String code;
449
450 DartCodeInfo(this.libraryName, this.partOf, this.directives, this.code);
451 }
452
453 /** Information about a single import/export/part directive. */
454 class DartDirectiveInfo {
455 /** Directive's label: import, export, or part. */
456 String label;
457
458 /** Referenced uri being imported, exported, or included by a part. */
459 String uri;
460
461 /** Prefix used for imports, if any. */
462 String prefix;
463
464 /** Hidden identifiers. */
465 List<String> hide;
466
467 /** Shown identifiers. */
468 List<String> show;
469
470 DartDirectiveInfo(this.label, this.uri, [this.prefix, this.hide, this.show]);
471 }
OLDNEW
« lib/src/emitters.dart ('K') | « lib/src/emitters.dart ('k') | lib/src/messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698