ActionCallback (@NotNull List<? extends LibraryOrderEntry> orderEntriesContainingFile) { Map<LibraryOrderEntry, Module> gradleModules = getGradleModules(orderEntries); if (gradleModules.isEmpty()) { return ActionCallback.REJECTED; } Map.Entry<LibraryOrderEntry, Module> next = gradleModules.entrySet().iterator().next(); Module module = next.getValue(); if (CachedModuleDataFinder.getGradleModuleData(module) == null) { return ActionCallback.REJECTED; } LibraryOrderEntry libraryOrderEntry = next.getKey(); String libraryName = libraryOrderEntry.getLibraryName(); if (libraryName == null) { return ActionCallback.REJECTED; } String artifactCoordinates = StringUtil.trimStart(libraryName, GradleConstants.SYSTEM_ID.getReadableName() + ": "); if (StringUtil.equals(libraryName, artifactCoordinates)) { return ActionCallback.REJECTED; } String externalProjectPath = ExternalSystemApiUtil.getExternalRootProjectPath(module); if (externalProjectPath == null) { return ActionCallback.REJECTED; } String sourceArtifactNotation = getSourcesArtifactNotation(artifactCoordinates, artifactIdCandidate -> { VirtualFile[] rootFiles = libraryOrderEntry.getRootFiles(OrderRootType.CLASSES); return rootFiles.length == 0 || ContainerUtil.exists(rootFiles, file -> file.getName().startsWith(artifactIdCandidate)); }); Path cachedSourcesPath = lookupSourcesPathFromCache(libraryOrderEntry, sourceArtifactNotation, psiFile.getProject(), externalProjectPath); if (cachedSourcesPath != null && isValidJar(cachedSourcesPath)) { attachSources(cachedSourcesPath.toFile(), orderEntries); return ActionCallback.DONE; } return downloadSources(psiFile, sourceArtifactNotation, artifactCoordinates, externalProjectPath); }