throw RuntimeExceptionFactory.io(values.string(e.getMessage()), null, null);
}
}
private IList consumeInputStreamLines(ISourceLocation sloc, Reader stream, RascalExecutionContext rex ) {
IListWriter w = values.listWriter();
BufferedReader in = null;
try{
in = new BufferedReader(stream);
java.lang.String line;
int i = 0;
// int offset = sloc.getOffset();
int beginLine = sloc.hasLineColumn() ? sloc.getBeginLine() : -1;
int beginColumn = sloc.hasLineColumn() ? sloc.getBeginColumn() : -1;
int endLine = sloc.hasLineColumn() ? sloc.getEndLine() : -1;
int endColumn = sloc.hasLineColumn() ? sloc.getEndColumn() : -1;
do{
line = in.readLine();
i++;
if(line != null){
if(!sloc.hasOffsetLength()){
w.append(values.string(line));
}else{
if(!sloc.hasLineColumn()){
endColumn = line.length();
}
if(i == beginLine){
if(i == endLine){
w.append(values.string(line.substring(beginColumn, Math.min(endColumn, line.length()))));
}else{
w.append(values.string(line.substring(beginColumn)));
}
}else if(i > beginLine){
if(i == endLine){
w.append(values.string(line.substring(0, Math.min(endColumn, line.length()))));
}
else if(i < endLine){
w.append(values.string(line));
}
}
}
}
}while(line != null);
}catch(IOException e){
throw RuntimeExceptionFactory.io(values.string(e.getMessage()), null, null);
}finally{
if(in != null){
try{
in.close();
}catch(IOException ioex){
throw RuntimeExceptionFactory.io(values.string(ioex.getMessage()), null, null);
}
}
}
return w.done();
}