private void doSetBreakpoints() { AccessToken token = ReadAction.start(); try { getSession().initBreakpoints(); } finally { token.finish(); } }
public static List<ScannableFile> createAndValidate(@NotNull final Collection<PsiFile> psiFiles, @NotNull final CheckStylePlugin plugin, @Nullable final Module module) { final AccessToken readAccessToken = ApplicationManager.getApplication().acquireReadActionLock(); try { return psiFiles.stream().filter(psiFile -> PsiFileValidator.isScannable(psiFile, ofNullable(module), plugin.configurationManager())).map(psiFile -> ScannableFile.create(psiFile, module)).filter (Objects::nonNull).collect(Collectors.toList()); } finally { readAccessToken.finish(); } }
private void moveEclipseModulesToGroup( @NotNull final Project project, @NotNull final List<Module> eclipseModules, @NotNull final Map<String,String[]> eclipseGroupMapping ) { final ModifiableModuleModel modifiableModuleModel = ModuleManager.getInstance(project).getModifiableModel(); for (Module module : eclipseModules) { module.setOption(HybrisConstants.DESCRIPTOR_TYPE, HybrisModuleDescriptorType.ECLIPSE.name()); modifiableModuleModel.setModuleGroupPath(module, eclipseGroupMapping.get(module.getName())); } AccessToken token = null; try { token = ApplicationManager.getApplication().acquireWriteActionLock(getClass()); modifiableModuleModel.commit(); } finally { if (token != null) { token.finish(); } } } }
private void moveMavenModulesToGroup( final @NotNull Project project, final @NotNull List<Module> mavenModules, final @NotNull Map<String, String[]> mavenGroupMapping ) { AccessToken token = null; final ModifiableModuleModel modifiableModuleModel; try { token = ApplicationManager.getApplication().acquireReadActionLock(); modifiableModuleModel = ModuleManager.getInstance(project).getModifiableModel(); for (Module module : mavenModules) { module.setOption(HybrisConstants.DESCRIPTOR_TYPE, HybrisModuleDescriptorType.MAVEN.name()); final String[] groupPath = modifiableModuleModel.getModuleGroupPath(module); modifiableModuleModel.setModuleGroupPath(module, ArrayUtils.addAll(mavenGroupMapping.get(module.getName()), groupPath)); } } finally { if (token != null) { token.finish(); } } ApplicationManager.getApplication().invokeAndWait(() -> WriteAction.run(modifiableModuleModel::commit)); }
private List<String> collectPathsForModule() { List<String> paths = new ArrayList<>(); AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock(); try { ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module); moduleRootManager.getFileIndex().iterateContent(virtualFile -> { if (!virtualFile.isDirectory()) { String path = appUtils.getPathRelativeToProjectBaseDir(module.getProject(), virtualFile); if (path != null) { paths.add(path); } } return true; }); } finally { accessToken.finish(); } return paths; } }
@Override public Integer getLine() { if (range != null && isValid()) { AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock(); try { return range.getDocument().getLineNumber(range.getStartOffset()) + 1; } finally { accessToken.finish(); } } return null; }
private boolean stash() { if (!syncResult.hasLocalRepository()) { LOG.error("unexpected null local repro in call to stash"); return false; } final ChangeListManager changeListManager = ChangeListManager.getInstance(project); if (changeListManager.isFreezedWithNotification("Can not stash changes now")) { return false; } final GitLineHandler handler = new GitLineHandler(project, sourceRepository.getRoot(), GitCommand.STASH); handler.addParameters("save"); handler.addParameters("--keep-index"); String date = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date()); stashMessage = "Cloud Debugger saved changes from branch " + originalBranchName + " at " + date; handler.addParameters(stashMessage); AccessToken token = DvcsUtil.workingTreeChangeStarted(project); try { GitHandlerUtil.doSynchronously( handler, GitBundle.getString("stashing.title"), handler.printableCommandLine()); } finally { token.finish(); } return true; }
public Tracking<RAW, BASE> track(Input<RAW> rawInput, Input<BASE> baseInput) { AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock(); try { Tracking<RAW, BASE> tracking = new Tracking<>(rawInput, baseInput); // 1. match issues with same rule, same line and same text range hash, but not necessarily with same message match(tracking, LineAndTextRangeHashKeyFactory.INSTANCE); // 2. match issues with same rule, same message and same text range hash match(tracking, TextRangeHashAndMessageKeyFactory.INSTANCE); // 3. match issues with same rule, same line and same message match(tracking, LineAndMessageKeyFactory.INSTANCE); // 4. match issues with same rule and same text range hash but different line and different message. // See SONAR-2812 match(tracking, TextRangeHashKeyFactory.INSTANCE); // 5. match issues with same rule, same line and same line hash match(tracking, LineAndLineHashKeyFactory.INSTANCE); // 6. match issues with same rule and same same line hash match(tracking, LineHashKeyFactory.INSTANCE); // 7. match issues with same server issue key match(tracking, ServerIssueSearchKeyFactory.INSTANCE); return tracking; } finally { accessToken.finish(); } }