try use_string_buffers lint (#10034)
This commit is contained in:
committed by
GitHub
parent
18eac03d76
commit
5bce52d6be
@@ -136,7 +136,7 @@ linter:
|
||||
- unnecessary_this
|
||||
# - use_rethrow_when_possible # not yet tested
|
||||
# - use_setters_to_change_properties # not yet tested
|
||||
# - use_string_buffers # not yet tested
|
||||
# - use_string_buffers # https://github.com/dart-lang/linter/pull/664
|
||||
# - use_to_and_as_if_applicable # not yet tested
|
||||
|
||||
# === pub rules ===
|
||||
|
||||
@@ -134,7 +134,7 @@ linter:
|
||||
- unnecessary_this
|
||||
# - use_rethrow_when_possible # not yet tested
|
||||
# - use_setters_to_change_properties # not yet tested
|
||||
# - use_string_buffers # not yet tested
|
||||
# - use_string_buffers # https://github.com/dart-lang/linter/pull/664
|
||||
# - use_to_and_as_if_applicable # not yet tested
|
||||
|
||||
# === pub rules ===
|
||||
|
||||
@@ -349,19 +349,21 @@ class ContainerLayer extends Layer {
|
||||
String debugDescribeChildren(String prefix) {
|
||||
if (firstChild == null)
|
||||
return '';
|
||||
String result = '$prefix \u2502\n';
|
||||
final StringBuffer result = new StringBuffer()
|
||||
..write(prefix)
|
||||
..write(' \u2502\n');
|
||||
Layer child = firstChild;
|
||||
int count = 1;
|
||||
while (child != lastChild) {
|
||||
result += '${child.toStringDeep("$prefix \u251C\u2500child $count: ", "$prefix \u2502")}';
|
||||
result.write(child.toStringDeep("$prefix \u251C\u2500child $count: ", "$prefix \u2502"));
|
||||
count += 1;
|
||||
child = child.nextSibling;
|
||||
}
|
||||
if (child != null) {
|
||||
assert(child == lastChild);
|
||||
result += '${child.toStringDeep("$prefix \u2514\u2500child $count: ", "$prefix ")}';
|
||||
result.write(child.toStringDeep("$prefix \u2514\u2500child $count: ", "$prefix "));
|
||||
}
|
||||
return result;
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3059,20 +3059,22 @@ abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, Parent
|
||||
@override
|
||||
String debugDescribeChildren(String prefix) {
|
||||
if (firstChild != null) {
|
||||
String result = '$prefix \u2502\n';
|
||||
final StringBuffer result = new StringBuffer()
|
||||
..write(prefix)
|
||||
..write(' \u2502\n');
|
||||
ChildType child = firstChild;
|
||||
int count = 1;
|
||||
while (child != lastChild) {
|
||||
result += '${child.toStringDeep("$prefix \u251C\u2500child $count: ", "$prefix \u2502")}';
|
||||
result.write(child.toStringDeep("$prefix \u251C\u2500child $count: ", "$prefix \u2502"));
|
||||
count += 1;
|
||||
final ParentDataType childParentData = child.parentData;
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
if (child != null) {
|
||||
assert(child == lastChild);
|
||||
result += '${child.toStringDeep("$prefix \u2514\u2500child $count: ", "$prefix ")}';
|
||||
result.write(child.toStringDeep("$prefix \u2514\u2500child $count: ", "$prefix "));
|
||||
}
|
||||
return result;
|
||||
return result.toString();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -590,15 +590,18 @@ class SemanticsNode extends AbstractNode {
|
||||
|
||||
/// Returns a string representation of this node and its descendants.
|
||||
String toStringDeep([String prefixLineOne = '', String prefixOtherLines = '']) {
|
||||
String result = '$prefixLineOne$this\n';
|
||||
final StringBuffer result = new StringBuffer()
|
||||
..write(prefixLineOne)
|
||||
..write(this)
|
||||
..write('\n');
|
||||
if (_children != null && _children.isNotEmpty) {
|
||||
for (int index = 0; index < _children.length - 1; index += 1) {
|
||||
final SemanticsNode child = _children[index];
|
||||
result += '${child.toStringDeep("$prefixOtherLines \u251C", "$prefixOtherLines \u2502")}';
|
||||
result.write(child.toStringDeep("$prefixOtherLines \u251C", "$prefixOtherLines \u2502"));
|
||||
}
|
||||
result += '${_children.last.toStringDeep("$prefixOtherLines \u2514", "$prefixOtherLines ")}';
|
||||
result.write(_children.last.toStringDeep("$prefixOtherLines \u2514", "$prefixOtherLines "));
|
||||
}
|
||||
return result;
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -476,16 +476,18 @@ abstract class RenderViewportBase<ParentDataClass extends ContainerParentDataMix
|
||||
if (firstChild == null)
|
||||
return '$prefix\n';
|
||||
int count = indexOfFirstChild;
|
||||
String result = '$prefix \u2502\n';
|
||||
final StringBuffer result = new StringBuffer()
|
||||
..write(prefix)
|
||||
..write(' \u2502\n');
|
||||
RenderSliver child = firstChild;
|
||||
while (child != lastChild) {
|
||||
result += '${child.toStringDeep("$prefix \u251C\u2500${labelForChild(count)}: ", "$prefix \u2502")}';
|
||||
result.write(child.toStringDeep("$prefix \u251C\u2500${labelForChild(count)}: ", "$prefix \u2502"));
|
||||
count += 1;
|
||||
child = childAfter(child);
|
||||
}
|
||||
assert(child == lastChild);
|
||||
result += '${child.toStringDeep("$prefix \u2514\u2500${labelForChild(count)}: ", "$prefix ")}';
|
||||
return result;
|
||||
result.write(child.toStringDeep("$prefix \u2514\u2500${labelForChild(count)}: ", "$prefix "));
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
// API TO BE IMPLEMENTED BY SUBCLASSES
|
||||
|
||||
@@ -2936,16 +2936,19 @@ abstract class Element implements BuildContext {
|
||||
|
||||
/// A detailed, textual description of this element, includings its children.
|
||||
String toStringDeep([String prefixLineOne = '', String prefixOtherLines = '']) {
|
||||
String result = '$prefixLineOne$this\n';
|
||||
final StringBuffer result = new StringBuffer()
|
||||
..write(prefixLineOne)
|
||||
..write(this)
|
||||
..write('\n');
|
||||
final List<Element> children = <Element>[];
|
||||
visitChildren(children.add);
|
||||
if (children.isNotEmpty) {
|
||||
final Element last = children.removeLast();
|
||||
for (Element child in children)
|
||||
result += '${child.toStringDeep("$prefixOtherLines\u251C", "$prefixOtherLines\u2502")}';
|
||||
result += '${last.toStringDeep("$prefixOtherLines\u2514", "$prefixOtherLines ")}';
|
||||
result.write(child.toStringDeep("$prefixOtherLines\u251C", "$prefixOtherLines\u2502"));
|
||||
result.write(last.toStringDeep("$prefixOtherLines\u2514", "$prefixOtherLines "));
|
||||
}
|
||||
return result;
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/// Returns true if the element has been marked as needing rebuilding.
|
||||
|
||||
@@ -560,26 +560,31 @@ class _RenderTheatre extends RenderBox
|
||||
|
||||
@override
|
||||
String debugDescribeChildren(String prefix) {
|
||||
String result = '';
|
||||
final StringBuffer result = new StringBuffer();
|
||||
if (child != null)
|
||||
result += '$prefix \u2502\n${child.toStringDeep('$prefix \u251C\u2500onstage: ', '$prefix \u254E')}';
|
||||
result
|
||||
..write(prefix)
|
||||
..write(' \u2502\n')
|
||||
..write(child.toStringDeep('$prefix \u251C\u2500onstage: ', '$prefix \u254E'));
|
||||
if (firstChild != null) {
|
||||
RenderBox child = firstChild;
|
||||
int count = 1;
|
||||
while (child != lastChild) {
|
||||
result += '${child.toStringDeep("$prefix \u254E\u254Coffstage $count: ", "$prefix \u254E")}';
|
||||
result.write(child.toStringDeep("$prefix \u254E\u254Coffstage $count: ", "$prefix \u254E"));
|
||||
count += 1;
|
||||
final StackParentData childParentData = child.parentData;
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
if (child != null) {
|
||||
assert(child == lastChild);
|
||||
result += '${child.toStringDeep("$prefix \u2514\u254Coffstage $count: ", "$prefix ")}';
|
||||
result.write(child.toStringDeep("$prefix \u2514\u254Coffstage $count: ", "$prefix "));
|
||||
}
|
||||
} else {
|
||||
result += '$prefix \u2514\u254Cno offstage children';
|
||||
result
|
||||
..write(prefix)
|
||||
..write(' \u2514\u254Cno offstage children');
|
||||
}
|
||||
return result;
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user