当前位置: 首页>>代码示例>>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;未经允许,请勿转载。