当前位置: 首页>>代码示例>>Java>>正文


Java ModuleRootManager.getSourceRoots方法代码示例

本文整理汇总了Java中com.intellij.openapi.roots.ModuleRootManager.getSourceRoots方法的典型用法代码示例。如果您正苦于以下问题:Java ModuleRootManager.getSourceRoots方法的具体用法?Java ModuleRootManager.getSourceRoots怎么用?Java ModuleRootManager.getSourceRoots使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.roots.ModuleRootManager的用法示例。


在下文中一共展示了ModuleRootManager.getSourceRoots方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSelectedDirectoriesInAmbiguousCase

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
@NotNull
protected PsiDirectory[] getSelectedDirectoriesInAmbiguousCase(@NotNull final DefaultMutableTreeNode node) {
  final Object userObject = node.getUserObject();
  if (userObject instanceof AbstractModuleNode) {
    final Module module = ((AbstractModuleNode)userObject).getValue();
    if (module != null) {
      final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
      final VirtualFile[] sourceRoots = moduleRootManager.getSourceRoots();
      List<PsiDirectory> dirs = new ArrayList<PsiDirectory>(sourceRoots.length);
      final PsiManager psiManager = PsiManager.getInstance(myProject);
      for (final VirtualFile sourceRoot : sourceRoots) {
        final PsiDirectory directory = psiManager.findDirectory(sourceRoot);
        if (directory != null) {
          dirs.add(directory);
        }
      }
      return dirs.toArray(new PsiDirectory[dirs.size()]);
    }
  }
  return PsiDirectory.EMPTY_ARRAY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:AbstractProjectViewPane.java

示例2: getPotentialRoots

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
private static List<VirtualFile> getPotentialRoots(Module module, PsiDirectory[] dirs) {
  if (dirs.length != 0) {
    final List<VirtualFile> result = new ArrayList<VirtualFile>();
    for (PsiDirectory dir : dirs) {
      final PsiDirectory parent = dir.getParentDirectory();
      if (parent != null) result.add(parent.getVirtualFile());
    }
    return result;
  }
  else {
    ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
    List<VirtualFile> resourceRoots = rootManager.getSourceRoots(JavaResourceRootType.RESOURCE);
    if (!resourceRoots.isEmpty()) {
      return resourceRoots;
    }
    return rootManager.getSourceRoots(JavaModuleSourceRootTypes.SOURCES);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:CreateHtmlDescriptionFix.java

示例3: getSourceRoots

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
public static List<VirtualFile> getSourceRoots( Module ijModule )
{
  final ModuleRootManager moduleManager = ModuleRootManager.getInstance( ijModule );
  final List<VirtualFile> sourcePaths = new ArrayList<>();
  List<VirtualFile> excludeRoots = Arrays.asList( moduleManager.getExcludeRoots() );
  for( VirtualFile sourceRoot : moduleManager.getSourceRoots() )
  {
    if( !excludeRoots.contains( sourceRoot ) )
    {
      sourcePaths.add( sourceRoot );
    }
  }

  return sourcePaths;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:16,代码来源:ManProject.java

示例4: hasChanges

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
/**
 * Allows to answer if any file that belongs to the given module has changes in comparison with VCS.
 * 
 * @param module  target module to check
 * @return        <code>true</code> if any file that belongs to the given module has changes in comparison with VCS
 *                <code>false</code> otherwise
 */
public static boolean hasChanges(@NotNull Module module) {
  final ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
  for (VirtualFile root : rootManager.getSourceRoots()) {
    if (hasChanges(root, module.getProject())) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:FormatChangedTextUtil.java

示例5: actionPerformed

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
  Module module = myContext.getModule();
  final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();

  if (contentRoots.length == 0) {
    return;
  }
  VirtualFile initialFile = null;
  String path = myTextField.getText().trim();
  if (path.length() == 0) {
    path = myDefaultPath;
  }
  if (path != null) {
    initialFile = LocalFileSystem.getInstance().findFileByPath(path);
  }
  if (initialFile == null) {
    ModuleRootManager manager = ModuleRootManager.getInstance(module);
    VirtualFile[] sourceRoots = manager.getSourceRoots();
    if (sourceRoots.length > 0) {
      initialFile = sourceRoots[0];
    }
    else {
      initialFile = module.getModuleFile();
      if (initialFile == null) {
        String p = AndroidRootUtil.getModuleDirPath(myContext.getModule());
        if (p != null) {
          initialFile = LocalFileSystem.getInstance().findFileByPath(p);
        }
      }
    }
  }
  final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  descriptor.setRoots(contentRoots);
  VirtualFile file = FileChooser.chooseFile(descriptor, myContentPanel, myContext.getProject(), initialFile);
  if (file != null) {
    myTextField.setText(FileUtil.toSystemDependentName(file.getPath()));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:AndroidFacetEditorTab.java

示例6: hasCustomCompile

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean hasCustomCompile(ModuleChunk chunk) {
  for (Module m : chunk.getModules()) {
    if (LibrariesUtil.hasGroovySdk(m)) {
      final Set<String> scriptExtensions = GroovyFileTypeLoader.getCustomGroovyScriptExtensions();
      final ContentIterator groovyFileSearcher = new ContentIterator() {
        @Override
        public boolean processFile(VirtualFile fileOrDir) {
          ProgressManager.checkCanceled();
          if (isCompilableGroovyFile(fileOrDir, scriptExtensions)) {
            return false;
          }
          return true;
        }
      };

      final ModuleRootManager rootManager = ModuleRootManager.getInstance(m);
      final ModuleFileIndex fileIndex = rootManager.getFileIndex();
      for (VirtualFile file : rootManager.getSourceRoots(JavaModuleSourceRootTypes.SOURCES)) {
        if (!fileIndex.iterateContentUnderDirectory(file, groovyFileSearcher)) {
          return true;
        }
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:GroovyAntCustomCompilerProvider.java

示例7: createTheme

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
private void createTheme(@NotNull Project project, Module module) {
    String[] commands = {"echo", "0", "|", "php", "bin/plugin", "devtools", "new-theme",
            "--name", themeData.getName(),
            "--description", themeData.getDescription(),
            "--developer", themeData.getDeveloper(),
            "--email", themeData.getEmail()};

    GravProjectSettings settings = GravProjectSettings.getInstance(project);
    ModuleRootManager root = ModuleRootManager.getInstance(module);
    VirtualFile srcFile = null;
    for (VirtualFile file : root.getSourceRoots()) {
        if (file.isDirectory() && file.getName().contentEquals("src")) {
            srcFile = file;
            break;
        }
    }

    if (srcFile == null) {
        if (settings != null && settings.withSrcDirectory) {
            NotificationHelper.showBaloon("No source root found in module '" + module.getName() + "'",
                    MessageType.ERROR, project);
            return;
        } else {
            srcFile = FileCreateUtil.getParentDirectory(module.getModuleFile(), module.getName());
        }
    }

    VirtualFile finalSrcFile = srcFile;
    ProcessUtils processUtils = new ProcessUtils(commands, new File(finalSrcFile.getPath()));
    Task.Backgroundable t = new Task.Backgroundable(project, "Create New Grav Theme in Module '" + module.getName() + "'") {
        @Override
        public boolean shouldStartInBackground() {
            return true;
        }

        @Override
        public void onSuccess() {
            super.onSuccess();
            String output = processUtils.getOutputAsString();
            if (processUtils.getErrorOutput() != null) {
                NotificationHelper.showBaloon(processUtils.getErrorOutput(), MessageType.ERROR, project);
            } else {
                NotificationHelper.showBaloon("Theme '" + themeData.getName() + "' was created", MessageType.INFO, project);
            }
        }

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            processUtils.execute();
        }
    };
    ProgressManager.getInstance().run(t);

}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:55,代码来源:CreateNewThemeAction.java

示例8: getTestSourceRootCount

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
private static int getTestSourceRootCount(@NotNull Module module) {
  final ModuleRootManager manager = ModuleRootManager.getInstance(module);
  return manager.getSourceRoots(true).length - manager.getSourceRoots(false).length;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:AndroidTestRunConfiguration.java


注:本文中的com.intellij.openapi.roots.ModuleRootManager.getSourceRoots方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。