Create a package to hold code shared between front_end and analyzer.

Previously such shared code was in the front_end package, but that
created problems because there is a lot of code in front_end that
isn't intended to be shared with the analyzer (including, notably, the
dependency on kernel).

This CL just moves over the flow_analysis logic to the new shared
package.  Follow-up CLs will move over other shared logic and tests.
The end goal is that the analyzer package will no longer have a
dependency on front_end.

Change-Id: I5642d6565204422d79808ca47648462db85e442a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123624
Reviewed-by: Jens Johansen <jensj@google.com>
This commit is contained in:
Paul Berry 2019-10-31 13:05:53 +00:00 committed by commit-bot@chromium.org
parent d76ffbc149
commit 499815842c
23 changed files with 99 additions and 15 deletions

View file

@ -6,6 +6,7 @@
# by DEPS into /third_party/pkg and /third_party/pkg_tested.
# Please update this file if you add a package to DEPS or /pkg
#
_fe_analyzer_shared:pkg/_fe_analyzer_shared/lib
analysis_server:pkg/analysis_server/lib
analysis_server_client:pkg/analysis_server_client/lib
analysis_tool:pkg/analysis_tool/lib

View file

@ -0,0 +1,26 @@
Copyright 2019, the Dart project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -0,0 +1,10 @@
# FE/analyzer shared code
This package contains logic that is shared between the front_end and
analyzer packages. It is intended solely to facilitate development of
the Dart SDK, and is not intended for use by end users. In
particular, this package has no public API, so no guarantee is made of
compatibility between one version of the package and the next.
End users should consider using the analyzer package to analyze Dart
source code.

View file

@ -0,0 +1,20 @@
# Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
include: analysis_options_no_lints.yaml
linter:
rules:
- curly_braces_in_flow_control_structures
- prefer_adjacent_string_concatenation
- unawaited_futures
- recursive_getters
- avoid_empty_else
- empty_statements
- list_remove_unrelated_type
- iterable_contains_unrelated_type
- valid_regexps
- package_api_docs
- lines_longer_than_80_chars
# - always_specify_types

View file

@ -0,0 +1,8 @@
# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
analyzer:
errors:
# Allow having TODOs in the code
todo: ignore

View file

@ -0,0 +1,10 @@
name: _fe_analyzer_shared
version: 1.0.0
author: Dart Team <misc@dartlang.org>
description: Logic that is shared between the front_end and analyzer packages.
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/_fe_analyzer_shared
environment:
sdk: '>=2.2.2 <3.0.0'
dependencies:
meta: ^1.0.2

View file

@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
@ -11,7 +12,6 @@ import 'package:analyzer/dart/element/type_system.dart';
import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/generated/type_system.dart' show Dart2TypeSystem;
import 'package:analyzer/src/generated/variable_type_provider.dart';
import 'package:front_end/src/fasta/flow_analysis/flow_analysis.dart';
/// Data gathered by flow analysis, retained for testing purposes.
class FlowAnalysisDataForTesting {

View file

@ -8,6 +8,7 @@ environment:
sdk: '>=2.2.2 <3.0.0'
dependencies:
_fe_analyzer_shared: 1.0.0
args: '>=0.12.1 <2.0.0'
charcode: ^1.1.0
collection: ^1.10.1

View file

@ -4,12 +4,12 @@
import 'dart:io';
import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/analysis/testing_data.dart';
import 'package:analyzer/src/dart/resolver/flow_analysis_visitor.dart';
import 'package:analyzer/src/util/ast_data_extractor.dart';
import 'package:front_end/src/fasta/flow_analysis/flow_analysis.dart';
import 'package:front_end/src/testing/id.dart' show ActualData, Id;
import 'package:front_end/src/testing/id_testing.dart';

View file

@ -6,6 +6,7 @@ library fasta.body_builder;
import 'dart:core' hide MapEntry;
import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
import 'package:kernel/ast.dart';
import 'package:kernel/type_environment.dart';
@ -42,8 +43,6 @@ import '../fasta_codes.dart' as fasta;
import '../fasta_codes.dart' show LocatedMessage, Message, noLength, Template;
import '../flow_analysis/flow_analysis.dart';
import '../identifiers.dart'
show
Identifier,

View file

@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE.md file.
import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
import 'package:kernel/ast.dart'
show
Constructor,
@ -30,8 +32,6 @@ import '../../base/instrumentation.dart' show Instrumentation;
import '../builder/library_builder.dart';
import '../flow_analysis/flow_analysis.dart';
import '../kernel/forest.dart';
import '../kernel/kernel_builder.dart'

View file

@ -4,6 +4,8 @@
import 'dart:core' hide MapEntry;
import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart';
import 'package:kernel/ast.dart' hide Variance;
@ -30,8 +32,6 @@ import '../builder/member_builder.dart';
import '../fasta_codes.dart';
import '../flow_analysis/flow_analysis.dart';
import '../kernel/expression_generator.dart' show buildIsNull;
import '../kernel/kernel_shadow_ast.dart'

View file

@ -8,6 +8,7 @@ homepage: https://github.com/dart-lang/sdk/tree/master/pkg/front_end
environment:
sdk: '>=2.2.2 <3.0.0'
dependencies:
_fe_analyzer_shared: 1.0.0
kernel: 0.3.28
package_config: '^1.1.0'
meta: ^1.0.2

View file

@ -75,8 +75,10 @@ Future<void> main() async {
Set<Uri> otherNonDartUris = new Set<Uri>();
Set<Uri> frontEndUris = new Set<Uri>();
Set<Uri> kernelUris = new Set<Uri>();
Set<Uri> feAnalyzerSharedUris = new Set<Uri>();
Set<Uri> dartPlatformUris = new Set<Uri>();
Uri kernelUri = repoDir.resolve("pkg/kernel/");
Uri feAnalyzerSharedUri = repoDir.resolve("pkg/_fe_analyzer_shared/");
Uri platformUri1 = repoDir.resolve("sdk/lib/");
Uri platformUri2 = repoDir.resolve("runtime/lib/");
Uri platformUri3 = repoDir.resolve("runtime/bin/");
@ -85,6 +87,8 @@ Future<void> main() async {
frontEndUris.add(uri);
} else if (uri.toString().startsWith(kernelUri.toString())) {
kernelUris.add(uri);
} else if (uri.toString().startsWith(feAnalyzerSharedUri.toString())) {
feAnalyzerSharedUris.add(uri);
} else if (uri.toString().startsWith(platformUri1.toString()) ||
uri.toString().startsWith(platformUri2.toString()) ||
uri.toString().startsWith(platformUri3.toString())) {

View file

@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:front_end/src/fasta/flow_analysis/flow_analysis.dart';
import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
import 'package:test/test.dart';
main() {

View file

@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:front_end/src/fasta/flow_analysis/flow_analysis.dart';
import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
import 'package:meta/meta.dart';
import 'package:test/test.dart';

View file

@ -3,9 +3,11 @@
// BSD-style license that can be found in the LICENSE file.
import 'dart:io' show Directory, Platform;
import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
import 'package:front_end/src/api_prototype/experimental_flags.dart'
show ExperimentalFlag;
import 'package:front_end/src/fasta/flow_analysis/flow_analysis.dart';
import 'package:front_end/src/fasta/builder/member_builder.dart';
import 'package:front_end/src/fasta/source/source_loader.dart';
import 'package:front_end/src/testing/id.dart' show ActualData, Id, IdKind;
@ -13,7 +15,6 @@ import 'package:front_end/src/testing/id_testing.dart'
show DataInterpreter, runTests;
import 'package:front_end/src/testing/id_testing.dart';
import 'package:front_end/src/testing/id_testing_helper.dart';
import 'package:front_end/src/fasta/builder/member_builder.dart';
import 'package:front_end/src/testing/id_testing_utils.dart';
import 'package:kernel/ast.dart' hide Variance;

View file

@ -2,9 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type_system.dart';
import 'package:front_end/src/fasta/flow_analysis/flow_analysis.dart';
import 'package:nnbd_migration/src/decorated_type.dart';
import 'package:nnbd_migration/src/node_builder.dart';
import 'package:nnbd_migration/src/nullability_node.dart';

View file

@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
@ -13,7 +14,6 @@ import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/dart/resolver/flow_analysis_visitor.dart';
import 'package:analyzer/src/generated/resolver.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:front_end/src/fasta/flow_analysis/flow_analysis.dart';
import 'package:meta/meta.dart';
import 'package:nnbd_migration/instrumentation.dart';
import 'package:nnbd_migration/nnbd_migration.dart';

View file

@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
@ -15,7 +16,6 @@ import 'package:analyzer/src/dart/element/type_provider.dart';
import 'package:analyzer/src/dart/resolver/flow_analysis_visitor.dart';
import 'package:analyzer/src/generated/resolver.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:front_end/src/fasta/flow_analysis/flow_analysis.dart';
import 'package:meta/meta.dart';
import 'package:nnbd_migration/src/decorated_class_hierarchy.dart';
import 'package:nnbd_migration/src/utilities/resolution_utils.dart';

View file

@ -3,4 +3,5 @@ publish_to: none
environment:
sdk: '>=2.2.2 <3.0.0'
dependencies:
_fe_analyzer_shared: 1.0.0
analyzer: ^0.37.0

View file

@ -180,6 +180,7 @@
"third_party/pkg_tested/",
"third_party/observatory_pub_packages/packages/",
"tools/sdks/dart-sdk/",
"pkg/_fe_analyzer_shared/",
"pkg/async_helper/",
"pkg/build_integration/",
"pkg/dart_internal/",
@ -254,6 +255,7 @@
"tests/search/",
"tests/standalone_2/",
"tests/ffi/",
"pkg/_fe_analyzer_shared/",
"pkg/async_helper/",
"pkg/build_integration/",
"pkg/dart_internal/",