use of org.jetbrains.android.facet.AndroidSourceType in project android by JetBrains.
the class AndroidModuleNode method getChildren.
@NotNull
public static Collection<AbstractTreeNode> getChildren(@NotNull AndroidFacet facet, @NotNull ViewSettings settings, @NotNull AndroidProjectViewPane pane, @NotNull List<IdeaSourceProvider> providers) {
Project project = facet.getModule().getProject();
List<AbstractTreeNode> result = Lists.newArrayList();
AndroidModuleModel androidModuleModel = AndroidModuleModel.get(facet);
HashMultimap<AndroidSourceType, VirtualFile> sourcesByType = getSourcesBySourceType(providers, androidModuleModel);
NdkModuleModel ndkModuleModel = NdkModuleModel.get(facet.getModule());
for (AndroidSourceType sourceType : sourcesByType.keySet()) {
if (sourceType == AndroidSourceType.CPP && ndkModuleModel != null) {
// Native sources will be added separately from NativeAndroidGradleModel.
continue;
}
if (sourceType == AndroidSourceType.MANIFEST) {
result.add(new AndroidManifestsGroupNode(project, facet, settings, sourcesByType.get(sourceType)));
continue;
}
if (sourceType == AndroidSourceType.RES) {
result.add(new AndroidResFolderNode(project, facet, settings, sourcesByType.get(sourceType), pane));
continue;
}
if (sourceType == AndroidSourceType.SHADERS) {
if (androidModuleModel == null || !androidModuleModel.getFeatures().isShadersSupported()) {
continue;
}
}
result.add(new AndroidSourceTypeNode(project, facet, settings, sourceType, sourcesByType.get(sourceType), pane));
}
if (ndkModuleModel != null) {
result.add(new AndroidJniFolderNode(project, ndkModuleModel, settings));
}
return result;
}
use of org.jetbrains.android.facet.AndroidSourceType in project android by JetBrains.
the class AndroidModuleNode method getSourcesBySourceType.
@NotNull
private static HashMultimap<AndroidSourceType, VirtualFile> getSourcesBySourceType(@NotNull List<IdeaSourceProvider> providers, @Nullable AndroidModuleModel androidModuleModel) {
HashMultimap<AndroidSourceType, VirtualFile> sourcesByType = HashMultimap.create();
// Multiple source types can sometimes be present in the same source folder, e.g.:
// sourcesSets.main.java.srcDirs = sourceSets.main.aidl.srcDirs = ['src']
// in such a case, we only want to show one of them. Source sets can be either proper or improper subsets. It is not entirely
// obvious there is a perfect solution here, but since this is not a common occurrence, we resort to the easiest solution here:
// If a set of sources has partially been included as part of another source type's source set, then we simply don't include it
// as part of this source type.
Set<VirtualFile> allSources = Sets.newHashSet();
for (AndroidSourceType sourceType : AndroidSourceType.values()) {
if (sourceType == AndroidSourceType.SHADERS && (androidModuleModel == null || !androidModuleModel.getFeatures().isShadersSupported())) {
continue;
}
Set<VirtualFile> sources = getSources(sourceType, providers);
if (sources.isEmpty()) {
continue;
}
if (SetUtil.intersect(allSources, sources).isEmpty()) {
// if we haven't seen any of these source folders, then create a new source type folder
sourcesByType.putAll(sourceType, sources);
} else if (!allSources.containsAll(sources)) {
// if we have a partial overlap, we put just the non overlapping sources into this source type
sources.removeAll(allSources);
sourcesByType.putAll(sourceType, sources);
}
allSources.addAll(sources);
}
return sourcesByType;
}
Aggregations