Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 : mixinType.typeArguments); | 325 : mixinType.typeArguments); |
| 326 } else { | 326 } else { |
| 327 // Generate a new class specific for this mixin application. | 327 // Generate a new class specific for this mixin application. |
| 328 var freshParameters = | 328 var freshParameters = |
| 329 getFreshTypeParameters(classNode.typeParameters); | 329 getFreshTypeParameters(classNode.typeParameters); |
| 330 var mixinClass = new ast.Class( | 330 var mixinClass = new ast.Class( |
| 331 name: '${classNode.name}^${mixinType.classNode.name}', | 331 name: '${classNode.name}^${mixinType.classNode.name}', |
| 332 isAbstract: true, | 332 isAbstract: true, |
| 333 typeParameters: freshParameters.freshTypeParameters, | 333 typeParameters: freshParameters.freshTypeParameters, |
| 334 supertype: freshParameters.substituteSuper(supertype), | 334 supertype: freshParameters.substituteSuper(supertype), |
| 335 mixedInType: freshParameters.substituteSuper(mixinType)); | 335 mixedInType: freshParameters.substituteSuper(mixinType), |
| 336 fileUri: "file://${element.source.fullName}"); | |
|
Kevin Millikin (Google)
2016/12/20 12:03:33
fileUri: classNode.fileUri
jensj
2016/12/20 13:30:22
Done.
| |
| 336 mixinClass.level = ast.ClassLevel.Type; | 337 mixinClass.level = ast.ClassLevel.Type; |
| 337 supertype = new ast.Supertype(mixinClass, | 338 supertype = new ast.Supertype(mixinClass, |
| 338 classNode.typeParameters.map(makeTypeParameterType).toList()); | 339 classNode.typeParameters.map(makeTypeParameterType).toList()); |
| 339 addMixinClassToLibrary(mixinClass, classNode.enclosingLibrary); | 340 addMixinClassToLibrary(mixinClass, classNode.enclosingLibrary); |
| 340 // This class cannot be used from anywhere else, so don't try to | 341 // This class cannot be used from anywhere else, so don't try to |
| 341 // generate shared mixin applications using it. | 342 // generate shared mixin applications using it. |
| 342 useSharedMixin = false; | 343 useSharedMixin = false; |
| 343 } | 344 } |
| 344 } | 345 } |
| 345 classNode.supertype = supertype; | 346 classNode.supertype = supertype; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 579 : typeArguments; | 580 : typeArguments; |
| 580 var mixinArgs = typeArguments.length != mixedInClass.typeParameters.length | 581 var mixinArgs = typeArguments.length != mixedInClass.typeParameters.length |
| 581 ? typeArguments.sublist(0, mixedInClass.typeParameters.length) | 582 ? typeArguments.sublist(0, mixedInClass.typeParameters.length) |
| 582 : typeArguments; | 583 : typeArguments; |
| 583 var result = new ast.Class( | 584 var result = new ast.Class( |
| 584 name: name, | 585 name: name, |
| 585 isAbstract: true, | 586 isAbstract: true, |
| 586 typeParameters: fresh.freshTypeParameters, | 587 typeParameters: fresh.freshTypeParameters, |
| 587 supertype: new ast.Supertype(superclass, superArgs), | 588 supertype: new ast.Supertype(superclass, superArgs), |
| 588 mixedInType: new ast.Supertype(mixedInClass, mixinArgs), | 589 mixedInType: new ast.Supertype(mixedInClass, mixinArgs), |
| 589 fileUri: mixedInClass.fileUri); | 590 fileUri: library.fileUri); |
| 590 result.level = ast.ClassLevel.Type; | 591 result.level = ast.ClassLevel.Type; |
| 591 library.addClass(result); | 592 library.addClass(result); |
| 592 return result; | 593 return result; |
| 593 }); | 594 }); |
| 594 } | 595 } |
| 595 | 596 |
| 596 String formatErrorMessage( | 597 String formatErrorMessage( |
| 597 AnalysisError error, String filename, LineInfo lines) { | 598 AnalysisError error, String filename, LineInfo lines) { |
| 598 var location = lines.getLocation(error.offset); | 599 var location = lines.getLocation(error.offset); |
| 599 return '[error] ${error.message} ($filename, ' | 600 return '[error] ${error.message} ($filename, ' |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 687 loadEverything(target: target, compileSdk: compileSdk); | 688 loadEverything(target: target, compileSdk: compileSdk); |
| 688 var program = new ast.Program(repository.libraries); | 689 var program = new ast.Program(repository.libraries); |
| 689 program.mainMethod = library.procedures.firstWhere( | 690 program.mainMethod = library.procedures.firstWhere( |
| 690 (member) => member.name?.name == 'main', | 691 (member) => member.name?.name == 'main', |
| 691 orElse: () => null); | 692 orElse: () => null); |
| 692 for (LibraryElement libraryElement in libraryElements) { | 693 for (LibraryElement libraryElement in libraryElements) { |
| 693 for (CompilationUnitElement compilationUnitElement | 694 for (CompilationUnitElement compilationUnitElement |
| 694 in libraryElement.units) { | 695 in libraryElement.units) { |
| 695 var source = compilationUnitElement.source; | 696 var source = compilationUnitElement.source; |
| 696 LineInfo lineInfo = context.computeLineInfo(source); | 697 LineInfo lineInfo = context.computeLineInfo(source); |
| 697 program.uriToLineStarts["file://${source.fullName}"] = | 698 String sourceCode = ""; |
| 698 new List<int>.generate(lineInfo.lineCount, lineInfo.getOffsetOfLine, | 699 try { |
| 699 growable: false); | 700 sourceCode = source.contents.data; |
|
Kevin Millikin (Google)
2016/12/20 12:03:33
I think context.getContents(source) will use the a
jensj
2016/12/20 13:30:22
Done.
| |
| 701 } catch (e) { | |
| 702 // if we cannot read the source code there's nothing to do about that. | |
|
Kevin Millikin (Google)
2016/12/20 12:03:33
The comment should be a complete sentence (start w
jensj
2016/12/20 13:30:22
Done.
| |
| 703 } | |
| 704 program.uriToLineStartsAndSource["file://${source.fullName}"] = | |
|
Kevin Millikin (Google)
2016/12/20 12:03:33
We should probably use source.uri instead of sourc
jensj
2016/12/20 13:30:22
Done.
| |
| 705 new ast.LineStartsAndSource( | |
| 706 new List<int>.from(lineInfo.lineStarts, growable: false), | |
|
Kevin Millikin (Google)
2016/12/20 12:03:33
lineInfo.lineStarts is already a List<int>, isn't
jensj
2016/12/20 13:30:22
Yes.
| |
| 707 sourceCode); | |
| 700 } | 708 } |
| 701 } | 709 } |
| 702 return program; | 710 return program; |
| 703 } | 711 } |
| 704 | 712 |
| 705 ast.Library loadLibrary(Uri uri) { | 713 ast.Library loadLibrary(Uri uri) { |
| 706 ast.Library library = | 714 ast.Library library = |
| 707 repository.getLibraryReference(applicationRoot.relativeUri(uri)); | 715 repository.getLibraryReference(applicationRoot.relativeUri(uri)); |
| 708 ensureLibraryIsLoaded(library); | 716 ensureLibraryIsLoaded(library); |
| 709 return library; | 717 return library; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 856 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext() | 864 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext() |
| 857 ..sourceFactory = new SourceFactory(resolvers) | 865 ..sourceFactory = new SourceFactory(resolvers) |
| 858 ..analysisOptions = createAnalysisOptions(options.strongMode); | 866 ..analysisOptions = createAnalysisOptions(options.strongMode); |
| 859 | 867 |
| 860 options.declaredVariables.forEach((String name, String value) { | 868 options.declaredVariables.forEach((String name, String value) { |
| 861 context.declaredVariables.define(name, value); | 869 context.declaredVariables.define(name, value); |
| 862 }); | 870 }); |
| 863 | 871 |
| 864 return context; | 872 return context; |
| 865 } | 873 } |
| OLD | NEW |