All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yiwowang.intellij.finding.util.ProjectUtils Maven / Gradle / Ivy

The newest version!
package com.yiwowang.intellij.finding.util;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;

import java.io.File;

public class ProjectUtils {
    public static Project getOpenProject() {
        Project[] projects = ProjectManager.getInstance().getOpenProjects();
        if (!ArrayUtils.isEmpty(projects)) {
            return projects[0];
        }
        return null;
    }

    public static File getProjectDir(Project project) {
        if (project == null) {
            return null;
        }
        String basePath = project.getBasePath();
        if (StringUtils.isEmpty(basePath)) {
            return null;
        }
        return new File(basePath);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy