/**
   * Constructs include path from one module to another.
   *
   * @param from - module to construct include path from.
   * @param toBuildPath - destination build-path.
   * @param toPath - path inside destination build-path.
   * @return constructed include path
   */
  public static ConstructedIncludePath constructIncludePath(
      IModule from, IBuildPath toBuildPath, IPath toPath) {
    IBuildPath fromBuildPath = from.getBuildPath();
    Set<IBuildPath> fromDependencies = fromBuildPath.getDependencies();

    // if "from" build-path directly depends from "to" build-path
    if (fromBuildPath.equals(toBuildPath) || fromDependencies.contains(toBuildPath)) {
      String includePath = constructPathFromRoot(toPath);
      return new ConstructedIncludePath(includePath, null, null);
    } else {
      // for local modules using its project-based build-path instead of native module build-path
      if (toBuildPath instanceof ProjectBuildPath
          || toBuildPath instanceof WorkspaceFolderBuildpath) {
        IProject project = null;
        if (toBuildPath instanceof ProjectBuildPath) {
          project = ((ProjectBuildPath) toBuildPath).getProject();
        } else {
          project = ((WorkspaceFolderBuildpath) toBuildPath).getFolder().getProject();
        }
        IBuildPath projectBuildPath =
            BuildPathManager.getInstance().getBuildPathByResource(project);
        if (projectBuildPath != null) {
          String includePath = constructPathFromRoot(toPath);
          return new ConstructedIncludePath(includePath, fromBuildPath, projectBuildPath);
        }
      }

      // in other case, using original build-paths for reporting unsatisfied state
      String includePath = constructPathFromRoot(toPath);
      return new ConstructedIncludePath(includePath, fromBuildPath, toBuildPath);
    }
  }
  /**
   * Constructs include path from one module to another.
   *
   * @param from - module to construct include path from.
   * @param to - module to construct include path to.
   * @return constructed include path
   */
  public static ConstructedIncludePath constructIncludePath(IModule from, IModule to) {
    IBuildPath fromBuildPath = from.getBuildPath();
    IBuildPath toBuildPath = to.getBuildPath();
    Set<IBuildPath> fromDependencies = fromBuildPath.getDependencies();
    if (fromDependencies.equals(toBuildPath)) {
      String includePath = constructPathFromRoot(to);
      return new ConstructedIncludePath(includePath, null, null);
    }
    // if "from" build-path directly depends from "to" build-path
    if (fromDependencies.contains(toBuildPath)) {
      String includePath = constructPathFromRoot(to);
      return new ConstructedIncludePath(includePath, null, null);
    } else {
      // for local modules using its project-based build-path instead of native module build-path
      if (to instanceof LocalModule) {
        IFile file = ((LocalModule) to).getFile();
        if (!file.isSynchronized(1)) {
          try {
            file.refreshLocal(1, new NullProgressMonitor());
            if (file.exists()) {
              IProject project = file.getProject();
              IBuildPath projectBuildPath =
                  BuildPathManager.getInstance().getBuildPathByResource(project);
              if (projectBuildPath != null) {
                IModule alternativeToModule = projectBuildPath.getModule(file);
                if (alternativeToModule != null) {
                  String includePath = constructPathFromRoot(alternativeToModule);
                  return new ConstructedIncludePath(includePath, fromBuildPath, projectBuildPath);
                }
              }
            }
          } catch (CoreException e) {
            IdeLog.logWarning(
                PHPEditorPlugin.getDefault(),
                "PHP Refactoring - Error while constructing an include-path (constructIncludePath)", //$NON-NLS-1$
                e,
                PHPEditorPlugin.DEBUG_SCOPE);
          }
        }
      }

      // in other case, using original build-paths for reporting unsatisfied state
      String includePath = constructPathFromRoot(to);
      return new ConstructedIncludePath(includePath, fromBuildPath, toBuildPath);
    }
  }