/**
   * Performs the reconcile and returns the AST if it was computed.
   *
   * @param unit the compilation unit
   * @param initialReconcile <code>true</code> if this is the initial reconcile
   * @return the AST or <code>null</code> if none
   * @throws JavaModelException if the original Java element does not exist
   * @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;
  }
  // Symfony2 requires > PHP 5.3
  protected void setPhpLangOptions() {

    ProjectOptions.setSupportingAspTags(false, getProject());
    ProjectOptions.setPhpVersion(PHPVersion.PHP5_3, getProject());
  }