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

Side by Side Diff: test/testing.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 unified diff | Download patch
« test/analyzer_test.dart ('K') | « test/analyzer_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** Common definitions used for setting up the test environment. */ 5 /** Common definitions used for setting up the test environment. */
6 library testing; 6 library testing;
7 7
8 import 'package:html5lib/dom.dart'; 8 import 'package:html5lib/dom.dart';
9 import 'package:html5lib/parser.dart'; 9 import 'package:html5lib/parser.dart';
10 import 'package:web_ui/src/analyzer.dart'; 10 import 'package:web_ui/src/analyzer.dart';
11 import 'package:web_ui/src/info.dart'; 11 import 'package:web_ui/src/info.dart';
12 import 'package:web_ui/src/messages.dart'; 12 import 'package:web_ui/src/messages.dart';
13 import 'package:web_ui/src/options.dart'; 13 import 'package:web_ui/src/options.dart';
14 import 'package:web_ui/src/files.dart'; 14 import 'package:web_ui/src/files.dart';
15 import 'package:web_ui/src/file_system/path.dart'; 15 import 'package:web_ui/src/file_system/path.dart';
16 import 'package:web_ui/src/utils.dart'; 16 import 'package:web_ui/src/utils.dart';
17 17
18 18
19 Document parseDocument(String html) => parse(html); 19 Document parseDocument(String html) => parse(html);
20 20
21 Element parseSubtree(String html) => parseFragment(html).nodes[0]; 21 Element parseSubtree(String html) => parseFragment(html).nodes[0];
22 22
23 ElementInfo analyzeElement(Element elem, {Messages messages}) { 23 ElementInfo analyzeElement(Element elem, {Messages messages}) {
24 messages = messages == null ? new Messages.silent() : messages;
25 var fileInfo = analyzeNodeForTesting(elem, messages: messages); 24 var fileInfo = analyzeNodeForTesting(elem, messages: messages);
26 return fileInfo.bodyInfo; 25 return fileInfo.bodyInfo;
27 } 26 }
28 27
29 FileInfo analyzeDefinitionsInTree(Document doc, {Messages messages}) { 28 FileInfo analyzeDefinitionsInTree(Document doc, {Messages messages}) {
30 messages = messages == null ? new Messages.silent() : messages;
31 return analyzeDefinitions( 29 return analyzeDefinitions(
32 new SourceFile(new Path(''))..document = doc, messages: messages 30 new SourceFile(new Path(''))..document = doc, messages: messages
33 ); 31 );
34 } 32 }
35 33
36 /** Parses files in [fileContents], with [mainHtmlFile] being the main file. */ 34 /** Parses files in [fileContents], with [mainHtmlFile] being the main file. */
37 List<SourceFile> parseFiles(Map<String, String> fileContents, 35 List<SourceFile> parseFiles(Map<String, String> fileContents,
38 [String mainHtmlFile = 'index.html']) { 36 [String mainHtmlFile = 'index.html']) {
39 37
40 var result = <SourceFile>[]; 38 var result = <SourceFile>[];
41 fileContents.forEach((filename, contents) { 39 fileContents.forEach((filename, contents) {
42 var src = new SourceFile(new Path(filename)); 40 var src = new SourceFile(new Path(filename));
43 src.document = parse(contents); 41 src.document = parse(contents);
44 result.add(src); 42 result.add(src);
45 }); 43 });
46 44
47 return result; 45 return result;
48 } 46 }
49 47
50 /** Analyze all files. */ 48 /** Analyze all files. */
51 Map<String, FileInfo> analyzeFiles(List<SourceFile> files) { 49 Map<String, FileInfo> analyzeFiles(List<SourceFile> files,
50 {Messages messages}) {
51
52 var result = new Map<Path, FileInfo>(); 52 var result = new Map<Path, FileInfo>();
53 // analyze definitions 53 // analyze definitions
54 for (var file in files) { 54 for (var file in files) {
55 result[file.path] = analyzeDefinitions(file); 55 result[file.path] = analyzeDefinitions(file, messages: messages);
56 } 56 }
57 57
58 // analyze file contents 58 // analyze file contents
59 var uniqueIds = new IntIterator(); 59 var uniqueIds = new IntIterator();
60 for (var file in files) { 60 for (var file in files) {
61 analyzeFile(file, result, uniqueIds); 61 analyzeFile(file, result, uniqueIds, messages: messages);
62 } 62 }
63 return _toStringMap(result); 63 return _toStringMap(result);
64 } 64 }
65 65
66 Map<Path, FileInfo> toPathMap(Map<String, FileInfo> map) { 66 Map<Path, FileInfo> toPathMap(Map<String, FileInfo> map) {
67 var res = new Map<Path, FileInfo>(); 67 var res = new Map<Path, FileInfo>();
68 for (var k in map.keys) { 68 for (var k in map.keys) {
69 res[new Path(k)] = map[k]; 69 res[new Path(k)] = map[k];
70 } 70 }
71 return res; 71 return res;
72 } 72 }
73 73
74 Map<String, FileInfo> _toStringMap(Map<Path, FileInfo> map) { 74 Map<String, FileInfo> _toStringMap(Map<Path, FileInfo> map) {
75 var res = new Map<String, FileInfo>(); 75 var res = new Map<String, FileInfo>();
76 for (var k in map.keys) { 76 for (var k in map.keys) {
77 res[k.toString()] = map[k]; 77 res[k.toString()] = map[k];
78 } 78 }
79 return res; 79 return res;
80 } 80 }
OLDNEW
« test/analyzer_test.dart ('K') | « test/analyzer_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698