use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class PydevConsoleRunner method findPythonSdkAndModule.
@NotNull
static Pair<Sdk, Module> findPythonSdkAndModule(@NotNull Project project, @Nullable Module contextModule) {
Sdk sdk = null;
Module module = null;
PyConsoleOptions.PyConsoleSettings settings = PyConsoleOptions.getInstance(project).getPythonConsoleSettings();
String sdkHome = settings.getSdkHome();
if (sdkHome != null) {
sdk = PythonSdkType.findSdkByPath(sdkHome);
if (settings.getModuleName() != null) {
module = ModuleManager.getInstance(project).findModuleByName(settings.getModuleName());
} else {
module = contextModule;
if (module == null && ModuleManager.getInstance(project).getModules().length > 0) {
module = ModuleManager.getInstance(project).getModules()[0];
}
}
}
if (sdk == null && settings.isUseModuleSdk()) {
if (contextModule != null) {
module = contextModule;
} else if (settings.getModuleName() != null) {
module = ModuleManager.getInstance(project).findModuleByName(settings.getModuleName());
}
if (module != null) {
if (PythonSdkType.findPythonSdk(module) != null) {
sdk = PythonSdkType.findPythonSdk(module);
}
}
} else if (contextModule != null) {
if (module == null) {
module = contextModule;
}
if (sdk == null) {
sdk = PythonSdkType.findPythonSdk(module);
}
}
if (sdk == null) {
for (Module m : ModuleManager.getInstance(project).getModules()) {
if (PythonSdkType.findPythonSdk(m) != null) {
sdk = PythonSdkType.findPythonSdk(m);
module = m;
break;
}
}
}
if (sdk == null) {
if (PythonSdkType.getAllSdks().size() > 0) {
//noinspection UnusedAssignment
//take any python sdk
sdk = PythonSdkType.getAllSdks().get(0);
}
}
return Pair.create(sdk, module);
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class Py3UnresolvedReferencesInspectionTest method doMultiFileTest.
private void doMultiFileTest(@NotNull final String filename, @NotNull List<String> sourceRoots) {
runWithLanguageLevel(LanguageLevel.PYTHON36, () -> {
final String testName = getTestName(false);
myFixture.copyDirectoryToProject(TEST_DIRECTORY + testName, "");
final Module module = myFixture.getModule();
for (String root : sourceRoots) {
PsiTestUtil.addSourceRoot(module, myFixture.findFileInTempDir(root));
}
try {
myFixture.configureFromTempProjectFile(filename);
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
myFixture.checkHighlighting(true, false, false);
} finally {
for (String root : sourceRoots) {
PsiTestUtil.removeSourceRoot(module, myFixture.findFileInTempDir(root));
}
}
});
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class HtmlFileReferenceHelper method getContexts.
@NotNull
@Override
public Collection<PsiFileSystemItem> getContexts(Project project, @NotNull VirtualFile vFile) {
final PsiFile file = PsiManager.getInstance(project).findFile(vFile);
final Module module = file != null ? ModuleUtilCore.findModuleForPsiElement(file) : null;
if (module == null || !(file instanceof XmlFile))
return Collections.emptyList();
final String basePath = HtmlUtil.getHrefBase((XmlFile) file);
if (basePath != null && !HtmlUtil.hasHtmlPrefix(basePath)) {
for (VirtualFile virtualFile : getBaseRoots(module)) {
final VirtualFile base = virtualFile.findFileByRelativePath(basePath);
final PsiDirectory result = base != null ? PsiManager.getInstance(project).findDirectory(base) : null;
if (result != null) {
return Collections.<PsiFileSystemItem>singletonList(result);
}
}
}
return Collections.emptyList();
}
use of com.intellij.openapi.module.Module in project kotlin by JetBrains.
the class TargetPlatformDetector method getPlatform.
public static TargetPlatform getPlatform(@NotNull PsiFile file) {
VirtualFile virtualFile = file.getOriginalFile().getVirtualFile();
if (virtualFile == null) {
return getDefaultPlatform(file);
}
Module moduleForFile = ProjectFileIndex.SERVICE.getInstance(file.getProject()).getModuleForFile(virtualFile);
if (moduleForFile == null) {
return getDefaultPlatform(file);
}
return getPlatform(moduleForFile);
}
use of com.intellij.openapi.module.Module in project kotlin by JetBrains.
the class KotlinTestNgConfigurationProducer method configure.
private boolean configure(TestNGConfiguration configuration, Location location, ConfigurationContext context, Project project, @Nullable PsiClass delegate, @Nullable PsiMethod method) {
if (delegate == null) {
return false;
}
setupConfigurationModule(context, configuration);
Module originalModule = configuration.getConfigurationModule().getModule();
configuration.setClassConfiguration(delegate);
if (method != null) {
configuration.setMethodConfiguration(PsiLocation.fromPsiElement(project, method));
}
configuration.restoreOriginalModule(originalModule);
configuration.setName(configuration.getName());
JavaRunConfigurationExtensionManager.getInstance().extendCreatedConfiguration(configuration, location);
return true;
}
Aggregations