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

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

Issue 12225039: Support for observable models, fixes #259 (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: small formatting fixes Created 7 years, 10 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
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 * Part of the template compilation that concerns with extracting information 6 * Part of the template compilation that concerns with extracting information
7 * from the HTML parse tree. 7 * from the HTML parse tree.
8 */ 8 */
9 library analyzer; 9 library analyzer;
10 10
11 import 'package:html5lib/dom.dart'; 11 import 'package:html5lib/dom.dart';
12 import 'package:html5lib/dom_parsing.dart'; 12 import 'package:html5lib/dom_parsing.dart';
13 13
14 import 'directive_parser.dart' show parseDartCode; 14 import 'dart_parser.dart';
15 import 'file_system/path.dart'; 15 import 'file_system/path.dart';
16 import 'files.dart'; 16 import 'files.dart';
17 import 'html5_utils.dart'; 17 import 'html5_utils.dart';
18 import 'info.dart'; 18 import 'info.dart';
19 import 'messages.dart'; 19 import 'messages.dart';
20 import 'utils.dart'; 20 import 'utils.dart';
21 21
22 /** 22 /**
23 * Finds custom elements in this file and the list of referenced files with 23 * Finds custom elements in this file and the list of referenced files with
24 * component declarations. This is the first pass of analysis on a file. 24 * component declarations. This is the first pass of analysis on a file.
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 } 705 }
706 706
707 /** 707 /**
708 * Stores a direct reference in [info] to a dart source file that was loaded 708 * Stores a direct reference in [info] to a dart source file that was loaded
709 * in a script tag with the 'src' attribute. 709 * in a script tag with the 'src' attribute.
710 */ 710 */
711 void _attachExtenalScript(LibraryInfo info, Map<Path, FileInfo> files) { 711 void _attachExtenalScript(LibraryInfo info, Map<Path, FileInfo> files) {
712 var path = info.externalFile; 712 var path = info.externalFile;
713 if (path != null) { 713 if (path != null) {
714 info.externalCode = files[path]; 714 info.externalCode = files[path];
715 info.externalCode.htmlFile = info;
715 info.userCode = info.externalCode.userCode; 716 info.userCode = info.externalCode.userCode;
716 } 717 }
717 } 718 }
718 719
719 /** Adds a component's tag name to the names in scope for [fileInfo]. */ 720 /** Adds a component's tag name to the names in scope for [fileInfo]. */
720 void _addComponent(FileInfo fileInfo, ComponentInfo componentInfo) { 721 void _addComponent(FileInfo fileInfo, ComponentInfo componentInfo) {
721 var existing = fileInfo.components[componentInfo.tagName]; 722 var existing = fileInfo.components[componentInfo.tagName];
722 if (existing != null) { 723 if (existing != null) {
723 if (existing == componentInfo) { 724 if (existing == componentInfo) {
724 // This is the same exact component as the existing one. 725 // This is the same exact component as the existing one.
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 assert(node.nodes.length == 1); 947 assert(node.nodes.length == 1);
947 Text text = node.nodes[0]; 948 Text text = node.nodes[0];
948 949
949 if (_currentInfo.codeAttached) { 950 if (_currentInfo.codeAttached) {
950 _tooManyScriptsError(node); 951 _tooManyScriptsError(node);
951 } else if (_currentInfo == _fileInfo && !_fileInfo.isEntryPoint) { 952 } else if (_currentInfo == _fileInfo && !_fileInfo.isEntryPoint) {
952 _messages.warning('top-level dart code is ignored on ' 953 _messages.warning('top-level dart code is ignored on '
953 ' HTML pages that define components, but are not the entry HTML ' 954 ' HTML pages that define components, but are not the entry HTML '
954 'file.', node.sourceSpan, file: _fileInfo.path); 955 'file.', node.sourceSpan, file: _fileInfo.path);
955 } else { 956 } else {
956 _currentInfo.inlinedCode = text.value; 957 var path = _currentInfo.inputPath;
957 _currentInfo.userCode = parseDartCode(text.value, 958 _currentInfo.userCode = parseDartCode(path, text.value, _messages);
958 _currentInfo.inputPath, messages:_messages);
959 if (_currentInfo.userCode.partOf != null) { 959 if (_currentInfo.userCode.partOf != null) {
960 _messages.error('expected a library, not a part.', 960 _messages.error('expected a library, not a part.',
961 node.sourceSpan, file: _fileInfo.path); 961 node.sourceSpan, file: _fileInfo.path);
962 } 962 }
963 } 963 }
964 } 964 }
965 965
966 void _tooManyScriptsError(Node node) { 966 void _tooManyScriptsError(Node node) {
967 var location = _currentInfo is ComponentInfo ? 967 var location = _currentInfo is ComponentInfo ?
968 'a custom element declaration' : 'the top-level HTML page'; 968 'a custom element declaration' : 'the top-level HTML page';
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 if (start == null) moveNext(); 1031 if (start == null) moveNext();
1032 if (start < length) { 1032 if (start < length) {
1033 do { 1033 do {
1034 bindings.add(binding); 1034 bindings.add(binding);
1035 content.add(textContent); 1035 content.add(textContent);
1036 } while (moveNext()); 1036 } while (moveNext());
1037 } 1037 }
1038 content.add(textContent); 1038 content.add(textContent);
1039 } 1039 }
1040 } 1040 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698