diff --git a/src/main/scala/com/neowit/apex/parser/SourceScanner.scala b/src/main/scala/com/neowit/apex/parser/SourceScanner.scala index 3fce11f9..040768f6 100644 --- a/src/main/scala/com/neowit/apex/parser/SourceScanner.scala +++ b/src/main/scala/com/neowit/apex/parser/SourceScanner.scala @@ -29,16 +29,25 @@ class SourceScanner (files: List[File]) extends Logging { if (completeScan || file.lastModified() > lastModifiedTime) { logger.debug("scanning file: " + file.getName) - val tokens = new CommonTokenStream(getLexer(file)) - val parser = new ApexcodeParser(tokens) - ApexParserUtils.removeConsoleErrorListener(parser) - //parser.setErrorHandler(new BailErrorStrategy()) - //parser.setErrorHandler(new CompletionErrorStrategy()) - val tree = parser.compilationUnit() - val extractor = new TreeListener(parser) - walker.walk(extractor, tree) - completeTree.extend(extractor.getTree) - fileModificationTimes.+=(file.getAbsolutePath -> file.lastModified()) + try { + val tokens = new CommonTokenStream(getLexer(file)) + val parser = new ApexcodeParser(tokens) + ApexParserUtils.removeConsoleErrorListener(parser) + //parser.setErrorHandler(new BailErrorStrategy()) + //parser.setErrorHandler(new CompletionErrorStrategy()) + val tree = parser.compilationUnit() + val extractor = new TreeListener(parser) + walker.walk(extractor, tree) + completeTree.extend(extractor.getTree) + fileModificationTimes.+=(file.getAbsolutePath -> file.lastModified()) + } catch { + case ex:Exception => + logger.error("Failed to parse file: " + file.getName, ex) + logger.error(ex.getStackTraceString) + println("Failed to parse file: " + file.getName) + println(ex) + println(ex.getStackTraceString) + } } } //println(getTree) diff --git a/src/main/scala/com/neowit/utils/Logging.scala b/src/main/scala/com/neowit/utils/Logging.scala index 28832071..a19f154a 100644 --- a/src/main/scala/com/neowit/utils/Logging.scala +++ b/src/main/scala/com/neowit/utils/Logging.scala @@ -32,7 +32,7 @@ trait Logging { def fatal(msg: Any) = if (log.isFatalEnabled) log.fatal(msg) def fatal(msg: Any, ex: Throwable) = if (log.isFatalEnabled) log.fatal(msg, ex) - def error(msg: Any) = if (log.isInfoEnabled) log.error(msg) + def error(msg: Any) = if (log.isErrorEnabled) log.error(msg) def error(msg: Any, ex: Throwable) = if (log.isErrorEnabled) log.error(msg, ex) def warn(msg: Any) = if (log.isWarnEnabled) log.warn(msg)