Search in sources :

Example 1 with PsLibraryDependencyNavigationPath

use of com.android.tools.idea.gradle.structure.navigation.PsLibraryDependencyNavigationPath in project android by JetBrains.

the class PsAnalyzerDaemon method checkForUpdates.

private boolean checkForUpdates(@NotNull PsLibraryDependency dependency) {
    PsContext context = getContext();
    AvailableLibraryUpdates results = context.getLibraryUpdateCheckerDaemon().getAvailableUpdates();
    PsArtifactDependencySpec spec = dependency.getDeclaredSpec();
    if (spec != null) {
        AvailableLibraryUpdate update = results.findUpdateFor(spec);
        if (update != null) {
            String text = String.format("Newer version available: <b>%1$s</b> (%2$s)", update.version, update.repository);
            PsLibraryDependencyNavigationPath mainPath = new PsLibraryDependencyNavigationPath(context, dependency);
            PsIssue issue = new PsIssue(text, mainPath, LIBRARY_UPDATES_AVAILABLE, UPDATE);
            issue.setExtraPath(new PsModulePath(dependency.getParent()));
            PsLibraryDependencyVersionQuickFixPath quickFix = new PsLibraryDependencyVersionQuickFixPath(dependency, update.version);
            quickFix.setHrefText("[Update]");
            issue.setQuickFixPath(quickFix);
            myIssues.add(issue);
            return true;
        }
    }
    return false;
}
Also used : AvailableLibraryUpdate(com.android.tools.idea.gradle.structure.daemon.AvailableLibraryUpdateStorage.AvailableLibraryUpdate) PsLibraryDependencyVersionQuickFixPath(com.android.tools.idea.gradle.structure.quickfix.PsLibraryDependencyVersionQuickFixPath) PsContext(com.android.tools.idea.gradle.structure.configurables.PsContext) PsModulePath(com.android.tools.idea.gradle.structure.model.PsModulePath) AvailableLibraryUpdates(com.android.tools.idea.gradle.structure.daemon.AvailableLibraryUpdateStorage.AvailableLibraryUpdates) PsLibraryDependencyNavigationPath(com.android.tools.idea.gradle.structure.navigation.PsLibraryDependencyNavigationPath)

Example 2 with PsLibraryDependencyNavigationPath

use of com.android.tools.idea.gradle.structure.navigation.PsLibraryDependencyNavigationPath in project android by JetBrains.

the class PsIssueCollection method findIssues.

@NotNull
public List<PsIssue> findIssues(@NotNull PsModel model, @Nullable Comparator<PsIssue> comparator) {
    PsPath path = null;
    if (model instanceof PsModule) {
        PsModule module = (PsModule) model;
        path = new PsModulePath(module);
    }
    if (model instanceof PsLibraryDependency) {
        PsLibraryDependency dependency = (PsLibraryDependency) model;
        path = new PsLibraryDependencyNavigationPath(myContext, dependency);
    }
    if (path != null) {
        return findIssues(path, comparator);
    }
    return Collections.emptyList();
}
Also used : PsLibraryDependencyNavigationPath(com.android.tools.idea.gradle.structure.navigation.PsLibraryDependencyNavigationPath) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with PsLibraryDependencyNavigationPath

use of com.android.tools.idea.gradle.structure.navigation.PsLibraryDependencyNavigationPath in project android by JetBrains.

the class PsAndroidModuleAnalyzer method doAnalyze.

@Override
protected void doAnalyze(@NotNull PsAndroidModule module, @NotNull PsIssueCollection issueCollection) {
    Multimap<String, SyncIssue> issuesByData = ArrayListMultimap.create();
    AndroidModuleModel gradleModel = module.getGradleModel();
    Collection<SyncIssue> syncIssues = gradleModel.getAndroidProject().getSyncIssues();
    for (SyncIssue syncIssue : syncIssues) {
        String data = nullToEmpty(syncIssue.getData());
        issuesByData.put(data, syncIssue);
    }
    PsModulePath modulePath = new PsModulePath(module);
    module.forEachDependency(dependency -> {
        if (dependency instanceof PsLibraryDependency && dependency.isDeclared()) {
            PsLibraryDependency libraryDependency = (PsLibraryDependency) dependency;
            PsPath path = new PsLibraryDependencyNavigationPath(getContext(), libraryDependency);
            PsArtifactDependencySpec resolvedSpec = libraryDependency.getResolvedSpec();
            String issueKey = resolvedSpec.group + GRADLE_PATH_SEPARATOR + resolvedSpec.name;
            Collection<SyncIssue> librarySyncIssues = issuesByData.get(issueKey);
            for (SyncIssue syncIssue : librarySyncIssues) {
                PsIssue issue = createIssueFrom(syncIssue, path, modulePath);
                issueCollection.add(issue);
            }
            analyzeDeclaredDependency(libraryDependency, modulePath, issueCollection);
        }
    });
}
Also used : SyncIssue(com.android.builder.model.SyncIssue) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) XmlStringUtil.escapeString(com.intellij.xml.util.XmlStringUtil.escapeString) PsLibraryDependencyNavigationPath(com.android.tools.idea.gradle.structure.navigation.PsLibraryDependencyNavigationPath)

Aggregations

PsLibraryDependencyNavigationPath (com.android.tools.idea.gradle.structure.navigation.PsLibraryDependencyNavigationPath)3 SyncIssue (com.android.builder.model.SyncIssue)1 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)1 PsContext (com.android.tools.idea.gradle.structure.configurables.PsContext)1 AvailableLibraryUpdate (com.android.tools.idea.gradle.structure.daemon.AvailableLibraryUpdateStorage.AvailableLibraryUpdate)1 AvailableLibraryUpdates (com.android.tools.idea.gradle.structure.daemon.AvailableLibraryUpdateStorage.AvailableLibraryUpdates)1 PsModulePath (com.android.tools.idea.gradle.structure.model.PsModulePath)1 PsLibraryDependencyVersionQuickFixPath (com.android.tools.idea.gradle.structure.quickfix.PsLibraryDependencyVersionQuickFixPath)1 XmlStringUtil.escapeString (com.intellij.xml.util.XmlStringUtil.escapeString)1 NotNull (org.jetbrains.annotations.NotNull)1