• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java DaemonProgressIndicator类的典型用法和代码示例

java 8次浏览

本文整理汇总了Java中com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator的典型用法代码示例。如果您正苦于以下问题:Java DaemonProgressIndicator类的具体用法?Java DaemonProgressIndicator怎么用?Java DaemonProgressIndicator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

DaemonProgressIndicator类属于com.intellij.codeInsight.daemon.impl包,在下文中一共展示了DaemonProgressIndicator类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: collectInformation

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator; //导入依赖的package包/类
@Override
public final void collectInformation(@NotNull ProgressIndicator progress) {
  if (!isValid()) return; //Document has changed.
  if (!(progress instanceof DaemonProgressIndicator)) {
    throw new IncorrectOperationException("Highlighting must be run under DaemonProgressIndicator, but got: "+progress);
  }
  myDumb = DumbService.getInstance(myProject).isDumb();
  doCollectInformation(progress);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:10,
代码来源:TextEditorHighlightingPass.java

示例2: testCorrectProgressAndReadAction

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator; //导入依赖的package包/类
public void testCorrectProgressAndReadAction() throws Throwable {
  checkProgressAndReadAction(Collections.singletonList(null), new DaemonProgressIndicator(), true);
  checkProgressAndReadAction(Collections.singletonList(null), new DaemonProgressIndicator(), false);
  checkProgressAndReadAction(Collections.emptyList(), new DaemonProgressIndicator(), true);
  checkProgressAndReadAction(Collections.emptyList(), new DaemonProgressIndicator(), false);
  checkProgressAndReadAction(Arrays.asList(new Object(), new Object()), new DaemonProgressIndicator(), true);
  checkProgressAndReadAction(Arrays.asList(new Object(), new Object()), new DaemonProgressIndicator(), false);
  checkProgressAndReadAction(Arrays.asList(new Object(), new Object()), null, false);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:10,
代码来源:JobUtilTest.java

示例3: checkProgressAndReadAction

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator; //导入依赖的package包/类
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.CORES_COUNT <= JobLauncherImpl.CORES_FORK_THRESHOLD) {
          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();
        if (progress == null) {
          assertNotNull(actualIndicator);
          assertTrue(actualIndicator instanceof AbstractProgressIndicatorBase);
        }
        else {
          assertTrue(actualIndicator instanceof SensitiveProgressWrapper);
          ProgressIndicator original = ((SensitiveProgressWrapper)actualIndicator).getOriginalProgressIndicator();
          assertSame(progress, original);
        }
        // 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();
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:36,
代码来源:JobUtilTest.java

示例4: doQueue

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator; //导入依赖的package包/类
private void doQueue(Project project, Document document, Object reason) {
  synchronized (documentsToCommit) {
    ProgressIndicator indicator = new DaemonProgressIndicator();
    CommitTask newTask = new CommitTask(document, project, indicator, reason);

    markRemovedFromDocsToCommit(newTask);
    markRemovedCurrentTask(newTask);
    removeFromDocsToApplyInEDT(newTask);

    documentsToCommit.addLast(newTask);
    log("Queued", newTask, false, reason);

    wakeUpQueue();
  }
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:16,
代码来源:DocumentCommitThread.java

示例5: checkProgressAndReadAction

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator; //导入依赖的package包/类
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.CORES_COUNT <= 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();
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:35,
代码来源:JobUtilTest.java

示例6: collectInformation

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator; //导入依赖的package包/类
@RequiredReadAction
@Override
public final void collectInformation(@Nonnull ProgressIndicator progress) {
  if (!isValid()) return; //Document has changed.
  if (!(progress instanceof DaemonProgressIndicator)) {
    throw new IncorrectOperationException("Highlighting must be run under DaemonProgressIndicator, but got: "+progress);
  }
  myDumb = DumbService.getInstance(myProject).isDumb();
  doCollectInformation(progress);
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:11,
代码来源:TextEditorHighlightingPass.java

示例7: mergePsi

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator; //导入依赖的package包/类
private static void mergePsi(@Nonnull PsiFile oldFile, @Nonnull ASTNode oldFileNode, @Nonnull PsiFile injectedPsi, @Nonnull ASTNode injectedNode) {
  if (!oldFile.textMatches(injectedPsi)) {
    InjectedFileViewProvider oldViewProvider = (InjectedFileViewProvider)oldFile.getViewProvider();
    oldViewProvider.performNonPhysically(() -> {
      DebugUtil.performPsiModification("injected tree diff", () -> {
        final DiffLog diffLog = BlockSupportImpl.mergeTrees((PsiFileImpl)oldFile, oldFileNode, injectedNode, new DaemonProgressIndicator(), oldFileNode.getText());
        diffLog.doActualPsiChange(oldFile);
      });
    });
  }
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:12,
代码来源:InjectionRegistrarImpl.java

示例8: optimizeImportsOnTheFlyLater

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator; //导入依赖的package包/类
private void optimizeImportsOnTheFlyLater(@NotNull final ProgressIndicator progress)
{
	if((myHasRedundantImports || myHasMissortedImports) && !progress.isCanceled())
	{
		// schedule optimise action at the time of session disposal, which is after all applyInformation() calls
		Disposable invokeFixLater = () ->
		{
			// later because should invoke when highlighting is finished
			TransactionGuard.getInstance().submitTransactionLater(myProject, () ->
			{
				if(!myFile.isValid() || !myFile.isWritable())
				{
					return;
				}
				IntentionAction optimizeImportsFix = QuickFixFactory.getInstance().createOptimizeImportsFix(true);
				if(optimizeImportsFix.isAvailable(myProject, null, myFile))
				{
					optimizeImportsFix.invoke(myProject, null, myFile);
				}
			});
		};
		try
		{
			Disposer.register((DaemonProgressIndicator) progress, invokeFixLater);
		}
		catch(Exception ignored)
		{
			// suppress "parent already has been disposed" exception here
		}
		if(progress.isCanceled())
		{
			Disposer.dispose(invokeFixLater);
			Disposer.dispose((DaemonProgressIndicator) progress);
			progress.checkCanceled();
		}
	}
}
 

开发者ID:consulo,
项目名称:consulo-java
代码行数:38,
代码来源:PostHighlightingVisitor.java

示例9: getProblems

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator; //导入依赖的package包/类
/**
 * Runs code anlyzis on document found in path and returns all problems found with the document.
 * @param path
 * @param fileContent
 * @return
 */
private static Pair<Document, List<HighlightInfo>> getProblems(final String path, @Nullable final String fileContent) {
    final Ref<PsiFile> psiFileRef = new Ref<>();
    final Ref<Editor> editorRef = new Ref<>();
    final Ref<Document> docRef = new Ref<>();
    final Ref<Project> projectRef = new Ref<>();

    UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
        PsiFile targetPsiFile = EmbeditorUtil.findTargetFile(path);
        VirtualFile targetVirtualFile =  targetPsiFile.getVirtualFile();
        Project project = targetPsiFile.getProject();

        PsiFile fileCopy = fileContent != null
                ? EmbeditorUtil.createDummyPsiFile(project, fileContent, targetPsiFile)
                : EmbeditorUtil.createDummyPsiFile(project, targetPsiFile.getText(), targetPsiFile);

        final Document document = fileCopy.getViewProvider().getDocument();

        editorRef.set(EditorFactory.getInstance().createEditor(document, project, targetVirtualFile, false));
        psiFileRef.set(targetPsiFile);
        docRef.set(document);
        projectRef.set(project);
    });
    Disposable context = Disposer.newDisposable();

    Ref<List<HighlightInfo>> highlightInfoList = new Ref<>();

    ApplicationManager.getApplication().runReadAction(() -> {
        final DaemonProgressIndicator progress = new DaemonProgressIndicator();
        Disposer.register(context, progress);

        ProgressManager.getInstance().runProcess(() -> {

            final DaemonCodeAnalyzerEx analyzer =
                    DaemonCodeAnalyzerEx.getInstanceEx(projectRef.get());
            //analyzer.restart(psiFileRef.get());

            // analyze!
            highlightInfoList.set(analyzer.runMainPasses(
                    psiFileRef.get(), docRef.get(), progress));
        }, progress);
    });
    return Pair.create(docRef.get(), highlightInfoList.get());
}
 

开发者ID:vhakulinen,
项目名称:neovim-intellij-complete,
代码行数:50,
代码来源:Inspect.java

示例10: testStress

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator; //导入依赖的package包/类
public void testStress() throws Exception {
  int numOfThreads = 10;
  int iterations = Timings.adjustAccordingToMySpeed(20, true);
  System.out.println("iterations = " + iterations);
  final int readIterations = iterations * 3;

  synchronized (this) {
    PsiClass myClass = myJavaFacade.findClass("StressClass", GlobalSearchScope.allScope(myProject));
    assertNotNull(myClass);
    myFile = (PsiJavaFile)myClass.getContainingFile();
  }

  final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());

  final CountDownLatch reads = new CountDownLatch(numOfThreads);
  final Random random = new Random();
  for (int i = 0; i < numOfThreads; i++) {
    new Thread(() -> {
      for (int i1 = 0; i1 < readIterations; i1++) {
        if (myPsiManager == null) return;
        ProgressManager.getInstance().runProcess(() -> ApplicationManager.getApplication().runReadAction(() -> {
          assertFalse(writeActionInProgress);
          readStep(random);
        }), new DaemonProgressIndicator());
      }

      reads.countDown();
    }, "stress thread" + i).start();
  }

  final Document document = documentManager.getDocument(myFile);

  for (int i = 0; i < iterations; i++) {
    Thread.sleep(100);
    new WriteCommandAction(myProject, myFile) {
      @Override
      protected void run(@NotNull final Result result) throws Throwable {
        writeActionInProgress = true;
        documentManager.commitAllDocuments();
        writeStep(random);
        documentManager.commitAllDocuments();
        assertEquals(document.getText(), myFile.getText());
        writeActionInProgress = false;
      }
    }.execute();
  }

  assertTrue("Timed out", reads.await(5, TimeUnit.MINUTES));
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:50,
代码来源:PsiConcurrencyStressTest.java

示例11: testStress

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator; //导入依赖的package包/类
public void testStress() throws Exception {
  int numOfThreads = 10;
  int iterations = Timings.adjustAccordingToMySpeed(20, true);
  System.out.println("iterations = " + iterations);
  final int readIterations = iterations * 3;
  final int writeIterations = iterations;

  synchronized (this) {
    PsiClass myClass = myJavaFacade.findClass("StressClass", GlobalSearchScope.allScope(myProject));
    assertNotNull(myClass);
    myFile = (PsiJavaFile)myClass.getContainingFile();
  }

  final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());

  final CountDownLatch reads = new CountDownLatch(numOfThreads);
  final Random random = new Random();
  for (int i = 0; i < numOfThreads; i++) {
    new Thread(new Runnable() {
      @Override
      public void run() {
        for (int i = 0; i < readIterations; i++) {
          if (myPsiManager == null) return;
          ProgressManager.getInstance().runProcess(new Runnable() {
            @Override
            public void run() {
              ApplicationManager.getApplication().runReadAction(new Runnable() {
                @Override
                public void run() {
                  assertFalse(writeActionInProgress);
                  readStep(random);
                }
              });
            }
          }, new DaemonProgressIndicator());
        }

        reads.countDown();
      }
    }, "stress thread" + i).start();
  }

  final Document document = documentManager.getDocument(myFile);

  for (int i = 0; i < writeIterations; i++) {
    Thread.sleep(100);
    new WriteCommandAction(myProject, myFile) {
      @Override
      protected void run(final Result result) throws Throwable {
        writeActionInProgress = true;
        documentManager.commitAllDocuments();
        writeStep(random);
        documentManager.commitAllDocuments();
        assertEquals(document.getText(), myFile.getText());
        writeActionInProgress = false;
      }
    }.execute();
  }

  assertTrue("Timed out", reads.await(5, TimeUnit.MINUTES));
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:62,
代码来源:PsiConcurrencyStressTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)