本文整理汇总了Java中com.intellij.openapi.projectRoots.Sdk.getSdkAdditionalData方法的典型用法代码示例。如果您正苦于以下问题:Java Sdk.getSdkAdditionalData方法的具体用法?Java Sdk.getSdkAdditionalData怎么用?Java Sdk.getSdkAdditionalData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.projectRoots.Sdk
的用法示例。
在下文中一共展示了Sdk.getSdkAdditionalData方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVEnvCallback
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@NotNull
private AbstractCreateVirtualEnvDialog.VirtualEnvCallback getVEnvCallback() {
return new CreateVirtualEnvDialog.VirtualEnvCallback() {
@Override
public void virtualEnvCreated(Sdk sdk, boolean associateWithProject) {
if (associateWithProject) {
SdkAdditionalData additionalData = sdk.getSdkAdditionalData();
if (additionalData == null) {
additionalData = new PythonSdkAdditionalData(PythonSdkFlavor.getFlavor(sdk.getHomePath()));
((ProjectJdkImpl)sdk).setSdkAdditionalData(additionalData);
}
if (myNewProject) {
((PythonSdkAdditionalData)additionalData).associateWithNewProject();
}
else {
((PythonSdkAdditionalData)additionalData).associateWithProject(myProject);
}
}
mySdkAddedCallback.consume(sdk);
}
};
}
示例2: parse
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Nullable
public static AndroidPlatform parse(@NotNull Sdk sdk) {
if (!isAndroidSdk(sdk)) {
return null;
}
AndroidSdkData sdkData = AndroidSdkData.getSdkData(sdk);
if (sdkData != null) {
SdkAdditionalData data = sdk.getSdkAdditionalData();
if (data instanceof AndroidSdkAdditionalData) {
IAndroidTarget target = ((AndroidSdkAdditionalData)data).getBuildTarget(sdkData);
if (target != null) {
return new AndroidPlatform(sdkData, target);
}
}
}
return null;
}
示例3: getFlavor
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Nullable
public static PythonSdkFlavor getFlavor(Sdk sdk) {
final SdkAdditionalData data = sdk.getSdkAdditionalData();
if (data instanceof PythonSdkAdditionalData) {
PythonSdkFlavor flavor = ((PythonSdkAdditionalData)data).getFlavor();
if (flavor != null) {
return flavor;
}
}
return getFlavor(sdk.getHomePath());
}
示例4: getAddedPaths
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public static List<String> getAddedPaths(Sdk pythonSdk) {
List<String> pathList = new ArrayList<String>();
final SdkAdditionalData sdkAdditionalData = pythonSdk.getSdkAdditionalData();
if (sdkAdditionalData instanceof PythonSdkAdditionalData) {
final Set<VirtualFile> addedPaths = ((PythonSdkAdditionalData)sdkAdditionalData).getAddedPathFiles();
for (VirtualFile file : addedPaths) {
addToPythonPath(file, pathList);
}
}
return pathList;
}
示例5: associatedWithCurrent
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
private static boolean associatedWithCurrent(Sdk o1, Project project) {
final PythonSdkAdditionalData data = (PythonSdkAdditionalData)o1.getSdkAdditionalData();
if (data != null) {
final String path = data.getAssociatedProjectPath();
final String projectBasePath = project.getBasePath();
if (path != null && path.equals(projectBasePath)) {
return true;
}
}
return false;
}
示例6: apply
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Override
public boolean apply(@Nullable final Sdk input) {
if (input != null && PythonSdkType.isVirtualEnv(input)) {
PythonSdkAdditionalData data = (PythonSdkAdditionalData) input.getSdkAdditionalData();
if (data != null) {
final String path = data.getAssociatedProjectPath();
if (path != null && (myBasePath == null || !path.equals(myBasePath))) {
return true;
}
}
}
return false;
}
示例7: editSdk
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
private void editSdk() {
final Sdk currentSdk = getSelectedSdk();
if (currentSdk != null) {
if (currentSdk.getSdkAdditionalData() instanceof RemoteSdkAdditionalData) {
editRemoteSdk(currentSdk);
}
else {
editSdk(currentSdk);
}
}
}
示例8: checkSdk
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
private void checkSdk(Sdk sdk, String sdkName, String buildTarget) {
assertNotNull(sdk);
assertEquals(sdkName, sdk.getName());
assertTrue(FileUtil.pathsEqual(AndroidTestCase.getDefaultTestSdkPath(), sdk.getHomePath()));
assertEquals(AndroidSdkType.getInstance(), sdk.getSdkType());
final SdkAdditionalData additionalData = sdk.getSdkAdditionalData();
assertNotNull(additionalData);
assertInstanceOf(additionalData, AndroidSdkAdditionalData.class);
final AndroidSdkAdditionalData data = (AndroidSdkAdditionalData)additionalData;
assertEquals(buildTarget, data.getBuildTargetHashString());
assertEquals(myJdk, data.getJavaSdk());
final HashSet<String> urls = new HashSet<String>(Arrays.asList(sdk.getRootProvider().getUrls(OrderRootType.CLASSES)));
assertTrue(urls.containsAll(Arrays.asList(myJdk.getRootProvider().getUrls(OrderRootType.CLASSES))));
}
示例9: getAndroidSdkApiLevel
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
private static int getAndroidSdkApiLevel(Sdk sdk) {
int androidSdkApiLevel = 1;
AndroidSdkAdditionalData additionalData = (AndroidSdkAdditionalData) sdk.getSdkAdditionalData();
if (additionalData != null) {
AndroidPlatform androidPlatform = additionalData.getAndroidPlatform();
if (androidPlatform != null) {
androidSdkApiLevel = androidPlatform.getApiLevel();
}
}
return androidSdkApiLevel;
}
示例10: isRemote
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public static boolean isRemote(@Nullable Sdk sdk) {
return sdk != null && sdk.getSdkAdditionalData() instanceof RemoteSdkAdditionalData;
}
示例11: configureProject
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public void configureProject(final Project project, @NotNull final VirtualFile baseDir, Ref<Module> moduleRef) {
// it it a virtualenv?
final PythonSdkType sdkType = PythonSdkType.getInstance();
//find virtualEnv in project directory
final List<String> candidates = new ArrayList<String>();
if (project == null) return;
final VirtualFile rootDir = project.getBaseDir();
if (rootDir != null)
candidates.addAll(VirtualEnvSdkFlavor.findInDirectory(rootDir));
if (!candidates.isEmpty()) {
String filePath = candidates.get(0);
if (StringUtil.startsWithChar(filePath, '~')) {
final String home = SystemProperties.getUserHome();
filePath = home + filePath.substring(1);
}
final Sdk virtualEnvSdk = SdkConfigurationUtil.createAndAddSDK(filePath, sdkType);
if (virtualEnvSdk != null) {
SdkConfigurationUtil.setDirectoryProjectSdk(project, virtualEnvSdk);
SdkAdditionalData additionalData = virtualEnvSdk.getSdkAdditionalData();
if (additionalData == null) {
additionalData = new PythonSdkAdditionalData(PythonSdkFlavor.getFlavor(virtualEnvSdk.getHomePath()));
((ProjectJdkImpl)virtualEnvSdk).setSdkAdditionalData(additionalData);
}
((PythonSdkAdditionalData) additionalData).associateWithProject(project);
return;
}
return;
}
final Sdk existingSdk = ProjectRootManager.getInstance(project).getProjectSdk();
if (existingSdk != null && existingSdk.getSdkType() == sdkType) return; // SdkConfigurationUtil does the same
final File executableFile = PythonSdkType.findExecutableFile(new File(project.getBasePath(), "bin"), "python");
if (executableFile != null) {
final File virtualEnvRoot = PythonSdkType.getVirtualEnvRoot(executableFile.getPath());
if (virtualEnvRoot != null) {
// yes, an unknown virtualenv; set it up as SDK
final Sdk sdk = SdkConfigurationUtil.createAndAddSDK(executableFile.getPath(), sdkType);
if (sdk != null) {
SdkConfigurationUtil.setDirectoryProjectSdk(project, sdk);
return;
}
}
}
// default
SdkConfigurationUtil.configureDirectoryProjectSdk(project, new PreferredSdkComparator(), sdkType);
}
示例12: consume
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Override
public void consume(@Nullable ProjectSettingsStepBase step) {
if (!(step instanceof ProjectSpecificSettingsStep)) return;
final ProjectSpecificSettingsStep settingsStep = (ProjectSpecificSettingsStep)step;
Sdk sdk = settingsStep.getSdk();
final Project project = ProjectManager.getInstance().getDefaultProject();
final ProjectSdksModel model = PyConfigurableInterpreterList.getInstance(project).getModel();
if (sdk instanceof PyDetectedSdk) {
final String name = sdk.getName();
VirtualFile sdkHome = ApplicationManager.getApplication().runWriteAction(new Computable<VirtualFile>() {
@Override
public VirtualFile compute() {
return LocalFileSystem.getInstance().refreshAndFindFileByPath(name);
}
});
PySdkService.getInstance().solidifySdk(sdk);
sdk = SdkConfigurationUtil.createAndAddSDK(sdkHome.getPath(), PythonSdkType.getInstance());
if (sdk != null) {
PythonSdkType.getInstance().setupSdkPathsImmediately(sdk, project);
}
model.addSdk(sdk);
settingsStep.setSdk(sdk);
try {
model.apply();
}
catch (ConfigurationException exception) {
LOG.error("Error adding detected python interpreter " + exception.getMessage());
}
}
Project newProject = generateProject(project, settingsStep);
if (newProject != null) {
SdkConfigurationUtil.setDirectoryProjectSdk(newProject, sdk);
final List<Sdk> sdks = PythonSdkType.getAllSdks();
for (Sdk s : sdks) {
final SdkAdditionalData additionalData = s.getSdkAdditionalData();
if (additionalData instanceof PythonSdkAdditionalData) {
((PythonSdkAdditionalData)additionalData).reassociateWithCreatedProject(newProject);
}
}
}
}
示例13: getAndroidSdkAdditionalData
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Nullable
public static AndroidSdkAdditionalData getAndroidSdkAdditionalData(@NotNull Sdk sdk) {
SdkAdditionalData sdkAdditionalData = sdk.getSdkAdditionalData();
return sdkAdditionalData instanceof AndroidSdkAdditionalData ? (AndroidSdkAdditionalData)sdkAdditionalData : null;
}
示例14: patchJavaParameters
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Override
public void patchJavaParameters(@Nullable Module module, JavaParameters javaParameters) {
if (module == null) {
return;
}
AndroidFacet androidFacet = AndroidFacet.getInstance(module);
if (androidFacet == null) {
return;
}
IdeaAndroidProject ideaAndroidProject = androidFacet.getIdeaAndroidProject();
if (ideaAndroidProject == null) {
return;
}
// Modify the class path only if we're dealing with the unit test artifact.
if (!ideaAndroidProject.getSelectedTestArtifactName().equals(AndroidProject.ARTIFACT_UNIT_TEST)) {
return;
}
final PathsList classPath = javaParameters.getClassPath();
final Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
if (sdk == null || !(sdk.getSdkType() instanceof AndroidSdkType)) {
return;
}
final SdkAdditionalData data = sdk.getSdkAdditionalData();
if (!(data instanceof AndroidSdkAdditionalData)) {
return;
}
final AndroidPlatform platform = ((AndroidSdkAdditionalData)data).getAndroidPlatform();
if (platform == null) {
return;
}
classPath.remove(platform.getTarget().getPath(IAndroidTarget.ANDROID_JAR));
// Move the mockable android jar to the end.
String mockableJarPath = null;
for (String path : classPath.getPathList()) {
if (new File(FileUtil.toSystemDependentName(path)).getName().startsWith("mockable-android")) {
// PathsList stores strings - use the one that's actually stored there.
mockableJarPath = path;
break;
}
}
if (mockableJarPath != null) {
classPath.remove(mockableJarPath);
classPath.addTail(mockableJarPath);
}
}