use of com.android.tools.idea.gradle.structure.model.android.PsAndroidModule 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));
}
});
}
use of com.android.tools.idea.gradle.structure.model.android.PsAndroidModule in project android by JetBrains.
the class AddLibraryDependencyDialog method doValidate.
@Override
@Nullable
protected ValidationInfo doValidate() {
List<Exception> searchErrors = myLibraryDependenciesForm.getSearchErrors();
if (!searchErrors.isEmpty()) {
StringBuilder buffer = new StringBuilder();
searchErrors.forEach(e -> buffer.append(getErrorMessage(e)).append("\n"));
return new ValidationInfo(buffer.toString(), myLibraryDependenciesForm.getPreferredFocusedComponent());
}
String selectedLibrary = myLibraryDependenciesForm.getSelectedLibrary();
if (isEmpty(selectedLibrary)) {
return new ValidationInfo("Please specify the library to add as dependency", myLibraryDependenciesForm.getPreferredFocusedComponent());
}
PsArtifactDependencySpec spec = PsArtifactDependencySpec.create(selectedLibrary);
PsModule module = getModule();
if (spec != null && module instanceof PsAndroidModule) {
PsAndroidModule androidModule = (PsAndroidModule) module;
Ref<Boolean> found = new Ref<>(false);
androidModule.forEachDeclaredDependency(dependency -> {
if (dependency instanceof PsLibraryAndroidDependency) {
PsLibraryAndroidDependency libraryDependency = (PsLibraryAndroidDependency) dependency;
PsArtifactDependencySpec resolvedSpec = libraryDependency.getResolvedSpec();
if (Objects.equals(spec.group, resolvedSpec.group) && Objects.equals(spec.name, resolvedSpec.name)) {
found.set(true);
}
}
});
if (found.get()) {
String msg = String.format("Library '%1$s' is already a dependency", spec.name);
return new ValidationInfo(msg, myLibraryDependenciesForm.getPreferredFocusedComponent());
}
}
return getScopesPanel().validateInput();
}
use of com.android.tools.idea.gradle.structure.model.android.PsAndroidModule in project android by JetBrains.
the class ModuleDependencyNode method setUp.
private void setUp(@NotNull PsModuleAndroidDependency moduleDependency) {
myName = moduleDependency.toText(PLAIN_TEXT);
PsAndroidModule dependentModule = moduleDependency.getParent();
PsProject project = dependentModule.getParent();
PsModule referred = project.findModuleByGradlePath(moduleDependency.getGradlePath());
if (referred instanceof PsAndroidModule) {
PsAndroidModule androidModule = (PsAndroidModule) referred;
androidModule.forEachDependency(dependency -> {
if (!dependency.isDeclared()) {
return;
}
String moduleVariant = moduleDependency.getConfigurationName();
if (!dependency.isIn(ARTIFACT_MAIN, moduleVariant)) {
return;
}
AbstractPsModelNode<?> child = AbstractDependencyNode.createNode(this, dependency);
if (child != null) {
myChildren.add(child);
}
});
}
}
Aggregations