Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
277,400
void (@NotNull LibraryOrderEntry orderEntry, @NotNull Library lib, @NotNull Module module, @NotNull LibraryDependencyData dependencyData) { orderEntry.setExported(dependencyData.isExported()); orderEntry.setScope(dependencyData.getScope()); if(LOG.isDebugEnabled()) { LOG.debug(String.format( "Configuring library '%s' of module '%s' to be%s exported and have scope %s", lib, module.getName(), dependencyData.isExported() ? " not" : "", dependencyData.getScope() )); } }
setLibraryScope
277,401
void (@NotNull IdeModifiableModelsProvider modelsProvider, @NotNull Map<Set<String>, LibraryDependencyData> moduleLibrariesToImport, @NotNull Map<String, LibraryDependencyData> projectLibrariesToImport, @NotNull Set<LibraryDependencyData> toImport, @NotNull Map<OrderEntry, OrderAware> orderEntryDataMap, @NotNull ModifiableRootModel moduleRootModel, boolean hasUnresolvedLibraries) { for (OrderEntry entry : moduleRootModel.getOrderEntries()) { if (OrderEntryUtil.isModuleLibraryOrderEntry(entry)) { LibraryOrderEntry moduleLibraryOrderEntry = (LibraryOrderEntry)entry; Library library = moduleLibraryOrderEntry.getLibrary(); final VirtualFile[] libraryFiles = library.getFiles(OrderRootType.CLASSES); final Set<String> moduleLibraryKey = new HashSet<>(libraryFiles.length); for (VirtualFile file : libraryFiles) { moduleLibraryKey.add(ExternalSystemApiUtil.getLocalFileSystemPath(file) + moduleLibraryOrderEntry.getScope().name()); } LibraryDependencyData existing = moduleLibrariesToImport.remove(moduleLibraryKey); if (existing == null || !StringUtil.equals(StringUtil.nullize(existing.getInternalName()), library.getName())) { moduleRootModel.removeOrderEntry(entry); } else { orderEntryDataMap.put(entry, existing); syncExistingLibraryDependency(modelsProvider, existing, library, moduleRootModel, moduleLibraryOrderEntry.getOwnerModule()); toImport.remove(existing); } } else if (entry instanceof LibraryOrderEntry libraryOrderEntry) { String libraryName = libraryOrderEntry.getLibraryName(); LibraryDependencyData existing = projectLibrariesToImport.remove(libraryName + libraryOrderEntry.getScope().name()); if (existing != null) { String module = modelsProvider.findModuleByPublication(existing.getTarget()); if(module == null) { toImport.remove(existing); orderEntryDataMap.put(entry, existing); libraryOrderEntry.setExported(existing.isExported()); libraryOrderEntry.setScope(existing.getScope()); } else { moduleRootModel.removeOrderEntry(entry); } } else if (!hasUnresolvedLibraries) { // There is a possible case that a project has been successfully imported from external model and after // that network/repo goes down. We don't want to drop existing binary mappings then. moduleRootModel.removeOrderEntry(entry); } } } }
syncExistingAndRemoveObsolete
277,402
LibraryOrderEntry (@NotNull IdeModifiableModelsProvider modelsProvider, @NotNull final LibraryDependencyData libraryDependencyData, @NotNull final Library library, @NotNull final ModifiableRootModel moduleRootModel, @NotNull final Module module) { final Library.ModifiableModel libraryModel = modelsProvider.getModifiableLibraryModel(library); final String libraryName = libraryDependencyData.getInternalName(); final LibraryData libraryDependencyDataTarget = libraryDependencyData.getTarget(); Map<OrderRootType, Collection<File>> files = ProjectDataService.EP_NAME.findExtensionOrFail(LibraryDataService.class) .prepareLibraryFiles(libraryDependencyDataTarget); Set<String> excludedPaths = libraryDependencyDataTarget.getPaths(LibraryPathType.EXCLUDED); LibraryDataService.registerPaths(libraryDependencyDataTarget.isUnresolved(), files, excludedPaths, libraryModel, libraryName); LibraryOrderEntry orderEntry = findLibraryOrderEntry(moduleRootModel, library, libraryDependencyData.getScope()); assert orderEntry != null; setLibraryScope(orderEntry, library, module, libraryDependencyData); return orderEntry; }
syncExistingLibraryDependency
277,403
LibraryOrderEntry (@NotNull ModifiableRootModel moduleRootModel, @NotNull Library library, @NotNull DependencyScope scope) { LibraryOrderEntry candidate = null; for (OrderEntry orderEntry : moduleRootModel.getOrderEntries()) { if (orderEntry instanceof LibraryOrderEntry libraryOrderEntry) { if (library == libraryOrderEntry.getLibrary()) { return libraryOrderEntry; } // LibraryImpl.equals will return true for unrelated module library if it's just created and empty if (library.equals(libraryOrderEntry.getLibrary()) && (candidate == null || libraryOrderEntry.getScope() == scope)) { candidate = libraryOrderEntry; } } } return candidate; }
findLibraryOrderEntry
277,404
void () { ExternalProjectsDataStorage.invalidateCaches(); }
invalidateCaches
277,405
Key<ProjectData> () { return ProjectKeys.PROJECT; }
getTargetDataKey
277,406
void (@NotNull Collection<? extends DataNode<ProjectData>> toImport, @Nullable ProjectData projectData, final @NotNull Project project, @NotNull IdeModifiableModelsProvider modelsProvider) { // root project can be marked as ignored if (toImport.isEmpty()) { return; } if (toImport.size() != 1) { throw new IllegalArgumentException(String.format("Expected to get a single project but got %d: %s", toImport.size(), toImport)); } DataNode<ProjectData> node = toImport.iterator().next(); assert projectData == node.getData(); if (!ExternalSystemApiUtil.isOneToOneMapping(project, node.getData(), modelsProvider.getModules())) { return; } if (!project.getName().equals(projectData.getInternalName())) { renameProject(projectData.getInternalName(), projectData.getOwner(), project); } }
importData
277,407
void (final @NotNull String newName, final @NotNull ProjectSystemId externalSystemId, final @NotNull Project project) { if (!(project instanceof ProjectEx) || newName.equals(project.getName())) { return; } ExternalSystemApiUtil.executeProjectChangeAction(true, new DisposeAwareProjectChange(project) { @Override public void execute() { String oldName = project.getName(); ((ProjectEx)project).setProjectName(newName); ExternalSystemApiUtil.getSettings(project, externalSystemId).getPublisher().onProjectRenamed(oldName, newName); } }); }
renameProject
277,408
void () { String oldName = project.getName(); ((ProjectEx)project).setProjectName(newName); ExternalSystemApiUtil.getSettings(project, externalSystemId).getPublisher().onProjectRenamed(oldName, newName); }
execute
277,409
void (@NotNull RunnerAndConfigurationSettings settings) { add(myMap, settings); }
runConfigurationAdded
277,410
void (@NotNull RunnerAndConfigurationSettings settings) { if (settings.getConfiguration() instanceof ExternalSystemRunConfiguration) { final Pair<String, RunnerAndConfigurationSettings> pair = myMap.remove(System.identityHashCode(settings)); if (pair == null) return; final ExternalProjectsStateProvider stateProvider = myManager.getStateProvider(); final ExternalSystemTaskExecutionSettings taskExecutionSettings = ((ExternalSystemRunConfiguration)settings.getConfiguration()).getSettings(); if(taskExecutionSettings.getExternalProjectPath() == null) return; final TaskActivationState activation = stateProvider.getTasksActivation(taskExecutionSettings.getExternalSystemId(), taskExecutionSettings.getExternalProjectPath()); for (Phase phase : Phase.values()) { for (Iterator<String> iterator = activation.getTasks(phase).iterator(); iterator.hasNext(); ) { String task = iterator.next(); if (pair.first.equals(task)) { iterator.remove(); break; } } } } }
runConfigurationRemoved
277,411
void (@NotNull RunnerAndConfigurationSettings settings) { if (settings.getConfiguration() instanceof ExternalSystemRunConfiguration) { final Pair<String, RunnerAndConfigurationSettings> pair = myMap.get(System.identityHashCode(settings)); if (pair != null) { final ExternalProjectsStateProvider stateProvider = myManager.getStateProvider(); final ExternalSystemTaskExecutionSettings taskExecutionSettings = ((ExternalSystemRunConfiguration)settings.getConfiguration()).getSettings(); if(taskExecutionSettings.getExternalProjectPath() == null) return; final TaskActivationState activation = stateProvider.getTasksActivation(taskExecutionSettings.getExternalSystemId(), taskExecutionSettings.getExternalProjectPath()); for (Phase phase : Phase.values()) { final List<String> modifiableActivationTasks = activation.getTasks(phase); for (String task : new ArrayList<>(modifiableActivationTasks)) { if (pair.first.equals(task)) { modifiableActivationTasks.remove(task); final String runConfigurationActivationTaskName = getRunConfigurationActivationTaskName(settings); modifiableActivationTasks.add(runConfigurationActivationTaskName); myMap.put(System.identityHashCode(settings), Pair.create(runConfigurationActivationTaskName, settings)); break; } } } } } }
runConfigurationChanged
277,412
void () { Project project = myManager.getProject(); eventDisposable = Disposer.newDisposable(); Disposer.register(project, eventDisposable); project.getMessageBus().connect(eventDisposable).subscribe(RunManagerListener.TOPIC, this); }
attach
277,413
void (@NotNull RunManager runManager, boolean isFirstLoadState) { myMap.clear(); for (ExternalSystemManager<?, ?, ?, ?, ?> systemManager : ExternalSystemApiUtil.getAllManagers()) { AbstractExternalSystemTaskConfigurationType configurationType = ExternalSystemUtil.findConfigurationType(systemManager.getSystemId()); if (configurationType == null) { continue; } for (RunnerAndConfigurationSettings configurationSettings : runManager.getConfigurationSettingsList(configurationType)) { add(myMap, configurationSettings); } } }
stateLoaded
277,414
void () { myMap.clear(); Disposable disposable = eventDisposable; if (disposable != null) { eventDisposable = null; Disposer.dispose(disposable); } }
detach
277,415
void (@NotNull ConcurrentIntObjectMap<Pair<String, RunnerAndConfigurationSettings>> map, @NotNull RunnerAndConfigurationSettings settings) { if (settings.getConfiguration() instanceof ExternalSystemRunConfiguration) { map.put(System.identityHashCode(settings), Pair.create(getRunConfigurationActivationTaskName(settings), settings)); } }
add
277,416
void () { ApplicationManager.getApplication().getMessageBus().connect(this).subscribe(KeymapManagerListener.TOPIC, new KeymapManagerListener() { @Override public void activeKeymapChanged(Keymap keymap) { fireShortcutsUpdated(); } @Override public void shortcutChanged(@NotNull Keymap keymap, @NotNull String actionId) { fireShortcutsUpdated(); } }); }
init
277,417
void (Keymap keymap) { fireShortcutsUpdated(); }
activeKeymapChanged
277,418
void (@NotNull Keymap keymap, @NotNull String actionId) { fireShortcutsUpdated(); }
shortcutChanged
277,419
String (@Nullable String projectPath, @Nullable String taskName) { StringBuilder result = new StringBuilder(ACTION_ID_PREFIX); result.append(myProject.getLocationHash()); if (projectPath != null) { String portablePath = FileUtil.toSystemIndependentName(projectPath); File file = new File(portablePath); result.append(file.getParentFile() != null ? file.getParentFile().getName() : file.getName()); result.append(Integer.toHexString(portablePath.hashCode())); if (taskName != null) result.append(taskName); } return result.toString(); }
getActionId
277,420
String (@Nullable String projectPath, @Nullable String taskName) { Shortcut[] shortcuts = getShortcuts(projectPath, taskName); if (shortcuts.length == 0) return ""; return KeymapUtil.getShortcutsText(shortcuts); }
getDescription
277,421
boolean (@Nullable String projectPath, @Nullable String taskName) { return getShortcuts(projectPath, taskName).length > 0; }
hasShortcuts
277,422
boolean (@NotNull String actionId) { return KeymapUtil.getPrimaryShortcut(actionId) != null; }
hasShortcuts
277,423
void () { for (Listener listener : myListeners) { listener.shortcutsUpdated(); } }
fireShortcutsUpdated
277,424
void (Listener listener, Disposable parent) { myListeners.add(listener, parent); }
addListener
277,425
void () { ExternalSystemKeymapExtension.clearActions(this); }
dispose
277,426
ExternalProjectsDataStorage (@NotNull Project project) { return project.getService(ExternalProjectsDataStorage.class); }
getInstance
277,427
void (@NotNull IdeaPluginDescriptor pluginDescriptor, boolean isUpdate) { ObjectSerializer.getInstance().clearBindingCache(); }
beforePluginUnload
277,428
void (@NotNull IdeaPluginDescriptor pluginDescriptor, boolean isUpdate) { Set<ProjectSystemId> existingEPs = ExternalSystemManager.EP_NAME.getExtensionList().stream() .map(ExternalSystemManager::getSystemId) .collect(Collectors.toSet()); Iterator<Map.Entry<Pair<ProjectSystemId, File>, InternalExternalProjectInfo>> iter = myExternalRootProjects.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<Pair<ProjectSystemId, File>, InternalExternalProjectInfo> entry = iter.next(); if (!existingEPs.contains(entry.getKey().first)) { iter.remove(); markDirty(entry.getValue().getExternalProjectPath()); } } }
pluginUnloaded
277,429
boolean () { for (ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemManager.EP_NAME.getIterable()) { if (!manager.getSettingsProvider().fun(myProject).getLinkedProjectsSettings().isEmpty()) { return true; } } return false; }
hasLinkedExternalProjects
277,430
void () { ExternalProjectsManager.getInstance(myProject).getExternalProjectsWatcher().markDirtyAllExternalProjects(); }
markDirtyAllExternalProjects
277,431
void (String projectPath) { ExternalProjectsManager.getInstance(myProject).getExternalProjectsWatcher().markDirty(projectPath); }
markDirty
277,432
boolean (InternalExternalProjectInfo externalProjectInfo) { final DataNode<ProjectData> projectStructure = externalProjectInfo.getExternalProjectStructure(); if (projectStructure == null) return false; ProjectDataManagerImpl.getInstance().ensureTheDataIsReadyToUse(projectStructure); return externalProjectInfo.getExternalProjectPath().equals(projectStructure.getData().getLinkedExternalProjectPath()); }
validate
277,433
void () { if (!changed.compareAndSet(true, false)) { return; } try { //noinspection SynchronizeOnThis synchronized (this) { long start = System.currentTimeMillis(); doSave(myProject, myExternalRootProjects.values()); long duration = System.currentTimeMillis() - start; LOG.info("Save external projects data in " + duration + " ms"); } } catch (IOException | SerializationException e) { LOG.error(e); } }
doSave
277,434
void () { if (changed.compareAndSet(false, true)) { SaveAndSyncHandler.getInstance().scheduleProjectSave(myProject, true); } }
markAsChangedAndScheduleSave
277,435
void () { for (ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemManager.EP_NAME.getIterable()) { ProjectSystemId systemId = manager.getSystemId(); AbstractExternalSystemLocalSettings<?> settings = manager.getLocalSettingsProvider().fun(myProject); Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> availableProjects = settings.getAvailableProjects(); for (Map.Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : availableProjects.entrySet()) { ExternalProjectPojo projectPojo = entry.getKey(); String externalProjectPath = projectPojo.getPath(); Pair<ProjectSystemId, File> key = Pair.create(systemId, new File(externalProjectPath)); InternalExternalProjectInfo externalProjectInfo = myExternalRootProjects.get(key); if (externalProjectInfo == null) { externalProjectInfo = myExternalRootProjects.computeIfAbsent(key, pair -> { DataNode<ProjectData> dataNode = convert(systemId, projectPojo, entry.getValue()); return new InternalExternalProjectInfo(systemId, externalProjectPath, dataNode); }); ExternalProjectsManager.getInstance(myProject).getExternalProjectsWatcher().markDirty(externalProjectPath); markAsChangedAndScheduleSave(); } // restore linked project sub-modules ExternalProjectSettings linkedProjectSettings = manager.getSettingsProvider().fun(myProject).getLinkedProjectSettings(externalProjectPath); if (linkedProjectSettings != null && ContainerUtil.isEmpty(linkedProjectSettings.getModules())) { final Set<String> modulePaths = ContainerUtil.map2Set( ExternalSystemApiUtil.findAllRecursively(externalProjectInfo.getExternalProjectStructure(), MODULE), node -> node.getData().getLinkedExternalProjectPath()); linkedProjectSettings.setModules(modulePaths); } } } }
mergeLocalSettings
277,436
DataNode<ProjectData> (@NotNull ProjectSystemId systemId, @NotNull ExternalProjectPojo rootProject, @NotNull Collection<? extends ExternalProjectPojo> childProjects) { ProjectData projectData = new ProjectData(systemId, rootProject.getName(), rootProject.getPath(), rootProject.getPath()); DataNode<ProjectData> projectDataNode = new DataNode<>(PROJECT, projectData, null); for (ExternalProjectPojo childProject : childProjects) { String moduleConfigPath = childProject.getPath(); ModuleData moduleData = new ModuleData(childProject.getName(), systemId, ModuleTypeId.JAVA_MODULE, childProject.getName(), moduleConfigPath, moduleConfigPath); projectDataNode.createChild(MODULE, moduleData); } return projectDataNode; }
convert
277,437
DataNode<ExternalConfigPathAware> (@NotNull DataNode node) { if ((MODULE.equals(node.getKey()) || PROJECT.equals(node.getKey())) && node.getData() instanceof ExternalConfigPathAware) { return (DataNode<ExternalConfigPathAware>)node; } DataNode parent = ExternalSystemApiUtil.findParent(node, MODULE); if (parent == null) { parent = ExternalSystemApiUtil.findParent(node, PROJECT); } return parent; }
resolveProjectNode
277,438
VersionedFile (@NotNull Project project) { return new VersionedFile(getProjectConfigurationDir(project).resolve("project.dat"), STORAGE_VERSION); }
getCacheFile
277,439
Path (@NotNull Project project) { return ProjectUtil.getExternalConfigurationDir(project); }
getProjectConfigurationDir
277,440
boolean (@NotNull ProjectState projectState, @Nullable ModuleState moduleState, @NotNull Key<?> key) { return projectState.isInclusion ^ (moduleState != null && moduleState.set.contains(key.getDataType())); }
isIgnored
277,441
File () { return PathManagerEx.getAppSystemDir().resolve("external_build_system").resolve(".broken").toFile(); }
getBrokenMarkerFile
277,442
boolean () { for (ExternalSystemTaskActivator.Phase phase : ExternalSystemTaskActivator.Phase.values()) { if (!getTasks(phase).isEmpty()) return false; } return true; }
isEmpty
277,443
List<String> (@NotNull ExternalSystemTaskActivator.Phase phase) { return switch (phase) { case AFTER_COMPILE -> afterCompileTasks; case BEFORE_COMPILE -> beforeCompileTasks; case AFTER_SYNC -> afterSyncTasks; case BEFORE_RUN -> beforeRunTasks; case BEFORE_SYNC -> beforeSyncTasks; case AFTER_REBUILD -> afterRebuildTask; case BEFORE_REBUILD -> beforeRebuildTask; }; }
getTasks
277,444
Key<ModuleData> () { return ProjectKeys.MODULE; }
getTargetDataKey
277,445
Computable<Collection<Module>> (final @NotNull Collection<? extends DataNode<ModuleData>> toImport, final @NotNull ProjectData projectData, final @NotNull Project project, final @NotNull IdeModifiableModelsProvider modelsProvider) { return () -> { List<Module> orphanIdeModules = new SmartList<>(); for (Module module : modelsProvider.getModules()) { if (!ExternalSystemApiUtil.isExternalSystemAwareModule(projectData.getOwner(), module)) continue; if (ExternalSystemApiUtil.getExternalModuleType(module) != null) continue; final String rootProjectPath = ExternalSystemApiUtil.getExternalRootProjectPath(module); if (projectData.getLinkedExternalProjectPath().equals(rootProjectPath)) { if (module.getUserData(AbstractModuleDataService.MODULE_DATA_KEY) == null) { orphanIdeModules.add(module); } } } return orphanIdeModules; }; }
computeOrphanData
277,446
void (@NotNull Collection<? extends DataNode<ModuleData>> toImport, @Nullable ProjectData projectData, @NotNull Project project, @NotNull IdeModifiableModelsProvider modelsProvider) { super.postProcess(toImport, projectData, project, modelsProvider); updateLocalSettings(toImport, project); }
postProcess
277,447
void (Collection<? extends DataNode<ModuleData>> toImport, Project project) { if (toImport.isEmpty()) { return; } ProjectSystemId externalSystemId = toImport.iterator().next().getData().getOwner(); ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId); assert manager != null; final MultiMap<DataNode<ProjectData>, DataNode<ModuleData>> grouped = ExternalSystemApiUtil.groupBy(toImport, ProjectKeys.PROJECT); Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> data = new HashMap<>(); for (Map.Entry<DataNode<ProjectData>, Collection<DataNode<ModuleData>>> entry : grouped.entrySet()) { data.put(ExternalProjectPojo.from(entry.getKey().getData()), ContainerUtil.map(entry.getValue(), node -> ExternalProjectPojo.from(node.getData()))); } AbstractExternalSystemLocalSettings settings = manager.getLocalSettingsProvider().fun(project); Set<String> pathsToForget = detectRenamedProjects(data, settings.getAvailableProjects()); if (!pathsToForget.isEmpty()) { settings.forgetExternalProjects(pathsToForget); } Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> projects = new HashMap<>(settings.getAvailableProjects()); projects.putAll(data); settings.setAvailableProjects(projects); }
updateLocalSettings
277,448
Set<String> (@NotNull Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> currentInfo, @NotNull Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> oldInfo) { Map<String/* external config path */, String/* project name */> map = new HashMap<>(); for (Map.Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : currentInfo.entrySet()) { map.put(entry.getKey().getPath(), entry.getKey().getName()); for (ExternalProjectPojo pojo : entry.getValue()) { map.put(pojo.getPath(), pojo.getName()); } } Set<String> result = new HashSet<>(); for (Map.Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : oldInfo.entrySet()) { String newName = map.get(entry.getKey().getPath()); if (newName != null && !newName.equals(entry.getKey().getName())) { result.add(entry.getKey().getPath()); } for (ExternalProjectPojo pojo : entry.getValue()) { newName = map.get(pojo.getPath()); if (newName != null && !newName.equals(pojo.getName())) { result.add(pojo.getPath()); } } } return result; }
detectRenamedProjects
277,449
String (@NotNull RunnerAndConfigurationSettings settings) { return RUN_CONFIGURATION_TASK_PREFIX + settings.getName(); }
getRunConfigurationActivationTaskName
277,450
void () { ProjectTaskManagerImpl projectTaskManager = (ProjectTaskManagerImpl)ProjectTaskManager.getInstance(myProject); projectTaskManager.addListener(new ProjectTaskManagerListener() { @Override public void beforeRun(@NotNull ProjectTaskContext context) throws ExecutionException { if (!doExecuteBuildPhaseTriggers(true, context)) { throw new ExecutionException(ExternalSystemBundle.message("dialog.message.before.build.triggering.task.failed")); } } @Override public void afterRun(@NotNull ProjectTaskManager.Result result) throws ExecutionException { if (!doExecuteBuildPhaseTriggers(false, result.getContext())) { throw new ExecutionException(ExternalSystemBundle.message("dialog.message.after.build.triggering.task.failed")); } } }); fireTasksChanged(); }
init
277,451
String (ProjectSystemId systemId, String projectPath, String taskName) { List<String> result = new ArrayList<>(); final ExternalProjectsStateProvider stateProvider = ExternalProjectsManagerImpl.getInstance(myProject).getStateProvider(); final TaskActivationState taskActivationState = stateProvider.getTasksActivation(systemId, projectPath); if (taskActivationState == null) { return null; } for (Phase phase : Phase.values()) { if (taskActivationState.getTasks(phase).contains(taskName)) { result.add(phase.toString()); } } return StringUtil.join(result, ", "); }
getDescription
277,452
boolean (boolean myBefore, @NotNull ProjectTaskContext context) { ProjectTaskScope taskScope = context.getUserData(ProjectTaskScope.KEY); if (taskScope == null) { return true; } Set<String> modulesToBuild = new LinkedHashSet<>(); Set<String> modulesToRebuild = new LinkedHashSet<>(); for (ModuleBuildTask task : taskScope.getRequestedTasks(ModuleBuildTask.class)) { String projectPath = ExternalSystemApiUtil.getExternalProjectPath(task.getModule()); if (projectPath == null) continue; if (task.isIncrementalBuild()) { modulesToBuild.add(projectPath); } else { modulesToRebuild.add(projectPath); } } boolean result = true; if (myBefore) { if (!modulesToRebuild.isEmpty()) { result = runTasks(modulesToRebuild, Phase.BEFORE_REBUILD); } if (result && !modulesToBuild.isEmpty()) { result = runTasks(modulesToBuild, Phase.BEFORE_COMPILE); } } else { if (!modulesToRebuild.isEmpty()) { result = runTasks(modulesToRebuild, Phase.AFTER_REBUILD); } if (result && !modulesToBuild.isEmpty()) { result = runTasks(modulesToBuild, Phase.AFTER_COMPILE); } } return result; }
doExecuteBuildPhaseTriggers
277,453
boolean (@NotNull String modulePath, Phase @NotNull ... phases) { return runTasks(Collections.singleton(modulePath), phases); }
runTasks
277,454
boolean (@NotNull Collection<String> modules, Phase @NotNull ... phases) { final ExternalProjectsStateProvider stateProvider = ExternalProjectsManagerImpl.getInstance(myProject).getStateProvider(); final Queue<Pair<ProjectSystemId, ExternalSystemTaskExecutionSettings>> tasksQueue = new LinkedList<>(); Map<ProjectSystemId, Map<String, RunnerAndConfigurationSettings>> lazyConfigurationsMap = FactoryMap.create(key -> { final AbstractExternalSystemTaskConfigurationType configurationType = ExternalSystemUtil.findConfigurationType(key); if (configurationType == null) { return null; } return ContainerUtil.map2Map(RunManager.getInstance(myProject).getConfigurationSettingsList(configurationType), configurationSettings1 -> Pair.create(configurationSettings1.getName(), configurationSettings1)); }); for (final ExternalProjectsStateProvider.TasksActivation activation : stateProvider.getAllTasksActivation()) { final boolean hashPath = modules.contains(activation.projectPath); final Set<String> tasks = new LinkedHashSet<>(); for (Phase phase : phases) { List<String> activationTasks = activation.state.getTasks(phase); if (hashPath || (phase.isSyncPhase() && !activationTasks.isEmpty() && isShareSameRootPath(modules, activation))) { tasks.addAll(activationTasks); } } if (tasks.isEmpty()) { continue; } for (Iterator<String> iterator = tasks.iterator(); iterator.hasNext(); ) { String task = iterator.next(); if (task.length() > RUN_CONFIGURATION_TASK_PREFIX.length() && task.startsWith(RUN_CONFIGURATION_TASK_PREFIX)) { iterator.remove(); final String configurationName = task.substring(RUN_CONFIGURATION_TASK_PREFIX.length()); Map<String, RunnerAndConfigurationSettings> settings = lazyConfigurationsMap.get(activation.systemId); if (settings == null) { continue; } RunnerAndConfigurationSettings configurationSettings = settings.get(configurationName); if (configurationSettings == null) { continue; } final RunConfiguration runConfiguration = configurationSettings.getConfiguration(); if (configurationName.equals(configurationSettings.getName()) && runConfiguration instanceof ExternalSystemRunConfiguration) { tasksQueue.add(Pair.create(activation.systemId, ((ExternalSystemRunConfiguration)runConfiguration).getSettings())); } } } if (tasks.isEmpty()) { continue; } if (ExternalProjectsManager.getInstance(myProject).isIgnored(activation.systemId, activation.projectPath) && !"true".equals(System.getProperty("force.execute.activated.tasks", "false"))) { continue; } ExternalSystemTaskExecutionSettings executionSettings = new ExternalSystemTaskExecutionSettings(); executionSettings.setExternalSystemIdString(activation.systemId.toString()); executionSettings.setExternalProjectPath(activation.projectPath); executionSettings.getTaskNames().addAll(tasks); tasksQueue.add(Pair.create(activation.systemId, executionSettings)); } return runTasksQueue(tasksQueue); }
runTasks
277,455
boolean (@NotNull Collection<String> modules, @NotNull ExternalProjectsStateProvider.TasksActivation activation) { final AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(myProject, activation.systemId); final String rootProjectPath = getRootProjectPath(systemSettings, activation.projectPath); final List<String> rootPath = ContainerUtil.mapNotNull(modules, path -> getRootProjectPath(systemSettings, path)); return rootPath.contains(rootProjectPath); }
isShareSameRootPath
277,456
String (@NotNull AbstractExternalSystemSettings systemSettings, @NotNull String projectPath) { final ExternalProjectSettings projectSettings = systemSettings.getLinkedProjectSettings(projectPath); return projectSettings != null ? projectSettings.getExternalProjectPath() : null; }
getRootProjectPath
277,457
boolean (final Queue<? extends Pair<ProjectSystemId, ExternalSystemTaskExecutionSettings>> tasksQueue) { final Pair<ProjectSystemId, ExternalSystemTaskExecutionSettings> pair = tasksQueue.poll(); if (pair == null) { return true; } String tasks = String.join(", ", pair.second.getTaskNames()); LOG.info(String.format("Started execution of %s", tasks)); final ProjectSystemId systemId = pair.first; final ExternalSystemTaskExecutionSettings executionSettings = pair.getSecond(); final Semaphore targetDone = new Semaphore(); targetDone.down(); final Ref<Boolean> result = new Ref<>(false); ExternalSystemUtil.runTask(executionSettings, DefaultRunExecutor.EXECUTOR_ID, myProject, systemId, new TaskCallback() { @Override public void onSuccess() { result.set(runTasksQueue(tasksQueue)); targetDone.up(); } @Override public void onFailure() { targetDone.up(); } }, ProgressExecutionMode.IN_BACKGROUND_ASYNC, false); targetDone.waitFor(); LOG.info(String.format("Finished execution of %s", tasks)); return result.get(); }
runTasksQueue
277,458
void () { result.set(runTasksQueue(tasksQueue)); targetDone.up(); }
onSuccess
277,459
void () { targetDone.up(); }
onFailure
277,460
void (@NotNull Listener l, @NotNull Disposable parent) { myListeners.add(l, parent); }
addListener
277,461
boolean (@NotNull TaskData taskData, @NotNull Phase phase) { final ExternalProjectsStateProvider stateProvider = ExternalProjectsManagerImpl.getInstance(myProject).getStateProvider(); final TaskActivationState taskActivationState = stateProvider.getTasksActivation(taskData.getOwner(), taskData.getLinkedExternalProjectPath()); if (taskActivationState == null) { return false; } return taskActivationState.getTasks(phase).contains(taskData.getName()); }
isTaskOfPhase
277,462
void (@NotNull Collection<? extends TaskData> tasks, @NotNull final Phase phase) { if (tasks.isEmpty()) { return; } addTasks(ContainerUtil.map(tasks, data -> new TaskActivationEntry(data.getOwner(), phase, data.getLinkedExternalProjectPath(), data.getName()))); fireTasksChanged(); }
addTasks
277,463
void (@NotNull Collection<? extends TaskActivationEntry> entries) { if (entries.isEmpty()) { return; } final ExternalProjectsStateProvider stateProvider = ExternalProjectsManagerImpl.getInstance(myProject).getStateProvider(); for (TaskActivationEntry entry : entries) { final TaskActivationState taskActivationState = stateProvider.getTasksActivation(entry.systemId, entry.projectPath); taskActivationState.getTasks(entry.phase).add(entry.taskName); } fireTasksChanged(); }
addTasks
277,464
void (@NotNull Collection<? extends TaskData> tasks, @NotNull final Phase phase) { if (tasks.isEmpty()) { return; } removeTasks(ContainerUtil.map(tasks, data -> new TaskActivationEntry(data.getOwner(), phase, data.getLinkedExternalProjectPath(), data.getName()))); }
removeTasks
277,465
void (@NotNull Collection<? extends TaskActivationEntry> entries) { if (entries.isEmpty()) { return; } final ExternalProjectsStateProvider stateProvider = ExternalProjectsManagerImpl.getInstance(myProject).getStateProvider(); for (TaskActivationEntry activationEntry : entries) { final TaskActivationState taskActivationState = stateProvider.getTasksActivation(activationEntry.systemId, activationEntry.projectPath); taskActivationState.getTasks(activationEntry.phase).remove(activationEntry.taskName); } fireTasksChanged(); }
removeTasks
277,466
void (@NotNull TaskActivationEntry entry) { addTasks(Collections.singleton(entry)); }
addTask
277,467
void (@NotNull TaskActivationEntry entry) { removeTasks(Collections.singleton(entry)); }
removeTask
277,468
void (@NotNull Collection<? extends TaskActivationEntry> entries, int increment) { LOG.assertTrue(increment == -1 || increment == 1); final ExternalProjectsStateProvider stateProvider = ExternalProjectsManagerImpl.getInstance(myProject).getStateProvider(); for (TaskActivationEntry activationEntry : entries) { final TaskActivationState taskActivationState = stateProvider.getTasksActivation(activationEntry.systemId, activationEntry.projectPath); final List<String> tasks = taskActivationState.getTasks(activationEntry.phase); final int i1 = tasks.indexOf(activationEntry.taskName); final int i2 = i1 + increment; if (i1 != -1 && tasks.size() > i2 && i2 >= 0) { Collections.swap(tasks, i1, i2); } } }
moveTasks
277,469
void (@NotNull ProjectSystemId systemId, @NotNull List<String> projectsPathsToMove, @Nullable Collection<String> pathsGroup, int increment) { LOG.assertTrue(increment == -1 || increment == 1); final ExternalProjectsStateProvider stateProvider = ExternalProjectsManagerImpl.getInstance(myProject).getStateProvider(); final Map<String, TaskActivationState> activationMap = stateProvider.getProjectsTasksActivationMap(systemId); final List<String> currentPaths = new ArrayList<>(activationMap.keySet()); if (pathsGroup != null) { currentPaths.retainAll(pathsGroup); } for (String path : projectsPathsToMove) { final int i1 = currentPaths.indexOf(path); final int i2 = i1 + increment; if (i1 != -1 && currentPaths.size() > i2 && i2 >= 0) { Collections.swap(currentPaths, i1, i2); } } Map<String, TaskActivationState> rearrangedMap = new LinkedHashMap<>(); for (String path : currentPaths) { rearrangedMap.put(path, activationMap.get(path)); activationMap.remove(path); } activationMap.putAll(rearrangedMap); }
moveProjects
277,470
void () { for (Listener each : myListeners) { each.tasksActivationChanged(); } }
fireTasksChanged
277,471
boolean () { return this == BEFORE_SYNC || this == AFTER_SYNC; }
isSyncPhase
277,472
String () { return ExternalSystemBundle.message(myMessageKey); }
toString
277,473
ProjectSystemId () { return systemId; }
getSystemId
277,474
Phase () { return phase; }
getPhase
277,475
String () { return projectPath; }
getProjectPath
277,476
String () { return taskName; }
getTaskName
277,477
Key<LibraryData> () { return ProjectKeys.LIBRARY; }
getTargetDataKey
277,478
void (final @NotNull Collection<? extends DataNode<LibraryData>> toImport, final @Nullable ProjectData projectData, final @NotNull Project project, final @NotNull IdeModifiableModelsProvider modelsProvider) { Map<String, LibraryData> processedLibraries = new HashMap<>(); for (DataNode<LibraryData> dataNode: toImport) { LibraryData libraryData = dataNode.getData(); String libraryName = libraryData.getInternalName(); LibraryData importedLibrary = processedLibraries.putIfAbsent(libraryName, libraryData); if (importedLibrary == null) { importLibrary(libraryData, modelsProvider); } else { LOG.warn("Multiple project level libraries found with the same name '" + libraryName + "'"); if (LOG.isDebugEnabled()) { LOG.debug("Chosen library:" + importedLibrary.getPaths(LibraryPathType.BINARY)); LOG.debug("Ignored library:" + libraryData.getPaths(LibraryPathType.BINARY)); } } } }
importData
277,479
void (final @NotNull LibraryData toImport, final @NotNull IdeModifiableModelsProvider modelsProvider) { final String libraryName = toImport.getInternalName(); Library library = modelsProvider.getLibraryByName(libraryName); ProjectModelExternalSource source = ExternalSystemApiUtil.toExternalSource(toImport.getOwner()); if (library != null) { if (library.getExternalSource() == null) { ((LibraryEx.ModifiableModelEx)modelsProvider.getModifiableLibraryModel(library)).setExternalSource(source); } syncPaths(toImport, library, modelsProvider); return; } LibraryTable.ModifiableModel librariesModel = modelsProvider.getModifiableProjectLibrariesModel(); library = librariesModel.createLibrary(libraryName, getLibraryKind(toImport), source); Library.ModifiableModel libraryModel = modelsProvider.getModifiableLibraryModel(library); prepareNewLibrary(toImport, libraryName, libraryModel); }
importLibrary
277,480
void (@NotNull LibraryData libraryData, @NotNull String libraryName, @NotNull Library.ModifiableModel libraryModel) { Map<OrderRootType, Collection<File>> libraryFiles = prepareLibraryFiles(libraryData); Set<String> excludedPaths = libraryData.getPaths(LibraryPathType.EXCLUDED); registerPaths(libraryData.isUnresolved(), libraryFiles, excludedPaths, libraryModel, libraryName); EP_NAME.forEachExtensionSafe(extension -> extension.prepareNewLibrary(libraryData, libraryModel)); }
prepareNewLibrary
277,481
void (Collection<? extends File> files) { VirtualFileManager virtualFileManager = VirtualFileManager.getInstance(); for (File file : files) { Path path = file.toPath(); // search for jar file first otherwise lib root won't be found! virtualFileManager.refreshAndFindFileByNioPath(path); } }
refreshVfsFiles
277,482
void (boolean unresolved, @NotNull Map<OrderRootType, Collection<File>> libraryFiles, @NotNull Set<String> excludedPaths, @NotNull Library.ModifiableModel model, @NotNull String libraryName) { for (Map.Entry<OrderRootType, Collection<File>> entry: libraryFiles.entrySet()) { for (File file: entry.getValue()) { VirtualFile virtualFile = unresolved ? null : VirtualFileManager.getInstance().findFileByNioPath(file.toPath().toAbsolutePath()); if (virtualFile == null) { if (!unresolved && ExternalSystemConstants.VERBOSE_PROCESSING && entry.getKey() == OrderRootType.CLASSES) { LOG.warn( String.format("Can't find %s of the library '%s' at path '%s'", entry.getKey(), libraryName, file.getAbsolutePath()) ); } String url = VfsUtil.getUrlForLibraryRoot(file); String[] urls = model.getUrls(entry.getKey()); if (!ArrayUtil.contains(url, urls)) { model.addRoot(url, entry.getKey()); } continue; } if (virtualFile.isDirectory()) { VirtualFile[] files = model.getFiles(entry.getKey()); if (!ArrayUtil.contains(virtualFile, files)) { model.addRoot(virtualFile, entry.getKey()); } } else { VirtualFile root = virtualFile; if (virtualFile.getFileType() instanceof ArchiveFileType) { root = JarFileSystem.getInstance().getJarRootForLocalFile(virtualFile); if (root == null) { LOG.warn(String.format( "Can't parse contents of the JAR file at path '%s' for the library '%s''", file.getAbsolutePath(), libraryName )); continue; } } VirtualFile[] files = model.getFiles(entry.getKey()); if (!ArrayUtil.contains(root, files)) { model.addRoot(root, entry.getKey()); } } } } if (model instanceof LibraryEx.ModifiableModelEx modelEx) { for (String excludedPath : excludedPaths) { String url = VfsUtil.getUrlForLibraryRoot(new File(excludedPath)); String[] urls = modelEx.getExcludedRootUrls(); if (!ArrayUtil.contains(url, urls)) { modelEx.addExcludedRoot(url); } } } }
registerPaths
277,483
void (@NotNull Collection<? extends DataNode<LibraryData>> toImport, @Nullable ProjectData projectData, @NotNull Project project, @NotNull IdeModifiableModelsProvider modelsProvider) { if (projectData == null) return; // do not cleanup orphan project libraries if import runs from Project Structure Dialog // since libraries order entries cannot be imported for modules in that case // and hence orphans will be detected incorrectly if (modelsProvider instanceof ProjectStructureUIModifiableModelsProvider) return; final List<Library> orphanIdeLibraries = new SmartList<>(); final LibraryTable.ModifiableModel librariesModel = modelsProvider.getModifiableProjectLibrariesModel(); final Map<String, Library> namesToLibs = new HashMap<>(); final Set<Library> potentialOrphans = new HashSet<>(); RootPolicy<Void> excludeUsedLibraries = new RootPolicy<>() { @Override public Void visitLibraryOrderEntry(@NotNull LibraryOrderEntry ideDependency, Void value) { if (ideDependency.isModuleLevel()) { return null; } Library lib = ideDependency.getLibrary(); if (lib == null) { lib = namesToLibs.get(ideDependency.getLibraryName()); } if (lib != null) { potentialOrphans.remove(lib); } return null; } }; for (Library library: librariesModel.getLibraries()) { if (!ExternalSystemApiUtil.isExternalSystemLibrary(library, projectData.getOwner())) continue; namesToLibs.put(library.getName(), library); potentialOrphans.add(library); } for (Module module: modelsProvider.getModules()) { for (OrderEntry entry: modelsProvider.getOrderEntries(module)) { entry.accept(excludeUsedLibraries, null); } } for (Library lib: potentialOrphans) { if (!modelsProvider.isSubstituted(lib.getName())) { orphanIdeLibraries.add(lib); } } for (Library library: orphanIdeLibraries) { String libraryName = library.getName(); if (libraryName != null) { Library libraryToRemove = librariesModel.getLibraryByName(libraryName); if (libraryToRemove != null) { librariesModel.removeLibrary(libraryToRemove); } } } }
postProcess
277,484
Void (@NotNull LibraryOrderEntry ideDependency, Void value) { if (ideDependency.isModuleLevel()) { return null; } Library lib = ideDependency.getLibrary(); if (lib == null) { lib = namesToLibs.get(ideDependency.getLibraryName()); } if (lib != null) { potentialOrphans.remove(lib); } return null; }
visitLibraryOrderEntry
277,485
void (final @NotNull LibraryData externalLibrary, final @NotNull Library ideLibrary, final @NotNull IdeModifiableModelsProvider modelsProvider) { if (externalLibrary.isUnresolved()) { return; } final Map<OrderRootType, Set<String>> toRemove = new HashMap<>(); final Map<OrderRootType, Set<String>> toAdd = new HashMap<>(); ExternalLibraryPathTypeMapper externalLibraryPathTypeMapper = ExternalLibraryPathTypeMapper.getInstance(); for (LibraryPathType pathType: LibraryPathType.values()) { OrderRootType ideType = externalLibraryPathTypeMapper.map(pathType); if (ideType == null) continue; HashSet<String> toAddPerType = new HashSet<>(externalLibrary.getPaths(pathType)); toAdd.put(ideType, toAddPerType); // do not remove attached or manually added sources/javadocs if nothing to add if(pathType != LibraryPathType.BINARY && toAddPerType.isEmpty()) { continue; } HashSet<String> toRemovePerType = new HashSet<>(); toRemove.put(ideType, toRemovePerType); for (String url : ideLibrary.getUrls(ideType)) { String idePath = getLocalPath(url); if (!toAddPerType.remove(idePath)) { toRemovePerType.add(url); } } } if (toRemove.isEmpty() && toAdd.isEmpty()) { return; } final Library.ModifiableModel libraryModel = modelsProvider.getModifiableLibraryModel(ideLibrary); for (Map.Entry<OrderRootType, Set<String>> entry: toRemove.entrySet()) { for (String path: entry.getValue()) { libraryModel.removeRoot(path, entry.getKey()); } } Set<String> excludedPaths = externalLibrary.getPaths(LibraryPathType.EXCLUDED); for (Map.Entry<OrderRootType, Set<String>> entry: toAdd.entrySet()) { Map<OrderRootType, Collection<File>> roots = new HashMap<>(); roots.put(entry.getKey(), ContainerUtil.map(entry.getValue(), PATH_TO_FILE)); registerPaths(false, roots, excludedPaths, libraryModel, externalLibrary.getInternalName()); } }
syncPaths
277,486
String (@NotNull String url) { if (url.startsWith(StandardFileSystems.JAR_PROTOCOL_PREFIX)) { url = StringUtil.trimEnd(url, JarFileSystem.JAR_SEPARATOR); } return VfsUtilCore.urlToPath(url); }
getLocalPath
277,487
Object () { Object rootElement = super.getRootElement(); return customizeProjectsTreeRoot(rootElement); }
getRootElement
277,488
ExternalProjectsStructure () { return treeStructure; }
getStructure
277,489
void (ExternalSystemNode node) { treeStructure.updateUpTo(node); }
updateUpTo
277,490
boolean () { return groupTasks != null ? groupTasks : super.getGroupTasks(); }
getGroupTasks
277,491
boolean () { return useTasksNode != null ? useTasksNode : super.useTasksNode(); }
useTasksNode
277,492
void (@NotNull ExternalSystemNode node, @Nullable String actionId, InputEvent inputEvent) { SelectExternalSystemNodeDialog.this.handleDoubleClickOrEnter(node, actionId, inputEvent); }
handleDoubleClickOrEnter
277,493
Object (Object rootElement) { return rootElement; }
customizeProjectsTreeRoot
277,494
JComponent () { return myTree; }
getPreferredFocusedComponent
277,495
void (@NotNull ExternalSystemNode node, @Nullable String actionId, InputEvent inputEvent) { }
handleDoubleClickOrEnter
277,496
SimpleNode () { return myTree.getNodeFor(myTree.getSelectionPath()); }
getSelectedNode
277,497
JComponent () { final JScrollPane pane = ScrollPaneFactory.createScrollPane(myTree); pane.setPreferredSize(JBUI.size(320, 400)); return pane; }
createCenterPanel
277,498
void (@NotNull JList list, JdkComboBoxItem value, int index, boolean selected, boolean hasFocus) { if (value == null) return; CompositeAppearance appearance = new CompositeAppearance(); appearance.setIcon(AllIcons.Nodes.PpJdk); SimpleTextAttributes attributes = getTextAttributes(value.valid, selected); CompositeAppearance.DequeEnd ending = appearance.getEnding(); ending.addText(value.label, attributes); if (value.comment != null && !value.comment.equals(value.jdkName)) { final SimpleTextAttributes textAttributes; if (!value.valid) { textAttributes = SimpleTextAttributes.ERROR_ATTRIBUTES; } else { textAttributes = SystemInfo.isMac && selected ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, JBColor.WHITE) : SimpleTextAttributes.GRAY_ATTRIBUTES; } ending.addComment(value.comment, textAttributes); } final CompositeAppearance compositeAppearance = ending.getAppearance(); compositeAppearance.customize(this); }
customizeCellRenderer
277,499
Project () { return myProject; }
getProject