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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 169763003: Update dart2js diagnostics to prepare for filtering. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove optional Uri. Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 Element get currentElement; 8 Element get currentElement;
9 Setlet<Node> get superUses; 9 Setlet<Node> get superUses;
10 10
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 if (originParameterText != patchParameterText 350 if (originParameterText != patchParameterText
351 // We special case the list constructor because of the 351 // We special case the list constructor because of the
352 // optional parameter. 352 // optional parameter.
353 && origin != compiler.unnamedListConstructor) { 353 && origin != compiler.unnamedListConstructor) {
354 compiler.reportError( 354 compiler.reportError(
355 originParameter.parseNode(compiler), 355 originParameter.parseNode(compiler),
356 MessageKind.PATCH_PARAMETER_MISMATCH, 356 MessageKind.PATCH_PARAMETER_MISMATCH,
357 {'methodName': origin.name, 357 {'methodName': origin.name,
358 'originParameter': originParameterText, 358 'originParameter': originParameterText,
359 'patchParameter': patchParameterText}); 359 'patchParameter': patchParameterText});
360 compiler.reportMessage( 360 compiler.reportInfo(patchParameter,
361 compiler.spanFromSpannable(patchParameter), 361 MessageKind.PATCH_POINT_TO_PARAMETER,
362 MessageKind.PATCH_POINT_TO_PARAMETER.error( 362 {'parameterName': patchParameter.name});
363 {'parameterName': patchParameter.name}),
364 Diagnostic.INFO);
365 } 363 }
366 DartType originParameterType = originParameter.computeType(compiler); 364 DartType originParameterType = originParameter.computeType(compiler);
367 DartType patchParameterType = patchParameter.computeType(compiler); 365 DartType patchParameterType = patchParameter.computeType(compiler);
368 if (originParameterType != patchParameterType) { 366 if (originParameterType != patchParameterType) {
369 compiler.reportError( 367 compiler.reportError(
370 originParameter.parseNode(compiler), 368 originParameter.parseNode(compiler),
371 MessageKind.PATCH_PARAMETER_TYPE_MISMATCH, 369 MessageKind.PATCH_PARAMETER_TYPE_MISMATCH,
372 {'methodName': origin.name, 370 {'methodName': origin.name,
373 'parameterName': originParameter.name, 371 'parameterName': originParameter.name,
374 'originParameterType': originParameterType, 372 'originParameterType': originParameterType,
375 'patchParameterType': patchParameterType}); 373 'patchParameterType': patchParameterType});
376 compiler.reportMessage( 374 compiler.reportInfo(patchParameter,
377 compiler.spanFromSpannable(patchParameter), 375 MessageKind.PATCH_POINT_TO_PARAMETER,
378 MessageKind.PATCH_POINT_TO_PARAMETER.error( 376 {'parameterName': patchParameter.name});
379 {'parameterName': patchParameter.name}),
380 Diagnostic.INFO);
381 } 377 }
382 378
383 originParameters = originParameters.tail; 379 originParameters = originParameters.tail;
384 patchParameters = patchParameters.tail; 380 patchParameters = patchParameters.tail;
385 } 381 }
386 } 382 }
387 383
388 void checkMatchingPatchSignatures(FunctionElement origin, 384 void checkMatchingPatchSignatures(FunctionElement origin,
389 FunctionElement patch) { 385 FunctionElement patch) {
390 // TODO(johnniwinther): Show both origin and patch locations on errors. 386 // TODO(johnniwinther): Show both origin and patch locations on errors.
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 1541
1546 R visitEmptyStatement(Node node) => null; 1542 R visitEmptyStatement(Node node) => null;
1547 1543
1548 /** Convenience method for visiting nodes that may be null. */ 1544 /** Convenience method for visiting nodes that may be null. */
1549 R visit(Node node) => (node == null) ? null : node.accept(this); 1545 R visit(Node node) => (node == null) ? null : node.accept(this);
1550 1546
1551 void error(Spannable node, MessageKind kind, [Map arguments = const {}]) { 1547 void error(Spannable node, MessageKind kind, [Map arguments = const {}]) {
1552 compiler.reportFatalError(node, kind, arguments); 1548 compiler.reportFatalError(node, kind, arguments);
1553 } 1549 }
1554 1550
1555 void warning(Node node, MessageKind kind, [Map arguments = const {}]) { 1551 void warning(Spannable node, MessageKind kind, [Map arguments = const {}]) {
1556 ResolutionWarning message = 1552 compiler.reportWarning(node, kind, arguments);
1557 new ResolutionWarning(kind, arguments, compiler.terseDiagnostics);
1558 compiler.reportWarning(node, message);
1559 } 1553 }
1560 1554
1561 void cancel(Node node, String message) { 1555 void cancel(Node node, String message) {
1562 compiler.cancel(message, node: node); 1556 compiler.cancel(message, node: node);
1563 } 1557 }
1564 1558
1565 void internalError(Node node, String message) { 1559 void internalError(Node node, String message) {
1566 compiler.internalError(message, node: node); 1560 compiler.internalError(message, node: node);
1567 } 1561 }
1568 1562
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 } 1830 }
1837 1831
1838 /// Checks the type arguments of [type] against the type variable bounds. 1832 /// Checks the type arguments of [type] against the type variable bounds.
1839 void checkTypeVariableBounds(TreeElements elements, 1833 void checkTypeVariableBounds(TreeElements elements,
1840 TypeAnnotation node, GenericType type) { 1834 TypeAnnotation node, GenericType type) {
1841 void checkTypeVariableBound(_, DartType typeArgument, 1835 void checkTypeVariableBound(_, DartType typeArgument,
1842 TypeVariableType typeVariable, 1836 TypeVariableType typeVariable,
1843 DartType bound) { 1837 DartType bound) {
1844 compiler.backend.registerTypeVariableBoundCheck(elements); 1838 compiler.backend.registerTypeVariableBoundCheck(elements);
1845 if (!compiler.types.isSubtype(typeArgument, bound)) { 1839 if (!compiler.types.isSubtype(typeArgument, bound)) {
1846 compiler.reportWarningCode(node, 1840 compiler.reportWarning(node,
1847 MessageKind.INVALID_TYPE_VARIABLE_BOUND, 1841 MessageKind.INVALID_TYPE_VARIABLE_BOUND,
1848 {'typeVariable': typeVariable, 1842 {'typeVariable': typeVariable,
1849 'bound': bound, 1843 'bound': bound,
1850 'typeArgument': typeArgument, 1844 'typeArgument': typeArgument,
1851 'thisType': type.element.thisType}); 1845 'thisType': type.element.thisType});
1852 } 1846 }
1853 }; 1847 };
1854 1848
1855 compiler.types.checkTypeVariableBounds(type, checkTypeVariableBound); 1849 compiler.types.checkTypeVariableBounds(type, checkTypeVariableBound);
1856 } 1850 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 if (existing != element) { 1925 if (existing != element) {
1932 reportDuplicateDefinition(node, element, existing); 1926 reportDuplicateDefinition(node, element, existing);
1933 } 1927 }
1934 } 1928 }
1935 return element; 1929 return element;
1936 } 1930 }
1937 1931
1938 void reportDuplicateDefinition(/*Node|String*/ name, 1932 void reportDuplicateDefinition(/*Node|String*/ name,
1939 Spannable definition, 1933 Spannable definition,
1940 Spannable existing) { 1934 Spannable existing) {
1941 compiler.reportError( 1935 compiler.reportError(definition,
1942 definition,
1943 MessageKind.DUPLICATE_DEFINITION, {'name': name}); 1936 MessageKind.DUPLICATE_DEFINITION, {'name': name});
1944 compiler.reportMessage( 1937 compiler.reportInfo(existing,
1945 compiler.spanFromSpannable(existing), 1938 MessageKind.EXISTING_DEFINITION, {'name': name});
1946 MessageKind.EXISTING_DEFINITION.error({'name': name}),
1947 Diagnostic.INFO);
1948 } 1939 }
1949 } 1940 }
1950 1941
1951 /** 1942 /**
1952 * Core implementation of resolution. 1943 * Core implementation of resolution.
1953 * 1944 *
1954 * Do not subclass or instantiate this class outside this library 1945 * Do not subclass or instantiate this class outside this library
1955 * except for testing. 1946 * except for testing.
1956 */ 1947 */
1957 class ResolverVisitor extends MappingVisitor<Element> { 1948 class ResolverVisitor extends MappingVisitor<Element> {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 } 2090 }
2100 2091
2101 visitInStaticContext(Node node) { 2092 visitInStaticContext(Node node) {
2102 inStaticContext(() => visit(node)); 2093 inStaticContext(() => visit(node));
2103 } 2094 }
2104 2095
2105 ErroneousElement warnAndCreateErroneousElement(Node node, 2096 ErroneousElement warnAndCreateErroneousElement(Node node,
2106 String name, 2097 String name,
2107 DualKind kind, 2098 DualKind kind,
2108 [Map arguments = const {}]) { 2099 [Map arguments = const {}]) {
2109 ResolutionWarning warning = new ResolutionWarning( 2100 compiler.reportWarning(node, kind.warning, arguments);
2110 kind.warning, arguments, compiler.terseDiagnostics);
2111 compiler.reportWarning(node, warning);
2112 return new ErroneousElementX(kind.error, arguments, name, enclosingElement); 2101 return new ErroneousElementX(kind.error, arguments, name, enclosingElement);
2113 } 2102 }
2114 2103
2115 Element visitIdentifier(Identifier node) { 2104 Element visitIdentifier(Identifier node) {
2116 if (node.isThis()) { 2105 if (node.isThis()) {
2117 if (!inInstanceContext) { 2106 if (!inInstanceContext) {
2118 error(node, MessageKind.NO_INSTANCE_AVAILABLE, {'name': node}); 2107 error(node, MessageKind.NO_INSTANCE_AVAILABLE, {'name': node});
2119 } 2108 }
2120 return null; 2109 return null;
2121 } else if (node.isSuper()) { 2110 } else if (node.isSuper()) {
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
3477 compiler.reportError( 3466 compiler.reportError(
3478 label, 3467 label,
3479 MessageKind.DUPLICATE_LABEL.error, {'labelName': labelName}); 3468 MessageKind.DUPLICATE_LABEL.error, {'labelName': labelName});
3480 compiler.reportInfo( 3469 compiler.reportInfo(
3481 existingElement.label, 3470 existingElement.label,
3482 MessageKind.EXISTING_LABEL, {'labelName': labelName}); 3471 MessageKind.EXISTING_LABEL, {'labelName': labelName});
3483 } else { 3472 } else {
3484 // It's only a warning if it shadows another label. 3473 // It's only a warning if it shadows another label.
3485 existingElement = statementScope.lookupLabel(labelName); 3474 existingElement = statementScope.lookupLabel(labelName);
3486 if (existingElement != null) { 3475 if (existingElement != null) {
3487 compiler.reportWarningCode( 3476 compiler.reportWarning(
3488 label, 3477 label,
3489 MessageKind.DUPLICATE_LABEL.warning, {'labelName': labelName}); 3478 MessageKind.DUPLICATE_LABEL.warning, {'labelName': labelName});
3490 compiler.reportInfo( 3479 compiler.reportInfo(
3491 existingElement.label, 3480 existingElement.label,
3492 MessageKind.EXISTING_LABEL, {'labelName': labelName}); 3481 MessageKind.EXISTING_LABEL, {'labelName': labelName});
3493 } 3482 }
3494 } 3483 }
3495 3484
3496 TargetElement targetElement = getOrCreateTargetElement(switchCase); 3485 TargetElement targetElement = getOrCreateTargetElement(switchCase);
3497 LabelElement labelElement = targetElement.addLabel(label, labelName); 3486 LabelElement labelElement = targetElement.addLabel(label, labelName);
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
3921 } 3910 }
3922 3911
3923 DartType visitNamedMixinApplication(NamedMixinApplication node) { 3912 DartType visitNamedMixinApplication(NamedMixinApplication node) {
3924 invariant(node, element != null); 3913 invariant(node, element != null);
3925 invariant(element, element.resolutionState == STATE_STARTED, 3914 invariant(element, element.resolutionState == STATE_STARTED,
3926 message: () => 'cyclic resolution of class $element'); 3915 message: () => 'cyclic resolution of class $element');
3927 3916
3928 if (identical(node.classKeyword.stringValue, 'typedef')) { 3917 if (identical(node.classKeyword.stringValue, 'typedef')) {
3929 // TODO(aprelev@gmail.com): Remove this deprecation diagnostic 3918 // TODO(aprelev@gmail.com): Remove this deprecation diagnostic
3930 // together with corresponding TODO in parser.dart. 3919 // together with corresponding TODO in parser.dart.
3931 compiler.reportWarningCode(node.classKeyword, 3920 compiler.reportWarning(node.classKeyword,
3932 MessageKind.DEPRECATED_TYPEDEF_MIXIN_SYNTAX); 3921 MessageKind.DEPRECATED_TYPEDEF_MIXIN_SYNTAX);
3933 } 3922 }
3934 3923
3935 InterfaceType type = element.computeType(compiler); 3924 InterfaceType type = element.computeType(compiler);
3936 scope = new TypeDeclarationScope(scope, element); 3925 scope = new TypeDeclarationScope(scope, element);
3937 resolveTypeVariableBounds(node.typeParameters); 3926 resolveTypeVariableBounds(node.typeParameters);
3938 3927
3939 // Generate anonymous mixin application elements for the 3928 // Generate anonymous mixin application elements for the
3940 // intermediate mixin applications (excluding the last). 3929 // intermediate mixin applications (excluding the last).
3941 DartType supertype = resolveSupertype(element, node.superclass); 3930 DartType supertype = resolveSupertype(element, node.superclass);
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
4380 String targetName, DualKind kind, 4369 String targetName, DualKind kind,
4381 Map arguments) { 4370 Map arguments) {
4382 if (kind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { 4371 if (kind == MessageKind.CANNOT_FIND_CONSTRUCTOR) {
4383 compiler.backend.registerThrowNoSuchMethod(resolver.mapping); 4372 compiler.backend.registerThrowNoSuchMethod(resolver.mapping);
4384 } else { 4373 } else {
4385 compiler.backend.registerThrowRuntimeError(resolver.mapping); 4374 compiler.backend.registerThrowRuntimeError(resolver.mapping);
4386 } 4375 }
4387 if (inConstContext) { 4376 if (inConstContext) {
4388 compiler.reportError(diagnosticNode, kind.error, arguments); 4377 compiler.reportError(diagnosticNode, kind.error, arguments);
4389 } else { 4378 } else {
4390 ResolutionWarning warning = 4379 compiler.reportWarning(diagnosticNode, kind.warning, arguments);
4391 new ResolutionWarning(
4392 kind.warning, arguments, compiler.terseDiagnostics);
4393 compiler.reportWarning(diagnosticNode, warning);
4394 } 4380 }
4395 return new ErroneousElementX( 4381 return new ErroneousElementX(
4396 kind.error, arguments, targetName, enclosing); 4382 kind.error, arguments, targetName, enclosing);
4397 } 4383 }
4398 4384
4399 Selector createConstructorSelector(String constructorName) { 4385 Selector createConstructorSelector(String constructorName) {
4400 return constructorName == '' 4386 return constructorName == ''
4401 ? new Selector.callDefaultConstructor( 4387 ? new Selector.callDefaultConstructor(
4402 resolver.enclosingElement.getLibrary()) 4388 resolver.enclosingElement.getLibrary())
4403 : new Selector.callConstructor( 4389 : new Selector.callConstructor(
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
4537 return finishConstructorReference(visit(expression), 4523 return finishConstructorReference(visit(expression),
4538 expression, expression); 4524 expression, expression);
4539 } 4525 }
4540 } 4526 }
4541 4527
4542 /// Looks up [name] in [scope] and unwraps the result. 4528 /// Looks up [name] in [scope] and unwraps the result.
4543 Element lookupInScope(Compiler compiler, Node node, 4529 Element lookupInScope(Compiler compiler, Node node,
4544 Scope scope, String name) { 4530 Scope scope, String name) {
4545 return Elements.unwrap(scope.lookup(name), compiler, node); 4531 return Elements.unwrap(scope.lookup(name), compiler, node);
4546 } 4532 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698