Search in sources :

Example 1 with PsLibraryDependency

use of com.android.tools.idea.gradle.structure.model.PsLibraryDependency in project android by JetBrains.

the class QuickFixes method setLibraryDependencyVersion.

private static void setLibraryDependencyVersion(@NonNls PsContext context, @NotNull String moduleName, @NotNull String dependency, @NotNull String version) {
    PsModule module = context.getProject().findModuleByName(moduleName);
    if (module instanceof PsAndroidModule) {
        PsAndroidModule androidModule = (PsAndroidModule) module;
        androidModule.forEachDeclaredDependency(declaredDependency -> {
            if (declaredDependency instanceof PsLibraryDependency) {
                setLibraryDependencyVersion((PsLibraryDependency) declaredDependency, dependency, version);
            }
        });
    } else if (module instanceof PsJavaModule) {
        PsJavaModule javaModule = (PsJavaModule) module;
        javaModule.forEachDeclaredDependency(declaredDependency -> {
            if (declaredDependency instanceof PsLibraryDependency) {
                setLibraryDependencyVersion((PsLibraryDependency) declaredDependency, dependency, version);
            }
        });
    }
}
Also used : PsAndroidModule(com.android.tools.idea.gradle.structure.model.android.PsAndroidModule) List(java.util.List) PsJavaModule(com.android.tools.idea.gradle.structure.model.java.PsJavaModule) PsContext(com.android.tools.idea.gradle.structure.configurables.PsContext) NonNls(org.jetbrains.annotations.NonNls) PsLibraryDependency(com.android.tools.idea.gradle.structure.model.PsLibraryDependency) PsArtifactDependencySpec(com.android.tools.idea.gradle.structure.model.PsArtifactDependencySpec) PsModule(com.android.tools.idea.gradle.structure.model.PsModule) NotNull(org.jetbrains.annotations.NotNull) Splitter(com.google.common.base.Splitter) PsJavaModule(com.android.tools.idea.gradle.structure.model.java.PsJavaModule) PsModule(com.android.tools.idea.gradle.structure.model.PsModule) PsAndroidModule(com.android.tools.idea.gradle.structure.model.android.PsAndroidModule) PsLibraryDependency(com.android.tools.idea.gradle.structure.model.PsLibraryDependency)

Example 2 with PsLibraryDependency

use of com.android.tools.idea.gradle.structure.model.PsLibraryDependency in project android by JetBrains.

the class PsJavaModuleAnalyzer method doAnalyze.

@Override
protected void doAnalyze(@NotNull PsJavaModule module, @NotNull PsIssueCollection issueCollection) {
    PsModulePath modulePath = new PsModulePath(module);
    module.forEachDependency(dependency -> {
        if (dependency instanceof PsLibraryDependency && dependency.isDeclared()) {
            PsLibraryDependency libraryDependency = (PsLibraryDependency) dependency;
            analyzeDeclaredDependency(libraryDependency, modulePath, issueCollection);
        }
    });
}
Also used : PsModulePath(com.android.tools.idea.gradle.structure.model.PsModulePath) PsLibraryDependency(com.android.tools.idea.gradle.structure.model.PsLibraryDependency)

Aggregations

PsLibraryDependency (com.android.tools.idea.gradle.structure.model.PsLibraryDependency)2 PsContext (com.android.tools.idea.gradle.structure.configurables.PsContext)1 PsArtifactDependencySpec (com.android.tools.idea.gradle.structure.model.PsArtifactDependencySpec)1 PsModule (com.android.tools.idea.gradle.structure.model.PsModule)1 PsModulePath (com.android.tools.idea.gradle.structure.model.PsModulePath)1 PsAndroidModule (com.android.tools.idea.gradle.structure.model.android.PsAndroidModule)1 PsJavaModule (com.android.tools.idea.gradle.structure.model.java.PsJavaModule)1 Splitter (com.google.common.base.Splitter)1 List (java.util.List)1 NonNls (org.jetbrains.annotations.NonNls)1 NotNull (org.jetbrains.annotations.NotNull)1