mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-112280 Mark directory as... disappears from the context menu if multiple directories are selected
This commit is contained in:
@@ -21,7 +21,8 @@ import com.intellij.ide.impl.DataManagerImpl;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -40,22 +41,42 @@ public class ModuleRule implements GetDataRule {
|
||||
Project project = PlatformDataKeys.PROJECT.getData(dataProvider);
|
||||
if (project == null) {
|
||||
PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataProvider);
|
||||
if (element == null) {
|
||||
PsiElement[] psiElements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataProvider);
|
||||
if (psiElements != null && psiElements.length > 0) {
|
||||
element = psiElements[0];
|
||||
}
|
||||
}
|
||||
if (element == null || !element.isValid()) return null;
|
||||
project = element.getProject();
|
||||
}
|
||||
|
||||
VirtualFile virtualFile = PlatformDataKeys.VIRTUAL_FILE.getData(dataProvider);
|
||||
if (virtualFile == null) {
|
||||
GetDataRule dataRule = ((DataManagerImpl)DataManager.getInstance()).getDataRule(PlatformDataKeys.VIRTUAL_FILE.getName());
|
||||
VirtualFile[] files = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataProvider);
|
||||
if (files == null) {
|
||||
GetDataRule dataRule = ((DataManagerImpl)DataManager.getInstance()).getDataRule(PlatformDataKeys.VIRTUAL_FILE_ARRAY.getName());
|
||||
if (dataRule != null) {
|
||||
virtualFile = (VirtualFile)dataRule.getData(dataProvider);
|
||||
files = (VirtualFile[])dataRule.getData(dataProvider);
|
||||
}
|
||||
}
|
||||
|
||||
if (virtualFile == null) {
|
||||
if (files == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ModuleUtil.findModuleForFile(virtualFile, project);
|
||||
Module singleModule = null;
|
||||
for (VirtualFile file : files) {
|
||||
Module module = ModuleUtilCore.findModuleForFile(file, project);
|
||||
if (module == null) {
|
||||
return null;
|
||||
}
|
||||
if (singleModule == null) {
|
||||
singleModule = module;
|
||||
}
|
||||
else if (module != singleModule) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return singleModule;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user