belatuk_code_buffer

Creator: coderz1093

Last updated:

0 purchases

belatuk_code_buffer Image
belatuk_code_buffer Images

Languages

Categories

Add to Cart

Description:

belatuk code buffer

Belatuk Code Buffer #



Replacement of package:code_buffer with breaking changes to support NNBD.
An advanced StringBuffer geared toward generating code, and source maps.
Installation #
In your pubspec.yaml:
dependencies:
belatuk_code_buffer: ^5.1.0
copied to clipboard
Usage #
Use a CodeBuffer just like any regular StringBuffer:
String someFunc() {
var buf = CodeBuffer();
buf
..write('hello ')
..writeln('world!');
return buf.toString();
}
copied to clipboard
However, a CodeBuffer supports indentation.
void someOtherFunc() {
var buf = CodeBuffer();
// Custom options...
var buf = CodeBuffer(newline: '\r\n', space: '\t', trailingNewline: true);

// Any following lines will have an incremented indentation level...
buf.indent();

// And vice-versa:
buf.outdent();
}
copied to clipboard
CodeBuffer instances keep track of every SourceSpan they create.
This makes them useful for codegen tools, or to-JS compilers.
void someFunc(CodeBuffer buf) {
buf.write('hello');
expect(buf.lastLine.text, 'hello');

buf.writeln('world');
expect(buf.lastLine.lastSpan.start.column, 5);
}
copied to clipboard
You can copy a CodeBuffer into another, heeding indentation rules:
void yetAnotherFunc(CodeBuffer a, CodeBuffer b) {
b.copyInto(a);
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.