use of com.intellij.openapi.roots.ModuleRootManager in project intellij-community by JetBrains.
the class GroovyAntCustomCompilerProvider method hasCustomCompile.
/**
* {@inheritDoc}
*/
@Override
public boolean hasCustomCompile(ModuleChunk chunk) {
for (Module m : chunk.getModules()) {
if (LibrariesUtil.hasGroovySdk(m)) {
final Set<String> scriptExtensions = GroovyFileTypeLoader.getCustomGroovyScriptExtensions();
final ContentIterator groovyFileSearcher = new ContentIterator() {
@Override
public boolean processFile(VirtualFile fileOrDir) {
ProgressManager.checkCanceled();
if (isCompilableGroovyFile(fileOrDir, scriptExtensions)) {
return false;
}
return true;
}
};
final ModuleRootManager rootManager = ModuleRootManager.getInstance(m);
final ModuleFileIndex fileIndex = rootManager.getFileIndex();
for (VirtualFile file : rootManager.getSourceRoots(JavaModuleSourceRootTypes.SOURCES)) {
if (!fileIndex.iterateContentUnderDirectory(file, groovyFileSearcher)) {
return true;
}
}
}
}
return false;
}
use of com.intellij.openapi.roots.ModuleRootManager in project intellij-community by JetBrains.
the class MavenIdeaPluginConfigurer method configureJdk.
private static void configureJdk(Element cfg, @NotNull Module module) {
String jdkName = cfg.getChildTextTrim("jdkName");
if (StringUtil.isEmptyOrSpaces(jdkName))
return;
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
String currentSdkName = null;
Sdk sdk = rootManager.getSdk();
if (sdk != null) {
currentSdkName = sdk.getName();
}
if (!jdkName.equals(currentSdkName)) {
ModifiableRootModel model = rootManager.getModifiableModel();
if (jdkName.equals(ProjectRootManager.getInstance(model.getProject()).getProjectSdkName())) {
model.inheritSdk();
} else {
Sdk jdk = ProjectJdkTable.getInstance().findJdk(jdkName);
if (jdk != null) {
model.setSdk(jdk);
} else {
model.setInvalidSdk(jdkName, JavaSdk.getInstance().getName());
}
}
model.commit();
}
}
use of com.intellij.openapi.roots.ModuleRootManager in project intellij-community by JetBrains.
the class MvcRunConfiguration method getState.
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
final Module module = getModule();
if (module == null) {
throw new ExecutionException("Module is not specified");
}
if (!isSupport(module)) {
throw new ExecutionException(getNoSdkMessage());
}
final ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
final Sdk sdk = rootManager.getSdk();
if (sdk == null || !(sdk.getSdkType() instanceof JavaSdkType)) {
throw CantRunException.noJdkForModule(module);
}
return createCommandLineState(environment, module);
}
use of com.intellij.openapi.roots.ModuleRootManager in project intellij-community by JetBrains.
the class PyUtil method getSourceRoots.
/**
* @return Source roots <strong>and</strong> content roots for module
*/
@NotNull
public static Collection<VirtualFile> getSourceRoots(@NotNull Module module) {
final Set<VirtualFile> result = new LinkedHashSet<>();
final ModuleRootManager manager = ModuleRootManager.getInstance(module);
Collections.addAll(result, manager.getSourceRoots());
Collections.addAll(result, manager.getContentRoots());
return result;
}
use of com.intellij.openapi.roots.ModuleRootManager in project intellij-community by JetBrains.
the class ModuleChunkSourcePath method addExcludePatterns.
private static void addExcludePatterns(Module module, final VirtualFile root, VirtualFile dir, final CompositeGenerator generator, final boolean parentIncluded) {
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor() {
@Override
public boolean visitFile(@NotNull VirtualFile dir) {
if (!dir.isDirectory() || fileTypeManager.isFileIgnored(dir)) {
// ignored files are handled by global 'ignored' pattern set
return false;
}
final boolean isIncluded = moduleRootManager.getFileIndex().isInContent(dir);
if (isIncluded != parentIncluded) {
final String relativePath = VfsUtilCore.getRelativePath(dir, root, '/');
if (isIncluded) {
generator.add(new Include(relativePath + "/**"));
} else {
if (!isExcludedByDefault(dir.getName())) {
generator.add(new Exclude(relativePath + "/**"));
}
}
}
return true;
}
});
}
Aggregations