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

Unified Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 2426583003: Improve error messages and add many corrections (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « pkg/analyzer/lib/src/error/codes.dart ('k') | pkg/analyzer/lib/src/generated/parser.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/error_verifier.dart
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 792e5db72d251a5e32a28a775aed779fc66f9b7b..a6316a541177d7d0f213e3219ca645871774976c 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -3767,16 +3767,19 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
if (_isInNativeClass || list.isSynthetic) {
return;
}
-
+ bool isConst = list.isConst;
+ if (!(isConst || list.isFinal)) {
+ return;
+ }
NodeList<VariableDeclaration> variables = list.variables;
for (VariableDeclaration variable in variables) {
if (variable.initializer == null) {
- if (list.isConst) {
+ if (isConst) {
_errorReporter.reportErrorForNode(
CompileTimeErrorCode.CONST_NOT_INITIALIZED,
variable.name,
[variable.name.name]);
- } else if (list.isFinal) {
+ } else {
_errorReporter.reportErrorForNode(
StaticWarningCode.FINAL_NOT_INITIALIZED,
variable.name,
@@ -4256,7 +4259,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
_errorReporter.reportErrorForNode(
StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER,
name,
- [name.name]);
+ [name.name, _getKind(element), element.enclosingElement.name]);
}
}
@@ -4952,7 +4955,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
_errorReporter.reportErrorForNode(
CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT,
declaration.name,
- [superType.displayName]);
+ [superType.displayName, _enclosingClass.displayName]);
}
/**
@@ -5868,14 +5871,13 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
if (enclosingElement is! ClassElement) {
return;
}
- if ((element is MethodElement && !element.isStatic) ||
- (element is PropertyAccessorElement && !element.isStatic)) {
+ if (element is ExecutableElement && !element.isStatic) {
return;
}
_errorReporter.reportErrorForNode(
StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER,
name,
- [name.name]);
+ [enclosingElement.name]);
}
void _checkForValidField(FieldFormalParameter parameter) {
@@ -6314,6 +6316,32 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}
/**
+ * Return a human-readable representation of the kind of the [element].
+ */
+ String _getKind(ExecutableElement element) {
+ if (element is MethodElement) {
+ return 'method';
+ } else if (element is PropertyAccessorElement) {
+ if (element.isSynthetic) {
+ PropertyInducingElement variable = element.variable;
+ if (variable is FieldElement) {
+ return 'field';
+ }
+ return 'variable';
+ } else if (element.isGetter) {
+ return 'getter';
+ } else {
+ return 'setter';
+ }
+ } else if (element is ConstructorElement) {
+ return 'constructor';
+ } else if (element is FunctionElement) {
+ return 'function';
+ }
+ return 'member';
+ }
+
+ /**
* Return the name of the library that defines given [element].
*/
String _getLibraryName(Element element) {
« no previous file with comments | « pkg/analyzer/lib/src/error/codes.dart ('k') | pkg/analyzer/lib/src/generated/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698