Version 2.12.0-160.0.dev
Merge commit '543364df65673d4c42d0dbbcea77d91415d9be08' into 'dev'
diff --git a/pkg/analysis_server/lib/src/lsp/semantic_tokens/encoder.dart b/pkg/analysis_server/lib/src/lsp/semantic_tokens/encoder.dart
index 903aa12..b3e34c0 100644
--- a/pkg/analysis_server/lib/src/lsp/semantic_tokens/encoder.dart
+++ b/pkg/analysis_server/lib/src/lsp/semantic_tokens/encoder.dart
@@ -33,21 +33,22 @@
Iterable<HighlightRegion> translatedRegions = regions;
+ // Remove any tokens that will not be mapped as there's no point further processing
+ // them (eg. splitting multiline/overlaps) if they will be dropped.
+ translatedRegions = translatedRegions
+ .where((region) => highlightRegionTokenTypes.containsKey(region.type));
+
if (!allowMultilineTokens) {
translatedRegions = translatedRegions.expand(
(region) => _splitMultilineRegions(region, lineInfo, fileContent));
}
+
if (!allowOverlappingTokens) {
translatedRegions = _splitOverlappingTokens(translatedRegions);
}
for (final region in translatedRegions) {
final tokenType = highlightRegionTokenTypes[region.type];
- if (tokenType == null) {
- // Skip over tokens we don't have mappings for.
- continue;
- }
-
final start = lineInfo.getLocation(region.offset);
tokens.add(SemanticTokenInfo(
@@ -142,8 +143,12 @@
return;
}
+ // When tokens have the same offset, the longest should come first so
+ // the nested token "overwrites" it during the flattening.
final sortedRegions = regions.toList()
- ..sort((r1, r2) => r1.offset.compareTo(r2.offset));
+ ..sort((r1, r2) => r1.offset != r2.offset
+ ? r1.offset.compareTo(r2.offset)
+ : -r1.length.compareTo(r2.length));
final firstRegion = sortedRegions.first;
final stack = ListQueue<HighlightRegion>()..add(firstRegion);
diff --git a/pkg/analysis_server/lib/src/services/correction/fix.dart b/pkg/analysis_server/lib/src/services/correction/fix.dart
index 8bd57b2..d097a92 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix.dart
@@ -259,8 +259,8 @@
'Convert to single quoted string');
static const CONVERT_TO_SPREAD =
FixKind('dart.fix.convert.toSpread', 50, 'Convert to a spread');
- static const CONVERT_TO_WHERE_TYPE = FixKind(
- 'dart.fix.convert.toWhereType', 50, "Convert to a use 'whereType'");
+ static const CONVERT_TO_WHERE_TYPE =
+ FixKind('dart.fix.convert.toWhereType', 50, "Convert to use 'whereType'");
static const CREATE_CLASS =
FixKind('dart.fix.create.class', 50, "Create class '{0}'");
static const CREATE_CONSTRUCTOR =
diff --git a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/changes_selector.dart b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/changes_selector.dart
index 85f7b7e..c441575 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/changes_selector.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/changes_selector.dart
@@ -26,7 +26,8 @@
@override
List<Change> getChanges(TemplateContext context) {
for (var entry in changeMap.entries) {
- if (entry.key.evaluateIn(context)) {
+ var value = entry.key.evaluateIn(context);
+ if (value is bool && value) {
return entry.value;
}
}
diff --git a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/value_generator.dart b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/value_generator.dart
index b59bac9..527669f 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/value_generator.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/value_generator.dart
@@ -21,8 +21,12 @@
@override
String evaluateIn(TemplateContext context) {
Object target = context.node;
- for (var accessor in accessors) {
- target = accessor.getValue(target).result;
+ for (var i = 0; i < accessors.length; i++) {
+ var result = accessors[i].getValue(target);
+ if (!result.isValid) {
+ return '';
+ }
+ target = result.result;
}
if (target is AstNode) {
return context.utils.getRangeText(range.node(target));
diff --git a/pkg/analysis_server/test/lsp/semantic_tokens_test.dart b/pkg/analysis_server/test/lsp/semantic_tokens_test.dart
index 50b5a3f..5c6836b 100644
--- a/pkg/analysis_server/test/lsp/semantic_tokens_test.dart
+++ b/pkg/analysis_server/test/lsp/semantic_tokens_test.dart
@@ -429,6 +429,44 @@
expect(decoded, equals(expected));
}
+ Future<void> test_manyImports_sortBug() async {
+ // This test is for a bug where some "import" tokens would not be highlighted
+ // correctly. Imports are made up of a DIRECTIVE token that spans a
+ // BUILT_IN ("import") and LITERAL_STRING. The original code sorted by only
+ // offset when handling overlapping tokens, which for certain lists (such as
+ // the one created for the code below) would result in the BUILTIN coming before
+ // the DIRECTIVE, which resulted in the DIRECTIVE overwriting it.
+ final content = '''
+import 'dart:async';
+import 'dart:async';
+import 'dart:async';
+import 'dart:async';
+import 'dart:async';
+import 'dart:async';
+import 'dart:async';
+import 'dart:async';
+import 'dart:async';
+import 'dart:async';
+import 'dart:async';
+import 'dart:async';
+import 'dart:async';
+ ''';
+
+ final expected = [
+ for (var i = 0; i < 13; i++) ...[
+ _Token('import', SemanticTokenTypes.keyword),
+ _Token("'dart:async'", SemanticTokenTypes.string),
+ ],
+ ];
+
+ await initialize();
+ await openFile(mainFileUri, withoutMarkers(content));
+
+ final tokens = await getSemanticTokens(mainFileUri);
+ final decoded = decodeSemanticTokens(content, tokens);
+ expect(decoded, equals(expected));
+ }
+
Future<void> test_multilineRegions() async {
final content = '''
/**
diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/flutter_use_case_test.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/flutter_use_case_test.dart
index 7932354..cca4aef 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/flutter_use_case_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/flutter_use_case_test.dart
@@ -1001,6 +1001,94 @@
''');
}
+ Future<void> test_material_Scaffold_of_missingArgument() async {
+ setPackageContent('''
+class Scaffold {
+ static ScaffoldState of(BuildContext context) => ScaffoldState();
+ static ScaffoldState maybeOf(BuildContext context) => ScaffoldState();
+}
+class ScaffoldState {}
+class BuildContext {}
+''');
+ addPackageDataFile('''
+version: 1
+transforms:
+ - title: 'Remove nullOk'
+ date: 2020-11-04
+ element:
+ uris: ['$importUri']
+ method: 'of'
+ inClass: 'Scaffold'
+ oneOf:
+ - if: "nullOk == 'true'"
+ changes:
+ - kind: 'rename'
+ newName: 'maybeOf'
+ - kind: 'removeParameter'
+ name: 'nullOk'
+ - if: "nullOk == 'false'"
+ changes:
+ - kind: 'removeParameter'
+ name: 'nullOk'
+ variables:
+ nullOk:
+ kind: 'fragment'
+ value: 'arguments[nullOk]'
+''');
+ await resolveTestCode('''
+import '$importUri';
+
+void f(BuildContext context) {
+ Scaffold.of(context, undefined: 3);
+}
+''');
+ await assertNoFix();
+ }
+
+ @failingTest
+ Future<void> test_material_Scaffold_of_wrongType() async {
+ setPackageContent('''
+class Theme {
+ static ThemeData of(BuildContext context, {bool shadowThemeOnly: false}) => ThemeData();
+}
+class ThemeData {}
+class BuildContext {}
+''');
+ addPackageDataFile('''
+version: 1
+transforms:
+ - title: 'Remove nullOk'
+ date: 2020-11-04
+ element:
+ uris: ['$importUri']
+ method: 'of'
+ inClass: 'Scaffold'
+ oneOf:
+ - if: "nullOk == 'true'"
+ changes:
+ - kind: 'rename'
+ newName: 'maybeOf'
+ - kind: 'removeParameter'
+ name: 'nullOk'
+ - if: "nullOk == 'false'"
+ changes:
+ - kind: 'removeParameter'
+ name: 'nullOk'
+ variables:
+ nullOk:
+ kind: 'fragment'
+ value: 'arguments[nullOk]'
+''');
+ await resolveTestCode('''
+import '$importUri';
+
+void f(BuildContext context) {
+ Theme.of(context, nullOk: true);
+}
+''');
+ await assertNoFix();
+ }
+
Future<void>
test_material_Scaffold_resizeToAvoidBottomPadding_deprecated() async {
setPackageContent('''
diff --git a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
index 29516e9..84d29d8 100644
--- a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
+++ b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
@@ -511,8 +511,9 @@
YamlMap optionMap;
var separator = resourceProvider.pathContext.separator;
- var isThirdParty =
- path.contains('${separator}third_party${separator}dart$separator');
+ var isThirdParty = path
+ .contains('${separator}third_party${separator}dart$separator') ||
+ path.contains('${separator}third_party${separator}dart_lang$separator');
File optionsFile;
if (!isThirdParty) {
diff --git a/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart b/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart
index b462f39..2f77d87 100644
--- a/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart
+++ b/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart
@@ -273,6 +273,30 @@
]);
}
+ test_analysisOptions_file_inThirdPartyDartLang() async {
+ newFile('/workspace/dart/analysis_options/lib/third_party.yaml',
+ content: r'''
+analyzer:
+ strong-mode:
+ implicit-casts: false
+''');
+
+ newFile('/workspace/thid_party/dart_lang/aaa/analysis_options.yaml',
+ content: r'''
+analyzer:
+ strong-mode:
+ implicit-casts: true
+''');
+
+ var aPath = convertPath('/workspace/third_party/dart_lang/aaa/lib/a.dart');
+ await assertErrorsInFile(aPath, r'''
+num a = 0;
+int b = a;
+''', [
+ error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 19, 1),
+ ]);
+ }
+
test_analysisOptions_lints() async {
newFile('/workspace/dart/analysis_options/lib/default.yaml', content: r'''
linter:
diff --git a/pkg/front_end/test/unit_test_suites.dart b/pkg/front_end/test/unit_test_suites.dart
index a0d190f..0bd8b66 100644
--- a/pkg/front_end/test/unit_test_suites.dart
+++ b/pkg/front_end/test/unit_test_suites.dart
@@ -288,7 +288,7 @@
"../../testing.json"),
];
-const Duration timeoutDuration = Duration(minutes: 25);
+const Duration timeoutDuration = Duration(minutes: 30);
class SuiteConfiguration {
final String name;
diff --git a/runtime/bin/priority_heap_test.cc b/runtime/bin/priority_heap_test.cc
index 165f1a4..b0fdb5b 100644
--- a/runtime/bin/priority_heap_test.cc
+++ b/runtime/bin/priority_heap_test.cc
@@ -1,6 +1,6 @@
-// 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.md file.
+// 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.
#include "vm/unit_test.h"
diff --git a/runtime/observatory_2/tests/service_2/breakpoint_in_package_parts_class_file_uri_test.dart b/runtime/observatory_2/tests/service_2/breakpoint_in_package_parts_class_file_uri_test.dart
index 03a57f6..da48c7d 100644
--- a/runtime/observatory_2/tests/service_2/breakpoint_in_package_parts_class_file_uri_test.dart
+++ b/runtime/observatory_2/tests/service_2/breakpoint_in_package_parts_class_file_uri_test.dart
@@ -14,7 +14,8 @@
// Chop off the file name.
String baseDirectory = path.dirname(Platform.script.path) + '/';
Uri baseUri = Platform.script.replace(path: baseDirectory);
-Uri breakpointFile = baseUri.resolve('observatory_test_package/the_part.dart');
+Uri breakpointFile =
+ baseUri.resolve('observatory_test_package_2/the_part.dart');
const String shortFile = "the_part.dart";
const int LINE = 87;
diff --git a/tools/VERSION b/tools/VERSION
index 5e98251..6bda5c1 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 12
PATCH 0
-PRERELEASE 159
+PRERELEASE 160
PRERELEASE_PATCH 0
\ No newline at end of file