Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
277,200
void (Library library) { getModifiableProjectLibrariesModel().removeLibrary(library); }
removeLibrary
277,201
ModifiableWorkspace () { if (myModifiableWorkspace == null && ExternalProjectsWorkspaceImpl.isDependencySubstitutionEnabled()) { myModifiableWorkspace = doGetModifiableWorkspace(); } return myModifiableWorkspace; }
getModifiableWorkspace
277,202
ModalityState () { return ModalityState.nonModal(); }
getModalityStateForQuestionDialogs
277,203
List<Module> (@NotNull Module module) { final ArrayList<Module> list = new ArrayList<>(); final Graph<Module> graph = getModuleGraph(); for (Iterator<Module> i = graph.getOut(module); i.hasNext(); ) { list.add(i.next()); } return list; }
getAllDependentModules
277,204
ModifiableWorkspace () { return ReadAction.compute(() -> myProject.getService(ExternalProjectsWorkspaceImpl.class) .createModifiableWorkspace(() -> Arrays.asList(getModules()))); }
doGetModifiableWorkspace
277,205
Graph<Module> () { return GraphGenerator.generate(CachingSemiGraph.cache(new InboundSemiGraph<>() { @NotNull @Override public Collection<Module> getNodes() { return Arrays.asList(getModules()); } @NotNull @Override public Iterator<Module> getIn(Module m) { Module[] dependentModules = getModifiableRootModel(m).getModuleDependencies(true); return Arrays.asList(dependentModules).iterator(); } })); }
getModuleGraph
277,206
Collection<Module> () { return Arrays.asList(getModules()); }
getNodes
277,207
Iterator<Module> (Module m) { Module[] dependentModules = getModifiableRootModel(m).getModuleDependencies(true); return Arrays.asList(dependentModules).iterator(); }
getIn
277,208
void () { ProjectRootManagerEx.getInstanceEx(myProject).mergeRootsChangesDuring(() -> { if (ExternalProjectsWorkspaceImpl.isDependencySubstitutionEnabled()) { updateSubstitutions(); } for (Map.Entry<Library, Library.ModifiableModel> entry: myModifiableLibraryModels.entrySet()) { Library fromLibrary = entry.getKey(); Library.ModifiableModel modifiableModel = entry.getValue(); // removed and (previously) not committed library is being disposed by LibraryTableBase.LibraryModel.removeLibrary // the modifiable model of such library shouldn't be committed if ((fromLibrary instanceof LibraryEx && ((LibraryEx)fromLibrary).isDisposed()) || (getModifiableWorkspace() != null && getModifiableWorkspace().isSubstituted(fromLibrary.getName()))) { Disposer.dispose(modifiableModel); } else { modifiableModel.commit(); } } getModifiableProjectLibrariesModel().commit(); Collection<ModifiableRootModel> rootModels = myModifiableRootModels.values(); ModifiableRootModel[] rootModels1 = rootModels.toArray(new ModifiableRootModel[0]); for (ModifiableRootModel model: rootModels1) { assert !model.isDisposed() : "Already disposed: " + model; } if (myModifiableModuleModel != null) { ModifiableModelCommitter.multiCommit(rootModels1, myModifiableModuleModel); } else { for (ModifiableRootModel model: rootModels1) { model.commit(); } } for (Map.Entry<Module, String> entry: myProductionModulesForTestModules.entrySet()) { TestModuleProperties.getInstance(entry.getKey()).setProductionModuleName(entry.getValue()); } for (Map.Entry<Module, ModifiableFacetModel> each: myModifiableFacetModels.entrySet()) { if (!each.getKey().isDisposed()) { each.getValue().commit(); } } myModifiableModels.values().forEach(ModifiableModel::commit); }); myUserData.clear(); }
commit
277,209
void () { ApplicationManager.getApplication().assertWriteIntentLockAcquired(); assert !myDisposed : "Already disposed!"; myDisposed = true; for (ModifiableRootModel each: myModifiableRootModels.values()) { if (each.isDisposed()) continue; each.dispose(); } Disposer.dispose(getModifiableProjectLibrariesModel()); for (Library.ModifiableModel each: myModifiableLibraryModels.values()) { if (each instanceof LibraryEx && ((LibraryEx)each).isDisposed()) continue; Disposer.dispose(each); } if (myModifiableModuleModel != null && myModifiableModuleModel.isChanged()) { myModifiableModuleModel.dispose(); } myModifiableModels.values().forEach(ModifiableModel::dispose); myModifiableRootModels.clear(); myModifiableFacetModels.clear(); myModifiableLibraryModels.clear(); myUserData.clear(); }
dispose
277,210
void (Module testModule, String productionModuleName) { myProductionModulesForTestModules.put(testModule, productionModuleName); }
setTestModuleProperties
277,211
String (Module module) { return myProductionModulesForTestModules.get(module); }
getProductionModuleName
277,212
ModuleOrderEntry (Module ownerModule, LibraryOrderEntry libraryOrderEntry, ProjectCoordinate publicationId) { String workspaceModuleCandidate = findModuleByPublication(publicationId); Module workspaceModule = workspaceModuleCandidate == null ? null : findIdeModule(workspaceModuleCandidate); if (workspaceModule == null) { return null; } else { ModifiableRootModel modifiableRootModel = getModifiableRootModel(ownerModule); ModuleOrderEntry moduleOrderEntry = modifiableRootModel.findModuleOrderEntry(workspaceModule); if (moduleOrderEntry == null) // if that module exists already (after re-import) moduleOrderEntry = modifiableRootModel.addModuleOrderEntry(workspaceModule); moduleOrderEntry.setScope(libraryOrderEntry.getScope()); moduleOrderEntry.setExported(libraryOrderEntry.isExported()); ModifiableWorkspace workspace = getModifiableWorkspace(); assert workspace != null; workspace.addSubstitution(ownerModule.getName(), workspaceModule.getName(), libraryOrderEntry.getLibraryName(), libraryOrderEntry.getScope()); modifiableRootModel.removeOrderEntry(libraryOrderEntry); return moduleOrderEntry; } }
trySubstitute
277,213
void (Module module, ProjectCoordinate modulePublication) { ModifiableWorkspace workspace = getModifiableWorkspace(); if (workspace != null) { workspace.register(modulePublication, module); } }
registerModulePublication
277,214
boolean (String libraryName) { ModifiableWorkspace workspace = getModifiableWorkspace(); if (workspace == null) return false; return workspace.isSubstituted(libraryName); }
isSubstituted
277,215
String (ProjectCoordinate publicationId) { ModifiableWorkspace workspace = getModifiableWorkspace(); return workspace == null ? null : workspace.findModule(publicationId); }
findModuleByPublication
277,216
void () { ModifiableWorkspace workspace = getModifiableWorkspace(); if (workspace == null) return; final List<String> oldModules = ContainerUtil.map(ModuleManager.getInstance(myProject).getModules(), module -> module.getName()); final List<String> newModules = ContainerUtil.map(myModifiableModuleModel.getModules(), module -> module.getName()); final Collection<String> removedModules = new HashSet<>(oldModules); removedModules.removeAll(newModules); Map<String, String> toSubstitute = new HashMap<>(); ProjectDataManager projectDataManager = ProjectDataManager.getInstance(); for (ExternalSystemManager<?, ?, ?, ?, ?> manager: ExternalSystemManager.EP_NAME.getIterable()) { Collection<ExternalProjectInfo> projectsData = projectDataManager.getExternalProjectsData(myProject, manager.getSystemId()); for (ExternalProjectInfo projectInfo: projectsData) { if (projectInfo.getExternalProjectStructure() == null) { continue; } Collection<DataNode<LibraryData>> libraryNodes = ExternalSystemApiUtil.findAll(projectInfo.getExternalProjectStructure(), ProjectKeys.LIBRARY); for (DataNode<LibraryData> libraryNode: libraryNodes) { String substitutionModuleCandidate = findModuleByPublication(libraryNode.getData()); if (substitutionModuleCandidate != null) { toSubstitute.put(libraryNode.getData().getInternalName(), substitutionModuleCandidate); } } } } for (Module module: getModules()) { ModifiableRootModel modifiableRootModel = getModifiableRootModel(module); boolean changed = false; OrderEntry[] entries = modifiableRootModel.getOrderEntries(); for (int i = 0, length = entries.length; i < length; i++) { OrderEntry orderEntry = entries[i]; if (orderEntry instanceof ModuleOrderEntry) { String workspaceModule = ((ModuleOrderEntry)orderEntry).getModuleName(); if (removedModules.contains(workspaceModule)) { DependencyScope scope = ((ModuleOrderEntry)orderEntry).getScope(); if (workspace.isSubstitution(module.getName(), workspaceModule, scope)) { String libraryName = workspace.getSubstitutedLibrary(workspaceModule); if (libraryName != null) { Library library = getLibraryByName(libraryName); if (library != null) { modifiableRootModel.removeOrderEntry(orderEntry); entries[i] = modifiableRootModel.addLibraryEntry(library); changed = true; workspace.removeSubstitution(module.getName(), workspaceModule, libraryName, scope); } } } } } if (!(orderEntry instanceof LibraryOrderEntry libraryOrderEntry)) continue; if (!libraryOrderEntry.isModuleLevel() && libraryOrderEntry.getLibraryName() != null) { String workspaceModule = toSubstitute.get(libraryOrderEntry.getLibraryName()); if (workspaceModule != null) { Module ideModule = findIdeModule(workspaceModule); if (ideModule != null) { ModuleOrderEntry moduleOrderEntry = modifiableRootModel.addModuleOrderEntry(ideModule); moduleOrderEntry.setScope(libraryOrderEntry.getScope()); modifiableRootModel.removeOrderEntry(orderEntry); entries[i] = moduleOrderEntry; changed = true; workspace.addSubstitution(module.getName(), workspaceModule, libraryOrderEntry.getLibraryName(), libraryOrderEntry.getScope()); } } } } if (changed) { modifiableRootModel.rearrangeOrderEntries(entries); } } workspace.commit(); }
updateSubstitutions
277,217
ModifiableModuleModel () { return ReadAction.compute(() -> { ModuleManager moduleManager = ModuleManager.getInstance(myProject); ModifiableModuleModel modifiableModel = ((ModuleManagerBridgeImpl)moduleManager).getModifiableModel(getActualStorageBuilder()); Module[] modules = modifiableModel.getModules(); for (Module module : modules) { setIdeModelsProviderForModule(module); } return modifiableModel; }); }
doGetModifiableModuleModel
277,218
ModifiableRootModel (@NotNull final Module module) { RootConfigurationAccessor rootConfigurationAccessor = new RootConfigurationAccessor() { @Nullable @Override public Library getLibrary(Library library, String libraryName, String libraryLevel) { if (LibraryTablesRegistrar.PROJECT_LEVEL.equals(libraryLevel)) { return getModifiableProjectLibrariesModel().getLibraryByName(libraryName); } return library; } }; return ReadAction.compute(() -> { ModuleRootManagerEx rootManager = ModuleRootManagerEx.getInstanceEx(module); return ((ModuleRootComponentBridge)rootManager).getModifiableModel(getActualStorageBuilder(), rootConfigurationAccessor); }); }
doGetModifiableRootModel
277,219
Library (Library library, String libraryName, String libraryLevel) { if (LibraryTablesRegistrar.PROJECT_LEVEL.equals(libraryLevel)) { return getModifiableProjectLibrariesModel().getLibraryByName(libraryName); } return library; }
getLibrary
277,220
ModifiableFacetModel (Module module) { FacetManager facetManager = FacetManager.getInstance(module); return ((FacetManagerBridge)facetManager).createModifiableModel(getActualStorageBuilder()); }
doGetModifiableFacetModel
277,221
Module (@NotNull String filePath, String moduleTypeId) { Module module = super.newModule(filePath, moduleTypeId); setIdeModelsProviderForModule(module); return module; }
newModule
277,222
Module (@NotNull ModuleData moduleData) { Module module = super.newModule(moduleData); setIdeModelsProviderForModule(module); return module; }
newModule
277,223
void () { LOG.trace("Applying commit for IdeaModifiableModelProvider"); workspaceModelCommit(); }
commit
277,224
void () { ProjectRootManagerEx.getInstanceEx(myProject).mergeRootsChangesDuring(() -> { if (ExternalProjectsWorkspaceImpl.isDependencySubstitutionEnabled()) { updateSubstitutions(); } LibraryTable.ModifiableModel projectLibrariesModel = getModifiableProjectLibrariesModel(); for (Map.Entry<Library, Library.ModifiableModel> entry: myModifiableLibraryModels.entrySet()) { Library fromLibrary = entry.getKey(); String libraryName = fromLibrary.getName(); Library.ModifiableModel modifiableModel = entry.getValue(); // Modifiable model for the new library which was disposed via ModifiableModel.removeLibrary should also be disposed // Modifiable model for the old library which was removed from ProjectLibraryTable should also be disposed if ((fromLibrary instanceof LibraryEx && ((LibraryEx)fromLibrary).isDisposed()) || (fromLibrary.getTable() != null && libraryName != null && projectLibrariesModel.getLibraryByName(libraryName) == null) || (getModifiableWorkspace() != null && getModifiableWorkspace().isSubstituted(fromLibrary.getName()))) { Disposer.dispose(modifiableModel); } else { ((LibraryModifiableModelBridge)modifiableModel).prepareForCommit(); } } ((ProjectModifiableLibraryTableBridge)projectLibrariesModel).prepareForCommit(); ModifiableRootModel[] rootModels; if (myModifiableModuleModel != null) { Module[] modules = myModifiableModuleModel.getModules(); for (Module module : modules) { module.putUserData(MODIFIABLE_MODELS_PROVIDER_KEY, null); } Set<Module> existingModules = Set.of(modules); rootModels = myModifiableRootModels.entrySet().stream().filter(entry -> existingModules.contains(entry.getKey())).map(Map.Entry::getValue).toArray(ModifiableRootModel[]::new); ((ModifiableModuleModelBridge)myModifiableModuleModel).prepareForCommit(); } else { rootModels = myModifiableRootModels.values().toArray(new ModifiableRootModel[0]); } for (ModifiableRootModel model : rootModels) { assert !model.isDisposed() : "Already disposed: " + model; } for (ModifiableRootModel model : rootModels) { ((ModifiableRootModelBridge)model).prepareForCommit(); } for (Map.Entry<Module, String> entry: myProductionModulesForTestModules.entrySet()) { TestModuleProperties testModuleProperties = TestModuleProperties.getInstance(entry.getKey()); if (testModuleProperties instanceof TestModulePropertiesBridge bridge) { bridge.setProductionModuleNameToBuilder(entry.getValue(), myModifiableModuleModel.getActualName(entry.getKey()), getActualStorageBuilder()); } else { testModuleProperties.setProductionModuleName(entry.getValue()); } } for (Map.Entry<Module, ModifiableFacetModel> each: myModifiableFacetModels.entrySet()) { if (!each.getKey().isDisposed()) { ((ModifiableFacetModelBridge)each.getValue()).prepareForCommit(); } } myModifiableModels.values().forEach(ModifiableModel::commit); WorkspaceModel.getInstance(myProject).updateProjectModel("External system: commit model", builder -> { MutableEntityStorage storageBuilder = getActualStorageBuilder(); if (LOG.isTraceEnabled()) { LOG.trace("Apply builder in ModifiableModels commit. builder: " + storageBuilder); } builder.addDiff(storageBuilder); return null; }); for (ModifiableRootModel model : rootModels) { ((ModifiableRootModelBridge)model).postCommit(); } }); myUserData.clear(); }
workspaceModelCommit
277,225
void () { if (myModifiableModuleModel != null) { Module[] modules = myModifiableModuleModel.getModules(); for (Module module : modules) { module.putUserData(MODIFIABLE_MODELS_PROVIDER_KEY, null); } } super.dispose(); }
dispose
277,226
MutableEntityStorage () { if (diff != null) return diff; VersionedEntityStorage storage = WorkspaceModel.getInstance(myProject).getEntityStorage(); LOG.info("Ide modifiable models provider, create builder from version " + storage.getVersion()); var initialStorage = storage.getCurrent(); return diff = MutableEntityStorage.from(initialStorage.toSnapshot()); }
getActualStorageBuilder
277,227
void (@NotNull Module module) { module.putUserData(MODIFIABLE_MODELS_PROVIDER_KEY, this); }
setIdeModelsProviderForModule
277,228
ClassMap<ModifiableModel> () { return myModifiableModels; }
getModifiableModels
277,229
void () { updateSubstitutions(); }
forceUpdateSubstitutions
277,230
void (@NotNull Project project) { final ExternalSystemFacadeManager facadeManager = ApplicationManager.getApplication().getService(ExternalSystemFacadeManager.class); for (ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemApiUtil.getAllManagers()) { AbstractExternalSystemSettings settings = manager.getSettingsProvider().fun(project); //noinspection unchecked settings.subscribe(new ExternalSystemSettingsListener<>() { @Override public void onProjectRenamed(@NotNull String oldName, @NotNull String newName) { facadeManager.onProjectRename(oldName, newName); } }, settings); } }
beAware
277,231
void (@NotNull String oldName, @NotNull String newName) { facadeManager.onProjectRename(oldName, newName); }
onProjectRenamed
277,232
State () { return myState; }
getState
277,233
void (@NotNull State state) { myState = state; }
loadState
277,234
boolean () { return Registry.is("external.system.substitute.library.dependencies"); }
isDependencySubstitutionEnabled
277,235
ModifiableWorkspace (Supplier<? extends List<Module>> modulesSupplier) { return new ModifiableWorkspace(myState, modulesSupplier); }
createModifiableWorkspace
277,236
long () { return myId; }
getId
277,237
void (@NotNull String key, long millis) { performanceData.put(key, millis); }
logPerformance
277,238
void (@NotNull Map<String, Long> trace) { performanceData.putAll(trace); }
addTrace
277,239
void () { if (LOG.isDebugEnabled()) { LOG.debug("Gradle successful import performance trace"); for (var entry : getPerformanceTrace().entrySet()) { LOG.debug("%s : %d ms.".formatted(entry.getKey(), entry.getValue())); } } }
reportStatistics
277,240
void (@NotNull Path directory) { var traceJoiner = new StringJoiner("\n"); for (var entry : getPerformanceTrace().entrySet()) { var description = entry.getKey(); var duration = entry.getValue(); var apply = "%s : %d ms.".formatted(description, duration); traceJoiner.add(apply); } try { var file = FileUtil.findSequentNonexistentFile(directory.toFile(), "performance-trace", "txt"); Files.createDirectories(directory); Files.writeString(file.toPath(), traceJoiner.toString()); } catch (IOException e) { throw new RuntimeException(e); } }
reportStatisticsToFile
277,241
OrderRootType (@NotNull LibraryPathType type) { return MAPPINGS.get(type); }
map
277,242
Module (@NotNull ModuleData module) { Module cachedIdeModule = myIdeModulesCache.get(module); if (cachedIdeModule == null) { for (String candidate : suggestModuleNameCandidates(module)) { Module ideModule = findIdeModule(candidate); if (ideModule != null && isApplicableIdeModule(module, ideModule)) { myIdeModulesCache.put(module, ideModule); return ideModule; } } } else { return cachedIdeModule; } return null; }
findIdeModule
277,243
Iterable<String> (@NotNull ModuleData module) { ExternalProjectSettings settings = getSettings(myProject, module.getOwner()).getLinkedProjectSettings(module.getLinkedExternalProjectPath()); char delimiter = settings != null && settings.isUseQualifiedModuleNames() ? '.' : '-'; return new ModuleNameGenerator(module, delimiter).generate(); }
suggestModuleNameCandidates
277,244
boolean (@NotNull ModuleData moduleData, @NotNull Module ideModule) { for (VirtualFile root : ModuleRootManager.getInstance(ideModule).getContentRoots()) { if (VfsUtilCore.pathEqualsTo(root, moduleData.getLinkedExternalProjectPath())) { return true; } } return isExternalSystemAwareModule(moduleData.getOwner(), ideModule) && pathsEqual(getExternalProjectPath(ideModule), moduleData.getLinkedExternalProjectPath()); }
isApplicableIdeModule
277,245
Module (@NotNull String ideModuleName) { return ModuleManager.getInstance(myProject).findModuleByName(ideModuleName); }
findIdeModule
277,246
UnloadedModuleDescription (@NotNull ModuleData moduleData) { for (String moduleName : suggestModuleNameCandidates(moduleData)) { UnloadedModuleDescription unloadedModuleDescription = ModuleManager.getInstance(myProject).getUnloadedModuleDescription(moduleName); // TODO external system module options should be honored to handle duplicated module names issues if (unloadedModuleDescription != null) { return unloadedModuleDescription; } } return null; }
getUnloadedModuleDescription
277,247
Library (@NotNull LibraryData libraryData) { final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myProject); for (Library ideLibrary : libraryTable.getLibraries()) { if (isRelated(ideLibrary, libraryData)) return ideLibrary; } return null; }
findIdeLibrary
277,248
ModuleOrderEntry (@NotNull ModuleDependencyData dependency, @NotNull Module module) { Map<String, List<ModuleOrderEntry>> namesToEntries = myIdeModuleToModuleDepsCache.computeIfAbsent( module, (m) -> Arrays.stream(getOrderEntries(m)) .filter(ModuleOrderEntry.class::isInstance) .map(ModuleOrderEntry.class::cast) .collect(Collectors.groupingBy(ModuleOrderEntry::getModuleName)) ); List<ModuleOrderEntry> candidates = namesToEntries.get(dependency.getInternalName()); if (candidates == null) { return null; } for (ModuleOrderEntry candidate : candidates) { if (candidate.getScope().equals(dependency.getScope())) { return candidate; } } return null; }
findIdeModuleDependency
277,249
OrderEntry (@NotNull DependencyData data) { Module ownerIdeModule = findIdeModule(data.getOwnerModule()); if (ownerIdeModule == null) return null; LibraryDependencyData libraryDependencyData = null; ModuleDependencyData moduleDependencyData = null; if (data instanceof LibraryDependencyData) { libraryDependencyData = (LibraryDependencyData)data; } else if (data instanceof ModuleDependencyData) { moduleDependencyData = (ModuleDependencyData)data; } else { return null; } for (OrderEntry entry : getOrderEntries(ownerIdeModule)) { if (entry instanceof LibraryOrderEntry && libraryDependencyData != null) { if (((LibraryOrderEntry)entry).isModuleLevel() && libraryDependencyData.getLevel() != LibraryLevel.MODULE) continue; if (isEmpty(((LibraryOrderEntry)entry).getLibraryName())) { final Set<String> paths = ContainerUtil.map2Set(libraryDependencyData.getTarget().getPaths(LibraryPathType.BINARY), PathUtil::getLocalPath); final Set<String> entryPaths = ContainerUtil.map2Set(((LibraryOrderEntry)entry).getRootUrls(OrderRootType.CLASSES), s -> PathUtil.getLocalPath(VfsUtilCore.urlToPath(s))); if (entryPaths.equals(paths) && ((LibraryOrderEntry)entry).getScope() == data.getScope()) return entry; continue; } } String entryName = libraryDependencyData != null ? libraryDependencyData.getInternalName() : moduleDependencyData.getInternalName(); if (entryName.equals(entry.getPresentableName()) && (!(entry instanceof ExportableOrderEntry) || ((ExportableOrderEntry)entry).getScope() == data.getScope())) { return entry; } } return null; }
findIdeModuleOrderEntry
277,250
Library (String name) { return LibraryTablesRegistrar.getInstance().getLibraryTable(myProject).getLibraryByName(name); }
getLibraryByName
277,251
List<Module> (@NotNull Module module) { return ModuleUtilCore.getAllDependentModules(module); }
getAllDependentModules
277,252
Iterator<String> () { return ContainerUtil.concatIterators(names.iterator(), new Iterator<>() { int current = 0; @Override public boolean hasNext() { return current < MAX_NUMBER_SEQ; } @Override public String next() { current++; return namePrefix + '~' + current; } }); }
iterator
277,253
boolean () { return current < MAX_NUMBER_SEQ; }
hasNext
277,254
String () { current++; return namePrefix + '~' + current; }
next
277,255
void () { ExternalSystemProjectTracker projectTracker = ExternalSystemProjectTracker.getInstance(project); List<ExternalSystemProjectId> projectSettings = findAllProjectSettings(); ApplicationManager.getApplication().invokeLater(() -> { projectSettings.forEach(it -> projectTracker.markDirty(it)); for (Contributor contributor : EP_NAME.getExtensions()) { contributor.markDirtyAllExternalProjects(project); } projectTracker.scheduleProjectRefresh(); }, project.getDisposed()); }
markDirtyAllExternalProjects
277,256
void (@NotNull Module module) { ExternalSystemProjectTracker projectTracker = ExternalSystemProjectTracker.getInstance(project); String projectPath = ExternalSystemApiUtil.getExternalProjectPath(module); List<ExternalSystemProjectId> projectSettings = findAllProjectSettings(); ApplicationManager.getApplication().invokeLater(() -> { projectSettings.stream() .filter(it -> it.getExternalProjectPath().equals(projectPath)) .forEach(it -> projectTracker.markDirty(it)); for (Contributor contributor : EP_NAME.getExtensions()) { contributor.markDirty(module); } projectTracker.scheduleProjectRefresh(); }, module.getDisposed()); }
markDirty
277,257
void (@NotNull String projectPath) { ExternalSystemProjectTracker projectTracker = ExternalSystemProjectTracker.getInstance(project); List<ExternalSystemProjectId> projectSettings = findAllProjectSettings(); ApplicationManager.getApplication().invokeLater(() -> { projectSettings.stream() .filter(it -> it.getExternalProjectPath().equals(projectPath)) .forEach(it -> projectTracker.markDirty(it)); for (Contributor contributor : EP_NAME.getExtensions()) { contributor.markDirty(projectPath); } projectTracker.scheduleProjectRefresh(); }, project.getDisposed()); }
markDirty
277,258
List<ExternalSystemProjectId> () { List<ExternalSystemProjectId> list = new ArrayList<>(); ExternalSystemManager.EP_NAME.forEachExtensionSafe(manager -> { ProjectSystemId systemId = manager.getSystemId(); Collection<? extends ExternalProjectSettings> linkedProjectsSettings = manager.getSettingsProvider().fun(project).getLinkedProjectsSettings(); for (ExternalProjectSettings settings : linkedProjectsSettings) { String externalProjectPath = settings.getExternalProjectPath(); if (externalProjectPath == null) continue; list.add(new ExternalSystemProjectId(systemId, externalProjectPath)); } }); return list; }
findAllProjectSettings
277,259
void (@NotNull List<? extends @NotNull VFileEvent> events) { for (VFileEvent each : events) { if (each instanceof VFileDeleteEvent) { deleteRecursively(each.getFile(), each); } else { if (!isRelevant(each.getPath())) continue; if (each instanceof VFilePropertyChangeEvent) { if (isRenamed(each)) { deleteRecursively(each.getFile(), each); } } else if (each instanceof VFileMoveEvent moveEvent) { String newPath = moveEvent.getNewParent().getPath() + "/" + moveEvent.getFile().getName(); if (!isRelevant(newPath)) { deleteRecursively(moveEvent.getFile(), each); } } } } }
before
277,260
void (VirtualFile f, final VFileEvent event) { VfsUtilCore.visitChildrenRecursively(f, new VirtualFileVisitor<Void>() { @Override public boolean visitFile(@NotNull VirtualFile f) { if (isRelevant(f.getPath())) deleteFile(f, event); return true; } @Nullable @Override public Iterable<VirtualFile> getChildrenIterable(@NotNull VirtualFile f) { return f.isDirectory() && f instanceof NewVirtualFile ? ((NewVirtualFile)f).iterInDbChildren() : null; } }); }
deleteRecursively
277,261
boolean (@NotNull VirtualFile f) { if (isRelevant(f.getPath())) deleteFile(f, event); return true; }
visitFile
277,262
Iterable<VirtualFile> (@NotNull VirtualFile f) { return f.isDirectory() && f instanceof NewVirtualFile ? ((NewVirtualFile)f).iterInDbChildren() : null; }
getChildrenIterable
277,263
void (@NotNull List<? extends @NotNull VFileEvent> events) { for (VFileEvent each : events) { if (!isRelevant(each.getPath())) continue; if (each instanceof VFileCreateEvent createEvent) { VirtualFile newChild = createEvent.getParent().findChild(createEvent.getChildName()); if (newChild != null) { updateFile(newChild, each); } } else if (each instanceof VFileCopyEvent copyEvent) { VirtualFile newChild = copyEvent.getNewParent().findChild(copyEvent.getNewChildName()); if (newChild != null) { updateFile(newChild, each); } } else if (each instanceof VFileContentChangeEvent) { updateFile(each.getFile(), each); } else if (each instanceof VFilePropertyChangeEvent) { if (isRenamed(each)) { updateFile(each.getFile(), each); } } else if (each instanceof VFileMoveEvent) { updateFile(each.getFile(), each); } } apply(); }
after
277,264
boolean (VFileEvent each) { return ((VFilePropertyChangeEvent)each).getPropertyName().equals(VirtualFile.PROP_NAME) && !Comparing.equal(((VFilePropertyChangeEvent)each).getOldValue(), ((VFilePropertyChangeEvent)each).getNewValue()); }
isRenamed
277,265
List<File> (String projectPath, @NotNull Project project) { return myDelegate.getAffectedExternalProjectFiles(projectPath, project); }
getAffectedExternalProjectFiles
277,266
boolean (@Nullable ProjectResolverPolicy resolverPolicy) { return myDelegate.isApplicable(resolverPolicy); }
isApplicable
277,267
JComponent () { PaintAwarePanel result = myComponent; if (result == null) { result = new PaintAwarePanel(); myControl.fillUi(result, 0); myControl.reset(true, null); ExternalSystemUiUtil.fillBottom(result); myComponent = result; } return result; }
getComponent
277,268
void () { myControl.apply(myExternalModuleBuilder.getExternalProjectSettings()); }
updateDataModel
277,269
void () { String contentPath = myExternalModuleBuilder.getContentEntryPath(); if (contentPath != null) { myControl.getInitialSettings().setExternalProjectPath(contentPath); } myControl.reset(true, myContext, null); }
updateStep
277,270
void () { super.disposeUIResources(); myControl.disposeUIResources(); }
disposeUIResources
277,271
boolean () { return myContext == null || !Boolean.TRUE.equals(myContext.getUserData(SKIP_STEP_KEY)); }
isStepVisible
277,272
String () { return myControl.getHelpId(); }
getHelpId
277,273
String () { return myExternalSystemId.getReadableName(); }
getPresentableName
277,274
String () { return ExternalSystemBundle.message("module.type.description", myExternalSystemId.getReadableName()); }
getDescription
277,275
Icon () { return myIcon; }
getNodeIcon
277,276
S () { return myExternalProjectSettings; }
getExternalProjectSettings
277,277
Project (String name, String path) { Project project = super.createProject(name, path); if(project != null) { project.putUserData(ExternalSystemDataKeys.NEWLY_CREATED_PROJECT, Boolean.TRUE); } return project; }
createProject
277,278
Key<ContentRootData> () { return ProjectKeys.CONTENT_ROOT; }
getTargetDataKey
277,279
void (@NotNull Collection<? extends DataNode<ContentRootData>> toImport, @Nullable ProjectData projectData, @NotNull Project project, @NotNull IdeModifiableModelsProvider modelsProvider) { logUnitTest("Importing data. Data size is [" + toImport.size() + "]"); if (toImport.isEmpty()) { return; } boolean isNewlyImportedProject = project.getUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT) == Boolean.TRUE; boolean forceDirectoriesCreation = false; DataNode<ProjectData> projectDataNode = ExternalSystemApiUtil.findParent(toImport.iterator().next(), ProjectKeys.PROJECT); if (projectDataNode != null) { forceDirectoriesCreation = projectDataNode.getUserData(CREATE_EMPTY_DIRECTORIES) == Boolean.TRUE; } Set<Module> modulesToExpand = CollectionFactory.createSmallMemoryFootprintSet(); MultiMap<DataNode<ModuleData>, DataNode<ContentRootData>> byModule = ExternalSystemApiUtil.groupBy(toImport, ModuleData.class); filterAndReportDuplicatingContentRoots(byModule, project); for (Map.Entry<DataNode<ModuleData>, Collection<DataNode<ContentRootData>>> entry : byModule.entrySet()) { Module module = entry.getKey().getUserData(AbstractModuleDataService.MODULE_KEY); module = module != null ? module : modelsProvider.findIdeModule(entry.getKey().getData()); if (module == null) { LOG.warn(String.format( "Can't import content roots. Reason: target module (%s) is not found at the ide. Content roots: %s", entry.getKey(), entry.getValue() )); continue; } importData(project, modelsProvider, entry.getValue(), module, forceDirectoriesCreation, projectData == null ? null : projectData.getOwner()); if (forceDirectoriesCreation || (isNewlyImportedProject && projectData != null && projectData.getLinkedExternalProjectPath().equals(ExternalSystemApiUtil.getExternalProjectPath(module)))) { modulesToExpand.add(module); } } if (!ApplicationManager.getApplication().isHeadlessEnvironment() && !modulesToExpand.isEmpty()) { for (Module module : modulesToExpand) { String productionModuleName = modelsProvider.getProductionModuleName(module); if (productionModuleName == null || !modulesToExpand.contains(modelsProvider.findIdeModule(productionModuleName))) { VirtualFile[] roots = modelsProvider.getModifiableRootModel(module).getContentRoots(); if (roots.length > 0) { VirtualFile virtualFile = roots[0]; StartupManager.getInstance(project).runAfterOpened(() -> { ApplicationManager.getApplication().invokeLater(() -> { final ProjectView projectView = ProjectView.getInstance(project); projectView.changeViewCB(ProjectViewPane.ID, null).doWhenProcessed(() -> projectView.selectCB(null, virtualFile, false)); }, ModalityState.nonModal(), project.getDisposed()); }); } } } } }
importData
277,280
void (@NotNull Project project, @NotNull IdeModifiableModelsProvider modelsProvider, @NotNull final Collection<? extends DataNode<ContentRootData>> data, @NotNull final Module module, boolean forceDirectoriesCreation, @Nullable ProjectSystemId owner) { logUnitTest("Import data for module [" + module.getName() + "], data size [" + data.size() + "]"); final SourceFolderManager sourceFolderManager = SourceFolderManager.getInstance(project); final ModifiableRootModel modifiableRootModel = modelsProvider.getModifiableRootModel(module); final ContentEntry[] contentEntries = modifiableRootModel.getContentEntries(); final Map<String, ContentEntry> contentEntriesMap = new HashMap<>(); for (ContentEntry contentEntry : contentEntries) { contentEntriesMap.put(contentEntry.getUrl(), contentEntry); } sourceFolderManager.removeSourceFolders(module); final Set<ContentEntry> importedContentEntries = new ReferenceOpenHashSet<>(); for (final DataNode<ContentRootData> node : data) { final ContentRootData contentRoot = node.getData(); final ContentEntry contentEntry = findOrCreateContentRoot(modifiableRootModel, contentRoot); if (!importedContentEntries.contains(contentEntry)) { removeSourceFoldersIfAbsent(contentEntry, contentRoot); removeImportedExcludeFolders(contentEntry, modelsProvider, owner, project); importedContentEntries.add(contentEntry); } logDebug("Importing content root '%s' for module '%s' forceDirectoriesCreation=[%b]", contentRoot.getRootPath(), module.getName(), forceDirectoriesCreation); Set<String> updatedSourceRoots = new HashSet<>(); for (ExternalSystemSourceType externalSrcType : ExternalSystemSourceType.values()) { final JpsModuleSourceRootType<?> type = getJavaSourceRootType(externalSrcType); if (type != null) { for (SourceRoot sourceRoot : contentRoot.getPaths(externalSrcType)) { String sourceRootPath = sourceRoot.getPath(); boolean createSourceFolder = !updatedSourceRoots.contains(sourceRootPath); if (createSourceFolder) { createOrReplaceSourceFolder(sourceFolderManager, contentEntry, sourceRoot, module, type, forceDirectoriesCreation, ExternalSystemApiUtil.toExternalSource(contentRoot.getOwner())); if (externalSrcType == ExternalSystemSourceType.SOURCE || externalSrcType == ExternalSystemSourceType.TEST) { updatedSourceRoots.add(sourceRootPath); } } configureSourceFolder(sourceFolderManager, contentEntry, sourceRoot, createSourceFolder, externalSrcType.isGenerated()); } } } for (SourceRoot path : contentRoot.getPaths(ExternalSystemSourceType.EXCLUDED)) { createExcludedRootIfAbsent(contentEntry, path, module.getName()); } contentEntriesMap.remove(contentEntry.getUrl()); } for (ContentEntry contentEntry : contentEntriesMap.values()) { modifiableRootModel.removeContentEntry(contentEntry); } }
importData
277,281
void (@NotNull ContentEntry contentEntry, @NotNull IdeModifiableModelsProvider modelsProvider, @Nullable ProjectSystemId owner, @NotNull Project project) { if (owner == null) { return; // can not remove imported exclude folders is source is not known } if (modelsProvider instanceof IdeModifiableModelsProviderImpl impl) { MutableEntityStorage diff = impl.getActualStorageBuilder(); VirtualFileUrl vfu = project.getService(VirtualFileUrlManager.class).fromUrl(contentEntry.getUrl()); Pair<WorkspaceEntity, String> result = ContainerUtil.find(diff.getVirtualFileUrlIndex().findEntitiesByUrl(vfu).iterator(), pair -> { return "url".equals(pair.component2()) && pair.component1() instanceof ContentRootEntity; }); if (result != null && result.component1() instanceof ContentRootEntity contentRootEntity) { for (ExcludeUrlEntity excludeEntity : contentRootEntity.getExcludedUrls()) { if (isImportedEntity(owner, excludeEntity)) { diff.removeEntity(excludeEntity); } } } } }
removeImportedExcludeFolders
277,282
boolean (@NotNull ProjectSystemId owner, @NotNull ExcludeUrlEntity excludeEntity) { return excludeEntity.getEntitySource() instanceof JpsImportedEntitySource importedEntitySource && owner.getId().equals(importedEntitySource.getExternalSystemId()); }
isImportedEntity
277,283
ContentEntry (@NotNull ModifiableRootModel model, @NotNull ContentRootData contentRootData) { String path = contentRootData.getRootPath(); ContentEntry[] entries = model.getContentEntries(); for (ContentEntry entry : entries) { VirtualFile file = entry.getFile(); if (file == null) { continue; } if (ExternalSystemApiUtil.getLocalFileSystemPath(file).equals(path)) { return entry; } } return model.addContentEntry(pathToUrl(path), ExternalSystemApiUtil.toExternalSource(contentRootData.getOwner())); }
findOrCreateContentRoot
277,284
Set<String> (@NotNull ContentRootData contentRoot) { Set<String> sourceRoots = CollectionFactory.createFilePathSet(); for (ExternalSystemSourceType externalSrcType : ExternalSystemSourceType.values()) { final JpsModuleSourceRootType<?> type = getJavaSourceRootType(externalSrcType); if (type == null) continue; for (SourceRoot path : contentRoot.getPaths(externalSrcType)) { if (path == null) continue; sourceRoots.add(path.getPath()); } } return sourceRoots; }
getSourceRoots
277,285
void (@NotNull ContentEntry contentEntry, @NotNull ContentRootData contentRoot) { SourceFolder[] sourceFolders = contentEntry.getSourceFolders(); if (sourceFolders.length == 0) return; Set<String> sourceRoots = getSourceRoots(contentRoot); for (SourceFolder sourceFolder : sourceFolders) { String url = sourceFolder.getUrl(); String path = VfsUtilCore.urlToPath(url); if (!sourceRoots.contains(path)) { contentEntry.removeSourceFolder(sourceFolder); } } }
removeSourceFoldersIfAbsent
277,286
void (@NotNull SourceFolderManager sourceFolderManager, @NotNull ContentEntry contentEntry, @NotNull final SourceRoot sourceRoot, @NotNull Module module, @NotNull JpsModuleSourceRootType<?> sourceRootType, boolean createEmptyContentRootDirectories, @NotNull ProjectModelExternalSource externalSource) { String path = sourceRoot.getPath(); if (SystemInfo.isWindows) { if (!path.isEmpty() && StringUtil.isWhiteSpace(path.charAt(path.length() - 1))) { LOG.warn("Source root ending with a space found. Such directories is not properly supported by JDK on Windows, see https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8190546. " + "The source root will not be added: '" + path + "'"); return; } } if (createEmptyContentRootDirectories) { createEmptyDirectory(path); } SourceFolder folder = findSourceFolder(contentEntry, sourceRoot); if (folder != null) { final JpsModuleSourceRootType<?> folderRootType = folder.getRootType(); if (sourceRootType.equals(folderRootType)) { return; } contentEntry.removeSourceFolder(folder); } String url = pathToUrl(path); if (!Files.exists(Path.of(path))) { logDebug("Source folder [%s] does not exist and will not be created, will add when dir is created", url); logUnitTest("Adding source folder listener to watch [%s] for creation in project [hashCode=%d]", url, module.getProject().hashCode()); sourceFolderManager.addSourceFolder(module, url, sourceRootType); } else { contentEntry.addSourceFolder(url, sourceRootType, externalSource); } }
createOrReplaceSourceFolder
277,287
void (@NotNull SourceFolderManager sourceFolderManager, @NotNull ContentEntry contentEntry, @NotNull SourceRoot sourceRoot, boolean updatePackagePrefix, boolean generated) { String packagePrefix = sourceRoot.getPackagePrefix(); String url = pathToUrl(sourceRoot.getPath()); logDebug("Importing root '%s' with packagePrefix=[%s] generated=[%b]", sourceRoot, packagePrefix, generated); SourceFolder folder = findSourceFolder(contentEntry, sourceRoot); if (folder == null) { if (updatePackagePrefix) { sourceFolderManager.setSourceFolderPackagePrefix(url, packagePrefix); } if (generated) { sourceFolderManager.setSourceFolderGenerated(url, true); } } else { if (updatePackagePrefix && StringUtil.isNotEmpty(packagePrefix)) { folder.setPackagePrefix(packagePrefix); } if (generated) { setForGeneratedSources(folder, true); } } }
configureSourceFolder
277,288
void (@NotNull String path) { if (Files.exists(Path.of(path))) return; ExternalSystemApiUtil.doWriteAction(() -> { try { VfsUtil.createDirectoryIfMissing(path); } catch (IOException e) { LOG.warn(String.format("Unable to create directory for the path: %s", path), e); } }); }
createEmptyDirectory
277,289
SourceFolder (@NotNull ContentEntry contentEntry, @NotNull SourceRoot sourceRoot) { for (SourceFolder folder : contentEntry.getSourceFolders()) { VirtualFile file = folder.getFile(); if (file == null) continue; String folderPath = ExternalSystemApiUtil.getLocalFileSystemPath(file); String rootPath = sourceRoot.getPath(); if (folderPath.equals(rootPath)) return folder; } return null; }
findSourceFolder
277,290
void (@NotNull SourceFolder folder, boolean generated) { JpsModuleSourceRoot jpsElement = folder.getJpsElement(); JavaSourceRootProperties properties = jpsElement.getProperties(JavaModuleSourceRootTypes.SOURCES); if (properties != null) properties.setForGeneratedSources(generated); }
setForGeneratedSources
277,291
void (@NotNull String format, Object... args) { if (ApplicationManager.getApplication().isUnitTestMode()) { LOG.info(String.format(format, args)); } }
logUnitTest
277,292
void (@NotNull String format, Object... args) { if (LOG.isDebugEnabled()) { LOG.debug(String.format(format, args)); } }
logDebug
277,293
void (@NotNull ContentEntry entry, @NotNull SourceRoot root, @NotNull String moduleName) { String rootPath = root.getPath(); for (VirtualFile file : entry.getExcludeFolderFiles()) { if (ExternalSystemApiUtil.getLocalFileSystemPath(file).equals(rootPath)) { return; } } logDebug("Importing excluded root '%s' for content root '%s' of module '%s'", root, entry.getUrl(), moduleName); entry.addExcludeFolder(pathToUrl(rootPath), true); }
createExcludedRootIfAbsent
277,294
void (@NotNull MultiMap<DataNode<ModuleData>, DataNode<ContentRootData>> moduleNodeToRootNodes, @NotNull Project project) { Map<String, DuplicateModuleReport> filter = new LinkedHashMap<>(); for (Map.Entry<DataNode<ModuleData>, Collection<DataNode<ContentRootData>>> entry : moduleNodeToRootNodes.entrySet()) { ModuleData moduleData = entry.getKey().getData(); Collection<DataNode<ContentRootData>> crDataNodes = entry.getValue(); for (Iterator<DataNode<ContentRootData>> iterator = crDataNodes.iterator(); iterator.hasNext(); ) { DataNode<ContentRootData> crDataNode = iterator.next(); String rootPath = crDataNode.getData().getRootPath(); DuplicateModuleReport report = filter.putIfAbsent(rootPath, new DuplicateModuleReport(moduleData)); if (report != null) { report.addDuplicate(moduleData); iterator.remove(); crDataNode.clear(true); } } } Map<String, DuplicateModuleReport> toReport = filter.entrySet().stream() .filter(e -> e.getValue().hasDuplicates()) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (r1, r2) -> { LOG.warn("Unexpected duplicates in keys while collecting filtered reports"); return r2; }, LinkedHashMap::new)); boolean hasDuplicates = !toReport.isEmpty(); HasSharedSourcesUtil.setHasSharedSources(project, hasDuplicates); if (hasDuplicates) { String notificationMessage = prepareMessageAndLogWarnings(toReport); if (notificationMessage != null) { showNotificationsPopup(project, toReport.size(), notificationMessage); } } }
filterAndReportDuplicatingContentRoots
277,295
void (@NotNull Project project, int reportsCount, @NotNull @Nls String notificationMessage) { int extraReportsCount = reportsCount - 1; if (extraReportsCount > 0) { notificationMessage += ExternalSystemBundle.message("duplicate.content.roots.extra", extraReportsCount); } Notification notification = new Notification("Content root duplicates", ExternalSystemBundle.message("duplicate.content.roots.detected"), notificationMessage, NotificationType.WARNING); Notifications.Bus.notify(notification, project); }
showNotificationsPopup
277,296
void (@NotNull ModuleData duplicate) { myDuplicates.add(duplicate); }
addDuplicate
277,297
boolean () { return !myDuplicates.isEmpty(); }
hasDuplicates
277,298
String () { return myOriginal.getInternalName(); }
getOriginalName
277,299
Collection<String> () { return ContainerUtil.map(myDuplicates, ModuleData::getInternalName); }
getDuplicatesNames