本文整理汇总了Java中com.intellij.openapi.roots.ContentEntry.getSourceFolders方法的典型用法代码示例。如果您正苦于以下问题:Java ContentEntry.getSourceFolders方法的具体用法?Java ContentEntry.getSourceFolders怎么用?Java ContentEntry.getSourceFolders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.roots.ContentEntry
的用法示例。
在下文中一共展示了ContentEntry.getSourceFolders方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: suitableTestSourceFolders
import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
@Nullable
private static SourceFolder suitableTestSourceFolders(Project project, Module module) {
ContentEntry[] contentEntries = ModuleRootManager.getInstance(module).getContentEntries();
for (ContentEntry contentEntry : contentEntries) {
List<SourceFolder> testSourceFolders =
contentEntry.getSourceFolders(JavaSourceRootType.TEST_SOURCE);
for (SourceFolder testSourceFolder : testSourceFolders) {
if (testSourceFolder.getFile() != null) {
if (!JavaProjectRootsUtil.isInGeneratedCode(testSourceFolder.getFile(), project)) {
return testSourceFolder;
}
}
}
}
return null;
}
示例2: getSourceFolders
import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
private List<VirtualFile> getSourceFolders() {
ModuleRootManager rootManager = ModuleRootManager.getInstance(getValue());
List<VirtualFile> folders = Lists.newArrayList();
ContentEntry[] contentEntries = rootManager.getContentEntries();
for (ContentEntry entry : contentEntries) {
List<SourceFolder> sources = entry.getSourceFolders(mySourceType.rootType);
for (SourceFolder folder : sources) {
VirtualFile file = folder.getFile();
if (file != null) {
folders.add(file);
}
}
}
return folders;
}
示例3: getNonEmptySourceTypes
import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
private static Set<NonAndroidSourceType> getNonEmptySourceTypes(Module module) {
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
Set<NonAndroidSourceType> sourceTypes = Sets.newHashSetWithExpectedSize(NonAndroidSourceType.values().length);
ContentEntry[] contentEntries = rootManager.getContentEntries();
for (ContentEntry entry : contentEntries) {
for (NonAndroidSourceType type : NonAndroidSourceType.values()) {
for (SourceFolder sourceFolder : entry.getSourceFolders(type.rootType)) {
if (sourceFolder.getFile() != null) {
sourceTypes.add(type);
break;
}
}
}
}
return sourceTypes;
}
示例4: createSourceRootIfAbsent
import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
private static void createSourceRootIfAbsent(
@NotNull ContentEntry entry, @NotNull final SourceRoot root, @NotNull String moduleName,
@NotNull JpsModuleSourceRootType<?> sourceRootType, boolean generated, boolean createEmptyContentRootDirectories) {
List<SourceFolder> folders = entry.getSourceFolders(sourceRootType);
for (SourceFolder folder : folders) {
VirtualFile file = folder.getFile();
if (file == null) {
continue;
}
if (ExternalSystemApiUtil.getLocalFileSystemPath(file).equals(root.getPath())) {
return;
}
}
LOG.debug(String.format("Importing %s for content root '%s' of module '%s'", root, entry.getUrl(), moduleName));
SourceFolder sourceFolder = entry.addSourceFolder(toVfsUrl(root.getPath()), sourceRootType);
if (!StringUtil.isEmpty(root.getPackagePrefix())) {
sourceFolder.setPackagePrefix(root.getPackagePrefix());
}
if (generated) {
JavaSourceRootProperties properties = sourceFolder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
if(properties != null) {
properties.setForGeneratedSources(true);
}
}
if(createEmptyContentRootDirectories) {
ExternalSystemApiUtil.doWriteAction(new Runnable() {
@Override
public void run() {
try {
VfsUtil.createDirectoryIfMissing(root.getPath());
}
catch (IOException e) {
LOG.warn(String.format("Unable to create directory for the path: %s", root.getPath()), e);
}
}
});
}
}
示例5: getPresentablePrefix
import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
private static String getPresentablePrefix(final ContentEntry entry, final VirtualFile file) {
for (final SourceFolder sourceFolder : entry.getSourceFolders()) {
if (file.equals(sourceFolder.getFile())) {
JpsModuleSourceRoot element = sourceFolder.getJpsElement();
JavaSourceRootProperties properties = element.getProperties(JavaModuleSourceRootTypes.SOURCES);
if (properties != null) return properties.getPackagePrefix();
JavaResourceRootProperties resourceRootProperties = element.getProperties(JavaModuleSourceRootTypes.RESOURCES);
if (resourceRootProperties != null) return resourceRootProperties.getRelativeOutputPath();
}
}
return "";
}
示例6: findSourceFolder
import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
@Nullable
private static SourceFolder findSourceFolder(ContentEntry entry, VirtualFile file) {
for (SourceFolder sourceFolder : entry.getSourceFolders()) {
if (file.equals(sourceFolder.getFile())) {
return sourceFolder;
}
}
return null;
}