Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Unified Diff: pkg/compiler/lib/src/resolution/signatures.dart

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/resolution/signatures.dart
diff --git a/pkg/compiler/lib/src/resolution/signatures.dart b/pkg/compiler/lib/src/resolution/signatures.dart
index 0fc9aac7dc86c83f8a0243f21f74f47e1b107960..7b166d95d579dcea065dea2654e49dba1d470eac 100644
--- a/pkg/compiler/lib/src/resolution/signatures.dart
+++ b/pkg/compiler/lib/src/resolution/signatures.dart
@@ -5,33 +5,26 @@
library dart2js.resolution.signatures;
import '../common.dart';
-import '../compiler.dart' show
- Compiler;
+import '../compiler.dart' show Compiler;
import '../dart_types.dart';
import '../elements/elements.dart';
-import '../elements/modelx.dart' show
- ErroneousFieldElementX,
- ErroneousInitializingFormalElementX,
- FormalElementX,
- FunctionElementX,
- FunctionSignatureX,
- InitializingFormalElementX,
- LocalParameterElementX;
+import '../elements/modelx.dart'
+ show
+ ErroneousFieldElementX,
+ ErroneousInitializingFormalElementX,
+ FormalElementX,
+ FunctionElementX,
+ FunctionSignatureX,
+ InitializingFormalElementX,
+ LocalParameterElementX;
import '../tree/tree.dart';
-import '../universe/use.dart' show
- TypeUse;
-import '../util/util.dart' show
- Link,
- LinkBuilder;
+import '../universe/use.dart' show TypeUse;
+import '../util/util.dart' show Link, LinkBuilder;
-import 'members.dart' show
- ResolverVisitor;
-import 'registry.dart' show
- ResolutionRegistry;
-import 'resolution_common.dart' show
- MappingVisitor;
-import 'scope.dart' show
- Scope;
+import 'members.dart' show ResolverVisitor;
+import 'registry.dart' show ResolutionRegistry;
+import 'resolution_common.dart' show MappingVisitor;
+import 'scope.dart' show Scope;
/**
* [SignatureResolver] resolves function signatures.
@@ -48,11 +41,9 @@ class SignatureResolver extends MappingVisitor<FormalElementX> {
bool optionalParametersAreNamed = false;
VariableDefinitions currentDefinitions;
- SignatureResolver(Compiler compiler,
- FunctionTypedElement enclosingElement,
- ResolutionRegistry registry,
- {this.defaultValuesError,
- this.createRealParameters})
+ SignatureResolver(Compiler compiler, FunctionTypedElement enclosingElement,
+ ResolutionRegistry registry,
+ {this.defaultValuesError, this.createRealParameters})
: this.enclosingElement = enclosingElement,
this.scope = enclosingElement.buildScope(),
this.resolver =
@@ -117,11 +108,14 @@ class SignatureResolver extends MappingVisitor<FormalElementX> {
}
void computeParameterType(FormalElementX element,
- [VariableElement fieldElement]) {
+ [VariableElement fieldElement]) {
void computeFunctionType(FunctionExpression functionExpression) {
FunctionSignature functionSignature = SignatureResolver.analyze(
- compiler, functionExpression.parameters,
- functionExpression.returnType, element, registry,
+ compiler,
+ functionExpression.parameters,
+ functionExpression.returnType,
+ element,
+ registry,
defaultValuesError: MessageKind.FUNCTION_TYPE_FORMAL_WITH_DEFAULT);
element.functionSignature = functionSignature;
}
@@ -137,7 +131,7 @@ class SignatureResolver extends MappingVisitor<FormalElementX> {
// Inline function typed parameter, like `void m(int f(String s))`.
computeFunctionType(link.head);
} else if (link.head.asSend() != null &&
- link.head.asSend().selector.asFunctionExpression() != null) {
+ link.head.asSend().selector.asFunctionExpression() != null) {
// Inline function typed initializing formal or
// parameter with default value, like `C(int this.f(String s))` or
// `void m([int f(String s) = null])`.
@@ -170,8 +164,8 @@ class SignatureResolver extends MappingVisitor<FormalElementX> {
functionExpression.name.asIdentifier() != null) {
return functionExpression.name.asIdentifier();
} else {
- reporter.internalError(node,
- 'internal error: unimplemented receiver on parameter send');
+ reporter.internalError(
+ node, 'internal error: unimplemented receiver on parameter send');
return null;
}
}
@@ -188,18 +182,18 @@ class SignatureResolver extends MappingVisitor<FormalElementX> {
FormalElementX parameter;
if (createRealParameters) {
parameter = new LocalParameterElementX(
- enclosingElement, currentDefinitions, name, initializer,
- isOptional: isOptionalParameter, isNamed: optionalParametersAreNamed);
+ enclosingElement, currentDefinitions, name, initializer,
+ isOptional: isOptionalParameter, isNamed: optionalParametersAreNamed);
} else {
parameter = new FormalElementX(
- ElementKind.PARAMETER, enclosingElement, currentDefinitions, name);
+ ElementKind.PARAMETER, enclosingElement, currentDefinitions, name);
}
computeParameterType(parameter);
return parameter;
}
- InitializingFormalElementX createFieldParameter(Send node,
- Expression initializer) {
+ InitializingFormalElementX createFieldParameter(
+ Send node, Expression initializer) {
InitializingFormalElementX element;
Identifier receiver = node.receiver.asIdentifier();
if (receiver == null || !receiver.isThis()) {
@@ -221,16 +215,16 @@ class SignatureResolver extends MappingVisitor<FormalElementX> {
!identical(fieldElement.kind, ElementKind.FIELD)) {
reporter.reportErrorMessage(
node, MessageKind.NOT_A_FIELD, {'fieldName': name});
- fieldElement = new ErroneousFieldElementX(
- name, enclosingElement.enclosingClass);
+ fieldElement =
+ new ErroneousFieldElementX(name, enclosingElement.enclosingClass);
} else if (!fieldElement.isInstanceMember) {
reporter.reportErrorMessage(
node, MessageKind.NOT_INSTANCE_FIELD, {'fieldName': name});
- fieldElement = new ErroneousFieldElementX(
- name, enclosingElement.enclosingClass);
+ fieldElement =
+ new ErroneousFieldElementX(name, enclosingElement.enclosingClass);
}
- element = new InitializingFormalElementX(enclosingElement,
- currentDefinitions, name, initializer, fieldElement,
+ element = new InitializingFormalElementX(
+ enclosingElement, currentDefinitions, name, initializer, fieldElement,
isOptional: isOptionalParameter, isNamed: optionalParametersAreNamed);
computeParameterType(element, fieldElement);
}
@@ -243,7 +237,7 @@ class SignatureResolver extends MappingVisitor<FormalElementX> {
if (node.receiver != null) {
element = createFieldParameter(node, node.arguments.first);
} else if (node.selector.asIdentifier() != null ||
- node.selector.asFunctionExpression() != null) {
+ node.selector.asFunctionExpression() != null) {
element = createParameter(getParameterName(node), node.arguments.first);
}
Node defaultValue = node.arguments.head;
@@ -258,8 +252,7 @@ class SignatureResolver extends MappingVisitor<FormalElementX> {
Modifiers modifiers = currentDefinitions.modifiers;
if (modifiers.isFinal) {
reporter.reportErrorMessage(
- modifiers,
- MessageKind.FINAL_FUNCTION_TYPE_PARAMETER);
+ modifiers, MessageKind.FINAL_FUNCTION_TYPE_PARAMETER);
}
if (modifiers.isVar) {
reporter.reportErrorMessage(
@@ -278,7 +271,7 @@ class SignatureResolver extends MappingVisitor<FormalElementX> {
} else {
// If parameter is null, the current node should be the last,
// and a list of optional named parameters.
- if (!link.tail.isEmpty || (link.head is !NodeList)) {
+ if (!link.tail.isEmpty || (link.head is! NodeList)) {
reporter.internalError(link.head, "expected optional parameters");
}
}
@@ -301,12 +294,13 @@ class SignatureResolver extends MappingVisitor<FormalElementX> {
FunctionTypedElement element,
ResolutionRegistry registry,
{MessageKind defaultValuesError,
- bool createRealParameters: false,
- bool isFunctionExpression: false}) {
+ bool createRealParameters: false,
+ bool isFunctionExpression: false}) {
DiagnosticReporter reporter = compiler.reporter;
- SignatureResolver visitor = new SignatureResolver(compiler, element,
- registry, defaultValuesError: defaultValuesError,
+ SignatureResolver visitor = new SignatureResolver(
+ compiler, element, registry,
+ defaultValuesError: defaultValuesError,
createRealParameters: createRealParameters);
List<Element> parameters = const <Element>[];
int requiredParameterCount = 0;
@@ -324,17 +318,17 @@ class SignatureResolver extends MappingVisitor<FormalElementX> {
}
} else {
if (element.isGetter) {
- if (!identical(formalParameters.endToken.next.stringValue,
- // TODO(ahe): Remove the check for native keyword.
- 'native')) {
+ if (!identical(
+ formalParameters.endToken.next.stringValue,
+ // TODO(ahe): Remove the check for native keyword.
+ 'native')) {
reporter.reportErrorMessage(
- formalParameters,
- MessageKind.EXTRA_FORMALS);
+ formalParameters, MessageKind.EXTRA_FORMALS);
}
}
LinkBuilder<Element> parametersBuilder =
- visitor.analyzeNodes(formalParameters.nodes);
- requiredParameterCount = parametersBuilder.length;
+ visitor.analyzeNodes(formalParameters.nodes);
+ requiredParameterCount = parametersBuilder.length;
parameters = parametersBuilder.toList();
}
DartType returnType;
@@ -354,33 +348,32 @@ class SignatureResolver extends MappingVisitor<FormalElementX> {
asyncMarker = function.asyncMarker;
}
switch (asyncMarker) {
- case AsyncMarker.SYNC:
- returnType = visitor.resolveReturnType(returnNode);
- break;
- case AsyncMarker.SYNC_STAR:
- returnType = compiler.coreTypes.iterableType();
- break;
- case AsyncMarker.ASYNC:
- returnType = compiler.coreTypes.futureType();
- break;
- case AsyncMarker.ASYNC_STAR:
- returnType = compiler.coreTypes.streamType();
- break;
+ case AsyncMarker.SYNC:
+ returnType = visitor.resolveReturnType(returnNode);
+ break;
+ case AsyncMarker.SYNC_STAR:
+ returnType = compiler.coreTypes.iterableType();
+ break;
+ case AsyncMarker.ASYNC:
+ returnType = compiler.coreTypes.futureType();
+ break;
+ case AsyncMarker.ASYNC_STAR:
+ returnType = compiler.coreTypes.streamType();
+ break;
}
}
- if (element.isSetter && (requiredParameterCount != 1 ||
- visitor.optionalParameterCount != 0)) {
+ if (element.isSetter &&
+ (requiredParameterCount != 1 || visitor.optionalParameterCount != 0)) {
// If there are no formal parameters, we already reported an error above.
if (formalParameters != null) {
reporter.reportErrorMessage(
- formalParameters,
- MessageKind.ILLEGAL_SETTER_FORMALS);
+ formalParameters, MessageKind.ILLEGAL_SETTER_FORMALS);
}
}
LinkBuilder<DartType> parameterTypes = new LinkBuilder<DartType>();
for (FormalElement parameter in parameters) {
- parameterTypes.addLast(parameter.type);
+ parameterTypes.addLast(parameter.type);
}
List<DartType> optionalParameterTypes = const <DartType>[];
List<String> namedParameters = const <String>[];
@@ -390,7 +383,7 @@ class SignatureResolver extends MappingVisitor<FormalElementX> {
if (visitor.optionalParametersAreNamed) {
// TODO(karlklose); replace when [visitor.optinalParameters] is a [List].
orderedOptionalParameters.sort((Element a, Element b) {
- return a.name.compareTo(b.name);
+ return a.name.compareTo(b.name);
});
LinkBuilder<String> namedParametersBuilder = new LinkBuilder<String>();
LinkBuilder<DartType> namedParameterTypesBuilder =
@@ -400,8 +393,8 @@ class SignatureResolver extends MappingVisitor<FormalElementX> {
namedParameterTypesBuilder.addLast(parameter.type);
}
namedParameters = namedParametersBuilder.toLink().toList(growable: false);
- namedParameterTypes = namedParameterTypesBuilder.toLink()
- .toList(growable: false);
+ namedParameterTypes =
+ namedParameterTypesBuilder.toLink().toList(growable: false);
} else {
// TODO(karlklose); replace when [visitor.optinalParameters] is a [List].
LinkBuilder<DartType> optionalParameterTypesBuilder =
@@ -409,8 +402,8 @@ class SignatureResolver extends MappingVisitor<FormalElementX> {
for (FormalElement parameter in visitor.optionalParameters) {
optionalParameterTypesBuilder.addLast(parameter.type);
}
- optionalParameterTypes = optionalParameterTypesBuilder.toLink()
- .toList(growable: false);
+ optionalParameterTypes =
+ optionalParameterTypesBuilder.toLink().toList(growable: false);
}
FunctionType type = new FunctionType(
element.declaration,
« no previous file with comments | « pkg/compiler/lib/src/resolution/send_structure.dart ('k') | pkg/compiler/lib/src/resolution/tree_elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698