Java 类com.intellij.openapi.projectRoots.SdkAdditionalData 实例源码

项目:intellij-ce-playground    文件:PythonSdkDetailsStep.java   
@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);
      }
    };
}
项目:intellij-ce-playground    文件:AndroidPlatform.java   
@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;
}
项目:intellij-haxe    文件:HaxelibCommandUtils.java   
/**
 * Find the path to the 'haxelib' executable, using a specific SDK.
 *
 * @param sdk - SDK to look up haxelib for.
 * @return the configured haxelib for the SDK; "haxelib" if not specified.
 */
@NotNull
public static String getHaxelibPath(@NotNull Sdk sdk) {

  String haxelibPath = "haxelib";
  if (sdk != null) {
    SdkAdditionalData data = sdk.getSdkAdditionalData();

    if (data instanceof HaxeSdkData) {
      HaxeSdkData sdkData = (HaxeSdkData)data;
      String path = sdkData.getHaxelibPath();
      if (!path.isEmpty()) {
        haxelibPath = path;
      }
    }
  }

  return haxelibPath;
}
项目:educational-plugin    文件:PyStudyDirectoryProjectGenerator.java   
public void createAndAddVirtualEnv(Project project, PyNewProjectSettings settings) {
  final ProjectSdksModel model = PyConfigurableInterpreterList.getInstance(project).getModel();
  Course course = StudyTaskManager.getInstance(project).getCourse();
  if (course == null) {
    return;
  }
  final String baseSdk = getBaseSdk(course);

  if (baseSdk != null) {
    final PyPackageManager packageManager = PyPackageManager.getInstance(new PyDetectedSdk(baseSdk));
    try {
      final String path = packageManager.createVirtualEnv(project.getBasePath() + "/.idea/VirtualEnvironment", false);
      AbstractCreateVirtualEnvDialog.setupVirtualEnvSdk(path, true, new AbstractCreateVirtualEnvDialog.VirtualEnvCallback() {
        @Override
        public void virtualEnvCreated(Sdk createdSdk, boolean associateWithProject) {
          settings.setSdk(createdSdk);
          model.addSdk(createdSdk);
          try {
            model.apply();
          }
          catch (ConfigurationException exception) {
            LOG.error("Error adding created virtual env " + exception.getMessage());
          }
          if (associateWithProject) {
            SdkAdditionalData additionalData = createdSdk.getSdkAdditionalData();
            if (additionalData == null) {
              additionalData = new PythonSdkAdditionalData(PythonSdkFlavor.getFlavor(createdSdk.getHomePath()));
              ((ProjectJdkImpl)createdSdk).setSdkAdditionalData(additionalData);
            }
            ((PythonSdkAdditionalData)additionalData).associateWithNewProject();
          }
        }
      });
    }
    catch (ExecutionException e) {
      LOG.warn("Failed to create virtual env " + e.getMessage());
    }
  }
}
项目:intellij-ce-playground    文件:SdkConfigurationUtil.java   
@Nullable
public static Sdk setupSdk(final Sdk[] allSdks,
                           final VirtualFile homeDir, final SdkType sdkType, final boolean silent,
                           @Nullable final SdkAdditionalData additionalData,
                           @Nullable final String customSdkSuggestedName) {
  final List<Sdk> sdksList = Arrays.asList(allSdks);

  final ProjectJdkImpl sdk;
  try {
    String sdkPath = sdkType.sdkPath(homeDir);

    final String sdkName = customSdkSuggestedName == null
                           ? createUniqueSdkName(sdkType, sdkPath, sdksList)
                           : createUniqueSdkName(customSdkSuggestedName, sdksList);
    sdk = new ProjectJdkImpl(sdkName, sdkType);

    if (additionalData != null) {
      // additional initialization.
      // E.g. some ruby sdks must be initialized before
      // setupSdkPaths() method invocation
      sdk.setSdkAdditionalData(additionalData);
    }

    sdk.setHomePath(sdkPath);
    sdkType.setupSdkPaths(sdk);
  }
  catch (Exception e) {
    if (!silent) {
      Messages.showErrorDialog("Error configuring SDK: " +
                               e.getMessage() +
                               ".\nPlease make sure that " +
                               FileUtil.toSystemDependentName(homeDir.getPath()) +
                               " is a valid home path for this SDK type.", "Error Configuring SDK");
    }
    return null;
  }
  return sdk;
}
项目:intellij-ce-playground    文件:PythonSdkFlavor.java   
@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());
}
项目:intellij-ce-playground    文件:PythonCommandLineState.java   
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;
}
项目:intellij-ce-playground    文件:PythonPathEditor.java   
private SdkAdditionalData collectSdkAdditionalData(SdkModificator sdkModificator) {
  PythonSdkAdditionalData data = (PythonSdkAdditionalData)sdkModificator.getSdkAdditionalData();
  if (data == null) {
    data = new PythonSdkAdditionalData(null);
  }
  data.setAddedPathsFromVirtualFiles(myAdded);
  data.setExcludedPathsFromVirtualFiles(myExcluded);
  return data;
}
项目:intellij-ce-playground    文件:AndroidFacetImporterTest.java   
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))));
}
项目:tools-idea    文件:SdkConfigurationUtil.java   
@Nullable
public static Sdk setupSdk(final Sdk[] allSdks,
                           final VirtualFile homeDir, final SdkType sdkType, final boolean silent,
                           @Nullable final SdkAdditionalData additionalData,
                           @Nullable final String customSdkSuggestedName) {
  final List<Sdk> sdksList = Arrays.asList(allSdks);

  final ProjectJdkImpl sdk;
  try {
    final String sdkName = customSdkSuggestedName == null
                           ? createUniqueSdkName(sdkType, homeDir.getPath(), sdksList)
                           : createUniqueSdkName(customSdkSuggestedName, sdksList);
    sdk = new ProjectJdkImpl(sdkName, sdkType);

    if (additionalData != null) {
      // additional initialization.
      // E.g. some ruby sdks must be initialized before
      // setupSdkPaths() method invocation
      sdk.setSdkAdditionalData(additionalData);
    }

    sdk.setHomePath(homeDir.getPath());
    sdkType.setupSdkPaths(sdk);
  }
  catch (Exception e) {
    if (!silent) {
      Messages.showErrorDialog("Error configuring SDK: " +
                               e.getMessage() +
                               ".\nPlease make sure that " +
                               FileUtil.toSystemDependentName(homeDir.getPath()) +
                               " is a valid home path for this SDK type.", "Error Configuring SDK");
    }
    return null;
  }
  return sdk;
}
项目:intellij-haxe    文件:HaxeSdkUtilBase.java   
@Nullable
public static HaxeSdkAdditionalDataBase getSdkData(@Nullable Sdk sdk) {
  if(sdk != null) {
    SdkAdditionalData sdkData = sdk.getSdkAdditionalData();
    if(sdkData != null && sdkData instanceof HaxeSdkAdditionalDataBase) {
      return (HaxeSdkAdditionalDataBase)sdkData;
    }
  }
  return null;
}
项目:consulo-haxe    文件:HaxeSdkType.java   
@Override
public void setupSdkPaths(Sdk sdk)
{
    final SdkModificator modificator = sdk.getSdkModificator();

    SdkAdditionalData data = sdk.getSdkAdditionalData();
    if(data == null)
    {
        data = HaxeSdkUtil.testHaxeSdk(sdk.getHomePath());
        modificator.setSdkAdditionalData(data);
    }

    VirtualFile homeDirectory = sdk.getHomeDirectory();
    if(homeDirectory != null)
    {
        final VirtualFile stdRoot = homeDirectory.findChild("std");
        if(stdRoot != null)
        {
            modificator.addRoot(stdRoot, BinariesOrderRootType.getInstance());
            modificator.addRoot(stdRoot, SourcesOrderRootType.getInstance());
        }
        final VirtualFile docRoot = homeDirectory.findChild("doc");
        if(docRoot != null)
        {
            modificator.addRoot(docRoot, DocumentationOrderRootType.getInstance());
        }
    }

    modificator.commitChanges();
}
项目:consulo-haxe    文件:HaxeSdkType.java   
@Override
public void saveAdditionalData(SdkAdditionalData additionalData, Element additional)
{
    if(additionalData instanceof HaxeSdkData)
    {
        XmlSerializer.serializeInto(additionalData, additional);
    }
}
项目:intellij-ce-playground    文件:MockJdkWrapper.java   
public SdkAdditionalData getSdkAdditionalData() {
  return null;
}
项目:intellij-ce-playground    文件:CoreSdkType.java   
@Override
public void saveAdditionalData(@NotNull SdkAdditionalData additionalData, @NotNull Element additional) {
}
项目:intellij-ce-playground    文件:CoreSdkType.java   
@Override
public SdkAdditionalData loadAdditionalData(@NotNull Sdk currentSdk, Element additional) {
  return null;
}
项目:intellij-ce-playground    文件:PythonSdkConfigurator.java   
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);
}
项目:intellij-ce-playground    文件:GenerateProjectCallback.java   
@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);
      }
    }
  }
}
项目:intellij-ce-playground    文件:AndroidSdkUtils.java   
@Nullable
public static AndroidSdkAdditionalData getAndroidSdkAdditionalData(@NotNull Sdk sdk) {
  SdkAdditionalData sdkAdditionalData = sdk.getSdkAdditionalData();
  return sdkAdditionalData instanceof AndroidSdkAdditionalData ? (AndroidSdkAdditionalData)sdkAdditionalData : null;
}
项目:intellij-ce-playground    文件:AndroidJunitPatcher.java   
@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);
  }
}
项目:intellij-perl-plugin    文件:PerlSdkTypeId.java   
@Nullable
@Override
public SdkAdditionalData loadAdditionalData(@NotNull Sdk sdk, Element element) {
    return null;
}
项目:intellij-perl-plugin    文件:PerlSdkModificator.java   
@Override
public SdkAdditionalData getSdkAdditionalData() {
    return null;
}
项目:intellij-perl-plugin    文件:PerlSdk.java   
@Nullable
@Override
public SdkAdditionalData getSdkAdditionalData() {
    return null;
}
项目:tools-idea    文件:MockJdkWrapper.java   
public SdkAdditionalData getSdkAdditionalData() {
  return null;
}
项目:tools-idea    文件:CoreSdkType.java   
@Override
public void saveAdditionalData(SdkAdditionalData additionalData, Element additional) {
}
项目:tools-idea    文件:CoreSdkType.java   
@Override
public SdkAdditionalData loadAdditionalData(Sdk currentSdk, Element additional) {
  return null;
}
项目:consulo-haxe    文件:HaxeSdkType.java   
@Override
public SdkAdditionalData loadAdditionalData(Sdk sdk, Element additional)
{
    return XmlSerializer.deserialize(additional, HaxeSdkData.class);
}
项目:consulo    文件:MockSdkWrapper.java   
@Override
public SdkAdditionalData getSdkAdditionalData() {
  return null;
}
项目:consulo    文件:SdkConfigurationUtil.java   
@Nullable
public static Sdk setupSdk(final Sdk[] allSdks,
                           final VirtualFile homeDir,
                           final SdkType sdkType,
                           final boolean silent,
                           boolean predefined,
                           @Nullable final SdkAdditionalData additionalData,
                           @Nullable final String customSdkSuggestedName) {
  final SdkImpl sdk;
  try {
    String sdkPath = sdkType.sdkPath(homeDir);

    String sdkName = null;
    if (predefined) {
      sdkName = sdkType.getName() + PREDEFINED_PREFIX;
    }
    else {
      sdkName = customSdkSuggestedName == null
                ? createUniqueSdkName(sdkType, sdkPath, allSdks)
                : createUniqueSdkName(customSdkSuggestedName, allSdks);
    }

    sdk = new SdkImpl(sdkName, sdkType);
    sdk.setPredefined(predefined);

    if (additionalData != null) {
      // additional initialization.
      // E.g. some ruby sdks must be initialized before
      // setupSdkPaths() method invocation
      sdk.setSdkAdditionalData(additionalData);
    }

    sdk.setHomePath(sdkPath);
    sdkType.setupSdkPaths(sdk);
  }
  catch (Exception e) {
    if (!silent) {
      Messages.showErrorDialog("Error configuring SDK: " +
                               e.getMessage() +
                               ".\nPlease make sure that " +
                               FileUtil.toSystemDependentName(homeDir.getPath()) +
                               " is a valid home path for this SDK type.", "Error Configuring SDK");
    }
    return null;
  }
  return sdk;
}
项目:intellij-perl-plugin    文件:PerlSdkTypeId.java   
@Override
public void saveAdditionalData(@NotNull SdkAdditionalData sdkAdditionalData, @NotNull Element element) {

}
项目:intellij-perl-plugin    文件:PerlSdkModificator.java   
@Override
public void setSdkAdditionalData(SdkAdditionalData sdkAdditionalData) {

}
项目:defrac-plugin-intellij    文件:DefracFacetEditorTab.java   
@Override
public void apply() throws ConfigurationException {
  if(!isModified()) {
    return;
  }

  //

  configuration.getState().PLATFORM = form.getSelectedPlatform().name;
  configuration.getState().IS_MACRO_LIBRARY = form.isMacroLibrary();

  //

  final Sdk sdk = form.getSelectedSdk();

  if(sdk == null) {
    throw new ConfigurationException("SDK is not configured");
  }

  final SdkAdditionalData arbitraryData = sdk.getSdkAdditionalData();

  if(!(arbitraryData instanceof DefracSdkAdditionalData)) {
    throw new ConfigurationException("Illegal SDK");
  }

  final DefracSdkAdditionalData data = (DefracSdkAdditionalData)arbitraryData;
  final DefracVersion version = data.getDefracVersion();

  if(version == null) {
    throw new ConfigurationException("SDK is not configured");
  }

  configuration.getState().DEFRAC_VERSION = version.getName();

  //

  final String absSettingsPath = form.getSettingsPath();

  if(isEmpty(absSettingsPath)) {
    throw new ConfigurationException("Settings file not specified");
  }

  final String relSettingsPath = getAndCheckRelativePath(absSettingsPath, true);

  configuration.getState().SETTINGS_FILE_RELATIVE_PATH = '/'+relSettingsPath;
}
项目:intellij-ce-playground    文件:PythonRemoteInterpreterManager.java   
public abstract SdkAdditionalData loadRemoteSdkData(Sdk sdk, Element additional);