Update code_buffer
This commit is contained in:
parent
03857aba7c
commit
94d3adb3f1
7 changed files with 20 additions and 13 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
# 2.0.3
|
||||||
|
* Resolved static analysis warnings
|
||||||
|
|
||||||
# 2.0.2
|
# 2.0.2
|
||||||
* Updated README
|
* Updated README
|
||||||
# 2.0.1
|
# 2.0.1
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# angel3_code_buffer
|
# angel3_code_buffer
|
||||||
[](https://pub.dartlang.org/packages/angel3_code_buffer)
|
[](https://pub.dartlang.org/packages/angel3_code_buffer)
|
||||||
[](https://dart.dev/null-safety)
|
[](https://dart.dev/null-safety)
|
||||||
[](https://gitter.im/angel_dart/discussion)
|
[](https://gitter.im/angel_dart/discussion)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
include: package:pedantic/analysis_options.yaml
|
||||||
analyzer:
|
analyzer:
|
||||||
strong-mode:
|
strong-mode:
|
||||||
implicit-casts: false
|
implicit-casts: false
|
|
@ -3,7 +3,7 @@ import 'package:test/test.dart';
|
||||||
|
|
||||||
/// Use a `CodeBuffer` just like any regular `StringBuffer`:
|
/// Use a `CodeBuffer` just like any regular `StringBuffer`:
|
||||||
String someFunc() {
|
String someFunc() {
|
||||||
var buf = new CodeBuffer();
|
var buf = CodeBuffer();
|
||||||
buf
|
buf
|
||||||
..write('hello ')
|
..write('hello ')
|
||||||
..writeln('world!');
|
..writeln('world!');
|
||||||
|
@ -12,16 +12,16 @@ String someFunc() {
|
||||||
|
|
||||||
/// However, a `CodeBuffer` supports indentation.
|
/// However, a `CodeBuffer` supports indentation.
|
||||||
void someOtherFunc() {
|
void someOtherFunc() {
|
||||||
var buf = new CodeBuffer();
|
var buf = CodeBuffer();
|
||||||
|
|
||||||
// Custom options...
|
// Custom options...
|
||||||
// ignore: unused_local_variable
|
// ignore: unused_local_variable
|
||||||
var customBuf =
|
var customBuf =
|
||||||
new CodeBuffer(newline: '\r\n', space: '\t', trailingNewline: true);
|
CodeBuffer(newline: '\r\n', space: '\t', trailingNewline: true);
|
||||||
|
|
||||||
// Without whitespace..
|
// Without whitespace..
|
||||||
// ignore: unused_local_variable
|
// ignore: unused_local_variable
|
||||||
var minifyingBuf = new CodeBuffer.noWhitespace();
|
var minifyingBuf = CodeBuffer.noWhitespace();
|
||||||
|
|
||||||
// Any following lines will have an incremented indentation level...
|
// Any following lines will have an incremented indentation level...
|
||||||
buf.indent();
|
buf.indent();
|
||||||
|
|
|
@ -69,7 +69,7 @@ class CodeBuffer implements StringBuffer {
|
||||||
/// Copies the contents of this [CodeBuffer] into another, preserving indentation and source mapping information.
|
/// Copies the contents of this [CodeBuffer] into another, preserving indentation and source mapping information.
|
||||||
void copyInto(CodeBuffer other) {
|
void copyInto(CodeBuffer other) {
|
||||||
if (_lines.isEmpty) return;
|
if (_lines.isEmpty) return;
|
||||||
int i = 0;
|
var i = 0;
|
||||||
|
|
||||||
for (var line in _lines) {
|
for (var line in _lines) {
|
||||||
// To compute offset:
|
// To compute offset:
|
||||||
|
@ -175,25 +175,27 @@ class CodeBuffer implements StringBuffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void writeln([Object? obj = ""]) {
|
void writeln([Object? obj = '']) {
|
||||||
if (obj != null && obj != '') write(obj);
|
if (obj != null && obj != '') write(obj);
|
||||||
_currentLine = null;
|
_currentLine = null;
|
||||||
_length++;
|
_length++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void writeAll(Iterable objects, [String separator = ""]) {
|
void writeAll(Iterable objects, [String separator = '']) {
|
||||||
write(objects.join(separator));
|
write(objects.join(separator));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
var buf = StringBuffer();
|
var buf = StringBuffer();
|
||||||
int i = 0;
|
var i = 0;
|
||||||
|
|
||||||
for (var line in lines) {
|
for (var line in lines) {
|
||||||
if (i++ > 0) buf.write(newline);
|
if (i++ > 0) buf.write(newline);
|
||||||
for (int j = 0; j < line.indentationLevel; j++) buf.write(space);
|
for (var j = 0; j < line.indentationLevel; j++) {
|
||||||
|
buf.write(space);
|
||||||
|
}
|
||||||
buf.write(line._buf.toString());
|
buf.write(line._buf.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: angel3_code_buffer
|
name: angel3_code_buffer
|
||||||
version: 2.0.2
|
version: 2.0.3
|
||||||
description: An advanced StringBuffer geared toward generating code, and source maps.
|
description: An advanced StringBuffer geared toward generating code, and source maps.
|
||||||
homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/code_buffer
|
homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/code_buffer
|
||||||
environment:
|
environment:
|
||||||
|
@ -9,3 +9,4 @@ dependencies:
|
||||||
source_span: ^1.8.1
|
source_span: ^1.8.1
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
test: ^1.17.3
|
test: ^1.17.3
|
||||||
|
pedantic: ^1.11.0
|
||||||
|
|
|
@ -2,7 +2,7 @@ import 'package:charcode/charcode.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
import 'package:angel3_code_buffer/angel3_code_buffer.dart';
|
import 'package:angel3_code_buffer/angel3_code_buffer.dart';
|
||||||
|
|
||||||
main() {
|
void main() {
|
||||||
var buf = CodeBuffer();
|
var buf = CodeBuffer();
|
||||||
tearDown(buf.clear);
|
tearDown(buf.clear);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue