當前位置: 首頁>>代碼示例>>Java>>正文


Java NullityInferrer類代碼示例

本文整理匯總了Java中com.intellij.codeInspection.inferNullity.NullityInferrer的典型用法代碼示例。如果您正苦於以下問題:Java NullityInferrer類的具體用法?Java NullityInferrer怎麽用?Java NullityInferrer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NullityInferrer類屬於com.intellij.codeInspection.inferNullity包,在下文中一共展示了NullityInferrer類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doTest

import com.intellij.codeInspection.inferNullity.NullityInferrer; //導入依賴的package包/類
private void doTest(boolean annotateLocalVariables) throws Exception  {
  final String nullityPath = "/codeInsight/nullityinferrer";
  final VirtualFile aLib = LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + nullityPath + "/lib/annotations.jar");
  if (aLib != null) {
    final VirtualFile file = JarFileSystem.getInstance().getJarRootForLocalFile(aLib);
    if (file != null) {
      ModuleRootModificationUtil.addModuleLibrary(myModule, file.getUrl());
    }
  }

  configureByFile(nullityPath + "/before" + getTestName(false) + ".java");
  final NullityInferrer nullityInferrer = new NullityInferrer(annotateLocalVariables, getProject());
  nullityInferrer.collect(getFile());
  nullityInferrer.apply(getProject());
  checkResultByFile(nullityPath + "/after" + getTestName(false)+ ".java");
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:NullityInferrerTest.java

示例2: doTest

import com.intellij.codeInspection.inferNullity.NullityInferrer; //導入依賴的package包/類
private void doTest(boolean annotateLocalVariables) throws Exception  {
  final String nullityPath = "/codeInsight/nullityinferrer";
  final VirtualFile aLib = LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + nullityPath + "/lib/annotations.jar");
  if (aLib != null) {
    final VirtualFile file = ArchiveVfsUtil.getJarRootForLocalFile(aLib);
    if (file != null) {
      ModuleRootModificationUtil.addModuleLibrary(myModule, file.getUrl());
    }
  }

  configureByFile(nullityPath + "/before" + getTestName(false) + ".java");
  final NullityInferrer nullityInferrer = new NullityInferrer(annotateLocalVariables, getProject());
  nullityInferrer.collect(getFile());
  nullityInferrer.apply(getProject());
  checkResultByFile(nullityPath + "/after" + getTestName(false)+ ".java");
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:17,代碼來源:NullityInferrerTest.java

示例3: testParameterCheckedForInstanceof

import com.intellij.codeInspection.inferNullity.NullityInferrer; //導入依賴的package包/類
public void testParameterCheckedForInstanceof() throws Exception {
  try {
    doTest(false);
    fail("Should infer nothing");
  }
  catch (RuntimeException e) {
    if (!Comparing.strEqual(e.getMessage(), NullityInferrer.NOTHING_FOUND_TO_INFER)) {
      fail();
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:12,代碼來源:NullityInferrerTest.java

示例4: applyRunnable

import com.intellij.codeInspection.inferNullity.NullityInferrer; //導入依賴的package包/類
private static Runnable applyRunnable(final Project project, final Computable<UsageInfo[]> computable) {
  return new Runnable() {
    @Override
    public void run() {
      final LocalHistoryAction action = LocalHistory.getInstance().startAction(INFER_NULLITY_ANNOTATIONS);
      try {
        new WriteCommandAction(project, INFER_NULLITY_ANNOTATIONS) {
          @Override
          protected void run(@NotNull Result result) throws Throwable {
            final UsageInfo[] infos = computable.compute();
            if (infos.length > 0) {

              final Set<PsiElement> elements = new LinkedHashSet<PsiElement>();
              for (UsageInfo info : infos) {
                final PsiElement element = info.getElement();
                if (element != null) {
                  ContainerUtil.addIfNotNull(elements, element.getContainingFile());
                }
              }
              if (!FileModificationService.getInstance().preparePsiElementsForWrite(elements)) return;

              final SequentialModalProgressTask progressTask = new SequentialModalProgressTask(project, INFER_NULLITY_ANNOTATIONS, false);
              progressTask.setMinIterationTime(200);
              progressTask.setTask(new AnnotateTask(project, progressTask, infos));
              ProgressManager.getInstance().run(progressTask);
            } else {
              NullityInferrer.nothingFoundMessage(project);
            }
          }
        }.execute();
      }
      finally {
        action.finish();
      }
    }
  };
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:38,代碼來源:AndroidInferNullityAnnotationAction.java

示例5: iteration

import com.intellij.codeInspection.inferNullity.NullityInferrer; //導入依賴的package包/類
@Override
public boolean iteration() {
  final ProgressIndicator indicator = myTask.getIndicator();
  if (indicator != null) {
    indicator.setFraction(((double)myCount) / myTotal);
  }

  NullityInferrer.apply(myProject, myNotNullManager, myInfos[myCount++]);

  return isDone();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:12,代碼來源:AnnotateTask.java

示例6: findUsages

import com.intellij.codeInspection.inferNullity.NullityInferrer; //導入依賴的package包/類
private static UsageInfo[] findUsages(@NotNull final Project project,
                                      @NotNull final AnalysisScope scope,
                                      final int fileCount) {
  final NullityInferrer inferrer = new NullityInferrer(false, project);
  final PsiManager psiManager = PsiManager.getInstance(project);
  final Runnable searchForUsages = new Runnable() {
    @Override
    public void run() {
      scope.accept(new PsiElementVisitor() {
        int myFileCount = 0;

        @Override
        public void visitFile(final PsiFile file) {
          myFileCount++;
          final VirtualFile virtualFile = file.getVirtualFile();
          final FileViewProvider viewProvider = psiManager.findViewProvider(virtualFile);
          final Document document = viewProvider == null ? null : viewProvider.getDocument();
          if (document == null || virtualFile.getFileType().isBinary()) return; //do not inspect binary files
          final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
          if (progressIndicator != null) {
            progressIndicator.setText2(ProjectUtil.calcRelativeToProjectPath(virtualFile, project));
            progressIndicator.setFraction(((double)myFileCount) / fileCount);
          }
          if (file instanceof PsiJavaFile) {
            inferrer.collect(file);
          }
        }
      });
    }
  };
  if (ApplicationManager.getApplication().isDispatchThread()) {
    if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(searchForUsages, INFER_NULLITY_ANNOTATIONS, true, project)) {
      return null;
    }
  } else {
    searchForUsages.run();
  }

  final List<UsageInfo> usages = new ArrayList<UsageInfo>();
  inferrer.collect(usages);
  return usages.toArray(new UsageInfo[usages.size()]);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:43,代碼來源:AndroidInferNullityAnnotationAction.java


注:本文中的com.intellij.codeInspection.inferNullity.NullityInferrer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。