Skip to content

Commit

Permalink
Version 2.17.0-13.0.dev
Browse files Browse the repository at this point in the history
Merge commit 'a32e171a6fb1da8bdf3212433b389976dc079461' into 'dev'
  • Loading branch information
Dart CI committed Jan 14, 2022
2 parents ba044d5 + a32e171 commit aa6fbac
Show file tree
Hide file tree
Showing 48 changed files with 1,889 additions and 727 deletions.
57 changes: 0 additions & 57 deletions pkg/_fe_analyzer_shared/lib/src/macros/api/introspection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ abstract class TypeAnnotation {

/// A [Code] object representation of this type annotation.
Code get code;

/// Allows you to check the kind of a [TypeAnnotation] in a switch statement,
/// and without `is` checks.
TypeAnnotationKind get kind;
}

/// The base class for function type declarations.
Expand All @@ -33,9 +29,6 @@ abstract class FunctionTypeAnnotation implements TypeAnnotation {

/// The type parameters for this function.
Iterable<TypeParameterDeclaration> get typeParameters;

@override
TypeAnnotationKind get kind => TypeAnnotationKind.functionType;
}

/// An unresolved reference to a type.
Expand All @@ -48,9 +41,6 @@ abstract class NamedTypeAnnotation implements TypeAnnotation {

/// The type arguments, if applicable.
Iterable<TypeAnnotation> get typeArguments;

@override
TypeAnnotationKind get kind => TypeAnnotationKind.namedType;
}

/// The interface representing a resolved type.
Expand All @@ -75,10 +65,6 @@ abstract class NamedStaticType implements StaticType {
abstract class Declaration {
/// The name of this declaration.
String get name;

/// Allows you to check the kind of a [Declaration] in a switch statement,
/// and without `is` checks.
DeclarationKind get kind;
}

/// A declaration that defines a new type in the program.
Expand All @@ -105,9 +91,6 @@ abstract class TypeDeclaration implements Declaration {
/// Information about fields, methods, and constructors must be retrieved from
/// the `builder` objects.
abstract class ClassDeclaration implements TypeDeclaration {
@override
DeclarationKind get kind => DeclarationKind.clazz;

/// Whether this class has an `abstract` modifier.
bool get isAbstract;

Expand All @@ -129,18 +112,12 @@ abstract class ClassDeclaration implements TypeDeclaration {

/// Type alias introspection information.
abstract class TypeAliasDeclaration extends TypeDeclaration {
@override
DeclarationKind get kind => DeclarationKind.typeAlias;

/// The type annotation this is an alias for.
TypeAnnotation get type;
}

/// Function introspection information.
abstract class FunctionDeclaration implements Declaration {
@override
DeclarationKind get kind => DeclarationKind.function;

/// Whether this function has an `abstract` modifier.
bool get isAbstract;

Expand Down Expand Up @@ -168,9 +145,6 @@ abstract class FunctionDeclaration implements Declaration {

/// Method introspection information.
abstract class MethodDeclaration implements FunctionDeclaration {
@override
DeclarationKind get kind => DeclarationKind.method;

/// The class that defines this method.
TypeAnnotation get definingClass;
}
Expand All @@ -183,9 +157,6 @@ abstract class ConstructorDeclaration implements MethodDeclaration {

/// Variable introspection information.
abstract class VariableDeclaration implements Declaration {
@override
DeclarationKind get kind => DeclarationKind.variable;

/// Whether this function has an `abstract` modifier.
bool get isAbstract;

Expand All @@ -201,18 +172,12 @@ abstract class VariableDeclaration implements Declaration {

/// Field introspection information ..
abstract class FieldDeclaration implements VariableDeclaration {
@override
DeclarationKind get kind => DeclarationKind.field;

/// The class that defines this method.
TypeAnnotation get definingClass;
}

/// Parameter introspection information.
abstract class ParameterDeclaration implements Declaration {
@override
DeclarationKind get kind => DeclarationKind.parameter;

/// The type of this parameter.
TypeAnnotation get type;

Expand All @@ -230,28 +195,6 @@ abstract class ParameterDeclaration implements Declaration {

/// Type parameter introspection information.
abstract class TypeParameterDeclaration implements Declaration {
@override
DeclarationKind get kind => DeclarationKind.typeParameter;

/// The bounds for this type parameter, if it has any.
TypeAnnotation? get bounds;
}

// The kinds of type declarations.
enum DeclarationKind {
clazz,
constructor,
field,
function,
method,
parameter,
typeAlias,
typeParameter,
variable,
}

// The kinds of type annotations.
enum TypeAnnotationKind {
namedType,
functionType,
}
15 changes: 10 additions & 5 deletions pkg/_fe_analyzer_shared/lib/src/macros/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const String template = '''
import 'dart:async';
import 'dart:isolate';
import 'package:_fe_analyzer_shared/src/macros/executor_shared/introspection_impls.dart';
import 'package:_fe_analyzer_shared/src/macros/executor_shared/response_impls.dart';
import 'package:_fe_analyzer_shared/src/macros/executor_shared/serialization.dart';
import 'package:_fe_analyzer_shared/src/macros/executor_shared/protocol.dart';
Expand Down Expand Up @@ -99,12 +100,14 @@ Future<SerializableResponse> _instantiateMacro(
return new SerializableResponse(
responseType: MessageType.macroInstanceIdentifier,
response: identifier,
requestId: request.id);
requestId: request.id,
serializationZoneId: request.serializationZoneId);
} catch (e) {
return new SerializableResponse(
responseType: MessageType.error,
error: e.toString(),
requestId: request.id);
requestId: request.id,
serializationZoneId: request.serializationZoneId);
}
}
Expand All @@ -118,7 +121,7 @@ Future<SerializableResponse> _executeDefinitionsPhase(
}
Declaration declaration = request.declaration;
if (instance is FunctionDefinitionMacro &&
declaration is FunctionDeclaration) {
declaration is FunctionDeclarationImpl) {
FunctionDefinitionBuilderImpl builder = new FunctionDefinitionBuilderImpl(
declaration,
request.typeResolver,
Expand All @@ -128,7 +131,8 @@ Future<SerializableResponse> _executeDefinitionsPhase(
return new SerializableResponse(
responseType: MessageType.macroExecutionResult,
response: builder.result,
requestId: request.id);
requestId: request.id,
serializationZoneId: request.serializationZoneId);
} else {
throw new UnsupportedError(
('Only FunctionDefinitionMacros are supported currently'));
Expand All @@ -137,7 +141,8 @@ Future<SerializableResponse> _executeDefinitionsPhase(
return new SerializableResponse(
responseType: MessageType.error,
error: e.toString(),
requestId: request.id);
requestId: request.id,
serializationZoneId: request.serializationZoneId);
}
}
''';
6 changes: 3 additions & 3 deletions pkg/_fe_analyzer_shared/lib/src/macros/executor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ abstract class MacroExecutor {
///
/// Throws an exception if there is an error executing the macro.
Future<MacroExecutionResult> executeTypesPhase(
MacroInstanceIdentifier macro, Declaration declaration);
MacroInstanceIdentifier macro, covariant Declaration declaration);

/// Runs the declarations phase for [macro] on a given [declaration].
///
/// Throws an exception if there is an error executing the macro.
Future<MacroExecutionResult> executeDeclarationsPhase(
MacroInstanceIdentifier macro,
Declaration declaration,
covariant Declaration declaration,
TypeResolver typeResolver,
ClassIntrospector classIntrospector);

Expand All @@ -78,7 +78,7 @@ abstract class MacroExecutor {
/// Throws an exception if there is an error executing the macro.
Future<MacroExecutionResult> executeDefinitionsPhase(
MacroInstanceIdentifier macro,
Declaration declaration,
covariant Declaration declaration,
TypeResolver typeResolver,
ClassIntrospector classIntrospector,
TypeDeclarationResolver typeDeclarationResolver);
Expand Down
Loading

0 comments on commit aa6fbac

Please sign in to comment.