use of com.intellij.openapi.module.Module in project kotlin by JetBrains.
the class AbstractJavaAgainstKotlinCheckerTest method createMainModule.
@Override
protected Module createMainModule() throws IOException {
Module module = super.createMainModule();
String configFileText = getConfigFileText();
if (configFileText == null) {
return module;
}
if (InTextDirectivesUtils.isDirectiveDefined(configFileText, "// WITH_RUNTIME")) {
ConfigLibraryUtil.configureKotlinRuntime(module);
}
List<String> languageLevelLines = InTextDirectivesUtils.findLinesWithPrefixesRemoved(configFileText, "// LANGUAGE_LEVEL");
if (languageLevelLines.size() > 1) {
throw new AssertionError("Language level specified multiple times: " + languageLevelLines);
}
if (languageLevelLines.size() == 1) {
LanguageLevel level = LanguageLevel.parse(languageLevelLines.iterator().next());
if (level != null) {
IdeaTestUtil.setModuleLanguageLevel(module, level);
}
}
return module;
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class MavenActionUtil method getMavenProjects.
public static List<MavenProject> getMavenProjects(DataContext context) {
Project project = CommonDataKeys.PROJECT.getData(context);
if (project == null)
return Collections.emptyList();
VirtualFile[] virtualFiles = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(context);
if (virtualFiles == null || virtualFiles.length == 0)
return Collections.emptyList();
MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(project);
if (!projectsManager.isMavenizedProject())
return Collections.emptyList();
Set<MavenProject> res = new LinkedHashSet<>();
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
for (VirtualFile file : virtualFiles) {
MavenProject mavenProject;
if (file.isDirectory()) {
VirtualFile contentRoot = fileIndex.getContentRootForFile(file);
if (!file.equals(contentRoot))
return Collections.emptyList();
Module module = fileIndex.getModuleForFile(file);
if (module == null || !projectsManager.isMavenizedModule(module))
return Collections.emptyList();
mavenProject = projectsManager.findProject(module);
} else {
mavenProject = projectsManager.findProject(file);
}
if (mavenProject == null)
return Collections.emptyList();
res.add(mavenProject);
}
return new ArrayList<>(res);
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class RepositoryLibrarySynchronizer method collectLibraries.
private static Collection<Library> collectLibraries(@NotNull final Project project, @NotNull final Predicate<Library> predicate) {
final HashSet<Library> result = new HashSet<>();
ApplicationManager.getApplication().runReadAction(() -> {
for (final Module module : ModuleManager.getInstance(project).getModules()) {
OrderEnumerator.orderEntries(module).withoutSdk().forEachLibrary(library -> {
if (predicate.apply(library)) {
result.add(library);
}
return true;
});
}
for (Library library : ProjectLibraryTable.getInstance(project).getLibraries()) {
if (predicate.apply(library)) {
result.add(library);
}
}
});
return result;
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class MavenTestCase method createModule.
protected Module createModule(final String name, final ModuleType type) throws IOException {
return new WriteCommandAction<Module>(myProject) {
@Override
protected void run(@NotNull Result<Module> moduleResult) throws Throwable {
VirtualFile f = createProjectSubFile(name + "/" + name + ".iml");
Module module = ModuleManager.getInstance(myProject).newModule(f.getPath(), type.getId());
PsiTestUtil.addContentRoot(module, f.getParent());
moduleResult.setResult(module);
}
}.execute().getResultObject();
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class FormSourceCodeGenerator method generate.
public void generate(final VirtualFile formFile) {
myNeedLoadLabelText = false;
myNeedLoadButtonText = false;
final Module module = ModuleUtil.findModuleForFile(formFile, myProject);
if (module == null) {
return;
}
// ensure that new instances of generators are used for every run
ourContainerLayoutCodeGenerators.clear();
ourContainerLayoutCodeGenerators.put(UIFormXmlConstants.LAYOUT_INTELLIJ, new GridLayoutSourceGenerator());
ourContainerLayoutCodeGenerators.put(UIFormXmlConstants.LAYOUT_GRIDBAG, new GridBagLayoutSourceGenerator());
ourContainerLayoutCodeGenerators.put(UIFormXmlConstants.LAYOUT_BORDER, new BorderLayoutSourceGenerator());
ourContainerLayoutCodeGenerators.put(UIFormXmlConstants.LAYOUT_FLOW, new FlowLayoutSourceGenerator());
ourContainerLayoutCodeGenerators.put(UIFormXmlConstants.LAYOUT_CARD, new CardLayoutSourceGenerator());
ourContainerLayoutCodeGenerators.put(UIFormXmlConstants.LAYOUT_FORM, new FormLayoutSourceGenerator());
myErrors.clear();
final PsiPropertiesProvider propertiesProvider = new PsiPropertiesProvider(module);
final Document doc = FileDocumentManager.getInstance().getDocument(formFile);
final LwRootContainer rootContainer;
try {
rootContainer = Utils.getRootContainer(doc.getText(), propertiesProvider);
} catch (AlienFormFileException ignored) {
// ignoring this file
return;
} catch (Exception e) {
myErrors.add(new FormErrorInfo(null, UIDesignerBundle.message("error.cannot.process.form.file", e)));
return;
}
if (rootContainer.getClassToBind() == null) {
// form skipped - no class to bind
return;
}
ErrorAnalyzer.analyzeErrors(module, formFile, null, rootContainer, null);
FormEditingUtil.iterate(rootContainer, new FormEditingUtil.ComponentVisitor<LwComponent>() {
public boolean visit(final LwComponent iComponent) {
final ErrorInfo errorInfo = ErrorAnalyzer.getErrorForComponent(iComponent);
if (errorInfo != null) {
String message;
if (iComponent.getBinding() != null) {
message = UIDesignerBundle.message("error.for.component", iComponent.getBinding(), errorInfo.myDescription);
} else {
message = errorInfo.myDescription;
}
myErrors.add(new FormErrorInfo(iComponent.getId(), message));
}
return true;
}
});
if (myErrors.size() != 0) {
return;
}
try {
_generate(rootContainer, module);
} catch (ClassToBindNotFoundException e) {
// ignore
} catch (CodeGenerationException e) {
myErrors.add(new FormErrorInfo(e.getComponentId(), e.getMessage()));
} catch (IncorrectOperationException e) {
myErrors.add(new FormErrorInfo(null, e.getMessage()));
}
}
Aggregations