void () { final Project project = getProject(); if (project.isDisposed()) { return; } final List<Pair<String, AnAction>> actionList = new ArrayList<>(); for (final AntBuildFileBase buildFile : myBuildFiles) { final AntBuildModelBase model = buildFile.getModel(); String defaultTargetActionId = model.getDefaultTargetActionId(); if (defaultTargetActionId != null) { final TargetAction action = new TargetAction( buildFile, TargetAction.getDefaultTargetName(), Collections.singletonList(TargetAction.getDefaultTargetName()), null ); actionList.add(new Pair<>(defaultTargetActionId, action)); } collectTargetActions(model.getFilteredTargets(), actionList, buildFile); collectTargetActions(getMetaTargets(buildFile), actionList, buildFile); } //noinspection SynchronizeOnThis synchronized (this) { // unregister Ant actions ActionManagerEx actionManager = ActionManagerEx.getInstanceEx(); for (String oldId : actionManager.getActionIdList(AntConfiguration.getActionIdPrefix(project))) { actionManager.unregisterAction(oldId); } if (!actionList.isEmpty()) { final Set<String> registeredIds = new HashSet<>(); for (Pair<String, AnAction> pair : actionList) { if (!registeredIds.contains(pair.first)) { registeredIds.add(pair.first); actionManager.registerAction(pair.first, pair.second); } } } } }