Skip to content

Commit

Permalink
Version 2.12.0-104.0.dev
Browse files Browse the repository at this point in the history
Merge commit '95ad66642eab0c1dbd97d8743276391e1cd56af1' into 'dev'
  • Loading branch information
Dart CI committed Dec 1, 2020
2 parents e9a03fd + 95ad666 commit 5acaa5f
Show file tree
Hide file tree
Showing 52 changed files with 452 additions and 1,145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'package:analysis_server/src/protocol_server.dart';
import 'package:analysis_server/src/services/completion/yaml/producer.dart';
import 'package:analysis_server/src/utilities/extensions/yaml.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:yaml/yaml.dart';

Expand Down Expand Up @@ -182,62 +183,3 @@ class YamlCompletionResults {
replacementOffset = 0,
replacementLength = 0;
}

extension on YamlMap {
/// Return the node representing the key that corresponds to the value
/// represented by the [value] node.
YamlNode keyAtValue(YamlNode value) {
for (var entry in nodes.entries) {
if (entry.value == value) {
return entry.key;
}
}
return null;
}
}

extension on YamlNode {
/// Return the child of this node that contains the given [offset], or `null`
/// if none of the children contains the offset.
YamlNode childContainingOffset(int offset) {
var node = this;
if (node is YamlList) {
for (var element in node.nodes) {
if (element.containsOffset(offset)) {
return element;
}
}
for (var element in node.nodes) {
if (element is YamlScalar && element.value == null) {
// TODO(brianwilkerson) Testing for a null value probably gets
// confused when there are multiple null values.
return element;
}
}
} else if (node is YamlMap) {
for (var entry in node.nodes.entries) {
if ((entry.key as YamlNode).containsOffset(offset)) {
return entry.key;
}
var value = entry.value;
if (value.containsOffset(offset) ||
(value is YamlScalar && value.value == null)) {
// TODO(brianwilkerson) Testing for a null value probably gets
// confused when there are multiple null values or when there is a
// null value before the node that actually contains the offset.
return entry.value;
}
}
}
return null;
}

/// Return `true` if this node contains the given [offset].
bool containsOffset(int offset) {
// TODO(brianwilkerson) Nodes at the end of the file contain any trailing
// whitespace. This needs to be accounted for, here or elsewhere.
var nodeOffset = span.start.offset;
var nodeEnd = nodeOffset + span.length;
return nodeOffset <= offset && offset <= nodeEnd;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1033,18 +1033,3 @@ class TransformSetParser {
}
}
}

extension on YamlMap {
// TODO(brianwilkerson) Copied from YamlCompletionGenerator. Refactor to a
// utility file that is shared between them.
/// Return the node representing the key that corresponds to the value
/// represented by the [value] node.
YamlNode keyAtValue(YamlNode value) {
for (var entry in nodes.entries) {
if (entry.value == value) {
return entry.key;
}
}
return null;
}
}
57 changes: 57 additions & 0 deletions pkg/analysis_server/lib/src/utilities/extensions/yaml.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
import 'package:yaml/yaml.dart';

extension YamlMapExtensions on YamlMap {
/// Return the node representing the key that corresponds to the value
/// represented by the [value] node.
YamlNode keyAtValue(YamlNode value) {
for (var entry in nodes.entries) {
if (entry.value == value) {
return entry.key;
}
}
return null;
}

/// Return the value associated with the key whose value matches the given
/// [key], or `null` if there is no matching key.
YamlNode valueAt(String key) {
Expand All @@ -16,3 +27,49 @@ extension YamlMapExtensions on YamlMap {
return null;
}
}

extension YamlNodeExtensions on YamlNode {
/// Return the child of this node that contains the given [offset], or `null`
/// if none of the children contains the offset.
YamlNode childContainingOffset(int offset) {
var node = this;
if (node is YamlList) {
for (var element in node.nodes) {
if (element.containsOffset(offset)) {
return element;
}
}
for (var element in node.nodes) {
if (element is YamlScalar && element.value == null) {
// TODO(brianwilkerson) Testing for a null value probably gets
// confused when there are multiple null values.
return element;
}
}
} else if (node is YamlMap) {
for (var entry in node.nodes.entries) {
if ((entry.key as YamlNode).containsOffset(offset)) {
return entry.key;
}
var value = entry.value;
if (value.containsOffset(offset) ||
(value is YamlScalar && value.value == null)) {
// TODO(brianwilkerson) Testing for a null value probably gets
// confused when there are multiple null values or when there is a
// null value before the node that actually contains the offset.
return entry.value;
}
}
}
return null;
}

/// Return `true` if this node contains the given [offset].
bool containsOffset(int offset) {
// TODO(brianwilkerson) Nodes at the end of the file contain any trailing
// whitespace. This needs to be accounted for, here or elsewhere.
var nodeOffset = span.start.offset;
var nodeEnd = nodeOffset + span.length;
return nodeOffset <= offset && offset <= nodeEnd;
}
}
11 changes: 6 additions & 5 deletions pkg/front_end/lib/src/fasta/kernel/body_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5950,11 +5950,12 @@ class BodyBuilder extends ScopeListener<JumpTarget>
if (builder?.next != null) {
// Duplicated name, already reported.
return <Initializer>[
new LocalInitializer(new VariableDeclaration.forValue(buildProblem(
fasta.templateDuplicatedDeclarationUse.withArguments(name),
fieldNameOffset,
name.length)))
..fileOffset = fieldNameOffset
buildInvalidInitializer(
buildProblem(
fasta.templateDuplicatedDeclarationUse.withArguments(name),
fieldNameOffset,
name.length),
fieldNameOffset)
];
} else if (builder is FieldBuilder && builder.isDeclarationInstanceMember) {
initializedFields ??= <String, int>{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class A extends core::Object {
constructor •(core::int* a) → self::A*
: final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/duplicated_field_initializer.dart:8:10: Error: Can't use 'a' because it is declared more than once.
A(this.a);
^", super core::Object::•()
^"
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class A extends core::Object {
constructor •(core::int* a) → self::A*
: final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/duplicated_field_initializer.dart:8:10: Error: Can't use 'a' because it is declared more than once.
A(this.a);
^", super core::Object::•()
^"
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class A extends core::Object {
constructor •(core::int* v) → self::A*
: final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/issue38938.dart:8:10: Error: Can't use 'v' because it is declared more than once.
A(this.v);
^", super core::Object::•()
^"
;
constructor second() → self::A*
: super core::Object::•()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class A extends core::Object {
constructor •(core::int* v) → self::A*
: final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/issue38938.dart:8:10: Error: Can't use 'v' because it is declared more than once.
A(this.v);
^", super core::Object::•()
^"
;
constructor second() → self::A*
: super core::Object::•()
Expand Down
16 changes: 16 additions & 0 deletions pkg/front_end/testcases/general/issue43363.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.

class E {
final int x;
final int y;
E() : this.named(),
this.x = 1;
this.y = 2;

E.named() : this.x = 5,
this.y = 6;
}

main() {}
47 changes: 47 additions & 0 deletions pkg/front_end/testcases/general/issue43363.dart.outline.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/general/issue43363.dart:10:9: Error: Expected a class member, but got 'this'.
// this.y = 2;
// ^^^^
//
// pkg/front_end/testcases/general/issue43363.dart:10:13: Error: Expected a class member, but got '.'.
// this.y = 2;
// ^
//
// pkg/front_end/testcases/general/issue43363.dart:10:14: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
// Try adding the name of the type of the variable or the keyword 'var'.
// this.y = 2;
// ^
//
// pkg/front_end/testcases/general/issue43363.dart:10:14: Error: 'y' is already declared in this scope.
// this.y = 2;
// ^
// pkg/front_end/testcases/general/issue43363.dart:7:13: Context: Previous declaration of 'y'.
// final int y;
// ^
//
import self as self;
import "dart:core" as core;

class E extends core::Object {
final field core::int* x;
final field core::int* y;
constructor •() → self::E*
;
constructor named() → self::E*
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
static method main() → dynamic
;
60 changes: 60 additions & 0 deletions pkg/front_end/testcases/general/issue43363.dart.strong.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/general/issue43363.dart:10:9: Error: Expected a class member, but got 'this'.
// this.y = 2;
// ^^^^
//
// pkg/front_end/testcases/general/issue43363.dart:10:13: Error: Expected a class member, but got '.'.
// this.y = 2;
// ^
//
// pkg/front_end/testcases/general/issue43363.dart:10:14: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
// Try adding the name of the type of the variable or the keyword 'var'.
// this.y = 2;
// ^
//
// pkg/front_end/testcases/general/issue43363.dart:10:14: Error: 'y' is already declared in this scope.
// this.y = 2;
// ^
// pkg/front_end/testcases/general/issue43363.dart:7:13: Context: Previous declaration of 'y'.
// final int y;
// ^
//
// pkg/front_end/testcases/general/issue43363.dart:9:16: Error: A redirecting constructor can't have other initializers.
// this.x = 1;
// ^
//
// pkg/front_end/testcases/general/issue43363.dart:13:20: Error: Can't use 'y' because it is declared more than once.
// this.y = 6;
// ^
//
import self as self;
import "dart:core" as core;

class E extends core::Object {
final field core::int* x;
final field core::int* y = null;
constructor •() → self::E*
: final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/issue43363.dart:9:16: Error: A redirecting constructor can't have other initializers.
this.x = 1;
^", this self::E::named()
;
constructor named() → self::E*
: self::E::x = 5, final dynamic #t2 = invalid-expression "pkg/front_end/testcases/general/issue43363.dart:13:20: Error: Can't use 'y' because it is declared more than once.
this.y = 6;
^"
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
static method main() → dynamic {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/general/issue43363.dart:10:9: Error: Expected a class member, but got 'this'.
// this.y = 2;
// ^^^^
//
// pkg/front_end/testcases/general/issue43363.dart:10:13: Error: Expected a class member, but got '.'.
// this.y = 2;
// ^
//
// pkg/front_end/testcases/general/issue43363.dart:10:14: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
// Try adding the name of the type of the variable or the keyword 'var'.
// this.y = 2;
// ^
//
// pkg/front_end/testcases/general/issue43363.dart:10:14: Error: 'y' is already declared in this scope.
// this.y = 2;
// ^
// pkg/front_end/testcases/general/issue43363.dart:7:13: Context: Previous declaration of 'y'.
// final int y;
// ^
//
// pkg/front_end/testcases/general/issue43363.dart:9:16: Error: A redirecting constructor can't have other initializers.
// this.x = 1;
// ^
//
// pkg/front_end/testcases/general/issue43363.dart:13:20: Error: Can't use 'y' because it is declared more than once.
// this.y = 6;
// ^
//
import self as self;
import "dart:core" as core;

class E extends core::Object {
final field core::int* x;
final field core::int* y = null;
constructor •() → self::E*
: final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/issue43363.dart:9:16: Error: A redirecting constructor can't have other initializers.
this.x = 1;
^", this self::E::named()
;
constructor named() → self::E*
: self::E::x = 5, final dynamic #t2 = invalid-expression "pkg/front_end/testcases/general/issue43363.dart:13:20: Error: Can't use 'y' because it is declared more than once.
this.y = 6;
^"
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
static method main() → dynamic {}
Loading

0 comments on commit 5acaa5f

Please sign in to comment.