當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。