use of com.android.tools.idea.gradle.structure.configurables.PsContext 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);
}
});
}
}
use of com.android.tools.idea.gradle.structure.configurables.PsContext 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;
}
use of com.android.tools.idea.gradle.structure.configurables.PsContext 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));
}
});
}
Aggregations