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

Unified Diff: pkg/polymer/lib/src/info.dart

Issue 23658002: Remove processing of dart code, summary.dart, simplified info.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: pkg/polymer/lib/src/info.dart
diff --git a/pkg/polymer/lib/src/info.dart b/pkg/polymer/lib/src/info.dart
index e226ba6674ec866f5f9ee809f82b6e2b515e2222..e1a6d48fdf685be9ef89577d464f4473d98be25c 100644
--- a/pkg/polymer/lib/src/info.dart
+++ b/pkg/polymer/lib/src/info.dart
@@ -10,14 +10,11 @@ library polymer.src.info;
import 'dart:collection' show SplayTreeMap, LinkedHashMap;
-import 'package:analyzer_experimental/src/generated/ast.dart';
import 'package:csslib/visitor.dart';
import 'package:html5lib/dom.dart';
import 'package:source_maps/span.dart' show Span;
-import 'dart_parser.dart' show DartCodeInfo;
import 'messages.dart';
-import 'summary.dart';
import 'utils.dart';
/**
@@ -44,92 +41,17 @@ class GlobalInfo {
* component-level behavior code. This code can either be inlined in the HTML
* file or included in a script tag with the "src" attribute.
*/
-abstract class LibraryInfo implements LibrarySummary {
-
- /** Whether there is any code associated with the page/component. */
- bool get codeAttached => inlinedCode != null || externalFile != null;
-
- /**
- * The actual inlined code. Use [userCode] if you want the code from this file
- * or from an external file.
- */
- DartCodeInfo inlinedCode;
-
- /**
- * If this library's code was loaded using a script tag (e.g. in a component),
- * [externalFile] has the path to such Dart file relative from the compiler's
- * base directory.
- */
- UrlInfo externalFile;
-
- /** Info asscociated with [externalFile], if any. */
- FileInfo externalCode;
-
- /**
- * The inverse of [externalCode]. If this .dart file was imported via a script
- * tag, this refers to the HTML file that imported it.
- */
- LibraryInfo htmlFile;
-
- /** File where the top-level code was defined. */
- UrlInfo get dartCodeUrl;
-
- /**
- * Name of the file that will hold any generated Dart code for this library
- * unit. Note this is initialized after parsing.
- */
- String outputFilename;
-
+abstract class LibraryInfo {
/** Parsed cssSource. */
List<StyleSheet> styleSheets = [];
-
- /** This is used in transforming Dart code to track modified files. */
- bool modified = false;
-
- /**
- * This is used in transforming Dart code to compute files that reference
- * [modified] files.
- */
- List<FileInfo> referencedBy = [];
-
- /**
- * Components used within this library unit. For [FileInfo] these are
- * components used directly in the page. For [ComponentInfo] these are
- * components used within their shadowed template.
- */
- final Map<ComponentSummary, bool> usedComponents =
- new LinkedHashMap<ComponentSummary, bool>();
-
- /**
- * The actual code, either inlined or from an external file, or `null` if none
- * was defined.
- */
- DartCodeInfo get userCode =>
- externalCode != null ? externalCode.inlinedCode : inlinedCode;
}
/** Information extracted at the file-level. */
-class FileInfo extends LibraryInfo implements HtmlFileSummary {
+class FileInfo extends LibraryInfo {
/** Relative path to this file from the compiler's base directory. */
final UrlInfo inputUrl;
/**
- * Whether this file should be treated as the entry point of the web app, i.e.
- * the file users navigate to in their browser. This will be true if this file
- * was passed in the command line to the dwc compiler, and the
- * `--components_only` flag was omitted.
- */
- final bool isEntryPoint;
-
- // TODO(terry): Ensure that that the libraryName is a valid identifier:
- // a..z || A..Z || _ [a..z || A..Z || 0..9 || _]*
- String get libraryName =>
- path.basename(inputUrl.resolvedPath).replaceAll('.', '_');
-
- /** File where the top-level code was defined. */
- UrlInfo get dartCodeUrl => externalFile != null ? externalFile : inputUrl;
-
- /**
* All custom element definitions in this file. This may contain duplicates.
* Normally you should use [components] for lookup.
*/
@@ -140,8 +62,8 @@ class FileInfo extends LibraryInfo implements HtmlFileSummary {
*`<link rel='components'>` tag. Maps from the tag name to the component
* information. This map is sorted by the tag name.
*/
- final Map<String, ComponentSummary> components =
- new SplayTreeMap<String, ComponentSummary>();
+ final Map<String, ComponentInfo> components =
+ new SplayTreeMap<String, ComponentInfo>();
/** Files imported with `<link rel="import">` */
final List<UrlInfo> componentLinks = <UrlInfo>[];
@@ -149,24 +71,12 @@ class FileInfo extends LibraryInfo implements HtmlFileSummary {
/** Files imported with `<link rel="stylesheet">` */
final List<UrlInfo> styleSheetHrefs = <UrlInfo>[];
- /** Root is associated with the body node. */
- Element body;
-
- FileInfo(this.inputUrl, [this.isEntryPoint = false]);
-
- /**
- * Query for an [Element] matching the provided [tag], starting from the
- * [body].
- */
- Element query(String tag) => body.query(tag);
+ FileInfo(this.inputUrl);
}
/** Information about a web component definition declared locally. */
-// TODO(sigmund): use a mixin to pull in ComponentSummary.
-class ComponentInfo extends LibraryInfo implements ComponentSummary {
- /** The file that declares this component. */
- final FileInfo declaringFile;
+class ComponentInfo extends LibraryInfo {
/** The component tag name, defined with the `name` attribute on `element`. */
final String tagName;
@@ -182,30 +92,18 @@ class ComponentInfo extends LibraryInfo implements ComponentSummary {
* This will be `null` if the component extends a built-in HTML tag, or
* if the analyzer has not run yet.
*/
- ComponentSummary extendsComponent;
-
- /** The Dart class containing the component's behavior. */
- String className;
-
- /** The Dart class declaration. */
- ClassDeclaration get classDeclaration => _classDeclaration;
- ClassDeclaration _classDeclaration;
+ ComponentInfo extendsComponent;
/** The declaring `<element>` tag. */
final Node element;
- /** File where this component was defined. */
- UrlInfo get dartCodeUrl => externalFile != null
- ? externalFile : declaringFile.inputUrl;
-
/**
* True if [tagName] was defined by more than one component. If this happened
* we will skip over the component.
*/
bool hasConflict = false;
- ComponentInfo(this.element, this.declaringFile, this.tagName,
- this.extendsTag);
+ ComponentInfo(this.element, this.tagName, this.extendsTag);
/**
* Gets the HTML tag extended by the base of the component hierarchy.
@@ -221,52 +119,7 @@ class ComponentInfo extends LibraryInfo implements ComponentSummary {
bool get hasAuthorStyles =>
element.attributes.containsKey('apply-author-styles');
- /**
- * Finds the declaring class, and initializes [className] and
- * [classDeclaration]. Also [userCode] is generated if there was no script.
- */
- void findClassDeclaration(Messages messages) {
- var constructor = element.attributes['constructor'];
- className = constructor != null ? constructor :
- toCamelCase(tagName, startUppercase: true);
-
- // If we don't have any code, generate a small class definition, and
- // pretend the user wrote it as inlined code.
- if (userCode == null) {
- var superclass = extendsComponent != null ? extendsComponent.className
- : 'autogenerated.PolymerElement';
- inlinedCode = new DartCodeInfo(null, null, [],
- 'class $className extends $superclass {\n}', null);
- }
-
- var code = userCode.code;
- _classDeclaration = userCode.findClass(className);
- if (_classDeclaration == null) {
- // Check for deprecated x-tags implied constructor.
- if (tagName.startsWith('x-') && constructor == null) {
- var oldCtor = toCamelCase(tagName.substring(2), startUppercase: true);
- _classDeclaration = userCode.findClass(oldCtor);
- if (_classDeclaration != null) {
- messages.warning('Implied constructor name for x-tags has changed to '
- '"$className". You should rename your class or add a '
- 'constructor="$oldCtor" attribute to the element declaration. '
- 'Also custom tags are not required to start with "x-" if their '
- 'name has at least one dash.',
- element.sourceSpan);
- className = oldCtor;
- }
- }
-
- if (_classDeclaration == null) {
- messages.error('please provide a class definition '
- 'for $className:\n $code', element.sourceSpan);
- return;
- }
- }
- }
-
- String toString() => '#<ComponentInfo $tagName '
- '${inlinedCode != null ? "inline" : "from ${dartCodeUrl.resolvedPath}"}>';
+ String toString() => '#<ComponentInfo $tagName>';
}

Powered by Google App Engine
This is Rietveld 408576698