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

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

Issue 2982093003: Unifying compiler context (Closed)
Patch Set: revert change to kernel-service.dart Created 3 years, 5 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
11 import 'package:analyzer/dart/ast/visitor.dart'; 11 import 'package:analyzer/dart/ast/visitor.dart';
12 import 'package:analyzer/dart/element/element.dart'; 12 import 'package:analyzer/dart/element/element.dart';
13 import 'package:analyzer/dart/element/type.dart'; 13 import 'package:analyzer/dart/element/type.dart';
14 import 'package:analyzer/src/dart/analysis/driver.dart'; 14 import 'package:analyzer/src/dart/analysis/driver.dart';
15 import 'package:analyzer/src/generated/parser.dart'; 15 import 'package:analyzer/src/generated/parser.dart';
16 import 'package:analyzer/src/generated/scanner.dart'; 16 import 'package:analyzer/src/generated/scanner.dart';
17 import 'package:analyzer/src/generated/source.dart'; 17 import 'package:analyzer/src/generated/source.dart';
18 import 'package:analyzer/src/generated/utilities_dart.dart'; 18 import 'package:analyzer/src/generated/utilities_dart.dart';
19 import 'package:front_end/src/base/instrumentation.dart' as fasta; 19 import 'package:front_end/src/base/instrumentation.dart' as fasta;
20 import 'package:front_end/src/fasta/compiler_command_line.dart' as fasta;
21 import 'package:front_end/src/fasta/compiler_context.dart' as fasta; 20 import 'package:front_end/src/fasta/compiler_context.dart' as fasta;
22 import 'package:front_end/src/fasta/testing/validating_instrumentation.dart' 21 import 'package:front_end/src/fasta/testing/validating_instrumentation.dart'
23 as fasta; 22 as fasta;
24 import 'package:front_end/src/fasta/util/relativize.dart' show relativizeUri; 23 import 'package:front_end/src/fasta/util/relativize.dart' show relativizeUri;
25 import 'package:kernel/kernel.dart' as fasta; 24 import 'package:kernel/kernel.dart' as fasta;
26 import 'package:path/path.dart' as pathos; 25 import 'package:path/path.dart' as pathos;
27 import 'package:test/test.dart'; 26 import 'package:test/test.dart';
28 import 'package:test_reflective_loader/test_reflective_loader.dart'; 27 import 'package:test_reflective_loader/test_reflective_loader.dart';
29 28
30 import '../../dart/analysis/base.dart'; 29 import '../../dart/analysis/base.dart';
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 element is PropertyAccessorElement && 127 element is PropertyAccessorElement &&
129 element.isSetter) { 128 element.isSetter) {
130 name = name.substring(0, name.length - 1); 129 name = name.substring(0, name.length - 1);
131 } 130 }
132 buffer.write(name); 131 buffer.write(name);
133 } 132 }
134 } 133 }
135 134
136 class _FrontEndInferenceTest extends BaseAnalysisDriverTest { 135 class _FrontEndInferenceTest extends BaseAnalysisDriverTest {
137 Future<String> runTest(String path, String code) { 136 Future<String> runTest(String path, String code) {
138 return fasta.CompilerCommandLine.withGlobalOptions("", [""], (_) async { 137 return fasta.CompilerContext.runWithDefaultOptions((_) async {
139 Uri uri = provider.pathContext.toUri(path); 138 Uri uri = provider.pathContext.toUri(path);
140 139
141 List<int> lineStarts = new LineInfo.fromContent(code).lineStarts; 140 List<int> lineStarts = new LineInfo.fromContent(code).lineStarts;
142 fasta.CompilerContext.current.uriToSource[relativizeUri(uri).toString()] = 141 fasta.CompilerContext.current.uriToSource[relativizeUri(uri).toString()] =
143 new fasta.Source(lineStarts, UTF8.encode(code)); 142 new fasta.Source(lineStarts, UTF8.encode(code));
144 143
145 var validation = new fasta.ValidatingInstrumentation(); 144 var validation = new fasta.ValidatingInstrumentation();
146 await validation.loadExpectations(uri); 145 await validation.loadExpectations(uri);
147 146
148 _addFileAndImports(path, code); 147 _addFileAndImports(path, code);
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 640
642 /// Based on DDC code generator's `_recoverTypeArguments` 641 /// Based on DDC code generator's `_recoverTypeArguments`
643 Iterable<DartType> _recoverTypeArguments(FunctionType g, FunctionType f) { 642 Iterable<DartType> _recoverTypeArguments(FunctionType g, FunctionType f) {
644 assert(identical(g.element, f.element)); 643 assert(identical(g.element, f.element));
645 assert(g.typeFormals.isNotEmpty && f.typeFormals.isEmpty); 644 assert(g.typeFormals.isNotEmpty && f.typeFormals.isEmpty);
646 assert(g.typeFormals.length + g.typeArguments.length == 645 assert(g.typeFormals.length + g.typeArguments.length ==
647 f.typeArguments.length); 646 f.typeArguments.length);
648 return f.typeArguments.skip(g.typeArguments.length); 647 return f.typeArguments.skip(g.typeArguments.length);
649 } 648 }
650 } 649 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/tool/generate_kernel.dart » ('j') | pkg/front_end/lib/src/fasta/compiler_command_line.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698