Search in sources :

Example 1 with PsJavaModule

use of com.android.tools.idea.gradle.structure.model.java.PsJavaModule 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 PsJavaModule

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

the class DependenciesPerspectiveConfigurable method getConfigurable.

@Override
@Nullable
protected NamedConfigurable<? extends PsModule> getConfigurable(@NotNull PsModule module) {
    AbstractDependenciesConfigurable<? extends PsModule> configurable;
    if (module instanceof PsAllModulesFakeModule) {
        configurable = myExtraTopConfigurables.get(module);
        if (configurable == null) {
            configurable = new ProjectDependenciesConfigurable(module, getContext(), getExtraTopModules());
            configurable.setHistory(myHistory);
            myExtraTopConfigurables.put(module, configurable);
        }
    } else {
        String gradlePath = module.getGradlePath();
        configurable = myConfigurablesByGradlePath.get(gradlePath);
        if (configurable == null) {
            if (module instanceof PsAndroidModule) {
                PsAndroidModule androidModule = (PsAndroidModule) module;
                configurable = new AndroidModuleDependenciesConfigurable(androidModule, getContext(), getExtraTopModules());
                configurable.setHistory(myHistory);
                myConfigurablesByGradlePath.put(gradlePath, configurable);
            } else if (module instanceof PsJavaModule) {
                PsJavaModule javaModule = (PsJavaModule) module;
                configurable = new JavaModuleDependenciesConfigurable(javaModule, getContext(), getExtraTopModules());
            }
        }
    }
    return configurable;
}
Also used : PsJavaModule(com.android.tools.idea.gradle.structure.model.java.PsJavaModule) AndroidModuleDependenciesConfigurable(com.android.tools.idea.gradle.structure.configurables.android.dependencies.module.AndroidModuleDependenciesConfigurable) JavaModuleDependenciesConfigurable(com.android.tools.idea.gradle.structure.configurables.java.dependencies.JavaModuleDependenciesConfigurable) PsAllModulesFakeModule(com.android.tools.idea.gradle.structure.configurables.android.dependencies.PsAllModulesFakeModule) ProjectDependenciesConfigurable(com.android.tools.idea.gradle.structure.configurables.android.dependencies.project.ProjectDependenciesConfigurable) PsAndroidModule(com.android.tools.idea.gradle.structure.model.android.PsAndroidModule) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with PsJavaModule

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

the class AddLibraryDependencyDialog method addNewDependencies.

@Override
public void addNewDependencies() {
    String library = myLibraryDependenciesForm.getSelectedLibrary();
    assert library != null;
    AbstractDependencyScopesPanel scopesPanel = getScopesPanel();
    List<String> scopesNames = scopesPanel.getSelectedScopeNames();
    PsModule module = getModule();
    if (module instanceof PsAndroidModule) {
        PsNewDependencyScopes newScopes = ((AndroidDependencyScopesPanel) scopesPanel).getNewScopes();
        assert newScopes != null;
        ((PsAndroidModule) module).addLibraryDependency(library, newScopes, scopesNames);
    } else if (module instanceof PsJavaModule) {
        ((PsJavaModule) module).addLibraryDependency(library, scopesNames);
    }
}
Also used : PsJavaModule(com.android.tools.idea.gradle.structure.model.java.PsJavaModule) PsModule(com.android.tools.idea.gradle.structure.model.PsModule) PsNewDependencyScopes(com.android.tools.idea.gradle.structure.model.android.dependency.PsNewDependencyScopes) PsAndroidModule(com.android.tools.idea.gradle.structure.model.android.PsAndroidModule) AndroidDependencyScopesPanel(com.android.tools.idea.gradle.structure.dependencies.android.AndroidDependencyScopesPanel)

Example 4 with PsJavaModule

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

the class PsAnalyzerDaemon method addApplicableUpdatesAsIssues.

private void addApplicableUpdatesAsIssues() {
    PsContext context = getContext();
    context.getProject().forEachModule(module -> {
        Ref<Boolean> updatesFound = new Ref<>(false);
        if (module instanceof PsAndroidModule) {
            PsAndroidModule androidModule = (PsAndroidModule) module;
            androidModule.forEachDeclaredDependency(dependency -> {
                if (dependency instanceof PsLibraryDependency) {
                    boolean found = checkForUpdates((PsLibraryDependency) dependency);
                    if (found) {
                        updatesFound.set(true);
                    }
                }
            });
        } else if (module instanceof PsJavaModule) {
            PsJavaModule javaModule = (PsJavaModule) module;
            javaModule.forEachDeclaredDependency(dependency -> {
                if (dependency instanceof PsLibraryDependency) {
                    boolean found = checkForUpdates((PsLibraryDependency) dependency);
                    if (found) {
                        updatesFound.set(true);
                    }
                }
            });
        }
        if (updatesFound.get()) {
            myResultsUpdaterQueue.queue(new IssuesComputed(module));
        }
    });
}
Also used : PsLibraryDependencyNavigationPath(com.android.tools.idea.gradle.structure.navigation.PsLibraryDependencyNavigationPath) PsAndroidModuleAnalyzer(com.android.tools.idea.gradle.structure.daemon.analysis.PsAndroidModuleAnalyzer) EventDispatcher(com.intellij.util.EventDispatcher) LIBRARY_UPDATES_AVAILABLE(com.android.tools.idea.gradle.structure.model.PsIssueType.LIBRARY_UPDATES_AVAILABLE) PsModulePath(com.android.tools.idea.gradle.structure.model.PsModulePath) com.android.tools.idea.gradle.structure.model(com.android.tools.idea.gradle.structure.model) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ReadAction(com.intellij.openapi.application.ReadAction) AvailableLibraryUpdates(com.android.tools.idea.gradle.structure.daemon.AvailableLibraryUpdateStorage.AvailableLibraryUpdates) UPDATE(com.android.tools.idea.gradle.structure.model.PsIssue.Severity.UPDATE) PsJavaModule(com.android.tools.idea.gradle.structure.model.java.PsJavaModule) PsLibraryDependencyVersionQuickFixPath(com.android.tools.idea.gradle.structure.quickfix.PsLibraryDependencyVersionQuickFixPath) Map(java.util.Map) RunResult(com.intellij.openapi.application.RunResult) Logger(com.intellij.openapi.diagnostic.Logger) PsAndroidModule(com.android.tools.idea.gradle.structure.model.android.PsAndroidModule) AvailableLibraryUpdate(com.android.tools.idea.gradle.structure.daemon.AvailableLibraryUpdateStorage.AvailableLibraryUpdate) PsModelAnalyzer(com.android.tools.idea.gradle.structure.daemon.analysis.PsModelAnalyzer) ActionCallback(com.intellij.openapi.util.ActionCallback) Maps(com.google.common.collect.Maps) ANY_COMPONENT(com.intellij.util.ui.update.MergingUpdateQueue.ANY_COMPONENT) Disposable(com.intellij.openapi.Disposable) MergingUpdateQueue(com.intellij.util.ui.update.MergingUpdateQueue) EventListener(java.util.EventListener) Update(com.intellij.util.ui.update.Update) Result(com.intellij.openapi.application.Result) PsContext(com.android.tools.idea.gradle.structure.configurables.PsContext) PsJavaModuleAnalyzer(com.android.tools.idea.gradle.structure.daemon.analysis.PsJavaModuleAnalyzer) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) PsJavaModule(com.android.tools.idea.gradle.structure.model.java.PsJavaModule) Ref(com.intellij.openapi.util.Ref) PsContext(com.android.tools.idea.gradle.structure.configurables.PsContext) PsAndroidModule(com.android.tools.idea.gradle.structure.model.android.PsAndroidModule) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

Aggregations

PsAndroidModule (com.android.tools.idea.gradle.structure.model.android.PsAndroidModule)4 PsJavaModule (com.android.tools.idea.gradle.structure.model.java.PsJavaModule)4 PsContext (com.android.tools.idea.gradle.structure.configurables.PsContext)2 PsModule (com.android.tools.idea.gradle.structure.model.PsModule)2 NotNull (org.jetbrains.annotations.NotNull)2 PsAllModulesFakeModule (com.android.tools.idea.gradle.structure.configurables.android.dependencies.PsAllModulesFakeModule)1 AndroidModuleDependenciesConfigurable (com.android.tools.idea.gradle.structure.configurables.android.dependencies.module.AndroidModuleDependenciesConfigurable)1 ProjectDependenciesConfigurable (com.android.tools.idea.gradle.structure.configurables.android.dependencies.project.ProjectDependenciesConfigurable)1 JavaModuleDependenciesConfigurable (com.android.tools.idea.gradle.structure.configurables.java.dependencies.JavaModuleDependenciesConfigurable)1 AvailableLibraryUpdate (com.android.tools.idea.gradle.structure.daemon.AvailableLibraryUpdateStorage.AvailableLibraryUpdate)1 AvailableLibraryUpdates (com.android.tools.idea.gradle.structure.daemon.AvailableLibraryUpdateStorage.AvailableLibraryUpdates)1 PsAndroidModuleAnalyzer (com.android.tools.idea.gradle.structure.daemon.analysis.PsAndroidModuleAnalyzer)1 PsJavaModuleAnalyzer (com.android.tools.idea.gradle.structure.daemon.analysis.PsJavaModuleAnalyzer)1 PsModelAnalyzer (com.android.tools.idea.gradle.structure.daemon.analysis.PsModelAnalyzer)1 AndroidDependencyScopesPanel (com.android.tools.idea.gradle.structure.dependencies.android.AndroidDependencyScopesPanel)1 com.android.tools.idea.gradle.structure.model (com.android.tools.idea.gradle.structure.model)1 PsArtifactDependencySpec (com.android.tools.idea.gradle.structure.model.PsArtifactDependencySpec)1 UPDATE (com.android.tools.idea.gradle.structure.model.PsIssue.Severity.UPDATE)1 LIBRARY_UPDATES_AVAILABLE (com.android.tools.idea.gradle.structure.model.PsIssueType.LIBRARY_UPDATES_AVAILABLE)1 PsLibraryDependency (com.android.tools.idea.gradle.structure.model.PsLibraryDependency)1