mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
leftovers from idea
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
package com.intellij.openapi.projectRoots.impl;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkAdditionalData;
|
||||
import com.intellij.openapi.projectRoots.SdkModificator;
|
||||
import com.intellij.openapi.projectRoots.SdkType;
|
||||
import com.intellij.openapi.roots.RootProvider;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* used to override JdkHome location in order to provide correct paths
|
||||
*/
|
||||
public final class MockJdkWrapper implements Sdk {
|
||||
private final String myHomePath;
|
||||
private final Sdk myDelegate;
|
||||
|
||||
public MockJdkWrapper(String homePath, @NotNull Sdk delegate) {
|
||||
myHomePath = homePath;
|
||||
myDelegate = delegate;
|
||||
}
|
||||
|
||||
public VirtualFile getHomeDirectory() {
|
||||
return LocalFileSystem.getInstance().findFileByIoFile(new File(getHomePath()));
|
||||
}
|
||||
|
||||
public String getHomePath() {
|
||||
final String homePath = FileUtil.toSystemDependentName(myHomePath == null ? myDelegate.getHomePath() : myHomePath);
|
||||
return StringUtil.trimEnd(homePath, File.separator);
|
||||
}
|
||||
|
||||
public SdkType getSdkType() {
|
||||
return myDelegate.getSdkType();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return myDelegate.getName();
|
||||
}
|
||||
|
||||
public String getVersionString() {
|
||||
return myDelegate.getVersionString();
|
||||
}
|
||||
|
||||
public RootProvider getRootProvider() {
|
||||
return myDelegate.getRootProvider();
|
||||
}
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
throw new CloneNotSupportedException();
|
||||
}
|
||||
|
||||
public SdkAdditionalData getSdkAdditionalData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public SdkModificator getSdkModificator() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 19-Feb-2008
|
||||
*/
|
||||
package com.intellij.openapi.projectRoots.impl;
|
||||
|
||||
import com.intellij.openapi.components.RoamingType;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.projectRoots.JavaSdk;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkType;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import org.jdom.Element;
|
||||
|
||||
@State(
|
||||
name="ProjectJdkTable",
|
||||
roamingType = RoamingType.DISABLED,
|
||||
storages= {
|
||||
@Storage(
|
||||
id="other",
|
||||
file = "$APP_CONFIG$/jdk.table.xml"
|
||||
)}
|
||||
)
|
||||
public class JavaAwareProjectJdkTableImpl extends ProjectJdkTableImpl {
|
||||
public static JavaAwareProjectJdkTableImpl getInstanceEx() {
|
||||
return (JavaAwareProjectJdkTableImpl)ServiceManager.getService(ProjectJdkTable.class);
|
||||
}
|
||||
|
||||
private final JavaSdk myJavaSdk;
|
||||
private Sdk myInternalJdk;
|
||||
|
||||
public JavaAwareProjectJdkTableImpl(final JavaSdk javaSdk) {
|
||||
myJavaSdk = javaSdk;
|
||||
}
|
||||
|
||||
public Sdk getInternalJdk() {
|
||||
if (myInternalJdk == null) {
|
||||
final String jdkHome = SystemProperties.getJavaHome();
|
||||
final String versionName = ProjectBundle.message("sdk.java.name.template", SystemProperties.getJavaVersion());
|
||||
myInternalJdk = myJavaSdk.createJdk(versionName, jdkHome);
|
||||
}
|
||||
return myInternalJdk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeJdk(final Sdk jdk) {
|
||||
super.removeJdk(jdk);
|
||||
if (jdk.equals(myInternalJdk)) {
|
||||
myInternalJdk = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdkType getDefaultSdkType() {
|
||||
return myJavaSdk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(final Element element) {
|
||||
myInternalJdk = null;
|
||||
try {
|
||||
super.loadState(element);
|
||||
}
|
||||
finally {
|
||||
getInternalJdk();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSdkTypeName(final String type) {
|
||||
return type != null ? type : JavaSdk.getInstance().getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,405 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2004 by JetBrains s.r.o. All Rights Reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
package com.intellij.openapi.projectRoots.impl;
|
||||
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.projectRoots.*;
|
||||
import com.intellij.openapi.roots.JavadocOrderRootType;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Sep 17, 2004
|
||||
*/
|
||||
public class JavaSdkImpl extends JavaSdk {
|
||||
// do not use javaw.exe for Windows because of issues with encoding
|
||||
@NonNls private static final String VM_EXE_NAME = "java";
|
||||
@NonNls private final Pattern myVersionStringPattern = Pattern.compile("^(.*)java version \"([1234567890_.]*)\"(.*)$");
|
||||
public static final Icon ICON = IconLoader.getIcon("/nodes/ppJdkClosed.png");
|
||||
private static final Icon JDK_ICON_EXPANDED = IconLoader.getIcon("/nodes/ppJdkOpen.png");
|
||||
private static final Icon ADD_ICON = IconLoader.getIcon("/general/addJdk.png");
|
||||
@NonNls private static final String JAVA_VERSION_PREFIX = "java version ";
|
||||
|
||||
public JavaSdkImpl() {
|
||||
super("JavaSDK");
|
||||
}
|
||||
|
||||
public String getPresentableName() {
|
||||
return ProjectBundle.message("sdk.java.name");
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
return ICON;
|
||||
}
|
||||
|
||||
public Icon getIconForExpandedTreeNode() {
|
||||
return JDK_ICON_EXPANDED;
|
||||
}
|
||||
|
||||
public Icon getIconForAddAction() {
|
||||
return ADD_ICON;
|
||||
}
|
||||
|
||||
public AdditionalDataConfigurable createAdditionalDataConfigurable(SdkModel sdkModel, SdkModificator sdkModificator) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void saveAdditionalData(SdkAdditionalData additionalData, Element additional) {
|
||||
}
|
||||
|
||||
public SdkAdditionalData loadAdditionalData(Element additional) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public String getBinPath(Sdk sdk) {
|
||||
return getConvertedHomePath(sdk) + "bin";
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public String getToolsPath(Sdk sdk) {
|
||||
final String versionString = sdk.getVersionString();
|
||||
final boolean isJdk1_x = versionString != null && (versionString.contains("1.0") || versionString.contains("1.1"));
|
||||
return getConvertedHomePath(sdk) + "lib" + File.separator + (isJdk1_x? "classes.zip" : "tools.jar");
|
||||
}
|
||||
|
||||
public String getVMExecutablePath(Sdk sdk) {
|
||||
/*
|
||||
if ("64".equals(System.getProperty("sun.arch.data.model"))) {
|
||||
return getBinPath(sdk) + File.separator + System.getProperty("os.arch") + File.separator + VM_EXE_NAME;
|
||||
}
|
||||
*/
|
||||
return getBinPath(sdk) + File.separator + VM_EXE_NAME;
|
||||
}
|
||||
|
||||
private static String getConvertedHomePath(Sdk sdk) {
|
||||
String path = sdk.getHomePath().replace('/', File.separatorChar);
|
||||
if (!path.endsWith(File.separator)) {
|
||||
path += File.separator;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public String suggestHomePath() {
|
||||
if (SystemInfo.isMac) {
|
||||
return "/System/Library/Frameworks/JavaVM.framework/Versions/";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isValidSdkHome(String path) {
|
||||
return checkForJdk(new File(path));
|
||||
}
|
||||
|
||||
public String suggestSdkName(String currentSdkName, String sdkHome) {
|
||||
final String suggestedName;
|
||||
if (currentSdkName != null && currentSdkName.length() > 0) {
|
||||
final Matcher matcher = myVersionStringPattern.matcher(currentSdkName);
|
||||
final boolean replaceNameWithVersion = matcher.matches();
|
||||
if (replaceNameWithVersion){
|
||||
// user did not change name -> set it automatically
|
||||
final String versionString = getVersionString(sdkHome);
|
||||
suggestedName = versionString == null ? currentSdkName : matcher.replaceFirst("$1" + versionString + "$3");
|
||||
}
|
||||
else {
|
||||
suggestedName = currentSdkName;
|
||||
}
|
||||
}
|
||||
else {
|
||||
String versionString = getVersionString(sdkHome);
|
||||
if (versionString != null) {
|
||||
suggestedName = getVersionNumber(versionString);
|
||||
} else {
|
||||
suggestedName = ProjectBundle.message("sdk.java.unknown.name");
|
||||
}
|
||||
}
|
||||
return suggestedName;
|
||||
}
|
||||
|
||||
private static String getVersionNumber(String versionString) {
|
||||
if (versionString.startsWith(JAVA_VERSION_PREFIX)) {
|
||||
versionString = versionString.substring(JAVA_VERSION_PREFIX.length());
|
||||
if (versionString.startsWith("\"") && versionString.endsWith("\"")) {
|
||||
versionString = versionString.substring(1, versionString.length() - 1);
|
||||
}
|
||||
int dotIdx = versionString.indexOf('.');
|
||||
if (dotIdx > 0) {
|
||||
try {
|
||||
int major = Integer.parseInt(versionString.substring(0, dotIdx));
|
||||
int minorDot = versionString.indexOf('.', dotIdx + 1);
|
||||
if (minorDot > 0) {
|
||||
int minor = Integer.parseInt(versionString.substring(dotIdx + 1, minorDot));
|
||||
versionString = String.valueOf(major) + "." + String.valueOf(minor);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
// Do nothing. Use original version string if failed to parse according to major.minor pattern.
|
||||
}
|
||||
}
|
||||
}
|
||||
return versionString;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public void setupSdkPaths(Sdk sdk) {
|
||||
final File jdkHome = new File(sdk.getHomePath());
|
||||
VirtualFile[] classes = findClasses(jdkHome, false);
|
||||
VirtualFile sources = findSources(jdkHome);
|
||||
VirtualFile docs = findDocs(jdkHome, "docs/api");
|
||||
|
||||
final SdkModificator sdkModificator = sdk.getSdkModificator();
|
||||
for (VirtualFile aClass : classes) {
|
||||
sdkModificator.addRoot(aClass, OrderRootType.CLASSES);
|
||||
}
|
||||
if(sources != null){
|
||||
sdkModificator.addRoot(sources, OrderRootType.SOURCES);
|
||||
}
|
||||
if(docs != null){
|
||||
sdkModificator.addRoot(docs, JavadocOrderRootType.getInstance());
|
||||
}
|
||||
else if (SystemInfo.isMac) {
|
||||
VirtualFile commonDocs = findDocs(jdkHome, "docs");
|
||||
if (commonDocs == null) {
|
||||
commonDocs = findInJar(new File(jdkHome, "docs.jar"), "doc/api");
|
||||
}
|
||||
if (commonDocs != null) {
|
||||
sdkModificator.addRoot(commonDocs, JavadocOrderRootType.getInstance());
|
||||
}
|
||||
|
||||
VirtualFile appleDocs = findDocs(jdkHome, "appledocs");
|
||||
if (appleDocs == null) {
|
||||
appleDocs = findInJar(new File(jdkHome, "appledocs.jar"), "appledoc/api");
|
||||
}
|
||||
if (appleDocs != null) {
|
||||
sdkModificator.addRoot(appleDocs, JavadocOrderRootType.getInstance());
|
||||
}
|
||||
}
|
||||
sdkModificator.commitChanges();
|
||||
}
|
||||
|
||||
private final Map<String, String> myCachedVersionStrings = new HashMap<String, String>();
|
||||
|
||||
public final String getVersionString(final String sdkHome) {
|
||||
String versionString;
|
||||
|
||||
if(myCachedVersionStrings.containsKey(sdkHome)) {
|
||||
return myCachedVersionStrings.get(sdkHome);
|
||||
} else {
|
||||
versionString = getJdkVersion(sdkHome);
|
||||
}
|
||||
if (versionString != null && versionString.length() == 0) {
|
||||
versionString = null;
|
||||
}
|
||||
|
||||
if (versionString != null){
|
||||
myCachedVersionStrings.put(sdkHome, versionString);
|
||||
}
|
||||
|
||||
return versionString;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public void initComponent() { }
|
||||
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
public int compareTo(@NotNull String versionString, @NotNull String versionNumber) {
|
||||
return getVersionNumber(versionString).compareTo(versionNumber);
|
||||
}
|
||||
|
||||
public Sdk createJdk(final String jdkName, final String home, final boolean isJre) {
|
||||
ProjectJdkImpl jdk = new ProjectJdkImpl(jdkName, this);
|
||||
SdkModificator sdkModificator = jdk.getSdkModificator();
|
||||
|
||||
String path = home.replace(File.separatorChar, '/');
|
||||
sdkModificator.setHomePath(path);
|
||||
jdk.setVersionString(jdkName); // must be set after home path, otherwise setting home path clears the version string
|
||||
|
||||
File jdkHomeFile = new File(home);
|
||||
addClasses(jdkHomeFile, sdkModificator, isJre);
|
||||
addSources(jdkHomeFile, sdkModificator);
|
||||
addDocs(jdkHomeFile, sdkModificator);
|
||||
sdkModificator.commitChanges();
|
||||
return jdk;
|
||||
}
|
||||
|
||||
public static Sdk getMockJdk(@NonNls String versionName) {
|
||||
final String forcedPath = System.getProperty("idea.testingFramework.mockJDK");
|
||||
String jdkHome = forcedPath != null ? forcedPath : PathManager.getHomePath() + File.separator + "mockJDK";
|
||||
return createMockJdk(jdkHome, versionName, getInstance());
|
||||
}
|
||||
|
||||
public static Sdk getMockJdk15(@NonNls String versionName) {
|
||||
String jdkHome = PathManager.getHomePath() + File.separator + "mockJDK-1.5";
|
||||
return createMockJdk(jdkHome, versionName, getInstance());
|
||||
}
|
||||
public static Sdk getMockJdk17(@NonNls String versionName) {
|
||||
String jdkHome = PathManager.getHomePath() + File.separator + "mockJDK-1.7";
|
||||
return createMockJdk(jdkHome, versionName, getInstance());
|
||||
}
|
||||
|
||||
private static Sdk createMockJdk(String jdkHome, final String versionName, JavaSdk javaSdk) {
|
||||
File jdkHomeFile = new File(jdkHome);
|
||||
if (!jdkHomeFile.exists()) return null;
|
||||
|
||||
final Sdk jdk = new ProjectJdkImpl(versionName, javaSdk);
|
||||
final SdkModificator sdkModificator = jdk.getSdkModificator();
|
||||
|
||||
String path = jdkHome.replace(File.separatorChar, '/');
|
||||
sdkModificator.setHomePath(path);
|
||||
sdkModificator.setVersionString(versionName); // must be set after home path, otherwise setting home path clears the version string
|
||||
|
||||
addSources(jdkHomeFile, sdkModificator);
|
||||
addClasses(jdkHomeFile, sdkModificator, false);
|
||||
addClasses(jdkHomeFile, sdkModificator, true);
|
||||
sdkModificator.commitChanges();
|
||||
|
||||
return jdk;
|
||||
}
|
||||
|
||||
private static void addClasses(File file, SdkModificator sdkModificator, final boolean isJre) {
|
||||
VirtualFile[] classes = findClasses(file, isJre);
|
||||
for (VirtualFile virtualFile : classes) {
|
||||
sdkModificator.addRoot(virtualFile, OrderRootType.CLASSES);
|
||||
}
|
||||
}
|
||||
|
||||
private static VirtualFile[] findClasses(File file, boolean isJre) {
|
||||
FileFilter jarFileFilter = new FileFilter(){
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public boolean accept(File f){
|
||||
if (f.isDirectory()) return false;
|
||||
if (f.getName().endsWith(".jar")) return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
File[] jarDirs;
|
||||
if(SystemInfo.isMac && /*!ApplicationManager.getApplication().isUnitTestMode()) &&*/ !file.getName().startsWith("mockJDK")){
|
||||
File libFile = new File(file, "lib");
|
||||
@NonNls File classesFile = new File(file, "../Classes");
|
||||
@NonNls File libExtFile = new File(libFile, "ext");
|
||||
jarDirs = new File[]{libFile, classesFile, libExtFile};
|
||||
}
|
||||
else{
|
||||
@NonNls final String jre = "jre";
|
||||
File jreLibFile = isJre ? new File(file, "lib") : new File(new File(file, jre), "lib");
|
||||
@NonNls File jreLibExtFile = new File(jreLibFile, "ext");
|
||||
jarDirs = new File[]{jreLibFile, jreLibExtFile};
|
||||
}
|
||||
|
||||
ArrayList<File> childrenList = new ArrayList<File>();
|
||||
for (File jarDir : jarDirs) {
|
||||
if (jarDir != null && jarDir.isDirectory()) {
|
||||
File[] files = jarDir.listFiles(jarFileFilter);
|
||||
for (File file1 : files) {
|
||||
childrenList.add(file1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<VirtualFile> result = new ArrayList<VirtualFile>();
|
||||
for (File child : childrenList) {
|
||||
String url = JarFileSystem.PROTOCOL_PREFIX + child.getAbsolutePath().replace(File.separatorChar, '/') + JarFileSystem.JAR_SEPARATOR;
|
||||
VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(url);
|
||||
if (vFile != null) {
|
||||
result.add(vFile);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNls File classesZipFile = new File(new File(file, "lib"), "classes.zip");
|
||||
if(!classesZipFile.isDirectory() && classesZipFile.exists()){
|
||||
String url =
|
||||
JarFileSystem.PROTOCOL_PREFIX + classesZipFile.getAbsolutePath().replace(File.separatorChar, '/') + JarFileSystem.JAR_SEPARATOR;
|
||||
VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(url);
|
||||
if (vFile != null){
|
||||
result.add(vFile);
|
||||
}
|
||||
}
|
||||
|
||||
return result.toArray(new VirtualFile[result.size()]);
|
||||
}
|
||||
|
||||
private static void addSources(File file, SdkModificator sdkModificator) {
|
||||
VirtualFile vFile = findSources(file);
|
||||
if (vFile != null) {
|
||||
sdkModificator.addRoot(vFile, OrderRootType.SOURCES);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public static VirtualFile findSources(File file) {
|
||||
File srcfile = new File(file, "src");
|
||||
File jarfile = new File(file, "src.jar");
|
||||
if (!jarfile.exists()) {
|
||||
jarfile = new File(file, "src.zip");
|
||||
}
|
||||
|
||||
if (jarfile.exists()) {
|
||||
VirtualFile vFile = findInJar(jarfile, "src");
|
||||
if (vFile != null) return vFile;
|
||||
// try 1.4 format
|
||||
vFile = findInJar(jarfile, "");
|
||||
return vFile;
|
||||
}
|
||||
else {
|
||||
if (!srcfile.exists() || !srcfile.isDirectory()) return null;
|
||||
String path = srcfile.getAbsolutePath().replace(File.separatorChar, '/');
|
||||
return LocalFileSystem.getInstance().findFileByPath(path);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
private static void addDocs(File file, SdkModificator rootContainer) {
|
||||
VirtualFile vFile = findDocs(file, "docs/api");
|
||||
if (vFile != null) {
|
||||
rootContainer.addRoot(vFile, JavadocOrderRootType.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static VirtualFile findInJar(File jarFile, String relativePath) {
|
||||
if (!jarFile.exists()) return null;
|
||||
String url = JarFileSystem.PROTOCOL_PREFIX +
|
||||
jarFile.getAbsolutePath().replace(File.separatorChar, '/') + JarFileSystem.JAR_SEPARATOR + relativePath;
|
||||
return VirtualFileManager.getInstance().findFileByUrl(url);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VirtualFile findDocs(File file, final String relativePath) {
|
||||
file = new File(file.getAbsolutePath() + File.separator + relativePath.replace('/', File.separatorChar));
|
||||
if (!file.exists() || !file.isDirectory()) return null;
|
||||
String path = file.getAbsolutePath().replace(File.separatorChar, '/');
|
||||
return LocalFileSystem.getInstance().findFileByPath(path);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user