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

Side by Side Diff: pkg/analyzer/test/src/task/html_test.dart

Issue 1347223002: Produce LINE_INFO for HTML files. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « pkg/analyzer/lib/src/task/html.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library test.src.task.html_test; 5 library test.src.task.html_test;
6 6
7 import 'package:analyzer/src/generated/source.dart'; 7 import 'package:analyzer/src/generated/source.dart';
8 import 'package:analyzer/src/task/html.dart'; 8 import 'package:analyzer/src/task/html.dart';
9 import 'package:analyzer/task/general.dart';
9 import 'package:analyzer/task/html.dart'; 10 import 'package:analyzer/task/html.dart';
10 import 'package:analyzer/task/model.dart'; 11 import 'package:analyzer/task/model.dart';
11 import 'package:unittest/unittest.dart'; 12 import 'package:unittest/unittest.dart';
12 13
13 import '../../reflective_tests.dart'; 14 import '../../reflective_tests.dart';
14 import '../../utils.dart'; 15 import '../../utils.dart';
15 import '../context/abstract_context.dart'; 16 import '../context/abstract_context.dart';
16 17
17 main() { 18 main() {
18 initializeTestEnvironment(); 19 initializeTestEnvironment();
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 ParseHtmlTask task = new ParseHtmlTask(null, source); 288 ParseHtmlTask task = new ParseHtmlTask(null, source);
288 expect(task.description, isNotNull); 289 expect(task.description, isNotNull);
289 } 290 }
290 291
291 test_descriptor() { 292 test_descriptor() {
292 TaskDescriptor descriptor = ParseHtmlTask.DESCRIPTOR; 293 TaskDescriptor descriptor = ParseHtmlTask.DESCRIPTOR;
293 expect(descriptor, isNotNull); 294 expect(descriptor, isNotNull);
294 } 295 }
295 296
296 test_perform() { 297 test_perform() {
297 AnalysisTarget target = newSource( 298 String code = r'''
298 '/test.html',
299 r'''
300 <!DOCTYPE html> 299 <!DOCTYPE html>
301 <html> 300 <html>
302 <head> 301 <head>
303 <title>test page</title> 302 <title>test page</title>
304 </head> 303 </head>
305 <body> 304 <body>
306 <h1 Test> 305 <h1 Test>
307 </body> 306 </body>
308 </html> 307 </html>
309 '''); 308 ''';
309 AnalysisTarget target = newSource('/test.html', code);
310 computeResult(target, HTML_DOCUMENT); 310 computeResult(target, HTML_DOCUMENT);
311 expect(task, isParseHtmlTask); 311 expect(task, isParseHtmlTask);
312 expect(outputs[HTML_DOCUMENT], isNotNull); 312 expect(outputs[HTML_DOCUMENT], isNotNull);
313 expect(outputs[HTML_DOCUMENT_ERRORS], isNotEmpty); 313 expect(outputs[HTML_DOCUMENT_ERRORS], isNotEmpty);
314 // LINE_INFO
315 {
316 LineInfo lineInfo = outputs[LINE_INFO];
317 expect(lineInfo, isNotNull);
318 {
319 int offset = code.indexOf('<!DOCTYPE');
320 LineInfo_Location location = lineInfo.getLocation(offset);
321 expect(location.lineNumber, 1);
322 expect(location.columnNumber, 1);
323 }
324 {
325 int offset = code.indexOf('<html>');
326 LineInfo_Location location = lineInfo.getLocation(offset);
327 expect(location.lineNumber, 2);
328 expect(location.columnNumber, 1);
329 }
330 {
331 int offset = code.indexOf('<title>');
332 LineInfo_Location location = lineInfo.getLocation(offset);
333 expect(location.lineNumber, 4);
334 expect(location.columnNumber, 5);
335 }
336 }
314 } 337 }
315 } 338 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/html.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698