Skip to content

Commit

Permalink
Version 2.19.0-334.0.dev
Browse files Browse the repository at this point in the history
Merge 8c1b05c into dev
  • Loading branch information
Dart CI committed Oct 24, 2022
2 parents f59766b + 8c1b05c commit c5ad261
Show file tree
Hide file tree
Showing 67 changed files with 3,501 additions and 2,343 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ vars = {
# For more details, see https://github.com/dart-lang/sdk/issues/30164.
"dart_style_rev": "f79a9828ad07e50d6e8352ac154cc16eb4d78d5c", # manually rev'd

"dartdoc_rev": "3cd12f981c585f5744d169a1be2178e8ff6804e0",
"dartdoc_rev": "51464a30fad5ff38f52f60602c0f02ff205edd0c",
"devtools_rev": "b21cd59f1f6bb60cacd59ba39e376d2a50d82f74",
"ffi_rev": "fb5f2667826c0900e551d19101052f84e35f41bf",
"file_rev": "b2e31cb6ef40b223701dbfa0b907fe58468484d7",
Expand Down
249 changes: 207 additions & 42 deletions pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6973,6 +6973,155 @@ const MessageCode messageJsInteropEnclosingClassJSAnnotationContext =
severity: Severity.context,
problemMessage: r"""This is the enclosing class.""");

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<Message Function(String name)>
templateJsInteropExportClassNotMarkedExportable =
const Template<Message Function(String name)>(
problemMessageTemplate:
r"""Class '#name' does not have a `@JSExport` on it or any of its members.""",
correctionMessageTemplate:
r"""Use the `@JSExport` annotation on this class.""",
withArguments: _withArgumentsJsInteropExportClassNotMarkedExportable);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name)>
codeJsInteropExportClassNotMarkedExportable =
const Code<Message Function(String name)>(
"JsInteropExportClassNotMarkedExportable",
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsJsInteropExportClassNotMarkedExportable(String name) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
return new Message(codeJsInteropExportClassNotMarkedExportable,
problemMessage:
"""Class '${name}' does not have a `@JSExport` on it or any of its members.""",
correctionMessage: """Use the `@JSExport` annotation on this class.""",
arguments: {'name': name});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<Message Function(String name)>
templateJsInteropExportDartInterfaceHasNonEmptyJSExportValue =
const Template<Message Function(String name)>(
problemMessageTemplate:
r"""The value in the `@JSExport` annotation on the class or mixin '#name' will be ignored.""",
correctionMessageTemplate: r"""Remove the value in the annotation.""",
withArguments:
_withArgumentsJsInteropExportDartInterfaceHasNonEmptyJSExportValue);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name)>
codeJsInteropExportDartInterfaceHasNonEmptyJSExportValue =
const Code<Message Function(String name)>(
"JsInteropExportDartInterfaceHasNonEmptyJSExportValue",
severity: Severity.warning);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsJsInteropExportDartInterfaceHasNonEmptyJSExportValue(
String name) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
return new Message(codeJsInteropExportDartInterfaceHasNonEmptyJSExportValue,
problemMessage:
"""The value in the `@JSExport` annotation on the class or mixin '${name}' will be ignored.""",
correctionMessage: """Remove the value in the annotation.""",
arguments: {'name': name});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(
String
name)> templateJsInteropExportDisallowedMember = const Template<
Message Function(String name)>(
problemMessageTemplate:
r"""Member '#name' is not a concrete instance member, and therefore can't be exported.""",
correctionMessageTemplate:
r"""Remove the `@JSExport` annotation from the member, and use an instance member to call this member instead.""",
withArguments: _withArgumentsJsInteropExportDisallowedMember);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name)> codeJsInteropExportDisallowedMember =
const Code<Message Function(String name)>(
"JsInteropExportDisallowedMember",
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsJsInteropExportDisallowedMember(String name) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
return new Message(codeJsInteropExportDisallowedMember,
problemMessage:
"""Member '${name}' is not a concrete instance member, and therefore can't be exported.""",
correctionMessage: """Remove the `@JSExport` annotation from the member, and use an instance member to call this member instead.""",
arguments: {'name': name});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(
String name,
String
string)> templateJsInteropExportMemberCollision = const Template<
Message Function(String name, String string)>(
problemMessageTemplate:
r"""The following class members collide with the same export '#name': #string.""",
correctionMessageTemplate:
r"""Either remove the conflicting members or use a different export name.""",
withArguments: _withArgumentsJsInteropExportMemberCollision);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name, String string)>
codeJsInteropExportMemberCollision =
const Code<Message Function(String name, String string)>(
"JsInteropExportMemberCollision",
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsJsInteropExportMemberCollision(
String name, String string) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
if (string.isEmpty) throw 'No string provided';
return new Message(codeJsInteropExportMemberCollision,
problemMessage:
"""The following class members collide with the same export '${name}': ${string}.""",
correctionMessage: """Either remove the conflicting members or use a different export name.""",
arguments: {'name': name, 'string': string});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(
String
name)> templateJsInteropExportNoExportableMembers = const Template<
Message Function(String name)>(
problemMessageTemplate:
r"""Class '#name' has no exportable members in the class or the inheritance chain.""",
correctionMessageTemplate:
r"""Using `@JSExport`, annotate at least one instance member with a body or annotate a class that has such a member in the inheritance chain.""",
withArguments: _withArgumentsJsInteropExportNoExportableMembers);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name)>
codeJsInteropExportNoExportableMembers =
const Code<Message Function(String name)>(
"JsInteropExportNoExportableMembers",
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsJsInteropExportNoExportableMembers(String name) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
return new Message(codeJsInteropExportNoExportableMembers,
problemMessage:
"""Class '${name}' has no exportable members in the class or the inheritance chain.""",
correctionMessage: """Using `@JSExport`, annotate at least one instance member with a body or annotate a class that has such a member in the inheritance chain.""",
arguments: {'name': name});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeJsInteropExternalExtensionMemberOnTypeInvalid =
messageJsInteropExternalExtensionMemberOnTypeInvalid;
Expand Down Expand Up @@ -7148,73 +7297,89 @@ const MessageCode messageJsInteropStaticInteropGenerativeConstructor =
correctionMessage: r"""Use factory constructors instead.""");

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<Message Function(String name, String string)>
templateJsInteropStaticInteropMockExternalExtensionMemberConflict =
const Template<Message Function(String name, String string)>(
const Template<
Message Function(String name, String string, String string2,
String name2, String string3)>
templateJsInteropStaticInteropMockMissingGetterOrSetter = const Template<
Message Function(
String name,
String string,
String string2,
String name2,
String
string3)>(
problemMessageTemplate:
r"""External extension member with name '#name' is defined in the following extensions and none are more specific: #string.""",
r"""Dart class '#name' has a #string, but does not have a #string2 to implement any of the following extension member(s) with export name '#name2': #string3.""",
correctionMessageTemplate:
r"""Try using the `@JS` annotation to rename conflicting members.""",
r"""Declare an exportable #string2 that implements one of these extension members.""",
withArguments:
_withArgumentsJsInteropStaticInteropMockExternalExtensionMemberConflict);
_withArgumentsJsInteropStaticInteropMockMissingGetterOrSetter);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name, String string)>
codeJsInteropStaticInteropMockExternalExtensionMemberConflict =
const Code<Message Function(String name, String string)>(
"JsInteropStaticInteropMockExternalExtensionMemberConflict",
const Code<
Message Function(String name, String string, String string2,
String name2, String string3)>
codeJsInteropStaticInteropMockMissingGetterOrSetter = const Code<
Message Function(String name, String string, String string2,
String name2, String string3)>(
"JsInteropStaticInteropMockMissingGetterOrSetter",
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsJsInteropStaticInteropMockExternalExtensionMemberConflict(
String name, String string) {
Message _withArgumentsJsInteropStaticInteropMockMissingGetterOrSetter(
String name, String string, String string2, String name2, String string3) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
if (string.isEmpty) throw 'No string provided';
return new Message(
codeJsInteropStaticInteropMockExternalExtensionMemberConflict,
if (string2.isEmpty) throw 'No string provided';
if (name2.isEmpty) throw 'No name provided';
name2 = demangleMixinApplicationName(name2);
if (string3.isEmpty) throw 'No string provided';
return new Message(codeJsInteropStaticInteropMockMissingGetterOrSetter,
problemMessage:
"""External extension member with name '${name}' is defined in the following extensions and none are more specific: ${string}.""",
correctionMessage: """Try using the `@JS` annotation to rename conflicting members.""",
arguments: {'name': name, 'string': string});
"""Dart class '${name}' has a ${string}, but does not have a ${string2} to implement any of the following extension member(s) with export name '${name2}': ${string3}.""",
correctionMessage:
"""Declare an exportable ${string2} that implements one of these extension members.""",
arguments: {
'name': name,
'string': string,
'string2': string2,
'name2': name2,
'string3': string3
});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(
String name,
String name2,
String
name3)> templateJsInteropStaticInteropMockMissingOverride = const Template<
Message Function(
String name, String name2, String name3)>(
problemMessageTemplate:
r"""`@staticInterop` class '#name' has external extension member '#name2', but Dart class '#name3' does not have an overriding instance member.""",
correctionMessageTemplate:
r"""Add a Dart instance member in '#name3' that overrides '#name.#name2'.""",
withArguments: _withArgumentsJsInteropStaticInteropMockMissingOverride);
const Template<Message Function(String name, String name2, String string)>
templateJsInteropStaticInteropMockMissingImplements =
const Template<Message Function(String name, String name2, String string)>(
problemMessageTemplate:
r"""Dart class '#name' does not have any members that implement any of the following extension member(s) with export name '#name2': #string.""",
correctionMessageTemplate:
r"""Declare an exportable member that implements one of these extension members.""",
withArguments:
_withArgumentsJsInteropStaticInteropMockMissingImplements);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name, String name2, String name3)>
codeJsInteropStaticInteropMockMissingOverride =
const Code<Message Function(String name, String name2, String name3)>(
"JsInteropStaticInteropMockMissingOverride",
const Code<Message Function(String name, String name2, String string)>
codeJsInteropStaticInteropMockMissingImplements =
const Code<Message Function(String name, String name2, String string)>(
"JsInteropStaticInteropMockMissingImplements",
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsJsInteropStaticInteropMockMissingOverride(
String name, String name2, String name3) {
Message _withArgumentsJsInteropStaticInteropMockMissingImplements(
String name, String name2, String string) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
if (name2.isEmpty) throw 'No name provided';
name2 = demangleMixinApplicationName(name2);
if (name3.isEmpty) throw 'No name provided';
name3 = demangleMixinApplicationName(name3);
return new Message(codeJsInteropStaticInteropMockMissingOverride,
if (string.isEmpty) throw 'No string provided';
return new Message(codeJsInteropStaticInteropMockMissingImplements,
problemMessage:
"""`@staticInterop` class '${name}' has external extension member '${name2}', but Dart class '${name3}' does not have an overriding instance member.""",
correctionMessage: """Add a Dart instance member in '${name3}' that overrides '${name}.${name2}'.""",
arguments: {'name': name, 'name2': name2, 'name3': name3});
"""Dart class '${name}' does not have any members that implement any of the following extension member(s) with export name '${name2}': ${string}.""",
correctionMessage: """Declare an exportable member that implements one of these extension members.""",
arguments: {'name': name, 'name2': name2, 'string': string});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,7 @@ abstract class AbstractScanner implements Scanner {
if (($A <= next && next <= $Z) ||
($0 <= next && next <= $9) ||
identical(next, $_) ||
identical(next, $$)) {
(allowDollar && identical(next, $$))) {
return tokenizeIdentifier(next, start, allowDollar);
} else {
appendKeywordToken(keyword);
Expand Down
17 changes: 16 additions & 1 deletion pkg/_js_interop_checks/lib/js_interop_checks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ import 'package:_fe_analyzer_shared/src/messages/codes.dart'
templateJsInteropNativeClassInAnnotation,
templateJsInteropStaticInteropTrustTypesUsageNotAllowed,
templateJsInteropStaticInteropTrustTypesUsedWithoutStaticInterop;
import 'package:_js_interop_checks/src/transformations/static_interop_mock_creator.dart';

import 'src/js_interop.dart';

class JsInteropChecks extends RecursiveVisitor {
final CoreTypes _coreTypes;
final DiagnosticReporter<Message, LocatedMessage> _diagnosticsReporter;
final ExportChecker exportChecker;
final Map<String, Class> _nativeClasses;
final _TypeParameterVisitor _typeParameterVisitor = _TypeParameterVisitor();
bool _classHasJSAnnotation = false;
Expand Down Expand Up @@ -81,7 +83,9 @@ class JsInteropChecks extends RecursiveVisitor {
bool _libraryIsGlobalNamespace = false;

JsInteropChecks(
this._coreTypes, this._diagnosticsReporter, this._nativeClasses);
this._coreTypes, this._diagnosticsReporter, this._nativeClasses)
: exportChecker =
ExportChecker(_diagnosticsReporter, _coreTypes.objectClass);

/// Extract all native class names from the [component].
///
Expand All @@ -107,6 +111,7 @@ class JsInteropChecks extends RecursiveVisitor {
if (!_isJSInteropMember(member)) _checkDisallowedExternal(member);
// TODO(43530): Disallow having JS interop annotations on non-external
// members (class members or otherwise). Currently, they're being ignored.
exportChecker.visitMember(member);
super.defaultMember(member);
}

Expand Down Expand Up @@ -206,6 +211,9 @@ class JsInteropChecks extends RecursiveVisitor {
}
}
super.visitClass(cls);
// Validate `@JSExport` usage after so we know if the members have the
// annotation.
exportChecker.visitClass(cls);
_classHasAnonymousAnnotation = false;
_classHasJSAnnotation = false;
}
Expand Down Expand Up @@ -323,6 +331,7 @@ class JsInteropChecks extends RecursiveVisitor {
procedure.fileUri);
}
}
super.visitProcedure(procedure);
}

@override
Expand Down Expand Up @@ -366,6 +375,12 @@ class JsInteropChecks extends RecursiveVisitor {
}
}

@override
void visitExtension(Extension extension) {
exportChecker.visitExtension(extension);
super.visitExtension(extension);
}

/// Reports an error if [functionNode] has named parameters.
void _checkNoNamedParameters(FunctionNode functionNode) {
// ignore: unnecessary_null_comparison
Expand Down
Loading

0 comments on commit c5ad261

Please sign in to comment.