Java Code Examples for com.intellij.openapi.module.Module#isDisposed()
The following examples show how to use
com.intellij.openapi.module.Module#isDisposed() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlutterModuleUtils.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Return true if the passed module is of a Flutter type. Before version M16 this plugin had its own Flutter {@link ModuleType}. * Post M16 a Flutter module is defined by the following: * <p> * <code> * [Flutter support enabled for a module] === * [Dart support enabled && referenced Dart SDK is the one inside a Flutter SDK] * </code> */ public static boolean isFlutterModule(@Nullable final Module module) { if (module == null || module.isDisposed()) return false; if (PlatformUtils.isIntelliJ() || FlutterUtils.isAndroidStudio()) { // [Flutter support enabled for a module] === // [Dart support enabled && referenced Dart SDK is the one inside a Flutter SDK] final DartSdk dartSdk = DartPlugin.getDartSdk(module.getProject()); final String dartSdkPath = dartSdk != null ? dartSdk.getHomePath() : null; return validDartSdkPath(dartSdkPath) && DartPlugin.isDartSdkEnabled(module); } else { // If not IntelliJ, assume a small IDE (no multi-module project support). return declaresFlutter(module); } }
Example 2
Source File: FlutterModuleUtils.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Return true if the passed module is of a Flutter type. Before version M16 this plugin had its own Flutter {@link ModuleType}. * Post M16 a Flutter module is defined by the following: * <p> * <code> * [Flutter support enabled for a module] === * [Dart support enabled && referenced Dart SDK is the one inside a Flutter SDK] * </code> */ public static boolean isFlutterModule(@Nullable final Module module) { if (module == null || module.isDisposed()) return false; if (PlatformUtils.isIntelliJ() || FlutterUtils.isAndroidStudio()) { // [Flutter support enabled for a module] === // [Dart support enabled && referenced Dart SDK is the one inside a Flutter SDK] final DartSdk dartSdk = DartPlugin.getDartSdk(module.getProject()); final String dartSdkPath = dartSdk != null ? dartSdk.getHomePath() : null; return validDartSdkPath(dartSdkPath) && DartPlugin.isDartSdkEnabled(module); } else { // If not IntelliJ, assume a small IDE (no multi-module project support). return declaresFlutter(module); } }
Example 3
Source File: HaxeProjectSdkSetupValidator.java From intellij-haxe with Apache License 2.0 | 6 votes |
private SdkValidationResult validateSdk(Project project, VirtualFile file) { final Module module = ModuleUtilCore.findModuleForFile(file, project); if (module != null && !module.isDisposed()) { final Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); if (sdk == null) { if (ModuleRootManager.getInstance(module).isSdkInherited()) { return PROJECT_SDK_NOT_DEFINED; } else { return MODULE_SDK_NOT_DEFINED; } } else { return validateSdkRoots(sdk); } } return null; }
Example 4
Source File: HaxeProjectSdkSetupValidator.java From intellij-haxe with Apache License 2.0 | 6 votes |
private void pruneExcessiveRoots(Project project, VirtualFile file) { final Module module = ModuleUtilCore.findModuleForFile(file, project); if (module != null && !module.isDisposed()) { final Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); if (sdk != null) { final SdkModificator modificator = sdk.getSdkModificator(); final VirtualFile stdRoot = getDistinctRootsStream(sdk) .filter(root -> root.findChild(STD_TYPES_HX) != null) .findFirst() .orElse(null); if (stdRoot != null) { modificator.removeAllRoots(); modificator.addRoot(stdRoot, OrderRootType.CLASSES); modificator.addRoot(stdRoot, OrderRootType.SOURCES); WriteAction.run(modificator::commitChanges); } } } }
Example 5
Source File: AbstractModuleNode.java From consulo with Apache License 2.0 | 6 votes |
@Override public boolean contains(@Nonnull VirtualFile file) { Module module = getValue(); if (module == null || module.isDisposed()) return false; final VirtualFile testee; if (file.getFileSystem() instanceof ArchiveFileSystem) { testee = ((ArchiveFileSystem)file.getFileSystem()).getLocalVirtualFileFor(file); if (testee == null) return false; } else { testee = file; } for (VirtualFile root : ModuleRootManager.getInstance(module).getContentRoots()) { if (VfsUtilCore.isAncestor(root, testee, false)) return true; } return false; }
Example 6
Source File: TodoTreeBuilder.java From consulo with Apache License 2.0 | 6 votes |
/** * @return read-only iterator of all valid PSI files that can have T.O.D.O items * and which in specified {@code module}. * @see FileTree#getFiles(VirtualFile) */ public Iterator<PsiFile> getFiles(Module module) { if (module.isDisposed()) return Collections.emptyIterator(); ArrayList<PsiFile> psiFileList = new ArrayList<>(); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots(); for (VirtualFile virtualFile : contentRoots) { List<VirtualFile> files = myFileTree.getFiles(virtualFile); PsiManager psiManager = PsiManager.getInstance(myProject); for (VirtualFile file : files) { if (fileIndex.getModuleForFile(file) != module) continue; if (file.isValid()) { PsiFile psiFile = psiManager.findFile(file); if (psiFile != null) { psiFileList.add(psiFile); } } } } return psiFileList.iterator(); }
Example 7
Source File: WebProjectViewImpl.java From consulo with Apache License 2.0 | 5 votes |
/** * Project view has the same node for module and its single content root * => MODULE_CONTEXT data key should return the module when its content root is selected * When there are multiple content roots, they have different nodes under the module node * => MODULE_CONTEXT should be only available for the module node * otherwise VirtualFileArrayRule will return all module's content roots when just one of them is selected */ @javax.annotation.Nullable private Module moduleBySingleContentRoot(@Nonnull VirtualFile file) { if (ProjectRootsUtil.isModuleContentRoot(file, myProject)) { Module module = ProjectRootManager.getInstance(myProject).getFileIndex().getModuleForFile(file); if (module != null && !module.isDisposed() && ModuleRootManager.getInstance(module).getContentRoots().length == 1) { return module; } } return null; }
Example 8
Source File: ProjectViewModuleNode.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull @RequiredReadAction public Collection<AbstractTreeNode> getChildren() { Module module = getValue(); if (module == null || module.isDisposed()) { return Collections.emptyList(); } ModuleRootManager rootManager = ModuleRootManager.getInstance(module); ModuleFileIndex moduleFileIndex = rootManager.getFileIndex(); final VirtualFile[] contentRoots = rootManager.getContentRoots(); final List<AbstractTreeNode> children = new ArrayList<>(contentRoots.length + 1); final PsiManager psiManager = PsiManager.getInstance(module.getProject()); for (final VirtualFile contentRoot : contentRoots) { if (!moduleFileIndex.isInContent(contentRoot)) continue; if (contentRoot.isDirectory()) { PsiDirectory directory = psiManager.findDirectory(contentRoot); if(directory != null) { children.add(new PsiDirectoryNode(getProject(), directory, getSettings())); } } else { PsiFile file = psiManager.findFile(contentRoot); if(file != null) { children.add(new PsiFileNode(getProject(), file, getSettings())); } } } return children; }
Example 9
Source File: ProjectViewImpl.java From consulo with Apache License 2.0 | 5 votes |
/** * Project view has the same node for module and its single content root * => MODULE_CONTEXT data key should return the module when its content root is selected * When there are multiple content roots, they have different nodes under the module node * => MODULE_CONTEXT should be only available for the module node * otherwise VirtualFileArrayRule will return all module's content roots when just one of them is selected */ @Nullable private Module moduleBySingleContentRoot(@Nonnull VirtualFile file) { if (ProjectRootsUtil.isModuleContentRoot(file, myProject)) { Module module = ProjectRootManager.getInstance(myProject).getFileIndex().getModuleForFile(file); if (module != null && !module.isDisposed() && ModuleRootManager.getInstance(module).getContentRoots().length == 1) { return module; } } return null; }
Example 10
Source File: GotoModuleDirectory.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private static VirtualFile getModuleDir(final AnActionEvent e) { Module module = e.getData(LangDataKeys.MODULE_CONTEXT); if (module == null) { module = e.getData(LangDataKeys.MODULE); } if (module != null && !module.isDisposed()) { return module.getModuleDir(); } return null; }
Example 11
Source File: ContentEntriesEditor.java From consulo with Apache License 2.0 | 5 votes |
public ContentEntriesEditor(String moduleName, final ModuleConfigurationState state) { super(state); myState = state; myModuleName = moduleName; myModulesProvider = state.getModulesProvider(); final VirtualFileManagerAdapter fileManagerListener = new VirtualFileManagerAdapter() { @Override public void afterRefreshFinish(boolean asynchronous) { if (state.getProject().isDisposed()) { return; } final Module module = getModule(); if (module == null || module.isDisposed()) return; for (final ContentEntryEditor editor : myEntryToEditorMap.values()) { editor.update(); } } }; final VirtualFileManager fileManager = VirtualFileManager.getInstance(); fileManager.addVirtualFileManagerListener(fileManagerListener); registerDisposable(new Disposable() { @Override public void dispose() { fileManager.removeVirtualFileManagerListener(fileManagerListener); } }); }
Example 12
Source File: ProjectFileNode.java From consulo with Apache License 2.0 | 5 votes |
/** * Returns a {@link Module} to which the specified {@code file} belongs; * or a {@link Project} if the specified {@code file} does not belong to any module, but is located under the base project directory; * or {@code null} if the specified {@code file} does not correspond to the given {@code project} */ @Nullable static ComponentManager findArea(@Nonnull VirtualFile file, @Nullable Project project) { if (project == null || project.isDisposed() || !file.isValid()) return null; Module module = ProjectFileIndex.getInstance(project).getModuleForFile(file, false); if (module != null) return module.isDisposed() ? null : module; if (!is("projectView.show.base.dir")) return null; VirtualFile ancestor = findBaseDir(project); // file does not belong to any content root, but it is located under the project directory and not ignored return ancestor == null || FileTypeRegistry.getInstance().isFileIgnored(file) || !isAncestor(ancestor, file, false) ? null : project; }
Example 13
Source File: AnalysisScope.java From consulo with Apache License 2.0 | 5 votes |
public boolean isValid() { if (myModules != null){ for (Module module : myModules) { if (module.isDisposed()) return false; } return true; } if (myModule != null) return !myModule.isDisposed(); if (myElement != null) { return myElement.isValid(); } return myType == VIRTUAL_FILES || myType == CUSTOM || myType == PROJECT; }
Example 14
Source File: ModuleManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public Module findModuleByName(@Nonnull String name) { for (Module module : myModules) { if (!module.isDisposed() && module.getName().equals(name)) { return module; } } return null; }
Example 15
Source File: RunAnythingPopupUI.java From consulo with Apache License 2.0 | 4 votes |
@Nullable public VirtualFile getFirstContentRoot(@Nonnull final Module module) { if (module.isDisposed()) return null; return ArrayUtil.getFirstElement(ModuleRootManager.getInstance(module).getContentRoots()); }
Example 16
Source File: PackageViewModuleNode.java From consulo with Apache License 2.0 | 4 votes |
@Override public boolean contains(@Nonnull VirtualFile file) { Module module = getValue(); return module != null && !module.isDisposed() && (ModuleUtilCore.moduleContainsFile(module, file, false) || ModuleUtilCore.moduleContainsFile(module, file, true)); }
Example 17
Source File: ModuleDataValidator.java From consulo with Apache License 2.0 | 4 votes |
@Nullable @Override public Module findInvalid(Key<Module> key, Module data, Object dataSource) { return data.isDisposed() ? data : null; }
Example 18
Source File: VirtualFileArrayRule.java From consulo with Apache License 2.0 | 4 votes |
@Override public VirtualFile[] getData(@Nonnull final DataProvider dataProvider) { // Try to detect multiselection. Project project = dataProvider.getDataUnchecked(PlatformDataKeys.PROJECT_CONTEXT); if (project != null && !project.isDisposed()) { return ProjectRootManager.getInstance(project).getContentRoots(); } Module[] selectedModules = dataProvider.getDataUnchecked(LangDataKeys.MODULE_CONTEXT_ARRAY); if (selectedModules != null && selectedModules.length > 0) { return getFilesFromModules(selectedModules); } Module selectedModule = dataProvider.getDataUnchecked(LangDataKeys.MODULE_CONTEXT); if (selectedModule != null && !selectedModule.isDisposed()) { return ModuleRootManager.getInstance(selectedModule).getContentRoots(); } PsiElement[] psiElements = dataProvider.getDataUnchecked(LangDataKeys.PSI_ELEMENT_ARRAY); if (psiElements != null && psiElements.length != 0) { return getFilesFromPsiElements(psiElements); } // VirtualFile -> VirtualFile[] VirtualFile vFile = dataProvider.getDataUnchecked(PlatformDataKeys.VIRTUAL_FILE); if (vFile != null) { return new VirtualFile[]{vFile}; } // PsiFile psiFile = dataProvider.getDataUnchecked(LangDataKeys.PSI_FILE); if (psiFile != null && psiFile.getVirtualFile() != null) { return new VirtualFile[]{psiFile.getVirtualFile()}; } PsiElement elem = dataProvider.getDataUnchecked(LangDataKeys.PSI_ELEMENT); if (elem != null) { return getFilesFromPsiElement(elem); } Usage[] usages = dataProvider.getDataUnchecked(UsageView.USAGES_KEY); UsageTarget[] usageTargets = dataProvider.getDataUnchecked(UsageView.USAGE_TARGETS_KEY); if (usages != null || usageTargets != null) { return UsageDataUtil.provideVirtualFileArray(usages, usageTargets); } return null; }
Example 19
Source File: MindMapFacet.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
@Nullable public static MindMapFacet getInstance(@Nullable final Module module) { return module == null || module.isDisposed() ? null : FacetManager.getInstance(module).getFacetByType(ID); }