* @since 3.4
*/
private Program reconcile(ISourceModule unit, boolean initialReconcile)
throws ModelException {
/* fix for missing cancel flag communication */
IProblemRequestorExtension extension = getProblemRequestorExtension();
if (extension != null) {
extension.setProgressMonitor(fProgressMonitor);
extension.setIsActive(true);
}
try {
final ASTProvider astProvider = PHPUiPlugin.getDefault()
.getASTProvider();
synchronized (unit) {
unit.reconcile(true, null, fProgressMonitor);
}
// read DOM AST from provider if avaiable
Program createdAST = astProvider.getAST(unit,
SharedASTProvider.WAIT_NO, fProgressMonitor);
if (astProvider.isActive(unit) && createdAST != null) {
return createdAST;
}
if (initialReconcile || astProvider.isActive(unit)) {
PHPVersion phpVersion = ProjectOptions.getPhpVersion(unit
.getScriptProject().getProject());
ASTParser newParser = ASTParser.newParser(phpVersion, unit);
createdAST = newParser.createAST(null);
if (createdAST != null && document != null) {
createdAST.setSourceModule(unit);
createdAST.setSourceRange(0, document.getLength());
createdAST.setLineEndTable(Util.lineEndTable(document));
}
return createdAST;
}
} catch (OperationCanceledException ex) {
Assert.isTrue(fProgressMonitor == null
|| fProgressMonitor.isCanceled());
} catch (Exception e) {
throw new ModelException(e, IStatus.ERROR);
} finally {
/* fix for missing cancel flag communication */
if (extension != null) {
extension.setProgressMonitor(null);
extension.setIsActive(false);
}
}
return null;
}