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

Side by Side Diff: pkg/kernel/lib/analyzer/loader.dart

Issue 2530543002: Fix the pubspec and warnings in pkg/kernel. (Closed)
Patch Set: Created 4 years 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library kernel.analyzer.loader; 4 library kernel.analyzer.loader;
5 5
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:io' as io; 7 import 'dart:io' as io;
8 8
9 import 'package:analyzer/analyzer.dart'; 9 import 'package:analyzer/analyzer.dart';
10 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
(...skipping 12 matching lines...) Expand all
23 import '../repository.dart'; 23 import '../repository.dart';
24 import '../target/targets.dart' show Target; 24 import '../target/targets.dart' show Target;
25 import '../type_algebra.dart'; 25 import '../type_algebra.dart';
26 import 'analyzer.dart'; 26 import 'analyzer.dart';
27 import 'ast_from_analyzer.dart'; 27 import 'ast_from_analyzer.dart';
28 28
29 /// Options passed to the Dart frontend. 29 /// Options passed to the Dart frontend.
30 class DartOptions { 30 class DartOptions {
31 /// True if user code should be loaded in strong mode. 31 /// True if user code should be loaded in strong mode.
32 bool strongMode; 32 bool strongMode;
33
33 /// True if the Dart SDK should be loaded in strong mode. 34 /// True if the Dart SDK should be loaded in strong mode.
34 bool strongModeSdk; 35 bool strongModeSdk;
35 String sdk; 36 String sdk;
36 String packagePath; 37 String packagePath;
37 Map<Uri, Uri> customUriMappings; 38 Map<Uri, Uri> customUriMappings;
38 Map<String, String> declaredVariables; 39 Map<String, String> declaredVariables;
39 40
40 DartOptions( 41 DartOptions(
41 {bool strongMode: false, 42 {bool strongMode: false,
42 bool strongModeSdk, 43 bool strongModeSdk,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 assert(_libraryBeingLoaded == null); 126 assert(_libraryBeingLoaded == null);
126 _libraryBeingLoaded = element; 127 _libraryBeingLoaded = element;
127 var classes = <ast.Class>[]; 128 var classes = <ast.Class>[];
128 var procedures = <ast.Procedure>[]; 129 var procedures = <ast.Procedure>[];
129 var fields = <ast.Field>[]; 130 var fields = <ast.Field>[];
130 void loadClass(ClassElement classElement) { 131 void loadClass(ClassElement classElement) {
131 var node = getClassReference(classElement); 132 var node = getClassReference(classElement);
132 promoteToBodyLevel(node); 133 promoteToBodyLevel(node);
133 classes.add(node); 134 classes.add(node);
134 } 135 }
136
135 void loadProcedure(Element memberElement) { 137 void loadProcedure(Element memberElement) {
136 var node = getMemberReference(memberElement); 138 var node = getMemberReference(memberElement);
137 _buildTopLevelMember(node, memberElement); 139 _buildTopLevelMember(node, memberElement);
138 procedures.add(node); 140 procedures.add(node);
139 } 141 }
142
140 void loadField(Element memberElement) { 143 void loadField(Element memberElement) {
141 var node = getMemberReference(memberElement); 144 var node = getMemberReference(memberElement);
142 _buildTopLevelMember(node, memberElement); 145 _buildTopLevelMember(node, memberElement);
143 fields.add(node); 146 fields.add(node);
144 } 147 }
148
145 for (var unit in element.units) { 149 for (var unit in element.units) {
146 unit.types.forEach(loadClass); 150 unit.types.forEach(loadClass);
147 unit.enums.forEach(loadClass); 151 unit.enums.forEach(loadClass);
148 for (var accessor in unit.accessors) { 152 for (var accessor in unit.accessors) {
149 if (!accessor.isSynthetic) { 153 if (!accessor.isSynthetic) {
150 loadProcedure(accessor); 154 loadProcedure(accessor);
151 } 155 }
152 } 156 }
153 for (var function in unit.functions) { 157 for (var function in unit.functions) {
154 loadProcedure(function); 158 loadProcedure(function);
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 } 727 }
724 if (discoveryPath != null) { 728 if (discoveryPath != null) {
725 return findPackagesFromFile(Uri.parse(discoveryPath)); 729 return findPackagesFromFile(Uri.parse(discoveryPath));
726 } 730 }
727 return Packages.noPackages; 731 return Packages.noPackages;
728 } 732 }
729 733
730 AnalysisOptions createAnalysisOptions(bool strongMode) { 734 AnalysisOptions createAnalysisOptions(bool strongMode) {
731 return new AnalysisOptionsImpl() 735 return new AnalysisOptionsImpl()
732 ..strongMode = strongMode 736 ..strongMode = strongMode
733 ..enableGenericMethods = strongMode
734 ..generateImplicitErrors = false 737 ..generateImplicitErrors = false
735 ..generateSdkErrors = false 738 ..generateSdkErrors = false
736 ..preserveComments = false 739 ..preserveComments = false
737 ..hint = false 740 ..hint = false
738 ..enableSuperMixins = true; 741 ..enableSuperMixins = true;
739 } 742 }
740 743
741 DartSdk createDartSdk(String path, {bool strongMode}) { 744 DartSdk createDartSdk(String path, {bool strongMode}) {
742 var resources = PhysicalResourceProvider.INSTANCE; 745 var resources = PhysicalResourceProvider.INSTANCE;
743 return new FolderBasedDartSdk(resources, resources.getFolder(path)) 746 return new FolderBasedDartSdk(resources, resources.getFolder(path))
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext() 809 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext()
807 ..sourceFactory = new SourceFactory(resolvers) 810 ..sourceFactory = new SourceFactory(resolvers)
808 ..analysisOptions = createAnalysisOptions(options.strongMode); 811 ..analysisOptions = createAnalysisOptions(options.strongMode);
809 812
810 options.declaredVariables.forEach((String name, String value) { 813 options.declaredVariables.forEach((String name, String value) {
811 context.declaredVariables.define(name, value); 814 context.declaredVariables.define(name, value);
812 }); 815 });
813 816
814 return context; 817 return context;
815 } 818 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698