com.intellij.psi.SmartPointerManager#com.intellij.openapi.progress.ProgressManager源码实例Demo

下面列出了com.intellij.psi.SmartPointerManager#com.intellij.openapi.progress.ProgressManager 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: intellij-demandware   文件: DWCleanAction.java
public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();

    if (project != null) {
        for (Module module : ModuleManager.getInstance(project).getModules()) {
            if (ModuleType.get(module) instanceof DWModuleType) {
                ModuleServiceManager.getService(module, DWServerConnection.class);
                ProgressManager.getInstance().run(
                        new DWCleanTask(project, module, "Cleaning cartridges...", true, PerformInBackgroundOption.ALWAYS_BACKGROUND)
                );

            }
        }
    }

}
 
源代码2 项目: consulo   文件: FileHistoryPanelImpl.java
private void refreshFile(VcsFileRevision revision) {
  Runnable refresh = null;
  final VirtualFile vf = getVirtualFile();
  if (vf == null) {
    final LocalHistoryAction action = startLocalHistoryAction(revision);
    final VirtualFile vp = myFilePath.getVirtualFileParent();
    if (vp != null) {
      refresh = () -> vp.refresh(false, true, action::finish);
    }
  }
  else {
    refresh = () -> vf.refresh(false, false);
  }
  if (refresh != null) {
    ProgressManager.getInstance().runProcessWithProgressSynchronously(refresh, "Refreshing Files...", false, myVcs.getProject());
  }
}
 
源代码3 项目: consulo   文件: AnalysisScope.java
private static boolean processFile(@Nonnull final VirtualFile vFile,
                                   @Nonnull final PsiElementVisitor visitor,
                                   @Nonnull final PsiManager psiManager,
                                   final boolean needReadAction,
                                   final boolean clearResolveCache) {
  final Runnable runnable = new Runnable() {
    @Override
    public void run() {
      doProcessFile(visitor, psiManager, vFile, clearResolveCache);
    }
  };
  if (needReadAction && !ApplicationManager.getApplication().isDispatchThread()) {
    commitAndRunInSmartMode(runnable, psiManager.getProject());
  }
  else {
    runnable.run();
  }
  final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  return indicator == null || !indicator.isCanceled();
}
 
源代码4 项目: consulo   文件: WolfTheProblemSolverImpl.java
private boolean isToBeHighlighted(@Nullable VirtualFile virtualFile) {
  if (virtualFile == null) return false;

  synchronized (myFilters) {
    if (!myFiltersLoaded) {
      myFiltersLoaded = true;
      myFilters.addAll(Arrays.asList(FILTER_EP_NAME.getExtensions(myProject)));
    }
  }
  for (final Condition<VirtualFile> filter : myFilters) {
    ProgressManager.checkCanceled();
    if (filter.value(virtualFile)) {
      return true;
    }
  }

  return false;
}
 
源代码5 项目: consulo   文件: FindInProjectUtil.java
static int processUsagesInFile(@Nonnull final PsiFile psiFile, @Nonnull final VirtualFile virtualFile, @Nonnull final FindModel findModel, @Nonnull final Processor<? super UsageInfo> consumer) {
  if (findModel.getStringToFind().isEmpty()) {
    if (!ReadAction.compute(() -> consumer.process(new UsageInfo(psiFile)))) {
      throw new ProcessCanceledException();
    }
    return 1;
  }
  if (virtualFile.getFileType().isBinary()) return 0; // do not decompile .class files
  final Document document = ReadAction.compute(() -> virtualFile.isValid() ? FileDocumentManager.getInstance().getDocument(virtualFile) : null);
  if (document == null) return 0;
  final int[] offset = {0};
  int count = 0;
  int found;
  ProgressIndicator indicator = ProgressWrapper.unwrap(ProgressManager.getInstance().getProgressIndicator());
  TooManyUsagesStatus tooManyUsagesStatus = TooManyUsagesStatus.getFrom(indicator);
  do {
    tooManyUsagesStatus.pauseProcessingIfTooManyUsages(); // wait for user out of read action
    found = ReadAction.compute(() -> {
      if (!psiFile.isValid()) return 0;
      return addToUsages(document, findModel, psiFile, offset, USAGES_PER_READ_ACTION, consumer);
    });
    count += found;
  }
  while (found != 0);
  return count;
}
 
源代码6 项目: consulo   文件: CompilerPathsEx.java
protected void acceptDirectory(final VirtualFile file, final String fileRoot, final String filePath) {
  ProgressManager.checkCanceled();
  final VirtualFile[] children = file.getChildren();
  for (final VirtualFile child : children) {
    final String name = child.getName();
    final String _filePath;
    final StringBuilder buf = StringBuilderSpinAllocator.alloc();
    try {
      buf.append(filePath).append("/").append(name);
      _filePath = buf.toString();
    }
    finally {
      StringBuilderSpinAllocator.dispose(buf);
    }
    accept(child, fileRoot, _filePath);
  }
}
 
源代码7 项目: consulo   文件: ProgressIndicatorUtils.java
/**
 * Run the given computation with its execution time restricted to the given amount of time in milliseconds.<p></p>
 * <p>
 * Internally, it creates a new {@link ProgressIndicator}, runs the computation with that indicator and cancels it after the the timeout.
 * The computation should call {@link ProgressManager#checkCanceled()} frequently enough, so that after the timeout has been exceeded
 * it can stop the execution by throwing {@link ProcessCanceledException}, which will be caught by this {@code withTimeout}.<p></p>
 * <p>
 * If a {@link ProcessCanceledException} happens due to any other reason (e.g. a thread's progress indicator got canceled),
 * it'll be thrown out of this method.
 *
 * @return the computation result or {@code null} if timeout has been exceeded.
 */
@Nullable
public static <T> T withTimeout(long timeoutMs, @Nonnull Computable<T> computation) {
  ProgressManager.checkCanceled();
  ProgressIndicator outer = ProgressIndicatorProvider.getGlobalProgressIndicator();
  ProgressIndicator inner = outer != null ? new SensitiveProgressWrapper(outer) : new ProgressIndicatorBase(false, false);
  AtomicBoolean canceledByTimeout = new AtomicBoolean();
  ScheduledFuture<?> cancelProgress = AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> {
    canceledByTimeout.set(true);
    inner.cancel();
  }, timeoutMs, TimeUnit.MILLISECONDS);
  try {
    return ProgressManager.getInstance().runProcess(computation, inner);
  }
  catch (ProcessCanceledException e) {
    if (canceledByTimeout.get()) {
      return null;
    }
    throw e; // canceled not by timeout
  }
  finally {
    cancelProgress.cancel(false);
  }
}
 
源代码8 项目: GsonFormat   文件: DataWriter.java
public void execute(ClassEntity targetClass) {
        this.targetClass = targetClass;
        ProgressManager.getInstance().run(new Task.Backgroundable(project, "GsonFormat") {

            @Override
            public void run(@NotNull ProgressIndicator progressIndicator) {
                progressIndicator.setIndeterminate(true);
                long currentTimeMillis = System.currentTimeMillis();
                execute();
                progressIndicator.setIndeterminate(false);
                progressIndicator.setFraction(1.0);
                StringBuffer sb = new StringBuffer();
                sb.append("GsonFormat [" + (System.currentTimeMillis() - currentTimeMillis) + " ms]\n");
//                sb.append("generate class : ( "+generateClassList.size()+" )\n");
//                for (String item: generateClassList) {
//                    sb.append("    at "+item+"\n");
//                }
//                sb.append("  \n");
//                NotificationCenter.info(sb.toString());
                Toast.make(project, MessageType.INFO, sb.toString());
            }
        });
    }
 
源代码9 项目: intellij-haxe   文件: HaxeUtil.java
public static void reparseProjectFiles(@NotNull final Project project) {
  Task.Backgroundable task = new Task.Backgroundable(project, HaxeBundle.message("haxe.project.reparsing"), false) {
    public void run(@NotNull ProgressIndicator indicator) {
      final Collection<VirtualFile> haxeFiles = new ArrayList<VirtualFile>();
      final VirtualFile baseDir = project.getBaseDir();
      if (baseDir != null) {
        FileBasedIndex.getInstance().iterateIndexableFiles(new ContentIterator() {
          public boolean processFile(VirtualFile file) {
            if (HaxeFileType.HAXE_FILE_TYPE == file.getFileType()) {
              haxeFiles.add(file);
            }
            return true;
          }
        }, project, indicator);
      }
      ApplicationManager.getApplication().invokeAndWait(new Runnable() {
        public void run() {
          FileContentUtil.reparseFiles(project, haxeFiles, !project.isDefault());
        }
      }, ModalityState.NON_MODAL);
    }
  };
  ProgressManager.getInstance().run(task);
}
 
源代码10 项目: consulo   文件: ExtractMethodHelper.java
/**
 * Finds duplicates of the code fragment specified in the finder in given scopes.
 * Note that in contrast to {@link #processDuplicates} the search is performed synchronously because normally you need the results in
 * order to complete the refactoring. If user cancels it, empty list will be returned.
 *
 * @param finder          finder object to seek for duplicates
 * @param searchScopes    scopes where to look them in
 * @param generatedMethod new method that should be excluded from the search
 * @return list of discovered duplicate code fragments or empty list if user interrupted the search
 * @see #replaceDuplicates(PsiElement, Editor, Consumer, List)
 */
@Nonnull
public static List<SimpleMatch> collectDuplicates(@Nonnull SimpleDuplicatesFinder finder,
                                                  @Nonnull List<PsiElement> searchScopes,
                                                  @Nonnull PsiElement generatedMethod) {
  final Project project = generatedMethod.getProject();
  try {
    //noinspection RedundantCast
    return ProgressManager.getInstance().runProcessWithProgressSynchronously(
            (ThrowableComputable<List<SimpleMatch>, RuntimeException>)() -> {
              ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
              ThrowableComputable<List<SimpleMatch>, RuntimeException> action = () -> finder.findDuplicates(searchScopes, generatedMethod);
              return AccessRule.read(action);
            }, RefactoringBundle.message("searching.for.duplicates"), true, project);
  }
  catch (ProcessCanceledException e) {
    return Collections.emptyList();
  }
}
 
源代码11 项目: intellij   文件: AddSourceToProjectHelper.java
@Nullable
private static WorkspacePath findBlazePackagePath(Project project, WorkspacePath source) {
  WorkspacePathResolver pathResolver =
      WorkspacePathResolverProvider.getInstance(project).getPathResolver();
  if (pathResolver == null) {
    return null;
  }
  BuildSystemProvider provider = Blaze.getBuildSystemProvider(project);
  while (source != null) {
    ProgressManager.checkCanceled();
    if (provider.findBuildFileInDirectory(pathResolver.resolveToFile(source)) != null) {
      return source;
    }
    source = source.getParent();
  }
  return null;
}
 
源代码12 项目: consulo   文件: JarHandler.java
@Nonnull
private File copyToMirror(@Nonnull File original, @Nonnull File mirror) {
  ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
  if (progress != null) {
    progress.pushState();
    progress.setText(VfsBundle.message("jar.copy.progress", original.getPath()));
    progress.setFraction(0);
  }

  try {
    FileUtil.copy(original, mirror);
  }
  catch (final IOException e) {
    reportIOErrorWithJars(original, mirror, e);
    return original;
  }
  finally {
    if (progress != null) {
      progress.popState();
    }
  }


  return mirror;
}
 
源代码13 项目: consulo   文件: VcsSynchronousProgressWrapper.java
public static boolean wrap(final ThrowableRunnable<VcsException> runnable, final Project project, final String title) {
  final VcsException[] exc = new VcsException[1];
  final Runnable process = new Runnable() {
    @Override
    public void run() {
      try {
        runnable.run();
      }
      catch (VcsException e) {
        exc[0] = e;
      }
    }
  };
  final boolean notCanceled;
  if (ApplicationManager.getApplication().isDispatchThread()) {
    notCanceled = ProgressManager.getInstance().runProcessWithProgressSynchronously(process, title, true, project);
  } else {
    process.run();
    notCanceled = true;
  }
  if (exc[0] != null) {
    AbstractVcsHelper.getInstance(project).showError(exc[0], title);
    return false;
  }
  return notCanceled;
}
 
源代码14 项目: consulo   文件: ShelveChangesManager.java
public void unshelveSilentlyAsynchronously(@Nonnull final Project project,
                                           @Nonnull final List<ShelvedChangeList> selectedChangeLists,
                                           @Nonnull final List<ShelvedChange> selectedChanges,
                                           @Nonnull final List<ShelvedBinaryFile> selectedBinaryChanges,
                                           @Nullable final LocalChangeList forcePredefinedOneChangelist) {
  ProgressManager.getInstance().run(new Task.Backgroundable(project, VcsBundle.message("unshelve.changes.progress.title"), true) {
    @Override
    public void run(@Nonnull ProgressIndicator indicator) {
      for (ShelvedChangeList changeList : selectedChangeLists) {
        List<ShelvedChange> changesForChangelist = ContainerUtil.newArrayList(ContainerUtil.intersection(changeList.getChanges(myProject), selectedChanges));
        List<ShelvedBinaryFile> binariesForChangelist =
                ContainerUtil.newArrayList(ContainerUtil.intersection(changeList.getBinaryFiles(), selectedBinaryChanges));
        boolean shouldUnshelveAllList = changesForChangelist.isEmpty() && binariesForChangelist.isEmpty();
        unshelveChangeList(changeList, shouldUnshelveAllList ? null : changesForChangelist, shouldUnshelveAllList ? null : binariesForChangelist,
                           forcePredefinedOneChangelist != null ? forcePredefinedOneChangelist : getChangeListUnshelveTo(changeList), true);
      }
    }
  });
}
 
源代码15 项目: consulo   文件: ImplementationSearcher.java
/**
 *
 * @param element
 * @param editor
 * @return For the case the search has been cancelled
 */
@Nullable
protected PsiElement[] searchDefinitions(PsiElement element, Editor editor) {
  PsiElement[][] result = new PsiElement[1][];
  if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
    try {
      result[0] = search(element, editor).toArray(PsiElement.EMPTY_ARRAY);
    }
    catch (IndexNotReadyException e) {
      dumbModeNotification(element);
      result[0] = null;
    }
  }, SEARCHING_FOR_IMPLEMENTATIONS, true, element.getProject())) {
    return null;
  }
  return result[0];
}
 
源代码16 项目: consulo   文件: ModuleManagerComponent.java
@Override
protected void fireModulesAdded() {
  Runnable runnableWithProgress = () -> {
    for (final Module module : myModuleModel.getModules()) {
      final Application app = ApplicationManager.getApplication();
      final Runnable swingRunnable = () -> fireModuleAddedInWriteAction(module);
      if (app.isDispatchThread() || app.isHeadlessEnvironment()) {
        swingRunnable.run();
      }
      else {
        ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator();
        app.invokeAndWait(swingRunnable, pi.getModalityState());
      }
    }
  };

  ProgressIndicator progressIndicator = myProgressManager.getProgressIndicator();
  if (progressIndicator == null) {
    myProgressManager.runProcessWithProgressSynchronously(runnableWithProgress, "Loading modules", false, myProject);
  }
  else {
    runnableWithProgress.run();
  }
}
 
@Override
public boolean processTextOccurrence(@Nonnull PsiElement element, int offsetInElement, @Nonnull final Processor<? super PsiReference> consumer) {
  if (!myTarget.isValid()) {
    return false;
  }

  final List<PsiReference> references = ourReferenceService.getReferences(element, new PsiReferenceService.Hints(myTarget, offsetInElement));
  //noinspection ForLoopReplaceableByForEach
  for (int i = 0; i < references.size(); i++) {
    PsiReference ref = references.get(i);
    ProgressManager.checkCanceled();
    if (ReferenceRange.containsOffsetInElement(ref, offsetInElement) && ref.isReferenceTo(myTarget) && !consumer.process(ref)) {
      return false;
    }
  }
  return true;
}
 
@Override
public void startBackgroundTask(@Nonnull final MMDPrintPanel source, @Nonnull final String taskName, @Nonnull final Runnable task) {
  final Task.Backgroundable backgroundTask = new Task.Backgroundable(this.project, taskName) {
    @Override
    public void run(@Nonnull final ProgressIndicator indicator) {
      try {
        indicator.setIndeterminate(true);
        task.run();
        IdeaUtils.showPopup(String.format("%s has been sent to the printer", taskName), MessageType.INFO);
      } catch (Exception ex) {
        LOGGER.error("Print error", ex);
        IdeaUtils.showPopup("Print error! See the log!", MessageType.ERROR);
      } finally {
        indicator.stop();
      }
    }
  };
  ProgressManager.getInstance().run(backgroundTask);
}
 
源代码19 项目: consulo   文件: CompletionThreadingBase.java
public static void withBatchUpdate(Runnable runnable, CompletionProcess process) {
  if (ourIsInBatchUpdate.get().booleanValue() || !(process instanceof CompletionProgressIndicator)) {
    runnable.run();
    return;
  }

  try {
    ourIsInBatchUpdate.set(Boolean.TRUE);
    runnable.run();
    ProgressManager.checkCanceled();
    CompletionProgressIndicator currentIndicator = (CompletionProgressIndicator)process;
    CompletionThreadingBase threading = Objects.requireNonNull(currentIndicator.getCompletionThreading());
    threading.flushBatchResult(currentIndicator);
  }
  finally {
    ourIsInBatchUpdate.set(Boolean.FALSE);
  }
}
 
public static void runAfterCompilationCheck(Task.Backgroundable afterCompilationBackgroundable,
                                            Project project, ProjectInfo projectInfo) {
    final Task.Backgroundable compilationBackgroundable = new Task.Backgroundable(project, IntelliJDeodorantBundle.message("project.compiling.indicator.text"), true) {
        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            runAfterCompilationCheck(projectInfo, afterCompilationBackgroundable);
        }
    };

    ProgressManager.getInstance().run(compilationBackgroundable);
}
 
源代码21 项目: consulo   文件: CommitHelper.java
private void delegateCommitToVcsThread(final GeneralCommitProcessor processor) {
  final ProgressIndicator indicator = new DelegatingProgressIndicator();

  final Semaphore endSemaphore = new Semaphore();
  endSemaphore.down();

  ChangeListManagerImpl.getInstanceImpl(myProject).executeOnUpdaterThread(new Runnable() {
    @Override
    public void run() {
      indicator.setText("Performing VCS commit...");
      try {
        ProgressManager.getInstance().runProcess(new Runnable() {
          @Override
          public void run() {
            indicator.checkCanceled();
            generalCommit(processor);
          }
        }, indicator);
      }
      finally {
        endSemaphore.up();
      }
    }
  });

  indicator.setText("Waiting for VCS background tasks to finish...");
  while (!endSemaphore.waitFor(20)) {
    indicator.checkCanceled();
  }
}
 
源代码22 项目: consulo   文件: CallbackData.java
@Nonnull
private static CallbackData createInteractive(@Nonnull Project project,
                                              @Nonnull InvokeAfterUpdateMode mode,
                                              @Nonnull Runnable afterUpdate,
                                              String title,
                                              @Nullable ModalityState state) {
  Task task = mode.isSynchronous()
              ? new Waiter(project, afterUpdate, title, mode.isCancellable())
              : new FictiveBackgroundable(project, afterUpdate, title, mode.isCancellable(), state);
  Runnable callback = () -> {
    logUpdateFinished(project, mode);
    setDone(task);
  };
  return new CallbackData(callback, () -> ProgressManager.getInstance().run(task));
}
 
源代码23 项目: consulo   文件: JobUtilTest.java
private static void checkProgressAndReadAction(final List<Object> objects,
                                               final DaemonProgressIndicator progress,
                                               final boolean runInReadAction) throws Throwable {
  final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
  JobLauncher.getInstance().invokeConcurrentlyUnderProgress(objects, progress, runInReadAction, new Processor<Object>() {
    @Override
    public boolean process(Object o) {
      try {
        if (objects.size() <= 1 || JobSchedulerImpl.getCPUCoresCount() <= 2) {
          assertTrue(ApplicationManager.getApplication().isDispatchThread());
        }
        else {
          // generally we know nothing about current thread since FJP can help others task to execute while in current context
        }
        ProgressIndicator actualIndicator = ProgressManager.getInstance().getProgressIndicator();
        assertTrue(actualIndicator instanceof SensitiveProgressWrapper);
        actualIndicator = ((SensitiveProgressWrapper)actualIndicator).getOriginalProgressIndicator();
        if (progress != null) {
          assertSame(progress, actualIndicator);
        }
        else {
          assertNotNull(actualIndicator);
        }
        // there can be read access even if we didn't ask for it (e.g. when task under read action steals others work)
        assertTrue(!runInReadAction || ApplicationManager.getApplication().isReadAccessAllowed());
      }
      catch (Throwable e) {
        exception.set(e);
      }
      return true;
    }
  });
  if (exception.get() != null) throw exception.get();
}
 
@Override
public void generateProject(@NotNull final Project project, final @NotNull VirtualFile baseDir, final @NotNull ShopwareInstallerSettings settings, @NotNull Module module) {

    String downloadPath = settings.getVersion().getUrl();
    String toDir = baseDir.getPath();

    VirtualFile zipFile = PhpConfigurationUtil.downloadFile(project, null, toDir, downloadPath, "shopware.zip");

    if (zipFile == null) {
        showErrorNotification(project, "Cannot download Shopware.zip file");
        return;
    }

    // Convert files
    File zip = VfsUtil.virtualToIoFile(zipFile);
    File base = VfsUtil.virtualToIoFile(baseDir);

    Task.Backgroundable task = new Task.Backgroundable(project, "Extracting", true) {
        @Override
        public void run(@NotNull ProgressIndicator progressIndicator) {

            try {
                // unzip file
                ZipUtil.extract(zip, base, null);

                // Delete TMP File
                FileUtil.delete(zip);

                // Activate Plugin
                IdeHelper.enablePluginAndConfigure(project);
            } catch (IOException e) {
                showErrorNotification(project, "There is a error occurred");
            }
        }
    };

    ProgressManager.getInstance().run(task);
}
 
源代码25 项目: litho   文件: ComponentsCacheService.java
void invalidate() {
  final List<String> componentNames = new ArrayList<>(componentNameToClass.keySet());
  LOG.debug("Invalidating " + componentNames);
  if (componentNames.isEmpty()) return;
  IntervalLogger logger = new IntervalLogger(LOG);

  ProgressManager.getInstance()
      .run(
          new Task.Backgroundable(project, "Invalidating In-Memory Files") {
            @Override
            public void run(ProgressIndicator indicator) {
              indicator.setIndeterminate(false);
              for (int i = 0, size = componentNames.size(); i < size; i++) {
                indicator.setFraction(((double) i + 1) / size);
                indicator.setText2(i + 1 + "/" + size);
                String clsName = componentNames.get(i);
                AtomicBoolean found = new AtomicBoolean(false);
                ReadAction.run(
                    () -> {
                      final boolean foundCls =
                          Arrays.stream(PsiSearchUtils.findClasses(project, clsName))
                              .anyMatch(cls -> !ComponentScope.contains(cls.getContainingFile()));
                      found.set(foundCls);
                    });
                if (found.get()) {
                  logger.logStep("removing " + clsName);
                  componentNameToClass.remove(clsName);
                } else {
                  logger.logStep("keeping " + clsName);
                }
              }
            }
          });
}
 
源代码26 项目: consulo   文件: CustomRegionStructureUtil.java
@RequiredReadAction
private static Collection<CustomRegionTreeElement> collectCustomRegions(@Nonnull PsiElement rootElement, @Nonnull Set<? extends TextRange> ranges) {
  TextRange rootRange = getTextRange(rootElement);
  Iterator<PsiElement> iterator =
          SyntaxTraverser.psiTraverser(rootElement).filter(element -> isCustomRegionCommentCandidate(element) && rootRange.contains(element.getTextRange()) && !isInsideRanges(element, ranges)).iterator();

  List<CustomRegionTreeElement> customRegions = new SmartList<>();
  CustomRegionTreeElement currRegionElement = null;
  CustomFoldingProvider provider = null;
  while (iterator.hasNext()) {
    ProgressManager.checkCanceled();
    PsiElement child = iterator.next();
    if (provider == null) provider = getProvider(child);
    if (provider != null) {
      String commentText = child.getText();
      if (provider.isCustomRegionStart(commentText)) {
        if (currRegionElement == null) {
          currRegionElement = new CustomRegionTreeElement(child, provider);
          customRegions.add(currRegionElement);
        }
        else {
          currRegionElement = currRegionElement.createNestedRegion(child);
        }
      }
      else if (provider.isCustomRegionEnd(commentText) && currRegionElement != null) {
        currRegionElement = currRegionElement.endRegion(child);
      }
    }
  }
  return customRegions;
}
 
源代码27 项目: consulo   文件: InspectionProfileWrapper.java
public static void checkInspectionsDuplicates(@Nonnull InspectionToolWrapper[] toolWrappers) {
  if (alreadyChecked) return;
  alreadyChecked = true;
  Set<InspectionProfileEntry> uniqTools = new THashSet<InspectionProfileEntry>(toolWrappers.length);
  for (InspectionToolWrapper toolWrapper : toolWrappers) {
    ProgressManager.checkCanceled();
    if (!uniqTools.add(toolWrapper.getTool())) {
      LOG.error("Inspection " + toolWrapper.getDisplayName() + " (" + toolWrapper.getTool().getClass() + ") already registered");
    }
  }
}
 
源代码28 项目: consulo   文件: DumpDirectoryInfoAction.java
@Override
public void actionPerformed(AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  final DirectoryIndex index = DirectoryIndex.getInstance(project);
  if (project != null) {
    final VirtualFile root = e.getData(PlatformDataKeys.VIRTUAL_FILE);
    ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
      @Override
      public void run() {
        final ContentIterator contentIterator = new ContentIterator() {
          @Override
          public boolean processFile(VirtualFile fileOrDir) {
            LOG.info(fileOrDir.getPath());

            final DirectoryInfo directoryInfo = index.getInfoForDirectory(fileOrDir);
            if (directoryInfo != null) {
              LOG.info(directoryInfo.toString());
            }
            return true;
          }
        };
        if (root != null) {
          ProjectRootManager.getInstance(project).getFileIndex().iterateContentUnderDirectory(root, contentIterator);
        } else {
          ProjectRootManager.getInstance(project).getFileIndex().iterateContent(contentIterator);
        }
      }
    }, "Dumping directory index", true, project);
  }
}
 
源代码29 项目: AndroidGodEye   文件: OpenAction.java
private String parsePortByLogcatWithTimeout(Project project, String adbPath) {
    final String[] parsedPort = new String[1];
    ProgressManager.getInstance().
            runProcessWithProgressSynchronously(new Runnable() {
                public void run() {
                    ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
                    progressIndicator.setIndeterminate(false);
                    progressIndicator.setFraction(0.3);
                    mLogger.info("parsePortByLogcatWithTimeout start parsing");
                    Future<String> result = mExecutorService.submit(new Callable<String>() {
                        @Override
                        public String call() throws Exception {
                            return parsePortByLogcat(adbPath, progressIndicator);
                        }
                    });
                    mLogger.info("parsePortByLogcatWithTimeout wait parsing");
                    try {
                        parsedPort[0] = result.get(5, TimeUnit.SECONDS);
                        mLogger.info("parsePortByLogcatWithTimeout wait end,get parsed port:" + parsedPort[0]);
                    } catch (Throwable e) {
                        e.printStackTrace();
                        mLogger.info("parsePortByLogcatWithTimeout wait end, timeout.");
                    }
                    progressIndicator.setFraction(1.0);
                }
            }, "Parsing Port, Wait For 5 Seconds...", true, project);
    mLogger.info("parsePortByLogcatWithTimeout return");
    return parsedPort[0];
}
 
源代码30 项目: consulo   文件: FileTreeModelBuilder.java
private void counting() {
  myTotalFileCount++;
  ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  if (indicator != null) {
    update(indicator, true, -1);
  }
}