當前位置: 首頁>>代碼示例>>Java>>正文


Java ModuleRootManager類代碼示例

本文整理匯總了Java中com.intellij.openapi.roots.ModuleRootManager的典型用法代碼示例。如果您正苦於以下問題:Java ModuleRootManager類的具體用法?Java ModuleRootManager怎麽用?Java ModuleRootManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ModuleRootManager類屬於com.intellij.openapi.roots包,在下文中一共展示了ModuleRootManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAndroidSdkPath

import com.intellij.openapi.roots.ModuleRootManager; //導入依賴的package包/類
public static String getAndroidSdkPath(Project project) {
    ModuleManager manager = ModuleManager.getInstance(project);
    String androidSdkPath = null;

    for (Module module : manager.getModules()) {
        if (androidSdkPath != null) {
            break;
        }
        Sdk sdk = ModuleRootManager.getInstance(module).getSdk();

        if (sdk != null && sdk.getHomePath() != null) {
            File file = new File(sdk.getHomePath());
            String[] contents = file.list();

            if (contents != null) {
                for (String path : contents) {
                    if (path.equals("build-tools")) {
                        androidSdkPath = sdk.getHomePath();
                        break;
                    }
                }
            }
        }
    }
    return androidSdkPath;
}
 
開發者ID:andreyfomenkov,項目名稱:green-cat,代碼行數:27,代碼來源:Utils.java

示例2: getAlreadyOpenedModules

import com.intellij.openapi.roots.ModuleRootManager; //導入依賴的package包/類
@NotNull
protected Set<HybrisModuleDescriptor> getAlreadyOpenedModules(@NotNull final Project project) {
    Validate.notNull(project);

    final HybrisModuleDescriptorFactory hybrisModuleDescriptorFactory = ServiceManager.getService(
        HybrisModuleDescriptorFactory.class
    );

    final Set<HybrisModuleDescriptor> existingModules = new THashSet<HybrisModuleDescriptor>();

    for (Module module : ModuleManager.getInstance(project).getModules()) {
        try {
            final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();

            if (!ArrayUtils.isEmpty(contentRoots)) {
                existingModules.add(hybrisModuleDescriptorFactory.createDescriptor(
                    VfsUtil.virtualToIoFile(contentRoots[0]), this
                ));
            }
        } catch (HybrisConfigurationException e) {
            LOG.error(e);
        }
    }

    return existingModules;
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:27,代碼來源:DefaultHybrisProjectDescriptor.java

示例3: suitableTestSourceFolders

import com.intellij.openapi.roots.ModuleRootManager; //導入依賴的package包/類
@Nullable
private static SourceFolder suitableTestSourceFolders(Project project, Module module) {
  ContentEntry[] contentEntries = ModuleRootManager.getInstance(module).getContentEntries();
  for (ContentEntry contentEntry : contentEntries) {
    List<SourceFolder> testSourceFolders =
        contentEntry.getSourceFolders(JavaSourceRootType.TEST_SOURCE);
    for (SourceFolder testSourceFolder : testSourceFolders) {
      if (testSourceFolder.getFile() != null) {
        if (!JavaProjectRootsUtil.isInGeneratedCode(testSourceFolder.getFile(), project)) {
          return testSourceFolder;
        }
      }
    }
  }

  return null;
}
 
開發者ID:uber,項目名稱:RIBs,代碼行數:18,代碼來源:GenerateAction.java

示例4: createConfigurable

import com.intellij.openapi.roots.ModuleRootManager; //導入依賴的package包/類
@Override
@NotNull
public FrameworkSupportInModuleConfigurable createConfigurable( @NotNull final FrameworkSupportModel model )
{
  return new RepositoryLibrarySupportInModuleConfigurable( model.getProject(), RepositoryLibraryDescription.findDescription( "systems.manifold", "manifold-all" ) )
         {
           @Override
           public void addSupport( @NotNull Module module, @NotNull ModifiableRootModel rootModel, @NotNull ModifiableModelsProvider modifiableModelsProvider )
           {
             super.addSupport( module, rootModel, modifiableModelsProvider );
             
             // also add tools.jar to the SDK if not already present
             ApplicationManager.getApplication().invokeLater( () -> ApplicationManager.getApplication().runWriteAction( () -> {
               ModifiableRootModel rootModel2 = ModuleRootManager.getInstance( module ).getModifiableModel();
               ManSupportProvider.addToolsJar( rootModel2 );
               rootModel2.commit();
             } ) );
           }
         };
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:21,代碼來源:ManFrameworkSupportProvider.java

示例5: isExported

import com.intellij.openapi.roots.ModuleRootManager; //導入依賴的package包/類
public static boolean isExported( Module ijModule, Module child )
{
  for( OrderEntry entry : ModuleRootManager.getInstance( ijModule ).getOrderEntries() )
  {
    if( entry instanceof ModuleOrderEntry )
    {
      final ModuleOrderEntry moduleEntry = (ModuleOrderEntry)entry;
      final DependencyScope scope = moduleEntry.getScope();
      if( !scope.isForProductionCompile() && !scope.isForProductionRuntime() )
      {
        continue;
      }
      final Module module = moduleEntry.getModule();
      if( module != null && module == child )
      {
        return moduleEntry.isExported();
      }
    }
  }
  return false;
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:22,代碼來源:ManProject.java

示例6: getDirectClassPaths

import com.intellij.openapi.roots.ModuleRootManager; //導入依賴的package包/類
private static List<String> getDirectClassPaths( Module ijModule )
{
  final ModuleRootManager rootManager = ModuleRootManager.getInstance( ijModule );
  final List<OrderEntry> orderEntries = Arrays.asList( rootManager.getOrderEntries() );

  List<String> paths = new ArrayList<>();
  for( OrderEntry entry : orderEntries.stream().filter( (LibraryOrderEntry.class)::isInstance ).collect( Collectors.toList() ) )
  {
    final Library lib = ((LibraryOrderEntry)entry).getLibrary();
    if( lib != null )
    {
      for( VirtualFile virtualFile : lib.getFiles( OrderRootType.CLASSES ) )
      {
        final File file = new File( stripExtraCharacters( virtualFile.getPath() ) );
        if( file.exists() )
        {
          paths.add( file.getAbsolutePath() );
        }
      }
    }
  }
  return paths;
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:24,代碼來源:ManProject.java

示例7: dependencyChainContains

import com.intellij.openapi.roots.ModuleRootManager; //導入依賴的package包/類
private static boolean dependencyChainContains( Module ijModule, String path, List<Module> visited )
{
  if( !visited.contains( ijModule ) )
  {
    visited.add( ijModule );

    ModuleRootManager rootManager = ModuleRootManager.getInstance( ijModule );
    for( Module dep : rootManager.getDependencies() )
    {
      if( getDirectClassPaths( dep ).contains( path ) || dependencyChainContains( dep, path, visited ) )
      {
        return true;
      }
    }
  }
  return false;
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:18,代碼來源:ManProject.java

示例8: moduleCreated

import com.intellij.openapi.roots.ModuleRootManager; //導入依賴的package包/類
@Override
    public void moduleCreated(@NotNull Module module) {
        StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
        String msg = String.format("Please wait while module for project %s is created", project.getName());
        settings = GravProjectSettings.getInstance(project);

        JBPopupFactory.getInstance()
                .createHtmlTextBalloonBuilder(msg, MessageType.WARNING, null)
                .setFadeoutTime(4000)
                .createBalloon()
                .show(RelativePoint.getSouthEastOf(statusBar.getComponent()), Balloon.Position.above);

        VirtualFile[] roots1 = ModuleRootManager.getInstance(module).getContentRoots();
        if (roots1.length != 0) {
            final VirtualFile src = roots1[0];
            settings.withSrcDirectory = withSrcDirectory;
            settings.gravInstallationPath = getGravInstallPath().getPath();
//            settings.withSrcDirectory =
            GravProjectGeneratorUtil generatorUtil = new GravProjectGeneratorUtil();
            generatorUtil.generateProject(project, src, settings, module);
        }
    }
 
開發者ID:PioBeat,項目名稱:GravSupport,代碼行數:23,代碼來源:GravModuleBuilder.java

示例9: createModule

import com.intellij.openapi.roots.ModuleRootManager; //導入依賴的package包/類
private static Module createModule(
        ProjectDescriptor projectDescriptor,
        final ModuleDescriptor descriptor,
        final Map<LibraryDescriptor, Library> projectLibs,
        final ModifiableModuleModel moduleModel) {

    logger.info("Starting createModule in ProjectFromSourcesBuilderImplModified");
    final String moduleFilePath = descriptor.computeModuleFilePath();
    ModuleBuilder.deleteModuleFile(moduleFilePath);

    final Module module =
            moduleModel.newModule(moduleFilePath, descriptor.getModuleType().getId());
    final ModifiableRootModel modifiableModel =
            ModuleRootManager.getInstance(module).getModifiableModel();
    setupRootModel(projectDescriptor, descriptor, modifiableModel, projectLibs);
    descriptor.updateModuleConfiguration(module, modifiableModel);
    modifiableModel.commit();
    logger.info("ending createModule in ProjectFromSourcesBuilderImplModified");
    return module;
}
 
開發者ID:testmycode,項目名稱:tmc-intellij,代碼行數:21,代碼來源:ProjectFromSourcesBuilderImplModified.java

示例10: resetModel

import com.intellij.openapi.roots.ModuleRootManager; //導入依賴的package包/類
private void resetModel() {
  List<Module> possibleDependencies = new ArrayList<Module>();
  myInitialDependencies = Arrays.asList(ModuleRootManager.getInstance(myModule).getDependencies());
  possibleDependencies.addAll(myInitialDependencies);
  for (Module otherModule : ModuleManager.getInstance(myModule.getProject()).getModules()) {
    if (!possibleDependencies.contains(otherModule) && otherModule != myModule) {
      possibleDependencies.add(otherModule);
    }
  }
  myDependenciesList.setItems(possibleDependencies, new Function<Module, String>() {
    @Override
    public String fun(Module module) {
      return module.getName();
    }
  });
  myDependenciesList.setBorder(null);
  for (Module dependency : myInitialDependencies) {
    myDependenciesList.setItemSelected(dependency, true);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:PyModuleDependenciesConfigurable.java

示例11: checkModule

import com.intellij.openapi.roots.ModuleRootManager; //導入依賴的package包/類
static void checkModule(String path, Module module) throws IOException, JDOMException, ConversionException {
  final File classpathFile1 = new File(path, EclipseXml.DOT_CLASSPATH_EXT);
  if (!classpathFile1.exists()) return;
  String fileText1 = FileUtil.loadFile(classpathFile1).replaceAll("\\$ROOT\\$", module.getProject().getBaseDir().getPath());
  if (!SystemInfo.isWindows) {
    fileText1 = fileText1.replaceAll(EclipseXml.FILE_PROTOCOL + "/", EclipseXml.FILE_PROTOCOL);
  }

  Element classpathElement1 = JDOMUtil.loadDocument(fileText1).getRootElement();
  ModuleRootModel model = ModuleRootManager.getInstance(module);
  Element resultClasspathElement = new EclipseClasspathWriter().writeClasspath(classpathElement1, model);

  String resulted = new String(JDOMUtil.printDocument(new Document(resultClasspathElement), "\n"));
  assertTrue(resulted.replaceAll(StringUtil.escapeToRegexp(module.getProject().getBaseDir().getPath()), "\\$ROOT\\$"),
             JDOMUtil.areElementsEqual(classpathElement1, resultClasspathElement));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:EclipseClasspathTest.java

示例12: checkConfiguration

import com.intellij.openapi.roots.ModuleRootManager; //導入依賴的package包/類
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
  if (getModule() == null) {
    throw new RuntimeConfigurationException(DevKitBundle.message("run.configuration.no.module.specified"));
  }
  String moduleName = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
    @Override
    public String compute() {
      return getModule().getName();
    }
  });
  if (ModuleManager.getInstance(getProject()).findModuleByName(moduleName) == null){
    throw new RuntimeConfigurationException(DevKitBundle.message("run.configuration.no.module.specified"));
  }
  final ModuleRootManager rootManager = ModuleRootManager.getInstance(getModule());
  final Sdk sdk = rootManager.getSdk();
  if (sdk == null) {
    throw new RuntimeConfigurationException(DevKitBundle.message("sdk.no.specified", moduleName));
  }
  if (IdeaJdk.findIdeaJdk(sdk) == null) {
    throw new RuntimeConfigurationException(DevKitBundle.message("sdk.type.incorrect", moduleName));
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:PluginRunConfiguration.java

示例13: findRequirementsTxt

import com.intellij.openapi.roots.ModuleRootManager; //導入依賴的package包/類
@Nullable
public static VirtualFile findRequirementsTxt(@NotNull Module module) {
  final String requirementsPath = PyPackageRequirementsSettings.getInstance(module).getRequirementsPath();
  if (!requirementsPath.isEmpty()) {
    final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(requirementsPath);
    if (file != null) {
      return file;
    }
    final ModuleRootManager manager = ModuleRootManager.getInstance(module);
    for (VirtualFile root : manager.getContentRoots()) {
      final VirtualFile fileInRoot = root.findFileByRelativePath(requirementsPath);
      if (fileInRoot != null) {
        return fileInRoot;
      }
    }
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:PyPackageUtil.java

示例14: createFile

import com.intellij.openapi.roots.ModuleRootManager; //導入依賴的package包/類
@NotNull
protected PsiFile createFile(@NotNull final Module module, @NotNull final VirtualFile vDir, @NotNull final String fileName, @NotNull final String text) throws IOException {
  return new WriteAction<PsiFile>() {
    @Override
    protected void run(@NotNull Result<PsiFile> result) throws Throwable {
      if (!ModuleRootManager.getInstance(module).getFileIndex().isInSourceContent(vDir)) {
        addSourceContentToRoots(module, vDir);
      }

      final VirtualFile vFile = vDir.createChildData(vDir, fileName);
      VfsUtil.saveText(vFile, text);
      assertNotNull(vFile);
      final PsiFile file = myPsiManager.findFile(vFile);
      assertNotNull(file);
      result.setResult(file);
    }
  }.execute().getResultObject();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:PsiTestCase.java

示例15: MoveClassToModuleFix

import com.intellij.openapi.roots.ModuleRootManager; //導入依賴的package包/類
public MoveClassToModuleFix(String referenceName, Module currentModule, PsiDirectory root, PsiElement psiElement) {
  myReferenceName = referenceName;
  myCurrentModule = currentModule;
  mySourceRoot = root;
  final Project project = psiElement.getProject();
  final PsiClass[] classes = PsiShortNamesCache.getInstance(project).getClassesByName(referenceName, GlobalSearchScope.allScope(project));
  final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  for (final PsiClass aClass : classes) {
    if (!facade.getResolveHelper().isAccessible(aClass, psiElement, aClass)) continue;
    final PsiFile psiFile = aClass.getContainingFile();
    if (!(psiFile instanceof PsiJavaFile)) continue;
    if (aClass.getQualifiedName() == null) continue;
    VirtualFile virtualFile = psiFile.getVirtualFile();
    if (virtualFile == null) continue;
    final Module classModule = fileIndex.getModuleForFile(virtualFile);
    if (classModule != null && classModule != currentModule && !ModuleRootManager.getInstance(currentModule).isDependsOn(classModule)) {
      myModules.put(aClass, classModule);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:MoveClassToModuleFix.java


注:本文中的com.intellij.openapi.roots.ModuleRootManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。