本文整理匯總了Java中com.intellij.openapi.module.ModuleManager.getModules方法的典型用法代碼示例。如果您正苦於以下問題:Java ModuleManager.getModules方法的具體用法?Java ModuleManager.getModules怎麽用?Java ModuleManager.getModules使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.module.ModuleManager
的用法示例。
在下文中一共展示了ModuleManager.getModules方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAndroidSdkPath
import com.intellij.openapi.module.ModuleManager; //導入方法依賴的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;
}
示例2: getReferences
import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
@NotNull
@Override
public PsiReference[] getReferences() {
String filename = getFilename();
if (filename == null) {
return new PsiReference[0];
}
Module module = ModuleUtilCore.findModuleForPsiElement(this);
if (module != null) {
referenceProvider.getReferencesByElement(this, filename, 1, true);
}
// fallback: if we are inside of a dependency, current module is null
// in this case we try to resolve reference in all dependencies of all modules
// (might be not fully correct, but better than nothing)
ModuleManager moduleManager = ModuleManager.getInstance(getProject());
Module[] modules = moduleManager.getModules();
return referenceProvider.getReferencesByElement(this, filename, 1, true, modules);
}
示例3: configureProject
import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
@Override
public void configureProject(final Project project, @NotNull final VirtualFile baseDir, final Ref<Module> moduleRef) {
final ModuleManager moduleManager = ModuleManager.getInstance(project);
final Module[] modules = moduleManager.getModules();
if (modules.length == 0) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
String moduleName = baseDir.getName().replace(":", ""); // correct module name when opening root of drive as project (RUBY-5181)
String imlName = baseDir.getPath() + "/.idea/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION;
ModuleTypeManager instance = ModuleTypeManager.getInstance();
String id = instance == null ? "unknown" : instance.getDefaultModuleType().getId();
final Module module = moduleManager.newModule(imlName, id);
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
ModifiableRootModel rootModel = rootManager.getModifiableModel();
if (rootModel.getContentRoots().length == 0) {
rootModel.addContentEntry(baseDir);
}
rootModel.inheritSdk();
rootModel.commit();
moduleRef.set(module);
}
});
}
}
示例4: getRoots
import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
private synchronized Map<Module, MultiValuesMap<LogicalRootType, LogicalRoot>> getRoots(final ModuleManager moduleManager) {
if (myRoots == null) {
myRoots = new THashMap<Module, MultiValuesMap<LogicalRootType, LogicalRoot>>();
final Module[] modules = moduleManager.getModules();
for (Module module : modules) {
final MultiValuesMap<LogicalRootType, LogicalRoot> map = new MultiValuesMap<LogicalRootType, LogicalRoot>();
for (Map.Entry<LogicalRootType, Collection<NotNullFunction>> entry : myProviders.entrySet()) {
final Collection<NotNullFunction> functions = entry.getValue();
for (NotNullFunction function : functions) {
map.putAll(entry.getKey(), (List<LogicalRoot>) function.fun(module));
}
}
myRoots.put(module, map);
}
}
return myRoots;
}
示例5: excludeOutputFolders
import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
/**
* Even though {@link com.android.tools.idea.gradle.customizer.android.ContentRootModuleCustomizer} already excluded the folders
* "$buildDir/intermediates" and "$buildDir/outputs" we go through the children of "$buildDir" and exclude any non-generated folders
* that may have been created by other plug-ins. We need to be aggressive when excluding folder to prevent over-indexing files, which
* will degrade the IDE's performance.
*/
private void excludeOutputFolders() {
if (myProject.isDisposed()) {
return;
}
ModuleManager moduleManager = ModuleManager.getInstance(myProject);
if (myProject.isDisposed()) {
return;
}
for (Module module : moduleManager.getModules()) {
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null && facet.isGradleProject()) {
excludeOutputFolders(facet);
}
}
}
示例6: guessLanguageLevel
import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
@NotNull
public static LanguageLevel guessLanguageLevel(@NotNull Project project) {
final ModuleManager moduleManager = ModuleManager.getInstance(project);
if (moduleManager != null) {
LanguageLevel maxLevel = null;
for (Module projectModule : moduleManager.getModules()) {
final Sdk sdk = PythonSdkType.findPythonSdk(projectModule);
if (sdk != null) {
final LanguageLevel level = PythonSdkType.getLanguageLevelForSdk(sdk);
if (maxLevel == null || maxLevel.isOlderThan(level)) {
maxLevel = level;
}
}
}
if (maxLevel != null) {
return maxLevel;
}
}
return LanguageLevel.getDefault();
}
示例7: syncSucceeded
import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
@Override
public void syncSucceeded(@NotNull Project project) {
disposeOnTearDown(project);
// Verify that project was imported correctly.
assertEquals(myProjectName, project.getName());
assertEquals(myProjectRootDir.getPath(), project.getBasePath());
// Verify that '.idea' directory was created.
File ideaProjectDir = new File(myProjectRootDir, Project.DIRECTORY_STORE_FOLDER);
assertTrue(ideaProjectDir.isDirectory());
// Verify that module was created.
ModuleManager moduleManager = ModuleManager.getInstance(project);
Module[] modules = moduleManager.getModules();
assertEquals(1, modules.length);
assertEquals(myModule.getName(), modules[0].getName());
}
示例8: findPathOfSdkMissingOrEmptyAddonsFolder
import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
@Nullable
private static File findPathOfSdkMissingOrEmptyAddonsFolder(@NotNull Project project) {
ModuleManager moduleManager = ModuleManager.getInstance(project);
for (Module module : moduleManager.getModules()) {
Sdk moduleSdk = ModuleRootManager.getInstance(module).getSdk();
if (moduleSdk != null && isAndroidSdk(moduleSdk)) {
String homePath = moduleSdk.getHomePath();
if (homePath != null) {
File sdkHomeDirPath = new File(FileUtil.toSystemDependentName(homePath));
File addonsDir = new File(sdkHomeDirPath, SdkConstants.FD_ADDONS);
if (!addonsDir.isDirectory() || FileUtil.notNullize(addonsDir.listFiles()).length == 0) {
return sdkHomeDirPath;
}
}
}
}
return null;
}
示例9: createAvailableTasks
import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
private List<String> createAvailableTasks() {
ModuleManager moduleManager = ModuleManager.getInstance(myProject);
List<String> gradleTasks = Lists.newArrayList();
for (Module module : moduleManager.getModules()) {
AndroidGradleFacet facet = AndroidGradleFacet.getInstance(module);
if (facet == null) {
continue;
}
IdeaGradleProject gradleProject = facet.getGradleProject();
if (gradleProject == null) {
continue;
}
gradleTasks.addAll(gradleProject.getTaskNames());
}
return gradleTasks;
}
示例10: getMuleModules
import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
public static List<Module> getMuleModules(Project project, boolean includeDomains)
{
final List<Module> muleModules = new ArrayList<>();
final ModuleManager moduleManager = ModuleManager.getInstance(project);
Module[] allModules = moduleManager.getModules();
for (Module m : allModules) {
if (MuleConfigUtils.isMuleModule(m) || (includeDomains && MuleConfigUtils.isMuleDomainModule(m)))
muleModules.add(m);
}
return muleModules;
}
示例11: isUniqueModuleName
import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
private boolean isUniqueModuleName(@NotNull String moduleName) {
if (myProject == null) {
return true;
}
// Check our modules
ModuleManager moduleManager = ModuleManager.getInstance(myProject);
for (Module m : moduleManager.getModules()) {
if (m.getName().equalsIgnoreCase(moduleName)) {
return false;
}
}
return true;
}
示例12: testComputeModuleName
import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
public void testComputeModuleName() throws Exception {
ModuleManager manager = ModuleManager.getInstance(getProject());
myStep = new ConfigureAndroidModuleStep(myState, getProject(), null, TemplateWizardStep.NONE);
Module module = manager.getModules()[0];
assertEquals("app", module.getName());
myState.myHidden.add(ATTR_PROJECT_LOCATION);
myState.put(ATTR_IS_LIBRARY_MODULE, true);
// "Lib" and "lib2" already exist
assertEquals("lib3", myStep.computeModuleName());
myState.put(ATTR_IS_LIBRARY_MODULE, false);
// "app" already exists
assertEquals("app2", myStep.computeModuleName());
}
示例13: findGradleProjectModule
import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
/**
* @see #isGradleProjectModule(Module)
*/
@Nullable
public static Module findGradleProjectModule(@NotNull Project project) {
ModuleManager moduleManager = ModuleManager.getInstance(project);
Module[] modules = moduleManager.getModules();
if (modules.length == 1) {
return modules[0];
}
for (Module module : modules) {
if (isGradleProjectModule(module)) {
return module;
}
}
return null;
}
示例14: getModulesWithAndroidFacet
import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
private static Module[] getModulesWithAndroidFacet(Project project) {
final ModuleManager moduleManager = ModuleManager.getInstance(project);
final Module[] modules = moduleManager.getModules();
List<Module> result = new ArrayList<Module>();
for (Module module : modules) {
final AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null && !facet.isLibraryProject()) {
result.add(module);
}
}
return result.toArray(new Module[result.size()]);
}
示例15: findAndroidFacetInProject
import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
@Nullable
private static AndroidFacet findAndroidFacetInProject(@NonNull com.intellij.openapi.project.Project project) {
ModuleManager moduleManager = ModuleManager.getInstance(project);
for (Module module : moduleManager.getModules()) {
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null) {
return facet;
}
}
return null;
}