Skip to content

Commit

Permalink
Version 2.10.0-77.0.dev
Browse files Browse the repository at this point in the history
Merge commit '0967d19156acc5ca4fc1cf7dcc129d6c680f3696' into 'dev'
  • Loading branch information
Dart CI committed Aug 31, 2020
2 parents 92782d2 + 0967d19 commit 84c3eac
Show file tree
Hide file tree
Showing 155 changed files with 2,613 additions and 908 deletions.
4 changes: 2 additions & 2 deletions .dart_tool/package_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
"name": "csslib",
"rootUri": "../third_party/pkg/csslib",
"packageUri": "lib/",
"languageVersion": "2.2"
"languageVersion": "2.10"
},
{
"name": "dart2js_info",
Expand Down Expand Up @@ -752,4 +752,4 @@
"languageVersion": "2.4"
}
]
}
}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

* Adds `Abort` method to class `HttpClientRequest`, which allows users
to cancel outgoing HTTP requests and stop following IO operations.
* A validtion check is added to `path` of class `Cookie`. Having characters
* A validation check is added to `path` of class `Cookie`. Having characters
ranging from 0x00 to 0x1f and 0x3b (";") will lead to a `FormatException`.

#### `dart:typed_data`
Expand Down
6 changes: 3 additions & 3 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ vars = {
# co19 is a cipd package. Use update.sh in tests/co19[_2] to update these
# hashes. It requires access to the dart-build-access group, which EngProd
# has.
"co19_rev": "d94e371b8aafa3f4b88821c63a5ef1f618c2124d",
"co19_rev": "12855e59cd7e031d076cc8cece9f5ee08e77ca8c",
"co19_2_rev": "e48b3090826cf40b8037648f19d211e8eab1b4b6",

# The internal benchmarks to use. See go/dart-benchmarks-internal
Expand Down Expand Up @@ -79,8 +79,8 @@ vars = {
"collection_rev": "583693680fc067e34ca5b72503df25e8b80579f9",
"convert_rev": "c1b01f832835d3d8a06b0b246a361c0eaab35d3c",
"crypto_rev": "f7c48b334b1386bc5ab0f706fbcd6df8496a87fc",
"csslib_rev": "451448a9ac03f87a8d0377fc0b411d8c388a6cb4",
"dart2js_info_rev" : "94ba36cb77067f28b75a4212e77b810a2d7385e9",
"csslib_rev": "166d3e07eabc8283c6137cfde17fb25b8bb40080",
"dart2js_info_rev" : "0632a623b08e1f601c7eba99e0186a581ae799e9",

# Note: Updates to dart_style have to be coordinated with the infrastructure
# team so that the internal formatter in `tools/sdks/dart-sdk/bin/dartfmt`
Expand Down
5 changes: 3 additions & 2 deletions pkg/_fe_analyzer_shared/lib/src/scanner/abstract_scanner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1894,8 +1894,9 @@ abstract class AbstractScanner implements Scanner {
codeUnits.add(next);
next = advance();
}
appendToken(new StringToken.fromString(TokenType.IDENTIFIER,
new String.fromCharCodes(codeUnits), charOffset));
appendToken(new StringToken.fromString(
TokenType.IDENTIFIER, new String.fromCharCodes(codeUnits), charOffset,
precedingComments: comments));
return next;
} else {
prependErrorToken(errorToken);
Expand Down
9 changes: 7 additions & 2 deletions pkg/analysis_server/lib/src/computer/computer_highlights.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DartUnitHighlightsComputer {

void _addCommentRanges() {
var token = _unit.beginToken;
do {
while (token != null) {
Token commentToken = token.precedingComments;
while (commentToken != null) {
HighlightRegionType highlightType;
Expand All @@ -44,8 +44,13 @@ class DartUnitHighlightsComputer {
}
commentToken = commentToken.next;
}
if (token.type == TokenType.EOF) {
// Only exit the loop *after* processing the EOF token as it may
// have preceeding comments.
break;
}
token = token.next;
} while (token != null && token.type != TokenType.EOF);
}
}

void _addIdentifierRegion(SimpleIdentifier node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DartUnitHighlightsComputer2 {

void _addCommentRanges() {
var token = _unit.beginToken;
do {
while (token != null) {
Token commentToken = token.precedingComments;
while (commentToken != null) {
HighlightRegionType highlightType;
Expand All @@ -44,8 +44,13 @@ class DartUnitHighlightsComputer2 {
}
commentToken = commentToken.next;
}
if (token.type == TokenType.EOF) {
// Only exit the loop *after* processing the EOF token as it may
// have preceeding comments.
break;
}
token = token.next;
} while (token != null && token.type != TokenType.EOF);
}
}

void _addIdentifierRegion(SimpleIdentifier node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:analysis_server/src/services/correction/dart/add_override.dart';
import 'package:analysis_server/src/services/correction/dart/convert_add_all_to_spread.dart';
import 'package:analysis_server/src/services/correction/dart/convert_conditional_expression_to_if_element.dart';
import 'package:analysis_server/src/services/correction/dart/convert_documentation_into_line.dart';
import 'package:analysis_server/src/services/correction/dart/convert_map_from_iterable_to_for_literal.dart';
import 'package:analysis_server/src/services/correction/dart/convert_quotes.dart';
import 'package:analysis_server/src/services/correction/dart/convert_to_contains.dart';
import 'package:analysis_server/src/services/correction/dart/convert_to_generic_function_syntax.dart';
Expand Down Expand Up @@ -86,6 +87,8 @@ class BulkFixProcessor {
LintNames.prefer_equal_for_default_values:
ReplaceColonWithEquals.newInstance,
LintNames.prefer_final_fields: MakeFinal.newInstance,
LintNames.prefer_for_elements_to_map_fromIterable:
ConvertMapFromIterableToForLiteral.newInstance,
LintNames.prefer_generic_function_type_aliases:
ConvertToGenericFunctionSyntax.newInstance,
LintNames.prefer_if_elements_to_conditional_expressions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class TransformSetErrorCode extends ErrorCode {
* Parameters:
* 0: the unsupported key
*/
static const TransformSetErrorCode unsupportedKey = TransformSetErrorCode(
'unsupported_key', "The key '{0}' isn't supported.");
static const TransformSetErrorCode unsupportedKey =
TransformSetErrorCode('unsupportedKey', "The key '{0}' isn't supported.");

/**
* Parameters:
* 0: the message produced by the YAML parser
*/
static const TransformSetErrorCode yamlSyntaxError =
TransformSetErrorCode('yaml_syntax_error', "{0}");
TransformSetErrorCode('yamlSyntaxError', "{0}");

/// Initialize a newly created error code.
const TransformSetErrorCode(String name, String message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ class TransformSetParser {
/// [errorReporter].
TransformSetParser(this.errorReporter);

/// Return the result of parsing the file [content] into a transform set.
/// Return the result of parsing the file [content] into a transform set, or
/// `null` if the content does not represent a valid transform set.
TransformSet parse(String content) {
assert(content != null);
var map = _parseYaml(content);
if (map == null) {
return TransformSet();
// The error has already been reported.
return null;
}
return _translateTransformSet(map);
}
Expand Down Expand Up @@ -89,7 +91,8 @@ class TransformSetParser {
}
}

/// Translate the [node] into a change.
/// Translate the [node] into a change. Return the resulting change, or `null`
/// if the [node] does not represent a valid change.
Change _translateChange(YamlNode node) {
if (node is YamlMap) {
var kind = _translateString(node.valueAt(_kindKey));
Expand All @@ -108,12 +111,22 @@ class TransformSetParser {
}
}

/// Translate the [node] into an element descriptor.
/// Translate the [node] into an element descriptor. Return the resulting
/// descriptor, or `null` if the [node] does not represent a valid element
/// descriptor.
ElementDescriptor _translateElement(YamlNode node) {
if (node is YamlMap) {
var uris = _translateList(node.valueAt(_urisKey), _translateString);
if (uris == null) {
// The error has already been reported.
return null;
}
var components =
_translateList(node.valueAt(_componentsKey), _translateString);
if (components == null) {
// The error has already been reported.
return null;
}
return ElementDescriptor(libraryUris: uris, components: components);
} else if (node == null) {
// TODO(brianwilkerson) Report the missing YAML.
Expand All @@ -124,7 +137,8 @@ class TransformSetParser {
}
}

/// Translate the [node] into an integer.
/// Translate the [node] into an integer. Return the resulting integer, or
/// `null` if the [node] does not represent a valid integer.
int _translateInteger(YamlNode node) {
if (node is YamlScalar) {
var value = node.value;
Expand All @@ -146,6 +160,9 @@ class TransformSetParser {
}

/// Translate the [node] into a list of objects using the [elementTranslator].
/// Return the resulting list, or `null` if the [node] does not represent a
/// valid list. If any of the elements of the list can't be translated, they
/// will be omitted from the list but the valid elements will be returned.
List<R> _translateList<R>(
YamlNode node, R Function(YamlNode) elementTranslator) {
if (node is YamlList) {
Expand All @@ -166,14 +183,19 @@ class TransformSetParser {
}
}

/// Translate the [node] into a rename change.
/// Translate the [node] into a rename change. Return the resulting change, or
/// `null` if the [node] does not represent a valid rename change.
Change _translateRenameChange(YamlMap node) {
_reportUnsupportedKeys(node, const {_kindKey, _newNameKey});
var newName = _translateString(node.valueAt(_newNameKey));
if (newName == null) {
return null;
}
return Rename(newName: newName);
}

/// Translate the [node] into a string.
/// Translate the [node] into a string. Return the resulting string, or `null`
/// if the [node] does not represent a valid string.
String _translateString(YamlNode node) {
if (node is YamlScalar) {
var value = node.value;
Expand All @@ -194,14 +216,19 @@ class TransformSetParser {
}
}

/// Translate the [node] into a transform.
/// Translate the [node] into a transform. Return the resulting transform, or
/// `null` if the [node] does not represent a valid transform.
Transform _translateTransform(YamlNode node) {
if (node is YamlMap) {
_reportUnsupportedKeys(node, const {_changesKey, _elementKey, _titleKey});
var title = _translateString(node.valueAt(_titleKey));
var element = _translateElement(node.valueAt(_elementKey));
var changes =
_translateList<Change>(node.valueAt(_changesKey), _translateChange);
if (changes == null) {
// The error has already been reported.
return null;
}
return Transform(title: title, element: element, changes: changes);
} else if (node == null) {
// TODO(brianwilkerson) Report the missing YAML.
Expand All @@ -212,7 +239,8 @@ class TransformSetParser {
}
}

/// Translate the [node] into a transform set.
/// Translate the [node] into a transform set. Return the resulting transform
/// set, or `null` if the [node] does not represent a valid transform set.
TransformSet _translateTransformSet(YamlNode node) {
if (node is YamlMap) {
_reportUnsupportedKeys(node, const {_transformsKey, _versionKey});
Expand All @@ -225,6 +253,10 @@ class TransformSetParser {
}
var transformations =
_translateList(node.valueAt(_transformsKey), _translateTransform);
if (transformations == null) {
// The error has already been reported.
return null;
}
for (var transform in transformations) {
set.addTransform(transform);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ class Highlights2ComputerTest extends AbstractContextTest {
sourcePath = convertPath('/home/test/lib/test.dart');
}

Future<void> test_comment() async {
await _computeHighlights('''
// A trailing comment
''');
_check(HighlightRegionType.COMMENT_END_OF_LINE, '// A trailing comment');
}

Future<void> test_comment_trailing() async {
await _computeHighlights('''
class A {}
// A trailing comment
''');
_check(HighlightRegionType.COMMENT_END_OF_LINE, '// A trailing comment');
}

Future<void> test_extension() async {
await _computeHighlights('''
extension E on String {}
Expand Down Expand Up @@ -62,13 +77,6 @@ void main() {
_check(HighlightRegionType.KEYWORD, 'throw');
}

Future<void> test_trailingComment() async {
await _computeHighlights('''
// A trailing comment
''');
_check(HighlightRegionType.COMMENT_END_OF_LINE, '// A trailing comment');
}

void _check(HighlightRegionType expectedType, String expectedText) {
for (var region in highlights) {
if (region.type == expectedType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ class HighlightsComputerTest extends AbstractContextTest {
sourcePath = convertPath('/home/test/lib/test.dart');
}

Future<void> test_comment() async {
await _computeHighlights('''
// A trailing comment
''');
_check(HighlightRegionType.COMMENT_END_OF_LINE, '// A trailing comment');
}

Future<void> test_comment_trailing() async {
await _computeHighlights('''
class A {}
// A trailing comment
''');
_check(HighlightRegionType.COMMENT_END_OF_LINE, '// A trailing comment');
}

Future<void> test_extension() async {
await _computeHighlights('''
extension E on String {}
Expand All @@ -48,13 +63,6 @@ main() {
_check(HighlightRegionType.IDENTIFIER_DEFAULT, 'foo');
}

Future<void> test_trailingComment() async {
await _computeHighlights('''
// A trailing comment
''');
_check(HighlightRegionType.COMMENT_END_OF_LINE, '// A trailing comment');
}

void _check(HighlightRegionType expectedType, String expectedText) {
for (var region in highlights) {
if (region.type == expectedType) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:analysis_server/src/services/linter/lint_names.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';

import 'bulk_fix_processor.dart';

void main() {
defineReflectiveSuite(() {
defineReflectiveTests(ConvertToForElementTest);
});
}

@reflectiveTest
class ConvertToForElementTest extends BulkFixProcessorTest {
@override
String get lintCode => LintNames.prefer_for_elements_to_map_fromIterable;

Future<void> test_singleFile() async {
await resolveTestUnit('''
f(Iterable<int> i) {
var k = 3;
return Map.fromIterable(i, key: (k) => k * 2, value: (v) => k);
}
f2(Iterable<int> i) {
return Map.fromIterable(i, key: (k) => k * 2, value: (v) => 0);
}
''');
await assertHasFix('''
f(Iterable<int> i) {
var k = 3;
return { for (var e in i) e * 2 : k };
}
f2(Iterable<int> i) {
return { for (var k in i) k * 2 : 0 };
}
''');
}
}
Loading

0 comments on commit 84c3eac

Please sign in to comment.