use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class MavenDomUtil method findContainingMavenizedModule.
@Nullable
public static Module findContainingMavenizedModule(@NotNull PsiFile psiFile) {
VirtualFile file = psiFile.getVirtualFile();
if (file == null)
return null;
Project project = psiFile.getProject();
MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
if (!manager.isMavenizedProject())
return null;
ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
Module module = index.getModuleForFile(file);
if (module == null || !manager.isMavenizedModule(module))
return null;
return module;
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class AbstractTestNGSuiteConfigurationProducer method setupConfigurationFromContext.
@Override
protected boolean setupConfigurationFromContext(TestNGConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
final PsiElement element = context.getPsiLocation();
final PsiFile containingFile = element != null ? element.getContainingFile() : null;
if (containingFile == null)
return false;
final VirtualFile virtualFile = containingFile.getVirtualFile();
if (virtualFile == null || !virtualFile.isValid())
return false;
if (!TestNGUtil.isTestngXML(virtualFile))
return false;
RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(context);
setupConfigurationModule(context, configuration);
final Module originalModule = configuration.getConfigurationModule().getModule();
configuration.getPersistantData().SUITE_NAME = virtualFile.getPath();
configuration.getPersistantData().TEST_OBJECT = TestType.SUITE.getType();
configuration.restoreOriginalModule(originalModule);
configuration.setGeneratedName();
settings.setName(configuration.getName());
sourceElement.set(containingFile);
return true;
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class XsltRunConfiguration method getEffectiveJDK.
@Nullable
public Sdk getEffectiveJDK() {
if (!XsltRunSettingsEditor.ALLOW_CHOOSING_SDK) {
return getDefaultSdk();
}
if (myJdkChoice == JdkChoice.JDK) {
return myJdk != null ? ProjectJdkTable.getInstance().findJdk(myJdk) : null;
}
Sdk jdk = null;
final Module module = getEffectiveModule();
if (module != null) {
jdk = ModuleRootManager.getInstance(module).getSdk();
}
if (jdk == null) {
jdk = ProjectRootManager.getInstance(getProject()).getProjectSdk();
}
// EA-33419
if (jdk == null || !(jdk.getSdkType() instanceof JavaSdkType)) {
return getDefaultSdk();
}
return jdk;
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class FindByXPathAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
final Module module = LangDataKeys.MODULE.getData(e.getDataContext());
if (project != null) {
executeSearch(project, module);
}
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class SearchScope method iterateContent.
public void iterateContent(@NotNull final Project project, final Processor<VirtualFile> processor) {
switch(getScopeType()) {
case PROJECT:
//noinspection unchecked
ProjectRootManager.getInstance(project).getFileIndex().iterateContent(new MyFileIterator(processor, Conditions.<VirtualFile>alwaysTrue()));
break;
case MODULE:
final Module module = ModuleManager.getInstance(project).findModuleByName(getModuleName());
assert module != null;
ModuleRootManager.getInstance(module).getFileIndex().iterateContent(new MyFileIterator(processor, Conditions.<VirtualFile>alwaysTrue()));
break;
case DIRECTORY:
final String dirName = getPath();
assert dirName != null;
final VirtualFile virtualFile = findFile(dirName);
if (virtualFile != null) {
iterateRecursively(virtualFile, processor, isRecursive());
}
break;
case CUSTOM:
assert myCustomScope != null;
final ContentIterator iterator;
if (myCustomScope instanceof GlobalSearchScope) {
final GlobalSearchScope searchScope = (GlobalSearchScope) myCustomScope;
iterator = new MyFileIterator(processor, virtualFile13 -> searchScope.contains(virtualFile13));
if (searchScope.isSearchInLibraries()) {
final OrderEnumerator enumerator = OrderEnumerator.orderEntries(project).withoutModuleSourceEntries().withoutDepModules();
final Collection<VirtualFile> libraryFiles = new THashSet<>();
Collections.addAll(libraryFiles, enumerator.getClassesRoots());
Collections.addAll(libraryFiles, enumerator.getSourceRoots());
final Processor<VirtualFile> adapter = virtualFile1 -> iterator.processFile(virtualFile1);
for (final VirtualFile file : libraryFiles) {
iterateRecursively(file, adapter, true);
}
}
} else {
final PsiManager manager = PsiManager.getInstance(project);
iterator = new MyFileIterator(processor, virtualFile12 -> {
final PsiFile element = manager.findFile(virtualFile12);
return element != null && PsiSearchScopeUtil.isInScope(myCustomScope, element);
});
}
ProjectRootManager.getInstance(project).getFileIndex().iterateContent(iterator);
}
}
Aggregations