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

Side by Side Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 1008583002: Fix hints (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library engine.resolver.error_verifier; 5 library engine.resolver.error_verifier;
6 6
7 import "dart:math" as math; 7 import "dart:math" as math;
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/src/generated/static_type_analyzer.dart'; 10 import 'package:analyzer/src/generated/static_type_analyzer.dart';
(...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 PropertyAccess propertyAccess = expression; 1954 PropertyAccess propertyAccess = expression;
1955 element = propertyAccess.propertyName.staticElement; 1955 element = propertyAccess.propertyName.staticElement;
1956 highlightedNode = propertyAccess.propertyName; 1956 highlightedNode = propertyAccess.propertyName;
1957 } 1957 }
1958 // check if element is assignable 1958 // check if element is assignable
1959 if (element is PropertyAccessorElement) { 1959 if (element is PropertyAccessorElement) {
1960 PropertyAccessorElement accessor = element as PropertyAccessorElement; 1960 PropertyAccessorElement accessor = element as PropertyAccessorElement;
1961 element = accessor.variable; 1961 element = accessor.variable;
1962 } 1962 }
1963 if (element is VariableElement) { 1963 if (element is VariableElement) {
1964 VariableElement variable = element as VariableElement; 1964 if (element.isConst) {
1965 if (variable.isConst) {
1966 _errorReporter.reportErrorForNode( 1965 _errorReporter.reportErrorForNode(
1967 StaticWarningCode.ASSIGNMENT_TO_CONST, expression); 1966 StaticWarningCode.ASSIGNMENT_TO_CONST, expression);
1968 return true; 1967 return true;
1969 } 1968 }
1970 if (variable.isFinal) { 1969 if (element.isFinal) {
1971 if (variable is FieldElementImpl && 1970 if (element is FieldElementImpl &&
1972 variable.setter == null && 1971 element.setter == null &&
1973 variable.isSynthetic) { 1972 element.isSynthetic) {
1974 _errorReporter.reportErrorForNode( 1973 _errorReporter.reportErrorForNode(
1975 StaticWarningCode.ASSIGNMENT_TO_FINAL_NO_SETTER, highlightedNode, 1974 StaticWarningCode.ASSIGNMENT_TO_FINAL_NO_SETTER, highlightedNode,
1976 [variable.name, variable.enclosingElement.displayName]); 1975 [element.name, element.enclosingElement.displayName]);
1977 return true; 1976 return true;
1978 } 1977 }
1979 _errorReporter.reportErrorForNode(StaticWarningCode.ASSIGNMENT_TO_FINAL, 1978 _errorReporter.reportErrorForNode(StaticWarningCode.ASSIGNMENT_TO_FINAL,
1980 highlightedNode, [variable.name]); 1979 highlightedNode, [element.name]);
1981 return true; 1980 return true;
1982 } 1981 }
1983 return false; 1982 return false;
1984 } 1983 }
1985 if (element is FunctionElement) { 1984 if (element is FunctionElement) {
1986 _errorReporter.reportErrorForNode( 1985 _errorReporter.reportErrorForNode(
1987 StaticWarningCode.ASSIGNMENT_TO_FUNCTION, expression); 1986 StaticWarningCode.ASSIGNMENT_TO_FUNCTION, expression);
1988 return true; 1987 return true;
1989 } 1988 }
1990 if (element is MethodElement) { 1989 if (element is MethodElement) {
(...skipping 3949 matching lines...) Expand 10 before | Expand all | Expand 10 after
5940 /** 5939 /**
5941 * @param node the 'this' expression to analyze 5940 * @param node the 'this' expression to analyze
5942 * @return `true` if the given 'this' expression is in the valid context 5941 * @return `true` if the given 'this' expression is in the valid context
5943 */ 5942 */
5944 bool _isThisInValidContext(ThisExpression node) { 5943 bool _isThisInValidContext(ThisExpression node) {
5945 for (AstNode n = node; n != null; n = n.parent) { 5944 for (AstNode n = node; n != null; n = n.parent) {
5946 if (n is CompilationUnit) { 5945 if (n is CompilationUnit) {
5947 return false; 5946 return false;
5948 } 5947 }
5949 if (n is ConstructorDeclaration) { 5948 if (n is ConstructorDeclaration) {
5950 ConstructorDeclaration constructor = n as ConstructorDeclaration; 5949 return n.factoryKeyword == null;
5951 return constructor.factoryKeyword == null;
5952 } 5950 }
5953 if (n is ConstructorInitializer) { 5951 if (n is ConstructorInitializer) {
5954 return false; 5952 return false;
5955 } 5953 }
5956 if (n is MethodDeclaration) { 5954 if (n is MethodDeclaration) {
5957 MethodDeclaration method = n as MethodDeclaration; 5955 return !n.isStatic;
5958 return !method.isStatic;
5959 } 5956 }
5960 } 5957 }
5961 return false; 5958 return false;
5962 } 5959 }
5963 5960
5964 /** 5961 /**
5965 * Return `true` if the given identifier is in a location where it is allowed to resolve to 5962 * Return `true` if the given identifier is in a location where it is allowed to resolve to
5966 * a static member of a supertype. 5963 * a static member of a supertype.
5967 * 5964 *
5968 * @param node the node being tested 5965 * @param node the node being tested
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
6144 toCheck.add(type.element); 6141 toCheck.add(type.element);
6145 // type arguments 6142 // type arguments
6146 if (type is InterfaceType) { 6143 if (type is InterfaceType) {
6147 InterfaceType interfaceType = type; 6144 InterfaceType interfaceType = type;
6148 for (DartType typeArgument in interfaceType.typeArguments) { 6145 for (DartType typeArgument in interfaceType.typeArguments) {
6149 _addTypeToCheck(typeArgument); 6146 _addTypeToCheck(typeArgument);
6150 } 6147 }
6151 } 6148 }
6152 } 6149 }
6153 } 6150 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | pkg/analyzer/lib/src/generated/incremental_resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698