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

Unified Diff: web_components/lib/build/common.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « web_components/lib/build.log ('k') | web_components/lib/build/html_import_annotation_recorder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: web_components/lib/build/common.dart
diff --git a/web_components/lib/build/common.dart b/web_components/lib/build/common.dart
deleted file mode 100644
index 41f490112cae93328565d3232ef60e190fbca5ff..0000000000000000000000000000000000000000
--- a/web_components/lib/build/common.dart
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-library web_components.build.common;
-
-import 'package:analyzer/analyzer.dart';
-import 'package:barback/barback.dart';
-import 'package:code_transformers/messages/build_logger.dart';
-import 'package:html/dom.dart' as dom;
-import 'package:html/parser.dart';
-import 'package:source_span/source_span.dart';
-import 'package:path/path.dart' as path;
-import 'messages.dart';
-
-/// Generate the import url for a file described by [id], referenced by a file
-/// with [sourceId].
-// TODO(sigmund): this should also be in barback (dartbug.com/12610)
-// TODO(jakemac): This is copied from polymer, we should move it to
-// the code_transformers package so it can be shared.
-String assetUrlFor(AssetId id, AssetId sourceId, BuildLogger logger,
- {bool allowAssetUrl: false}) {
- // use package: and asset: urls if possible
- if (id.path.startsWith('lib/')) {
- return 'package:${id.package}/${id.path.substring(4)}';
- }
-
- if (id.path.startsWith('asset/')) {
- if (!allowAssetUrl) {
- logger.error(internalErrorDontKnowHowToImport.create({
- 'target': id,
- 'source': sourceId,
- 'extra': ' (asset urls not allowed.)'
- }));
- return null;
- }
- return 'asset:${id.package}/${id.path.substring(6)}';
- }
-
- // Use relative urls only if it's possible.
- if (id.package != sourceId.package) {
- logger.error("don't know how to refer to $id from $sourceId");
- return null;
- }
-
- var builder = path.url;
- return builder.relative(builder.join('/', id.path),
- from: builder.join('/', builder.dirname(sourceId.path)));
-}
-
-/// Gets the appropriate URL to use in a span to produce messages (e.g.
-/// warnings) for users. This will attempt to format the URL in the most useful
-/// way:
-///
-/// - If the asset is within the primary package, then use the [id.path],
-/// the user will know it is a file from their own code.
-/// - If the asset is from another package, then use [assetUrlFor], this will
-/// likely be a "package:" url to the file in the other package, which is
-/// enough for users to identify where the error is.
-String spanUrlFor(AssetId id, AssetId sourceId, logger) {
- bool samePackage = id.package == sourceId.package;
- return samePackage
- ? id.path
- : assetUrlFor(id, sourceId, logger, allowAssetUrl: true);
-}
-
-/// Return the span in a file for an [AstNode].
-FileSpan getSpan(SourceFile file, AstNode node) =>
- file.span(node.offset, node.end);
-
-/// Parses an HTML file [contents] and returns a DOM-like tree.
-dom.Document parseHtml(String contents, String sourcePath) {
- var parser = new HtmlParser(contents,
- encoding: 'utf8', generateSpans: true, sourceUrl: sourcePath);
- return parser.parse();
-}
-
-const String dartType = "application/dart";
-const String jsType = "text/javascript";
« no previous file with comments | « web_components/lib/build.log ('k') | web_components/lib/build/html_import_annotation_recorder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698