dart - Modifying strings with source_span package in dartlang? -


i want transform parts of source files own transformer in dart. have dart file input , want edit file. know can contents of file with:

  var content = transform.primaryinput.readasstring(encoding: utf8); 

from inside transformers. know how find offset in source want apply changes.

is there kind of "cursor"-style editing package strings in dart? want kind of (pseudo-code!):

string sourcestring = transform.primaryinput.readasstring(encoding: utf8); //sourcefile comes source_span package, wrapped cursor implementation sourcefile source = new sourcefile(sourcestring); var cursor = new cursor(sourcefile);  //.jumpto(int linenumber, [int columnnumber]) cursor.jumpto(30); //deletes next 2 chars cursor.delete(2); //adds new text after cursor cursor.write("hello world!"); //accept sourcespans deletion cursor.delete(sourcespanobject) 

or there better way change contents of source files in transfomers in dart?


Comments

Popular posts from this blog

How to use SUM() in MySQL for calculated values -

loops - Spock: How to use test data with @Stepwise -