当前位置: 首页>>代码示例>>Java>>正文


Java ThrowableComputable.compute方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.ThrowableComputable.compute方法的典型用法代码示例。如果您正苦于以下问题:Java ThrowableComputable.compute方法的具体用法?Java ThrowableComputable.compute怎么用?Java ThrowableComputable.compute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.ThrowableComputable的用法示例。


在下文中一共展示了ThrowableComputable.compute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doActionAndRestoreEncoding

import com.intellij.openapi.util.ThrowableComputable; //导入方法依赖的package包/类
public static <E extends Throwable> VirtualFile doActionAndRestoreEncoding(@NotNull VirtualFile fileBefore,
                                                                           @NotNull ThrowableComputable<VirtualFile, E> action) throws E {
  EncodingRegistry registry = getInstance();
  Charset charsetBefore = registry.getEncoding(fileBefore, true);
  VirtualFile fileAfter = null;
  try {
    fileAfter = action.compute();
    return fileAfter;
  }
  finally {
    if (fileAfter != null) {
      Charset actual = registry.getEncoding(fileAfter, true);
      if (!Comparing.equal(actual, charsetBefore)) {
        registry.setEncoding(fileAfter, charsetBefore);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:EncodingRegistry.java

示例2: wrapNativeCall

import com.intellij.openapi.util.ThrowableComputable; //导入方法依赖的package包/类
private <T> T wrapNativeCall(final ThrowableComputable<T, SVNException> runnable) throws SVNException {
  try {
    NativeLogReader.startTracking();
    final T t = runnable.compute();
    final List<NativeLogReader.CallInfo> logged = NativeLogReader.getLogged();
    final StringBuilder sb = new StringBuilder();
    for (NativeLogReader.CallInfo info : logged) {
      final String message = SvnNativeCallsTranslator.getMessage(info);
      if (message != null) {
        if (sb.length() > 0) sb.append('\n');
        sb.append(message);
      }
    }
    if (sb.length() > 0) {
      VcsBalloonProblemNotifier.showOverChangesView(myProject, sb.toString(), MessageType.ERROR);
      LOG.info(sb.toString());
    }
    return t;
  } finally {
    NativeLogReader.clear();
    NativeLogReader.endTracking();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:SvnAuthenticationManager.java

示例3: runProcessWithProgressSynchronously

import com.intellij.openapi.util.ThrowableComputable; //导入方法依赖的package包/类
@Override
public <T, E extends Exception> T runProcessWithProgressSynchronously(@NotNull final ThrowableComputable<T, E> process,
                                                 @NotNull @Nls String progressTitle,
                                                 boolean canBeCanceled,
                                                 @Nullable Project project) throws E {

  final Ref<T> result = new Ref<T>();
  final Ref<E> exceptionRef = new Ref<E>();
  Task.Modal task = new Task.Modal(project, progressTitle, canBeCanceled) {
    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      try {
        T compute = process.compute();
        result.set(compute);
      }
      catch (Exception e) {
        exceptionRef.set((E)e);
      }
    }
  };
  runProcessWithProgressSynchronously(task, null);
  if (!exceptionRef.isNull()) throw exceptionRef.get();
  return result.get();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:ProgressManagerImpl.java

示例4: doActionAndRestoreEncoding

import com.intellij.openapi.util.ThrowableComputable; //导入方法依赖的package包/类
public static <E extends Throwable> VirtualFile doActionAndRestoreEncoding(@Nonnull VirtualFile fileBefore,
                                                                           @Nonnull ThrowableComputable<VirtualFile, E> action) throws E {
  EncodingRegistry registry = getInstance();
  Charset charsetBefore = registry.getEncoding(fileBefore, true);
  VirtualFile fileAfter = null;
  try {
    fileAfter = action.compute();
    return fileAfter;
  }
  finally {
    if (fileAfter != null) {
      Charset actual = registry.getEncoding(fileAfter, true);
      if (!Comparing.equal(actual, charsetBefore)) {
        registry.setEncoding(fileAfter, charsetBefore);
      }
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:EncodingRegistry.java

示例5: executeWithClassLoader

import com.intellij.openapi.util.ThrowableComputable; //导入方法依赖的package包/类
public static <T> T executeWithClassLoader(final ThrowableComputable<T, Exception> action, final ClassLoader classLoader)
  throws Exception {
  final Thread thread = Thread.currentThread();
  final ClassLoader prev = thread.getContextClassLoader();
  try {
    thread.setContextClassLoader(classLoader);
    return action.compute();
  }
  finally {
    thread.setContextClassLoader(prev);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:RemoteUtil.java

示例6: openCleanOrResetBroken

import com.intellij.openapi.util.ThrowableComputable; //导入方法依赖的package包/类
public static <T> T openCleanOrResetBroken(@NotNull ThrowableComputable<T, IOException> factoryComputable, Runnable cleanupCallback) throws IOException {
  for(int i = 0; i < 2; ++i) {
    try {
      return factoryComputable.compute();
    } catch (IOException ex) {
      if (i == 1) throw ex;
      cleanupCallback.run();
    }
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:IOUtil.java

示例7: runTransaction

import com.intellij.openapi.util.ThrowableComputable; //导入方法依赖的package包/类
public synchronized <T extends Throwable> void runTransaction(@NotNull GithubAuthData expected,
                                                              @NotNull ThrowableComputable<GithubAuthData, T> task) throws T {
  if (expected != myAuthData) {
    return;
  }

  myAuthData = task.compute();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:GithubAuthDataHolder.java

示例8: runInterruptable

import com.intellij.openapi.util.ThrowableComputable; //导入方法依赖的package包/类
public static <T> T runInterruptable(@NotNull final ProgressIndicator indicator,
                                     @NotNull ThrowableComputable<T, IOException> task) throws IOException {
  ScheduledFuture<?> future = null;
  try {
    final Thread thread = Thread.currentThread();
    future = addCancellationListener(indicator, thread);

    return task.compute();
  }
  finally {
    if (future != null) future.cancel(true);
    Thread.interrupted();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:GithubUtil.java

示例9: compute

import com.intellij.openapi.util.ThrowableComputable; //导入方法依赖的package包/类
public static <T, E extends Throwable> T compute(@Nonnull ThrowableComputable<T, E> action) throws E {
  AccessToken token = start();
  try {
    return action.compute();
  } finally {
    token.finish();
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:ReadAction.java

示例10: compute

import com.intellij.openapi.util.ThrowableComputable; //导入方法依赖的package包/类
public static <T, E extends Throwable> T compute(@Nonnull ThrowableComputable<T, E> action) throws E {
  AccessToken token = start();
  try {
    return action.compute();
  }
  finally {
    token.finish();
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:10,代码来源:WriteAction.java

示例11: openCleanOrResetBroken

import com.intellij.openapi.util.ThrowableComputable; //导入方法依赖的package包/类
public static <T> T openCleanOrResetBroken(@Nonnull ThrowableComputable<T, IOException> factoryComputable, Runnable cleanupCallback) throws IOException {
  for (int i = 0; i < 2; ++i) {
    try {
      return factoryComputable.compute();
    }
    catch (IOException ex) {
      if (i == 1) throw ex;
      cleanupCallback.run();
    }
  }

  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:14,代码来源:IOUtil.java

示例12: performPsiModification

import com.intellij.openapi.util.ThrowableComputable; //导入方法依赖的package包/类
public static <T, E extends Throwable> T performPsiModification(String trace, @Nonnull ThrowableComputable<T, E> runnable) throws E {
  startPsiModification(trace);
  try {
    return runnable.compute();
  }
  finally {
    finishPsiModification();
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:10,代码来源:DebugUtil.java

示例13: runReadAction

import com.intellij.openapi.util.ThrowableComputable; //导入方法依赖的package包/类
@Override
public <T, E extends Throwable> T runReadAction(@NotNull ThrowableComputable<T, E> computation) throws E {
  return computation.compute();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:MockApplication.java

示例14: runWriteAction

import com.intellij.openapi.util.ThrowableComputable; //导入方法依赖的package包/类
@Override
public <T, E extends Throwable> T runWriteAction(@NotNull ThrowableComputable<T, E> computation) throws E {
  return computation.compute();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:MockApplication.java

示例15: annotate

import com.intellij.openapi.util.ThrowableComputable; //导入方法依赖的package包/类
/**
 * @param currentRevision - just a hint for optimization
 */
private FileAnnotation annotate(VirtualFile file, final VcsRevisionNumber revisionNumber, final boolean currentRevision,
                                final ThrowableComputable<FileAnnotation, VcsException> delegate) throws VcsException {
  final AnnotationProvider annotationProvider = myAnnotationProvider;

  final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file);

  final VcsCacheableAnnotationProvider cacheableAnnotationProvider = (VcsCacheableAnnotationProvider)annotationProvider;

  VcsAnnotation vcsAnnotation = null;
  if (revisionNumber != null) {
    vcsAnnotation = myCache.get(VcsContextFactory.SERVICE.getInstance().createFilePathOn(file), myVcs.getKeyInstanceMethod(), revisionNumber);
  }

  if (vcsAnnotation != null) {
    final VcsHistoryProvider historyProvider = myVcs.getVcsHistoryProvider();
    final VcsAbstractHistorySession history = getHistory(revisionNumber, filePath, historyProvider, vcsAnnotation.getFirstRevision());
    if (history == null) return null;
    // question is whether we need "not moved" path here?
    final ContentRevision fileContent = myVcs.getDiffProvider().createFileContent(revisionNumber, file);
    final FileAnnotation restored = cacheableAnnotationProvider.
      restore(vcsAnnotation, history, fileContent.getContent(), currentRevision,
                                                                        revisionNumber);
    if (restored != null) {
      return restored;
    }
  }

  final FileAnnotation fileAnnotation = delegate.compute();
  vcsAnnotation = cacheableAnnotationProvider.createCacheable(fileAnnotation);
  if (vcsAnnotation == null) return fileAnnotation;

  if (revisionNumber != null) {
    myCache.put(filePath, myVcs.getKeyInstanceMethod(), revisionNumber, vcsAnnotation);
  }

  if (myVcs.getVcsHistoryProvider() instanceof VcsCacheableHistorySessionFactory) {
    loadHistoryInBackgroundToCache(revisionNumber, filePath, vcsAnnotation);
  }
  return fileAnnotation;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:VcsAnnotationCachedProxy.java


注:本文中的com.intellij.openapi.util.ThrowableComputable.compute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。