Search in sources :

Example 1 with NativeArtifact

use of com.android.builder.model.NativeArtifact in project android by JetBrains.

the class NativeAndroidLibraryNode method getDirectories.

@NotNull
@Override
public PsiDirectory[] getDirectories() {
    PsiManager psiManager = PsiManager.getInstance(myProject);
    List<PsiDirectory> psiDirectories = new ArrayList<>();
    for (NativeArtifact artifact : getArtifacts()) {
        for (VirtualFile f : getSourceFolders(artifact)) {
            PsiDirectory dir = psiManager.findDirectory(f);
            if (dir != null) {
                psiDirectories.add(dir);
            }
        }
    }
    return psiDirectories.toArray(new PsiDirectory[psiDirectories.size()]);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) NativeArtifact(com.android.builder.model.NativeArtifact) PsiDirectory(com.intellij.psi.PsiDirectory) PsiManager(com.intellij.psi.PsiManager) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with NativeArtifact

use of com.android.builder.model.NativeArtifact in project android by JetBrains.

the class NativeAndroidLibraryNode method getSourceDirectoryNodes.

@NotNull
public static Collection<AbstractTreeNode> getSourceDirectoryNodes(@NotNull Project project, @NotNull Collection<NativeArtifact> artifacts, @NotNull ViewSettings settings, @NotNull Collection<String> sourceFileExtensions) {
    TreeMap<String, RootDirectory> rootDirectories = new TreeMap<>();
    for (NativeArtifact artifact : artifacts) {
        addSourceFolders(rootDirectories, artifact);
        addSourceFiles(rootDirectories, artifact);
    }
    if (rootDirectories.size() > 1) {
        groupDirectories(rootDirectories);
    }
    if (rootDirectories.size() > 1) {
        mergeDirectories(rootDirectories);
    }
    Set<String> fileExtensions = Sets.newHashSetWithExpectedSize(sourceFileExtensions.size() + HEADER_FILE_EXTENSIONS.size());
    fileExtensions.addAll(sourceFileExtensions);
    // add header files extension explicitly as the model only provides the extensions of source files.
    fileExtensions.addAll(HEADER_FILE_EXTENSIONS);
    PsiManager psiManager = PsiManager.getInstance(project);
    List<AbstractTreeNode> children = Lists.newArrayList();
    for (RootDirectory rootDirectory : rootDirectories.values()) {
        PsiDirectory psiDir = psiManager.findDirectory(rootDirectory.rootDir);
        if (psiDir != null) {
            children.add(new NativeAndroidSourceDirectoryNode(project, psiDir, settings, fileExtensions, rootDirectory.sourceFolders, rootDirectory.sourceFiles));
        }
    }
    return children;
}
Also used : NativeArtifact(com.android.builder.model.NativeArtifact) PsiDirectory(com.intellij.psi.PsiDirectory) PsiManager(com.intellij.psi.PsiManager) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with NativeArtifact

use of com.android.builder.model.NativeArtifact in project android by JetBrains.

the class NdkModuleNode method getNativeSourceNodes.

@NotNull
public static Collection<AbstractTreeNode> getNativeSourceNodes(@NotNull Project project, @NotNull NdkModuleModel ndkModuleModel, @NotNull ViewSettings viewSettings) {
    NativeAndroidProject nativeAndroidProject = ndkModuleModel.getAndroidProject();
    Collection<String> sourceFileExtensions = nativeAndroidProject.getFileExtensions().keySet();
    NdkModuleModel.NdkVariant variant = ndkModuleModel.getSelectedVariant();
    Multimap<String, NativeArtifact> nativeLibraries = HashMultimap.create();
    for (NativeArtifact artifact : variant.getArtifacts()) {
        String artifactOutputFileName = artifact.getOutputFile().getName();
        nativeLibraries.put(artifactOutputFileName, artifact);
    }
    if (nativeLibraries.keySet().size() == 1) {
        return getSourceDirectoryNodes(project, nativeLibraries.values(), viewSettings, sourceFileExtensions);
    }
    List<AbstractTreeNode> children = Lists.newArrayList();
    for (String name : nativeLibraries.keySet()) {
        String nativeLibraryType = "";
        String nativeLibraryName = trimEnd(name, ".so");
        if (nativeLibraryName.length() < name.length()) {
            nativeLibraryType = "Shared Library";
        } else {
            nativeLibraryName = trimEnd(name, ".a");
            if (nativeLibraryName.length() < name.length()) {
                nativeLibraryType = "Static Library";
            }
        }
        nativeLibraryName = trimStart(nativeLibraryName, "lib");
        children.add(new NativeAndroidLibraryNode(project, nativeLibraryName, nativeLibraryType, nativeLibraries.get(name), viewSettings, sourceFileExtensions));
    }
    return children;
}
Also used : NativeAndroidProject(com.android.builder.model.NativeAndroidProject) NativeArtifact(com.android.builder.model.NativeArtifact) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) NdkModuleModel(com.android.tools.idea.gradle.project.model.NdkModuleModel) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NativeArtifact (com.android.builder.model.NativeArtifact)3 NotNull (org.jetbrains.annotations.NotNull)3 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)2 PsiDirectory (com.intellij.psi.PsiDirectory)2 PsiManager (com.intellij.psi.PsiManager)2 NativeAndroidProject (com.android.builder.model.NativeAndroidProject)1 NdkModuleModel (com.android.tools.idea.gradle.project.model.NdkModuleModel)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1