diff --git a/README.md b/README.md index 6b2bd6e9..248c9773 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ to generate Dart code. To install, please run: $ dart pub global activate protoc_plugin ``` -## Initialise Flutter +## Initialize Flutter The Flutter SDK needs to be downloaded and setup. diff --git a/lib/src/analysis_server.dart b/lib/src/analysis_server.dart index 10126a72..3450d6d9 100644 --- a/lib/src/analysis_server.dart +++ b/lib/src/analysis_server.dart @@ -313,19 +313,22 @@ abstract class AnalysisServerWrapper { final issues = errors.map((error) { final issue = proto.AnalysisIssue() ..kind = error.severity.toLowerCase() + ..code = error.code.toLowerCase() ..line = error.location.startLine + ..column = error.location.startColumn ..message = utils.normalizeFilePaths(error.message) ..sourceName = path.basename(error.location.file) ..hasFixes = error.hasFix ?? false ..charStart = error.location.offset ..charLength = error.location.length ..diagnosticMessages.addAll( - error.contextMessages?.map((m) => proto.DiagnosticMessage() - ..message = utils.normalizeFilePaths(m.message) - ..line = m.location.startLine - ..charStart = m.location.offset - ..charLength = m.location.length) ?? - []); + error.contextMessages?.map((m) => proto.DiagnosticMessage() + ..message = utils.normalizeFilePaths(m.message) + ..line = m.location.startLine + ..charStart = m.location.offset + ..charLength = m.location.length) ?? + [], + ); if (error.url != null) { issue.url = error.url!; diff --git a/lib/src/protos/dart_services.pb.dart b/lib/src/protos/dart_services.pb.dart index 4a18026a..b41ed135 100644 --- a/lib/src/protos/dart_services.pb.dart +++ b/lib/src/protos/dart_services.pb.dart @@ -488,6 +488,8 @@ class AnalysisIssue extends $pb.GeneratedMessage { 9, _omitFieldNames ? '' : 'diagnosticMessages', $pb.PbFieldType.PM, protoName: 'diagnosticMessages', subBuilder: DiagnosticMessage.create) ..aOS(10, _omitFieldNames ? '' : 'correction') + ..a<$core.int>(11, _omitFieldNames ? '' : 'column', $pb.PbFieldType.O3) + ..aOS(12, _omitFieldNames ? '' : 'code') ..hasRequiredFields = false; @$core.Deprecated('Using this can add significant overhead to your binary. ' @@ -623,6 +625,30 @@ class AnalysisIssue extends $pb.GeneratedMessage { $core.bool hasCorrection() => $_has(9); @$pb.TagNumber(10) void clearCorrection() => clearField(10); + + @$pb.TagNumber(11) + $core.int get column => $_getIZ(10); + @$pb.TagNumber(11) + set column($core.int v) { + $_setSignedInt32(10, v); + } + + @$pb.TagNumber(11) + $core.bool hasColumn() => $_has(10); + @$pb.TagNumber(11) + void clearColumn() => clearField(11); + + @$pb.TagNumber(12) + $core.String get code => $_getSZ(11); + @$pb.TagNumber(12) + set code($core.String v) { + $_setString(11, v); + } + + @$pb.TagNumber(12) + $core.bool hasCode() => $_has(11); + @$pb.TagNumber(12) + void clearCode() => clearField(12); } class DiagnosticMessage extends $pb.GeneratedMessage { diff --git a/lib/src/protos/dart_services.pbjson.dart b/lib/src/protos/dart_services.pbjson.dart index 8dc3b720..018141bc 100644 --- a/lib/src/protos/dart_services.pbjson.dart +++ b/lib/src/protos/dart_services.pbjson.dart @@ -206,6 +206,8 @@ const AnalysisIssue$json = { '10': 'diagnosticMessages' }, {'1': 'correction', '3': 10, '4': 1, '5': 9, '10': 'correction'}, + {'1': 'column', '3': 11, '4': 1, '5': 5, '10': 'column'}, + {'1': 'code', '3': 12, '4': 1, '5': 9, '10': 'code'}, ], }; @@ -217,7 +219,7 @@ final $typed_data.Uint8List analysisIssueDescriptor = $convert.base64Decode( 'N0YXJ0Eh4KCmNoYXJMZW5ndGgYByABKAVSCmNoYXJMZW5ndGgSEAoDdXJsGAggASgJUgN1cmwS' 'VAoSZGlhZ25vc3RpY01lc3NhZ2VzGAkgAygLMiQuZGFydF9zZXJ2aWNlcy5hcGkuRGlhZ25vc3' 'RpY01lc3NhZ2VSEmRpYWdub3N0aWNNZXNzYWdlcxIeCgpjb3JyZWN0aW9uGAogASgJUgpjb3Jy' - 'ZWN0aW9u'); + 'ZWN0aW9uEhYKBmNvbHVtbhgLIAEoBVIGY29sdW1uEhIKBGNvZGUYDCABKAlSBGNvZGU='); @$core.Deprecated('Use diagnosticMessageDescriptor instead') const DiagnosticMessage$json = { diff --git a/protos/dart_services.proto b/protos/dart_services.proto index 11795e42..e92e6036 100644 --- a/protos/dart_services.proto +++ b/protos/dart_services.proto @@ -75,6 +75,8 @@ message AnalysisIssue { string url = 8; repeated DiagnosticMessage diagnosticMessages = 9; string correction = 10; + int32 column = 11; + string code = 12; } message DiagnosticMessage { diff --git a/test/analysis_server_test.dart b/test/analysis_server_test.dart index 700bb6ef..8437bc89 100644 --- a/test/analysis_server_test.dart +++ b/test/analysis_server_test.dart @@ -103,9 +103,11 @@ void defineTests() { expect(results.issues.length, 1); final issue = results.issues[0]; expect(issue.line, 2); + expect(issue.column, 7); expect(issue.kind, 'info'); expect(issue.message, 'An uninitialized variable should have an explicit type annotation.'); + expect(issue.code, 'prefer_typing_uninitialized_variables'); }); test('repro #126 - completions polluted on second request', () async { diff --git a/test/common_server_api_test.dart b/test/common_server_api_test.dart index 02ddf5da..048ae45d 100644 --- a/test/common_server_api_test.dart +++ b/test/common_server_api_test.dart @@ -200,6 +200,8 @@ void main() { 'hasFixes': true, 'charStart': 29, 'charLength': 1, + 'column': 16, + 'code': 'expected_token', } ] }, @@ -677,6 +679,8 @@ void main() { 'hasFixes': true, 'charStart': 29, 'charLength': 1, + 'column': 16, + 'code': 'expected_token', } ] },