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

Unified Diff: lib/src/analyzer.dart

Issue 12016007: Add a warning about using a component that isn't referenced (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: Created 7 years, 11 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 | « no previous file | test/analyzer_test.dart » ('j') | test/analyzer_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/analyzer.dart
diff --git a/lib/src/analyzer.dart b/lib/src/analyzer.dart
index eebfd49609db96f46fe38ff9eb4e71ce70d9ebd7..fc7d6789b3ce737c1f48af6a1ecb43c5199bd6ea 100644
--- a/lib/src/analyzer.dart
+++ b/lib/src/analyzer.dart
@@ -135,6 +135,7 @@ class _Analyzer extends TreeVisitor {
// we skip the body of the element here.
var name = node.attributes['name'];
if (name == null) return;
+
var component = _fileInfo.components[name];
if (component == null) return;
@@ -201,7 +202,6 @@ class _Analyzer extends TreeVisitor {
component.extendsComponent = _fileInfo.components[component.extendsTag];
if (component.extendsComponent == null &&
component.extendsTag.startsWith('x-')) {
-
_messages.warning(
'custom element with tag name ${component.extendsTag} not found.',
component.element.sourceSpan, file: _fileInfo.path);
@@ -215,13 +215,16 @@ class _Analyzer extends TreeVisitor {
// TODO(jmesserly): warn for unknown element tags?
// <button is="x-fancy-button">
- var isAttr = node.attributes['is'];
- if (isAttr != null) {
- component = _fileInfo.components[isAttr];
- if (component == null) {
- _messages.warning('custom element with tag name $isAttr not found.',
- node.sourceSpan, file: _fileInfo.path);
- }
+ var componentName = node.attributes['is'];
+ if (componentName != null) {
+ component = _fileInfo.components[componentName];
+ } else if (node.tagName.startsWith('x-')) {
+ componentName = node.tagName;
+ }
+ if (component == null && componentName != null) {
+ _messages.warning(
+ 'custom element with tag name $componentName not found.',
+ node.sourceSpan, file: _fileInfo.path);
}
}
« no previous file with comments | « no previous file | test/analyzer_test.dart » ('j') | test/analyzer_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698