[cfe] Associate package uris with bin/test files in packages
This CL adds a package uri to SourceLibraryBuilder based on the package information computated by package:package_config. This uri is used to determine whether experimental flags are enabled and thus using allowed_experiments.json in bin/test folders as well as the lib folder. Change-Id: I60e6e97139a4a24b8d4d27d314cfc0f7d7bfc816 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152151 Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
d8eb844e5d
commit
711da04fb4
@@ -104,10 +104,13 @@ bool isExperimentEnabledInLibrary(ExperimentalFlag flag, Uri canonicalUri,
|
||||
allowedFlags = allowedExperimentalFlags.forSdkLibrary(canonicalUri.path);
|
||||
} else if (canonicalUri.scheme == 'package') {
|
||||
int index = canonicalUri.path.indexOf('/');
|
||||
String packageName;
|
||||
if (index >= 0) {
|
||||
String packageName = canonicalUri.path.substring(0, index);
|
||||
allowedFlags = allowedExperimentalFlags.forPackage(packageName);
|
||||
packageName = canonicalUri.path.substring(0, index);
|
||||
} else {
|
||||
packageName = canonicalUri.path;
|
||||
}
|
||||
allowedFlags = allowedExperimentalFlags.forPackage(packageName);
|
||||
}
|
||||
if (allowedFlags != null) {
|
||||
enabled = allowedFlags.contains(flag);
|
||||
|
||||
@@ -141,8 +141,10 @@ class DillLibraryBuilder extends LibraryBuilderImpl {
|
||||
void setLanguageVersion(Version version,
|
||||
{int offset: 0, int length, bool explicit}) {}
|
||||
|
||||
@override
|
||||
Uri get importUri => library.importUri;
|
||||
|
||||
@override
|
||||
Uri get fileUri => library.fileUri;
|
||||
|
||||
@override
|
||||
|
||||
@@ -65,6 +65,7 @@ class DillTarget extends TargetImplementation {
|
||||
DillLibraryBuilder createLibraryBuilder(
|
||||
Uri uri,
|
||||
Uri fileUri,
|
||||
Uri packageUri,
|
||||
LibraryBuilder origin,
|
||||
Library referencesFrom,
|
||||
bool referenceIsPartOwner) {
|
||||
|
||||
@@ -1589,6 +1589,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
|
||||
SourceLibraryBuilder debugLibrary = new SourceLibraryBuilder(
|
||||
libraryUri,
|
||||
debugExprUri,
|
||||
/*packageUri*/ null,
|
||||
userCode.loader,
|
||||
null,
|
||||
scope: libraryBuilder.scope.createNestedScope("expression"),
|
||||
|
||||
@@ -245,6 +245,7 @@ class KernelTarget extends TargetImplementation {
|
||||
LibraryBuilder createLibraryBuilder(
|
||||
Uri uri,
|
||||
Uri fileUri,
|
||||
Uri packageUri,
|
||||
SourceLibraryBuilder origin,
|
||||
Library referencesFrom,
|
||||
bool referenceIsPartOwner) {
|
||||
@@ -260,7 +261,7 @@ class KernelTarget extends TargetImplementation {
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
return new SourceLibraryBuilder(uri, fileUri, loader, origin,
|
||||
return new SourceLibraryBuilder(uri, fileUri, packageUri, loader, origin,
|
||||
referencesFrom: referencesFrom,
|
||||
referenceIsPartOwner: referenceIsPartOwner);
|
||||
}
|
||||
|
||||
@@ -146,22 +146,31 @@ abstract class Loader {
|
||||
}
|
||||
bool hasPackageSpecifiedLanguageVersion = false;
|
||||
Version version;
|
||||
if (packageForLanguageVersion != null &&
|
||||
packageForLanguageVersion.languageVersion != null) {
|
||||
hasPackageSpecifiedLanguageVersion = true;
|
||||
if (packageForLanguageVersion.languageVersion
|
||||
is! InvalidLanguageVersion) {
|
||||
version = new Version(packageForLanguageVersion.languageVersion.major,
|
||||
packageForLanguageVersion.languageVersion.minor);
|
||||
Uri packageUri;
|
||||
if (packageForLanguageVersion != null) {
|
||||
Uri importUri = origin?.importUri ?? uri;
|
||||
if (importUri.scheme != 'dart' &&
|
||||
importUri.scheme != 'package' &&
|
||||
packageForLanguageVersion.name != null) {
|
||||
packageUri =
|
||||
new Uri(scheme: 'package', path: packageForLanguageVersion.name);
|
||||
}
|
||||
if (packageForLanguageVersion.languageVersion != null) {
|
||||
hasPackageSpecifiedLanguageVersion = true;
|
||||
if (packageForLanguageVersion.languageVersion
|
||||
is! InvalidLanguageVersion) {
|
||||
version = new Version(
|
||||
packageForLanguageVersion.languageVersion.major,
|
||||
packageForLanguageVersion.languageVersion.minor);
|
||||
}
|
||||
}
|
||||
}
|
||||
LibraryBuilder library = target.createLibraryBuilder(
|
||||
uri, fileUri, origin, referencesFrom, referenceIsPartOwner);
|
||||
LibraryBuilder library = target.createLibraryBuilder(uri, fileUri,
|
||||
packageUri, origin, referencesFrom, referenceIsPartOwner);
|
||||
if (library == null) {
|
||||
throw new StateError("createLibraryBuilder for uri $uri, "
|
||||
"fileUri $fileUri returned null.");
|
||||
}
|
||||
|
||||
if (hasPackageSpecifiedLanguageVersion) {
|
||||
library.setLanguageVersion(version, explicit: false);
|
||||
}
|
||||
|
||||
@@ -188,6 +188,10 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
|
||||
|
||||
final Uri fileUri;
|
||||
|
||||
final Uri _packageUri;
|
||||
|
||||
Uri get packageUriForTesting => _packageUri;
|
||||
|
||||
final List<ImplementationInfo> implementationBuilders =
|
||||
<ImplementationInfo>[];
|
||||
|
||||
@@ -281,6 +285,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
|
||||
SourceLibraryBuilder.internal(
|
||||
SourceLoader loader,
|
||||
Uri fileUri,
|
||||
Uri packageUri,
|
||||
Scope scope,
|
||||
SourceLibraryBuilder actualOrigin,
|
||||
Library library,
|
||||
@@ -290,6 +295,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
|
||||
: this.fromScopes(
|
||||
loader,
|
||||
fileUri,
|
||||
packageUri,
|
||||
new TypeParameterScopeBuilder.library(),
|
||||
scope ?? new Scope.top(),
|
||||
actualOrigin,
|
||||
@@ -300,6 +306,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
|
||||
SourceLibraryBuilder.fromScopes(
|
||||
this.loader,
|
||||
this.fileUri,
|
||||
this._packageUri,
|
||||
this.libraryDeclaration,
|
||||
this.importScope,
|
||||
this.actualOrigin,
|
||||
@@ -312,6 +319,16 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
|
||||
referencesFrom == null ? null : new IndexedLibrary(referencesFrom),
|
||||
super(
|
||||
fileUri, libraryDeclaration.toScope(importScope), new Scope.top()) {
|
||||
assert(
|
||||
_packageUri == null ||
|
||||
importUri.scheme != 'package' ||
|
||||
importUri.path.startsWith(_packageUri.path),
|
||||
"Foreign package uri '$_packageUri' set on library with import uri "
|
||||
"'${importUri}'.");
|
||||
assert(
|
||||
importUri.scheme != 'dart' || _packageUri == null,
|
||||
"Package uri '$_packageUri' set on dart: library with import uri "
|
||||
"'${importUri}'.");
|
||||
updateLibraryNNBDSettings();
|
||||
}
|
||||
|
||||
@@ -321,26 +338,27 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
|
||||
bool _enableTripleShiftInLibrary;
|
||||
bool _enableExtensionMethodsInLibrary;
|
||||
|
||||
bool get enableVarianceInLibrary => _enableVarianceInLibrary ??= loader.target
|
||||
.isExperimentEnabledInLibrary(ExperimentalFlag.variance, importUri);
|
||||
bool get enableVarianceInLibrary =>
|
||||
_enableVarianceInLibrary ??= loader.target.isExperimentEnabledInLibrary(
|
||||
ExperimentalFlag.variance, _packageUri ?? importUri);
|
||||
|
||||
bool get enableNonfunctionTypeAliasesInLibrary =>
|
||||
_enableNonfunctionTypeAliasesInLibrary ??= loader.target
|
||||
.isExperimentEnabledInLibrary(
|
||||
ExperimentalFlag.nonfunctionTypeAliases, importUri);
|
||||
.isExperimentEnabledInLibrary(ExperimentalFlag.nonfunctionTypeAliases,
|
||||
_packageUri ?? importUri);
|
||||
|
||||
bool get enableNonNullableInLibrary => _enableNonNullableInLibrary ??= loader
|
||||
.target
|
||||
.isExperimentEnabledInLibrary(ExperimentalFlag.nonNullable, importUri);
|
||||
bool get enableNonNullableInLibrary => _enableNonNullableInLibrary ??=
|
||||
loader.target.isExperimentEnabledInLibrary(
|
||||
ExperimentalFlag.nonNullable, _packageUri ?? importUri);
|
||||
|
||||
bool get enableTripleShiftInLibrary => _enableTripleShiftInLibrary ??= loader
|
||||
.target
|
||||
.isExperimentEnabledInLibrary(ExperimentalFlag.tripleShift, importUri);
|
||||
bool get enableTripleShiftInLibrary => _enableTripleShiftInLibrary ??=
|
||||
loader.target.isExperimentEnabledInLibrary(
|
||||
ExperimentalFlag.tripleShift, _packageUri ?? importUri);
|
||||
|
||||
bool get enableExtensionMethodsInLibrary =>
|
||||
_enableExtensionMethodsInLibrary ??= loader.target
|
||||
.isExperimentEnabledInLibrary(
|
||||
ExperimentalFlag.extensionMethods, importUri);
|
||||
ExperimentalFlag.extensionMethods, _packageUri ?? importUri);
|
||||
|
||||
void updateLibraryNNBDSettings() {
|
||||
library.isNonNullableByDefault = isNonNullableByDefault;
|
||||
@@ -365,8 +383,8 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
|
||||
}
|
||||
}
|
||||
|
||||
SourceLibraryBuilder(
|
||||
Uri uri, Uri fileUri, Loader loader, SourceLibraryBuilder actualOrigin,
|
||||
SourceLibraryBuilder(Uri uri, Uri fileUri, Uri packageUri, Loader loader,
|
||||
SourceLibraryBuilder actualOrigin,
|
||||
{Scope scope,
|
||||
Library target,
|
||||
Library nameOrigin,
|
||||
@@ -375,6 +393,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
|
||||
: this.internal(
|
||||
loader,
|
||||
fileUri,
|
||||
packageUri,
|
||||
scope,
|
||||
actualOrigin,
|
||||
target ??
|
||||
|
||||
@@ -72,9 +72,23 @@ abstract class TargetImplementation extends Target {
|
||||
/// to locate the corresponding file.
|
||||
///
|
||||
/// [origin] is non-null if the created library is a patch to [origin].
|
||||
///
|
||||
/// [packageUri] is the base uri for the package which the library belongs to.
|
||||
/// For instance 'package:foo'.
|
||||
///
|
||||
/// This is used to associate libraries in for instance the 'bin' and 'test'
|
||||
/// folders of a package source with the package uri of the 'lib' folder.
|
||||
///
|
||||
/// If the [packageUri] is `null` the package association of this library is
|
||||
/// based on its [importUri].
|
||||
///
|
||||
/// For libraries with a 'package:' [importUri], the package path must match
|
||||
/// the path in the [importUri]. For libraries with a 'dart:' [importUri] the
|
||||
/// [packageUri] must be `null`.
|
||||
LibraryBuilder createLibraryBuilder(
|
||||
Uri uri,
|
||||
Uri fileUri,
|
||||
Uri packageUri,
|
||||
covariant LibraryBuilder origin,
|
||||
Library referencesFrom,
|
||||
bool referenceIsPartOwner);
|
||||
|
||||
@@ -72,6 +72,7 @@ main() async {
|
||||
SourceLibraryBuilder libraryBuilder = new SourceLibraryBuilder(
|
||||
uri,
|
||||
uri,
|
||||
/*packageUri*/ null,
|
||||
new KernelTarget(
|
||||
null,
|
||||
false,
|
||||
|
||||
@@ -1 +1 @@
|
||||
foo:lib//*error: PackagesFileFormat*/#dart=2.6
|
||||
foo:lib//*error: errors=PackagesFileFormat*/#dart=2.6
|
||||
@@ -9,7 +9,10 @@
|
||||
|
||||
import 'package:foo/foo.dart';
|
||||
|
||||
/*library: languageVersion=2.4*/
|
||||
/*library:
|
||||
languageVersion=2.4,
|
||||
packageUri=package:foo
|
||||
*/
|
||||
|
||||
main() {
|
||||
var result = foo();
|
||||
|
||||
@@ -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.
|
||||
|
||||
/*error: LanguageVersionTooHigh*/
|
||||
/*error: errors=LanguageVersionTooHigh*/
|
||||
// @dart = 3.5
|
||||
|
||||
// If no valid language version is specified, we default to the most reason one.
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
/*error: LanguageVersionTooHigh*/
|
||||
/*error: errors=LanguageVersionTooHigh*/
|
||||
// @dart = 3.5
|
||||
|
||||
// @dart = 2.5
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// except it still has to be within the range of the sdk. The library stays on
|
||||
// the .packages specified one (2.5) and an error is issued.
|
||||
|
||||
/*error: LanguageVersionTooHigh*/
|
||||
/*error: errors=LanguageVersionTooHigh*/
|
||||
// @dart = 2.9
|
||||
|
||||
/*library: languageVersion=2.5*/
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*error: PackagesFileFormat*/
|
||||
/*error: errors=PackagesFileFormat*/
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*error: LanguageVersionInvalidInDotPackages*/
|
||||
/*error: errors=LanguageVersionInvalidInDotPackages*/
|
||||
// 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.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*error: LanguageVersionInvalidInDotPackages*/
|
||||
/*error: errors=LanguageVersionInvalidInDotPackages*/
|
||||
// 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.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*error: PackagesFileFormat*/
|
||||
/*error: errors=PackagesFileFormat*/
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*error: LanguageVersionInvalidInDotPackages*/
|
||||
/*error: errors=LanguageVersionInvalidInDotPackages*/
|
||||
// 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.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*error: LanguageVersionInvalidInDotPackages*/
|
||||
/*error: errors=LanguageVersionInvalidInDotPackages*/
|
||||
// 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.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*error: PackagesFileFormat*/
|
||||
/*error: errors=PackagesFileFormat*/
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*error: LanguageVersionInvalidInDotPackages*/
|
||||
/*error: errors=LanguageVersionInvalidInDotPackages*/
|
||||
// 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.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*error: LanguageVersionInvalidInDotPackages*/
|
||||
/*error: errors=LanguageVersionInvalidInDotPackages*/
|
||||
// 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.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*error: PackagesFileFormat*/
|
||||
/*error: errors=PackagesFileFormat*/
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*error: LanguageVersionInvalidInDotPackages*/
|
||||
/*error: errors=LanguageVersionInvalidInDotPackages*/
|
||||
// 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.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*error: LanguageVersionInvalidInDotPackages*/
|
||||
/*error: errors=LanguageVersionInvalidInDotPackages*/
|
||||
// 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.
|
||||
|
||||
+4
-1
@@ -6,7 +6,10 @@ import 'package:foo/foo.dart';
|
||||
|
||||
// Version comes from the package foo having this file in it's root uri.
|
||||
|
||||
/*library: languageVersion=2.5*/
|
||||
/*library:
|
||||
languageVersion=2.5,
|
||||
packageUri=package:foo
|
||||
*/
|
||||
|
||||
main() {
|
||||
foo();
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*error: LanguageVersionTooHigh*/
|
||||
/*error: errors=LanguageVersionTooHigh*/
|
||||
// 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.
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
/*error: LanguageVersionTooHigh*/
|
||||
/*error: errors=LanguageVersionTooHigh*/
|
||||
// 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.
|
||||
|
||||
/*error: LanguageVersionTooHigh*/
|
||||
/*error: errors=LanguageVersionTooHigh*/
|
||||
// @dart = 2.9
|
||||
|
||||
/*library: languageVersion=2.8*/
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*error: LanguageVersionTooHigh*/
|
||||
/*error: errors=LanguageVersionTooHigh*/
|
||||
// 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.
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
{
|
||||
"name": "foo",
|
||||
"rootUri": "../foo/",
|
||||
"packageUri": "lib/"
|
||||
}
|
||||
]
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// Copyright (c) 2020, 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.
|
||||
|
||||
/*library:
|
||||
languageVersion=2.8,
|
||||
packageUri=package:foo
|
||||
*/
|
||||
|
||||
method1() {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright (c) 2020, 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.
|
||||
|
||||
/*library: languageVersion=2.8*/
|
||||
|
||||
method2() {}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// Copyright (c) 2020, 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.
|
||||
|
||||
/*library:
|
||||
languageVersion=2.8,
|
||||
packageUri=package:foo
|
||||
*/
|
||||
|
||||
method3() {}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2020, 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.
|
||||
|
||||
/*library: languageVersion=2.8*/
|
||||
|
||||
// Test that bin and test files within the root folder of a package are
|
||||
// associated with the package.
|
||||
|
||||
import 'foo/bin/bin_file.dart';
|
||||
import 'foo/test/test_file.dart';
|
||||
import 'package:foo/foo.dart';
|
||||
|
||||
main() {
|
||||
method1();
|
||||
method2();
|
||||
method3();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
foo:foo/lib/
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// Copyright (c) 2020, 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.
|
||||
|
||||
/*library:
|
||||
languageVersion=2.7,
|
||||
packageUri=package:foo
|
||||
*/
|
||||
|
||||
method1() {}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// Copyright (c) 2020, 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.
|
||||
|
||||
/*library: languageVersion=2.7*/
|
||||
|
||||
method2() {}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// Copyright (c) 2020, 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.
|
||||
|
||||
/*library:
|
||||
languageVersion=2.7,
|
||||
packageUri=package:foo
|
||||
*/
|
||||
|
||||
method3() {}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright (c) 2020, 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.
|
||||
|
||||
/*library: languageVersion=2.8*/
|
||||
|
||||
import 'foo/bin/bin_file.dart';
|
||||
import 'foo/test/test_file.dart';
|
||||
import 'package:foo/foo.dart';
|
||||
|
||||
main() {}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
{
|
||||
"name": "foo",
|
||||
"rootUri": "../foo/lib/"
|
||||
}
|
||||
]
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// Copyright (c) 2020, 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.
|
||||
|
||||
/*library: languageVersion=2.8*/
|
||||
|
||||
method1() {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright (c) 2020, 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.
|
||||
|
||||
/*library: languageVersion=2.8*/
|
||||
|
||||
method2() {}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// Copyright (c) 2020, 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.
|
||||
|
||||
/*library: languageVersion=2.8*/
|
||||
|
||||
method3() {}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2020, 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.
|
||||
|
||||
/*library: languageVersion=2.8*/
|
||||
|
||||
// Test that bin and test files within the root folder of a package are
|
||||
// associated with the package.
|
||||
|
||||
import 'foo/bin/bin_file.dart';
|
||||
import 'foo/test/test_file.dart';
|
||||
import 'package:foo/foo.dart';
|
||||
|
||||
main() {
|
||||
method1();
|
||||
method2();
|
||||
method3();
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
// @dart = 2.5
|
||||
|
||||
part /*error: LanguageVersionMismatchInPart*/ 'part.dart';
|
||||
part /*error: errors=LanguageVersionMismatchInPart*/ 'part.dart';
|
||||
|
||||
/*library: languageVersion=2.5*/
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
|
||||
// @dart = 2.5
|
||||
|
||||
part /*error: LanguageVersionMismatchInPart*/ 'part.dart';
|
||||
part /*error: errors=LanguageVersionMismatchInPart*/ 'part.dart';
|
||||
|
||||
/*library: languageVersion=2.5*/
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
// The library and its part is both technically at language version 2.5,
|
||||
// but one is explicitly set, the other is not. That's an error.
|
||||
|
||||
part /*error: LanguageVersionMismatchInPart*/ 'part.dart';
|
||||
part /*error: errors=LanguageVersionMismatchInPart*/ 'part.dart';
|
||||
|
||||
/*library: languageVersion=2.5*/
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
/*error: PackagesFileFormat*/foo:foo2/
|
||||
/*error: errors=PackagesFileFormat*/foo:foo2/
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
// @dart = 2.4
|
||||
|
||||
import /*error: UntranslatableUri*/ 'package:foo/foo.dart';
|
||||
import /*error: errors=UntranslatableUri*/ 'package:foo/foo.dart';
|
||||
|
||||
/*library: languageVersion=2.4*/
|
||||
|
||||
main() {
|
||||
var result = /*error: MethodNotFound*/ notNamedFoo();
|
||||
var result = /*error: errors=MethodNotFound*/ notNamedFoo();
|
||||
print(result);
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
/*error: PackageNotFound*/
|
||||
/*error: errors=PackageNotFound*/
|
||||
@@ -4,12 +4,15 @@
|
||||
|
||||
import 'dart:io' show Directory, File, Platform;
|
||||
import 'package:_fe_analyzer_shared/src/testing/id.dart' show ActualData, Id;
|
||||
import 'package:_fe_analyzer_shared/src/testing/features.dart';
|
||||
import 'package:_fe_analyzer_shared/src/testing/id_testing.dart'
|
||||
show DataInterpreter, StringDataInterpreter, runTests;
|
||||
show DataInterpreter, runTests;
|
||||
import 'package:_fe_analyzer_shared/src/testing/id_testing.dart';
|
||||
import 'package:front_end/src/api_prototype/compiler_options.dart';
|
||||
import 'package:front_end/src/api_prototype/language_version.dart' as lv;
|
||||
import 'package:front_end/src/fasta/messages.dart' show FormattedMessage;
|
||||
import 'package:front_end/src/fasta/builder/library_builder.dart';
|
||||
import 'package:front_end/src/fasta/source/source_library_builder.dart';
|
||||
import 'package:front_end/src/testing/id_testing_helper.dart'
|
||||
show
|
||||
CfeDataExtractor,
|
||||
@@ -19,6 +22,7 @@ import 'package:front_end/src/testing/id_testing_helper.dart'
|
||||
createUriForFileName,
|
||||
onFailure,
|
||||
runTestFor;
|
||||
import 'package:front_end/src/testing/id_testing_utils.dart';
|
||||
|
||||
import 'package:kernel/ast.dart' show Component, Library, Version;
|
||||
|
||||
@@ -29,7 +33,7 @@ main(List<String> args) async {
|
||||
new TestConfigWithLanguageVersion(cfeMarker, "cfe");
|
||||
|
||||
Directory dataDir = new Directory.fromUri(Platform.script.resolve('data'));
|
||||
await runTests<String>(dataDir,
|
||||
await runTests<Features>(dataDir,
|
||||
args: args,
|
||||
createUriForFileName: createUriForFileName,
|
||||
onFailure: onFailure,
|
||||
@@ -70,7 +74,13 @@ class TestConfigWithLanguageVersion extends TestConfig {
|
||||
}
|
||||
}
|
||||
|
||||
class LanguageVersioningDataComputer extends DataComputer<String> {
|
||||
class Tags {
|
||||
static const String languageVersion = 'languageVersion';
|
||||
static const String packageUri = 'packageUri';
|
||||
static const String errors = 'errors';
|
||||
}
|
||||
|
||||
class LanguageVersioningDataComputer extends DataComputer<Features> {
|
||||
const LanguageVersioningDataComputer();
|
||||
|
||||
Future<void> inspectComponent(Component component) async {
|
||||
@@ -95,7 +105,7 @@ Language version API (import URI): ${lvImportUri}
|
||||
TestConfig config,
|
||||
InternalCompilerResult compilerResult,
|
||||
Library library,
|
||||
Map<Id, ActualData<String>> actualMap,
|
||||
Map<Id, ActualData<Features>> actualMap,
|
||||
{bool verbose}) {
|
||||
new LanguageVersioningDataExtractor(compilerResult, actualMap)
|
||||
.computeForLibrary(library);
|
||||
@@ -104,24 +114,35 @@ Language version API (import URI): ${lvImportUri}
|
||||
@override
|
||||
bool get supportsErrors => true;
|
||||
|
||||
String computeErrorData(TestConfig config, InternalCompilerResult compiler,
|
||||
Features computeErrorData(TestConfig config, InternalCompilerResult compiler,
|
||||
Id id, List<FormattedMessage> errors) {
|
||||
return errors.map((m) => m.code.name).join(',');
|
||||
Features features = new Features();
|
||||
features[Tags.errors] = errors.map((m) => m.code.name).join(',');
|
||||
return features;
|
||||
}
|
||||
|
||||
@override
|
||||
DataInterpreter<String> get dataValidator => const StringDataInterpreter();
|
||||
DataInterpreter<Features> get dataValidator =>
|
||||
const FeaturesDataInterpreter();
|
||||
}
|
||||
|
||||
class LanguageVersioningDataExtractor extends CfeDataExtractor<String> {
|
||||
class LanguageVersioningDataExtractor extends CfeDataExtractor<Features> {
|
||||
LanguageVersioningDataExtractor(InternalCompilerResult compilerResult,
|
||||
Map<Id, ActualData<String>> actualMap)
|
||||
Map<Id, ActualData<Features>> actualMap)
|
||||
: super(compilerResult, actualMap);
|
||||
|
||||
@override
|
||||
String computeLibraryValue(Id id, Library library) {
|
||||
return "languageVersion=${library.languageVersion.major}"
|
||||
"."
|
||||
"${library.languageVersion.minor}";
|
||||
Features computeLibraryValue(Id id, Library library) {
|
||||
Features features = new Features();
|
||||
features[Tags.languageVersion] =
|
||||
"${library.languageVersion.major}.${library.languageVersion.minor}";
|
||||
LibraryBuilder libraryBuilder =
|
||||
lookupLibraryBuilder(compilerResult, library);
|
||||
if (libraryBuilder is SourceLibraryBuilder &&
|
||||
libraryBuilder.packageUriForTesting != null) {
|
||||
features[Tags.packageUri] =
|
||||
libraryBuilder.packageUriForTesting.toString();
|
||||
}
|
||||
return features;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ askesc
|
||||
aspx
|
||||
assigning
|
||||
assigns
|
||||
association
|
||||
ast
|
||||
asy
|
||||
async
|
||||
@@ -412,6 +413,7 @@ fn
|
||||
fo
|
||||
foo
|
||||
foobar
|
||||
foreign
|
||||
formed
|
||||
former
|
||||
fortunately
|
||||
|
||||
Reference in New Issue
Block a user