Skip to content

Commit

Permalink
failure to parse a specific file should not cause the failure of apex…
Browse files Browse the repository at this point in the history
… completion in other project files
  • Loading branch information
neowit committed Dec 29, 2014
1 parent c0fac6d commit 46b946d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
29 changes: 19 additions & 10 deletions src/main/scala/com/neowit/apex/parser/SourceScanner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/neowit/utils/Logging.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 46b946d

Please sign in to comment.