class JavaCompilationMessage inherits SourceException test line = 'hello.cobra.java:30: package Foo does not exist' assert not JavaCompilationMessage.willSkipMessage(line) msg = JavaCompilationMessage(line, TestCompiler()) assert msg.isError assert msg.hasSourceSite assert 'hello.cobra' in msg.fileName assert 'package Foo does not exist' in msg.message assert msg.lineNum == 30 def willSkipMessage(msg as String) as bool is shared return not '.java:' in msg #return false var _fileName as String? var _lineNum as int? var _isError as bool var _lpad = -1 cue init(line as String, compiler as Compiler) require not .willSkipMessage(line) base.init(line) # trace line line = line.trim _isError = true i = line.indexOf('.java:') if i >= 0 _fileName = line[:i] i += '.java:'.length j = line.indexOf(':', i) lineStr = line[i:j] _storeLineNum(lineStr, compiler) if compiler.verbosity or Utils.isDevMachine, line += ' (javac)' _message = _cleanUp(line) def append(line as String, compiler as Compiler) #line = line.trim if _lpad == -1 lineTrim = line.trimStart _lpad = line.length - lineTrim.length line = line.trim else if line.trim == '^' line = line[_lpad:] _message += '\n >: ' + line if System.Text.RegularExpressions.Regex.isMatch(line, r'// \d+\s*$') lidx = line.lastIndexOf('//') if lidx > 0 lidx += 3 # after '// ' lineStr = line[lidx:] _storeLineNum(lineStr, compiler) def _storeLineNum(lineStr as String, compiler as Compiler) try _lineNum = int.parse(lineStr) catch pass success _lineNum = compiler.cobraLineNumForCurly(.fileName, _lineNum to !) def _cleanUp(line as String) as String line = line.replace("`double'", "`float'") line = line.replace("null", "nil") # change C#'s `funky' quotes to double quotes line = line.replace("`", '"') line = line.replace("'", '"') return line get isError as bool is override return _isError get hasSourceSite as bool is override return _fileName is not nil get fileName as String is override return _fileName to ! get lineNum as int is override return _lineNum to !