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);
}
});
}
}
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;
}
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);
}
}
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));
}
});
}
Aggregations