final boolean initialParse, final String path, final String initialText,
final boolean updateSearchServer) {
if (module == null) {
return false;
}
OtpErlangList forms = null;
OtpErlangList comments = null;
OtpErlangTuple res = null;
if (initialParse) {
final String stateDir = ErlangEngine.getInstance().getStateDir();
final String pathNotNull = path == null ? "" : path;
res = ErlideNoparse.initialParse(backend, scannerName, pathNotNull,
initialText, stateDir, true, updateSearchServer);
} else {
res = ErlideNoparse.reparse(backend, scannerName, updateSearchServer);
}
if (Util.isOk(res)) {
final OtpErlangTuple t = (OtpErlangTuple) res.elementAt(1);
forms = (OtpErlangList) t.elementAt(1);
comments = (OtpErlangList) t.elementAt(2);
} else {
ErlLogger.error("error when parsing %s: %s", path, res);
}
if (forms == null) {
module.setChildren(null);
} else {
final List<IErlElement> children = createForms(module, forms);
module.setChildren(children);
}
if (comments == null) {
module.setComments(null);
} else {
final List<IErlComment> moduleComments = createComments(module, comments);
module.setComments(moduleComments);
}
attachFunctionComments(module);
String cached = "reparsed";
if (res != null && res.arity() > 2) {
final OtpErlangObject res2 = res.elementAt(2);
if (res2 instanceof OtpErlangAtom) {
final OtpErlangAtom atom = (OtpErlangAtom) res2;
cached = atom.atomValue();
}
}
if (TRACE) {
ErlLogger.debug("Parsed %d forms and %d comments (%s)",
forms != null ? forms.arity() : 0,
comments != null ? comments.arity() : 0, cached);
}
return forms != null && comments != null;
}