Java Code Examples for com.intellij.openapi.projectRoots.Sdk#getHomeDirectory()

The following examples show how to use com.intellij.openapi.projectRoots.Sdk#getHomeDirectory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntelliJAndroidSdk.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Nullable
private static IntelliJAndroidSdk fromSdk(@Nullable Sdk candidate) {
  if (candidate == null) {
    return null;
  }

  if (!"Android SDK".equals(candidate.getSdkType().getName())) {
    return null;
  }

  final VirtualFile home = candidate.getHomeDirectory();
  if (home == null) {
    return null; // Skip; misconfigured SDK?
  }

  return new IntelliJAndroidSdk(candidate, home);
}
 
Example 2
Source File: IntelliJAndroidSdk.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Nullable
private static IntelliJAndroidSdk fromSdk(@Nullable Sdk candidate) {
  if (candidate == null) {
    return null;
  }

  if (!"Android SDK".equals(candidate.getSdkType().getName())) {
    return null;
  }

  final VirtualFile home = candidate.getHomeDirectory();
  if (home == null) {
    return null; // Skip; misconfigured SDK?
  }

  return new IntelliJAndroidSdk(candidate, home);
}
 
Example 3
Source File: XQueryRunProfileState.java    From intellij-xquery with Apache License 2.0 6 votes vote down vote up
private Sdk getValidJdkToRunModule(final Module module) throws CantRunException {
    Sdk jdk = getJdkToRunModule(module);
    String currentRunningJavaHome = getCurrentRunningJavaHome();
    if (jdk == null) {
        if (currentRunningJavaHome != null) {
            jdk = createAlternativeJdk(currentRunningJavaHome);
        } else {
            throw CantRunException.noJdkForModule(module);
        }
    }
    final VirtualFile homeDirectory = jdk.getHomeDirectory();
    if (homeDirectory == null || !homeDirectory.isValid()) {
        throw CantRunException.jdkMisconfigured(jdk, module);
    }
    return jdk;
}
 
Example 4
Source File: AppCommandLineState.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
private List<File> invokeClassPathResolver(List<String> librariesNeeded, final Sdk sdk) {
    List<File> classPaths = new ArrayList<File>();
    VirtualFile homeDirectory = sdk.getHomeDirectory();
    for (String library : librariesNeeded) {
        //filter sdk libraries from classpath because it's too big
        if (!library.contains(homeDirectory.getPath())) {
            classPaths.add(new File(library));
        }
    }
    return classPaths;
}
 
Example 5
Source File: PantsUtil.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * @return Path to IDEA Project JDK if exists, else null
 */
@Nullable
public static String getJdkPathFromIntelliJCore() {
  // Followed example in com.twitter.intellij.pants.testFramework.PantsIntegrationTestCase.setUpInWriteAction()
  final Sdk sdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
  String javaHome = null;
  if (sdk.getHomeDirectory() != null) {
    javaHome = sdk.getHomeDirectory().getParent().getPath();
  }
  return javaHome;
}
 
Example 6
Source File: BaseInternalCompilerProvider.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public void insertCustomSdkItems(@Nullable DotNetSimpleModuleExtension extension, @Nonnull SdkComboBox comboBox)
{
	if(extension == null)
	{
		return;
	}

	if(extension.getId().equals(getExtensionId()))
	{
		Sdk sdk = extension.getSdk();
		if(sdk == null)
		{
			return;
		}

		VirtualFile homeDirectory = sdk.getHomeDirectory();
		if(homeDirectory == null)
		{
			return;
		}

		VirtualFile child = homeDirectory.findChild(CSharpCompilerUtil.COMPILER_NAME);
		if(child != null)
		{
			comboBox.insertCustomSdkItem(CSharpModuleExtension.INTERNAL_SDK_KEY, "<internal>", getIcon());
		}
	}
}
 
Example 7
Source File: Unity3dPackageOrderEntry.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
@RequiredReadAction
public VirtualFile[] getFiles(@Nonnull OrderRootType rootType)
{
	List<VirtualFile> files = new ArrayList<>();

	if(rootType == BinariesOrderRootType.getInstance() || rootType == SourcesOrderRootType.getInstance())
	{
		LocalFileSystem localFileSystem = LocalFileSystem.getInstance();

		// moved to project files
		String projectPackageCache = getProjectPackageCache();
		VirtualFile localFile = localFileSystem.findFileByIoFile(new File(projectPackageCache, myNameWithVersion));
		addDotNetModulesInsideLibrary(files, localFile);

		if(files.isEmpty())
		{
			Unity3dPackageWatcher watcher = Unity3dPackageWatcher.getInstance();
			for(String path : watcher.getPackageDirPaths())
			{
				VirtualFile file = localFileSystem.findFileByIoFile(new File(path, myNameWithVersion));
				addDotNetModulesInsideLibrary(files, file);
			}
		}
	}

	if(files.isEmpty())
	{
		Sdk sdk = getSdk();
		if(sdk != null)
		{
			VirtualFile homeDirectory = sdk.getHomeDirectory();
			if(homeDirectory != null)
			{
				VirtualFile builtInDirectory = homeDirectory.findFileByRelativePath(getBuiltInPackagesRelativePath());
				if(builtInDirectory != null)
				{
					VirtualFile packageDirectory = builtInDirectory.findChild(getPackageName());
					ContainerUtil.addIfNotNull(files, packageDirectory);
				}
			}
		}
	}
	return VfsUtilCore.toVirtualFileArray(files);
}