Commit 352e2f57 authored by pq's avatar pq

Update to latest analyzer (0.27.4-alpha.14) and misc. analysis fixes.

* brings in analyzer version (`0.27.4-alpha.14`) corresponding to current Dart SDK (`1.18.0-dev.2.0`).
* updates analysis to use prefered API for embedder URI resolution
* adds trampolines to `State` and `StatelessWidget` to allow for warning-free within-library @protected access (needed since we closed off access to @protected closures from outside subclasses).
* turns off cache dependency tracking for analysis (in DDC this amounted to a 10% speed improvement).
parent 0f2c3dc0
...@@ -326,6 +326,9 @@ abstract class StatelessWidget extends Widget { ...@@ -326,6 +326,9 @@ abstract class StatelessWidget extends Widget {
/// provides the set of inherited widgets for this location in the tree. /// provides the set of inherited widgets for this location in the tree.
@protected @protected
Widget build(BuildContext context); Widget build(BuildContext context);
/// Trampoline to make the [build] closure library-accessible.
Widget _build(BuildContext context) => build(context);
} }
/// StatefulWidgets provide the configuration for /// StatefulWidgets provide the configuration for
...@@ -484,6 +487,9 @@ abstract class State<T extends StatefulWidget> { ...@@ -484,6 +487,9 @@ abstract class State<T extends StatefulWidget> {
@protected @protected
Widget build(BuildContext context); Widget build(BuildContext context);
/// Trampoline to make the [build] closure library-accessible.
Widget _build(BuildContext context) => build(context);
/// Called when an Inherited widget in the ancestor chain has changed. Usually /// Called when an Inherited widget in the ancestor chain has changed. Usually
/// there is nothing to do here; whenever this is called, build() is also /// there is nothing to do here; whenever this is called, build() is also
/// called. /// called.
...@@ -1606,7 +1612,7 @@ abstract class ComponentElement extends BuildableElement { ...@@ -1606,7 +1612,7 @@ abstract class ComponentElement extends BuildableElement {
/// Instantiation of [StatelessWidget]s. /// Instantiation of [StatelessWidget]s.
class StatelessElement extends ComponentElement { class StatelessElement extends ComponentElement {
StatelessElement(StatelessWidget widget) : super(widget) { StatelessElement(StatelessWidget widget) : super(widget) {
_builder = widget.build; _builder = widget._build;
} }
@override @override
...@@ -1616,14 +1622,14 @@ class StatelessElement extends ComponentElement { ...@@ -1616,14 +1622,14 @@ class StatelessElement extends ComponentElement {
void update(StatelessWidget newWidget) { void update(StatelessWidget newWidget) {
super.update(newWidget); super.update(newWidget);
assert(widget == newWidget); assert(widget == newWidget);
_builder = widget.build; _builder = widget._build;
_dirty = true; _dirty = true;
rebuild(); rebuild();
} }
@override @override
void _reassemble() { void _reassemble() {
_builder = widget.build; _builder = widget._build;
super._reassemble(); super._reassemble();
} }
} }
...@@ -1636,7 +1642,7 @@ class StatefulElement extends ComponentElement { ...@@ -1636,7 +1642,7 @@ class StatefulElement extends ComponentElement {
assert(_state._element == null); assert(_state._element == null);
_state._element = this; _state._element = this;
assert(_builder == _buildNothing); assert(_builder == _buildNothing);
_builder = _state.build; _builder = _state._build;
assert(_state._config == null); assert(_state._config == null);
_state._config = widget; _state._config = widget;
assert(_state._debugLifecycleState == _StateLifecycle.created); assert(_state._debugLifecycleState == _StateLifecycle.created);
...@@ -1647,7 +1653,7 @@ class StatefulElement extends ComponentElement { ...@@ -1647,7 +1653,7 @@ class StatefulElement extends ComponentElement {
@override @override
void _reassemble() { void _reassemble() {
_builder = state.build; _builder = state._build;
super._reassemble(); super._reassemble();
} }
......
...@@ -10,7 +10,7 @@ dependencies: ...@@ -10,7 +10,7 @@ dependencies:
# We don't actually depend on 'analyzer', but 'test' and 'flutter_tools' do. # We don't actually depend on 'analyzer', but 'test' and 'flutter_tools' do.
# We pin the version of analyzer we depend on to avoid version skew across our # We pin the version of analyzer we depend on to avoid version skew across our
# packages. # packages.
analyzer: 0.27.4-alpha.9 analyzer: 0.27.4-alpha.14
flutter: flutter:
path: ../flutter path: ../flutter
...@@ -14,7 +14,6 @@ import 'package:analyzer/source/error_processor.dart'; ...@@ -14,7 +14,6 @@ import 'package:analyzer/source/error_processor.dart';
import 'package:analyzer/src/generated/engine.dart'; // ignore: implementation_imports import 'package:analyzer/src/generated/engine.dart'; // ignore: implementation_imports
import 'package:analyzer/src/generated/error.dart'; // ignore: implementation_imports import 'package:analyzer/src/generated/error.dart'; // ignore: implementation_imports
import 'package:analyzer/src/generated/java_io.dart'; // ignore: implementation_imports import 'package:analyzer/src/generated/java_io.dart'; // ignore: implementation_imports
import 'package:analyzer/src/generated/sdk_io.dart'; // ignore: implementation_imports
import 'package:analyzer/src/generated/source.dart'; // ignore: implementation_imports import 'package:analyzer/src/generated/source.dart'; // ignore: implementation_imports
import 'package:analyzer/src/generated/source_io.dart'; // ignore: implementation_imports import 'package:analyzer/src/generated/source_io.dart'; // ignore: implementation_imports
import 'package:analyzer/src/task/options.dart'; // ignore: implementation_imports import 'package:analyzer/src/task/options.dart'; // ignore: implementation_imports
...@@ -90,30 +89,33 @@ class AnalysisDriver { ...@@ -90,30 +89,33 @@ class AnalysisDriver {
List<UriResolver> _getResolvers(InternalAnalysisContext context, List<UriResolver> _getResolvers(InternalAnalysisContext context,
Map<String, List<file_system.Folder>> packageMap) { Map<String, List<file_system.Folder>> packageMap) {
DirectoryBasedDartSdk sdk = new DirectoryBasedDartSdk(new JavaFile(sdkDir));
// Locate our embedder.
EmbedderYamlLocator locator = new EmbedderYamlLocator(packageMap);
// Create and configure an SDK.
EmbedderSdk sdk = new EmbedderSdk(locator.embedderYamls);
// Fail fast if no URI mappings are found.
assert(sdk.libraryMap.size() > 0);
sdk.analysisOptions = context.analysisOptions; sdk.analysisOptions = context.analysisOptions;
// TODO(pq): re-enable once we have a proper story for SDK summaries // TODO(pq): re-enable once we have a proper story for SDK summaries
// in the presence of embedders (https://github.com/dart-lang/sdk/issues/26467). // in the presence of embedders (https://github.com/dart-lang/sdk/issues/26467).
sdk.useSummary = false; sdk.useSummary = false;
List<UriResolver> resolvers = <UriResolver>[];
EmbedderYamlLocator yamlLocator = context.embedderYamlLocator; // Create our list of resolvers.
yamlLocator.refresh(packageMap); List<UriResolver> resolvers = <UriResolver>[];
EmbedderUriResolver embedderUriResolver = resolvers.add(new DartUriResolver(sdk));
new EmbedderUriResolver(yamlLocator.embedderYamls);
if (embedderUriResolver.length == 0) {
resolvers.add(new DartUriResolver(sdk));
} else {
resolvers.add(embedderUriResolver);
}
if (options.packageRootPath != null) { if (options.packageRootPath != null) {
JavaFile packageDirectory = new JavaFile(options.packageRootPath); JavaFile packageDirectory = new JavaFile(options.packageRootPath);
resolvers.add(new PackageUriResolver(<JavaFile>[packageDirectory])); resolvers.add(new PackageUriResolver(<JavaFile>[packageDirectory]));
} }
resolvers.add(new FileUriResolver()); resolvers.add(new file_system.ResourceUriResolver(PhysicalResourceProvider.INSTANCE));
return resolvers; return resolvers;
} }
...@@ -202,6 +204,7 @@ class DriverOptions extends AnalysisOptionsImpl { ...@@ -202,6 +204,7 @@ class DriverOptions extends AnalysisOptionsImpl {
cacheSize = 512; cacheSize = 512;
lint = true; lint = true;
generateSdkErrors = false; generateSdkErrors = false;
trackCacheDependencies = false;
} }
/// The path to the dart SDK. /// The path to the dart SDK.
......
...@@ -33,7 +33,7 @@ dependencies: ...@@ -33,7 +33,7 @@ dependencies:
test: 0.12.13+5 test: 0.12.13+5
# Pinned in flutter_test as well. # Pinned in flutter_test as well.
analyzer: 0.27.4-alpha.9 analyzer: 0.27.4-alpha.14
dev_dependencies: dev_dependencies:
mockito: ^0.11.0 mockito: ^0.11.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment