@Override public boolean visitFile(@NotNull VirtualFile file) { return ReadAction.compute(() -> { boolean proceedToChildren; if (fileTypeManager.isFileIgnored(file)) { proceedToChildren = false; } else { proceedToChildren = true; if (file.isDirectory()) { propertiesUpdater.findAndUpdateValue(file, LevelPropertyPusher.this, level); } } return proceedToChildren; }); } });
private void doSetBreakpoints() { AccessToken token = ReadAction.start(); try { getSession().initBreakpoints(); } finally { token.finish(); } }
private static int getOffsetStart(final PsiFile file, final int startLine, final int startColumn) { final int[] retVal = {-1}; final ThrowableRunnable getOffset = new ThrowableRunnable() { public void run() { final Document document = PsiDocumentManager.getInstance(file.getProject()) .getDocument(file); final int line = getValidLineNumber(startLine, document); final int offset = StringUtil .lineColToOffset(file.getText(), line, startColumn - 1); retVal[0] = offset <= 1 ? 1 : offset; } }; ReadAction.run(getOffset); return retVal[0]; }
private List<ClientInputFile> getInputFiles(Module module, VirtualFileTestPredicate testPredicate, Collection<VirtualFile> filesToAnalyze) { List<ClientInputFile> inputFiles = new LinkedList<>(); ReadAction.run(() -> filesToAnalyze.stream() .map(f -> createClientInputFile(module, f, testPredicate)) .filter(Objects::nonNull) .forEach(inputFiles::add)); return inputFiles; }
@Override public void performInDumbMode(@NotNull ProgressIndicator indicator) { if (!project.isDisposed()) { final PerformanceWatcher.Snapshot snapshot = PerformanceWatcher.takeSnapshot(); final List<Runnable> tasks = ReadAction.compute(() -> rootUpdateTaskList(project, sdkSet)); PushedFilePropertiesUpdaterImpl.invokeConcurrentlyIfPossible(tasks); if (!ApplicationManager.getApplication().isUnitTestMode()) { snapshot.logResponsivenessSinceCreation( "Pushing Elixir language level to " + tasks.size() + " roots in " + sdkSet.size() + " SDKs"); } } } };
private Map<VirtualFile, String> getRelativePaths(Project project, Collection<VirtualFile> files) { Map<VirtualFile, String> relativePathPerFile = new HashMap<>(); ReadAction.run(() -> { for (VirtualFile file : files) { String relativePath = appUtils.getPathRelativeToProjectBaseDir(project, file); if (relativePath != null) { relativePathPerFile.put(file, relativePath); } } }); return relativePathPerFile; }
private void doSetBreakpoints() { AccessToken token = ReadAction.start(); try { getSession().initBreakpoints(); } finally { token.finish(); token.close(); } }
@Override public void run() { if (project.isDisposed() || !ReadAction.compute(root::isValid)) return; final FileTypeManager fileTypeManager = FileTypeManager.getInstance(); final PushedFilePropertiesUpdater propertiesUpdater = PushedFilePropertiesUpdater.getInstance(project); VfsUtilCore.visitChildrenRecursively(root, new VirtualFileVisitor() { @Override public boolean visitFile(@NotNull VirtualFile file) { return ReadAction.compute(() -> { boolean proceedToChildren; if (fileTypeManager.isFileIgnored(file)) { proceedToChildren = false; } else { proceedToChildren = true; if (file.isDirectory()) { propertiesUpdater.findAndUpdateValue(file, LevelPropertyPusher.this, level); } } return proceedToChildren; }); } }); }
private static void showError(@NotNull Project project, @NotNull String message) { ReadAction.run(() -> { if (!project.isDisposed()) { Notifications.Bus.notify( new Notification( PerlBundle.message("perl.coverage.loading.error"), PerlBundle.message("perl.coverage.loading.error"), message, NotificationType.ERROR ), project ); } }); }
public void process(final SonarLintJob job, ProgressIndicator indicator, final Collection<Issue> rawIssues, Collection<ClientInputFile> failedAnalysisFiles) { long start = System.currentTimeMillis(); Map<VirtualFile, Collection<LiveIssue>> transformedIssues = ReadAction.compute(() -> { Map<VirtualFile, Collection<LiveIssue>> issues = transformIssues(rawIssues, job.allFiles(), failedAnalysisFiles);
@Override public void actionPerformed(AnActionEvent e) { Project project = e.getProject(); ApplicationManager.getApplication().assertReadAccessAllowed(); if (project != null) { IssueManager issueManager = SonarLintUtils.get(project, IssueManager.class); DaemonCodeAnalyzer codeAnalyzer = SonarLintUtils.get(project, DaemonCodeAnalyzer.class); ReadAction.run(() -> { issueManager.clear(); // run annotator to remove highlighting of issues FileEditorManager editorManager = FileEditorManager.getInstance(project); VirtualFile[] openFiles = editorManager.getOpenFiles(); Collection<PsiFile> psiFiles = findFiles(project, openFiles); psiFiles.forEach(codeAnalyzer::restart); }); } }
private static void showMissingLibraryNotification(@NotNull Project project, @NotNull Sdk sdk, @NotNull String libraryName) { Notification notification = new Notification( PerlBundle.message("perl.missing.library.notification"), PerlBundle.message("perl.missing.library.notification.title", libraryName), PerlBundle.message("perl.missing.library.notification.message", libraryName), NotificationType.ERROR ); AnAction installCpanmAction = ReadAction .compute(() -> CpanminusAdapter.createInstallAction(sdk, project, Collections.singletonList(libraryName), notification::expire)); if (installCpanmAction != null) { notification.addAction(installCpanmAction); } notification.addAction(CpanAdapter.createInstallAction(sdk, project, Collections.singletonList(libraryName), notification::expire)); Notifications.Bus.notify(notification, project); }
private static void showMissingLibraryNotification(@NotNull Project project, @NotNull Sdk sdk, @NotNull Collection<String> packageNames) { if (packageNames.isEmpty()) { return; } if (packageNames.size() == 1) { showMissingLibraryNotification(project, sdk, packageNames.iterator().next()); return; } Notification notification = new Notification( PerlBundle.message("perl.missing.library.notification"), PerlBundle.message("perl.missing.library.notification.title", packageNames.size()), StringUtil.join(ContainerUtil.sorted(packageNames), ", "), NotificationType.ERROR ); AnAction installCpanmAction = ReadAction.compute(() -> CpanminusAdapter.createInstallAction(sdk, project, packageNames, notification::expire)); if (installCpanmAction != null) { notification.addAction(installCpanmAction); } notification.addAction(CpanAdapter.createInstallAction(sdk, project, packageNames, notification::expire)); Notifications.Bus.notify(notification, project); }
@Nullable private PerlCommandLine getPerlTidyCommandLine(@NotNull Project project) throws ExecutionException { PerlSharedSettings sharedSettings = PerlSharedSettings.getInstance(project); VirtualFile perlTidyScript = ReadAction.compute(() -> PerlRunUtil.findLibraryScriptWithNotification(project, SCRIPT_NAME, PACKAGE_NAME)); if (perlTidyScript == null) { return null; } PerlCommandLine commandLine = PerlRunUtil.getPerlCommandLine(project, perlTidyScript); if (commandLine == null) { return null; } commandLine.withParameters("-st", "-se").withWorkDirectory(project.getBasePath()); if (StringUtil.isNotEmpty(sharedSettings.PERL_TIDY_ARGS)) { commandLine.addParameters(StringUtil.split(sharedSettings.PERL_TIDY_ARGS, " ")); } return commandLine; }
@Nullable protected PerlCommandLine getPerlCriticCommandLine(Project project) throws ExecutionException { PerlSharedSettings sharedSettings = PerlSharedSettings.getInstance(project); VirtualFile perlCriticScript = ReadAction.compute(() -> PerlRunUtil.findLibraryScriptWithNotification(project, SCRIPT_NAME, PACKAGE_NAME)); if (perlCriticScript == null) { return null; } PerlCommandLine commandLine = PerlRunUtil.getPerlCommandLine(project, perlCriticScript); if (commandLine == null) { return null; } commandLine.withWorkDirectory(project.getBasePath()); if (StringUtil.isNotEmpty(sharedSettings.PERL_CRITIC_ARGS)) { commandLine.addParameters(StringUtil.split(sharedSettings.PERL_CRITIC_ARGS, " ")); } return commandLine; }
byte[] sourceBytes = ReadAction.compute(sourcePsiFile::getPerlContentInBytes); if (sourceBytes == null) { return null;
@Override public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(true); Map<String, Long> newFilesMap = ReadAction.compute(() -> { if (myProject.isDisposed()) { return null;
PerlCommandLine perlCommandLine = ReadAction.compute(() -> { if (project.isDisposed()) { return null;