Java 类com.intellij.openapi.util.Throwable2Computable 实例源码

项目:intellij-ce-playground    文件:GitContentRevision.java   
@Nullable
public String getContent() throws VcsException {
  if (myFile.isDirectory()) {
    return null;
  }
  try {
    return ContentRevisionCache
      .getOrLoadAsString(myProject, myFile, myRevision, GitVcs.getKey(), ContentRevisionCache.UniqueType.REPOSITORY_CONTENT,
                         new Throwable2Computable<byte[], VcsException, IOException>() {
                           @Override
                           public byte[] compute() throws VcsException, IOException {
                             return loadContent();
                           }
                         }, myCharset);
  }
  catch (IOException e) {
    throw new VcsException(e);
  }
}
项目:intellij-ce-playground    文件:SvnFileRevision.java   
public byte[] getContent() throws IOException, VcsException {
  byte[] result;

  if (SVNRevision.HEAD.equals(myRevision)) {
    result = loadContent();
  }
  else {
    result = ContentRevisionCache.getOrLoadAsBytes(myVCS.getProject(), VcsUtil.getFilePathOnNonLocal(myURL, false), getRevisionNumber(),
                                                   myVCS.getKeyInstanceMethod(), ContentRevisionCache.UniqueType.REMOTE_CONTENT,
                                                   new Throwable2Computable<byte[], VcsException, IOException>() {
                                                     @Override
                                                     public byte[] compute() throws VcsException, IOException {
                                                       return loadContent();
                                                     }
                                                   });
  }

  return result;
}
项目:intellij-ce-playground    文件:SvnRepositoryContentRevision.java   
@Nullable
public String getContent() throws VcsException {
  try {
    if (myFilePath.getVirtualFile() == null) {
      LocalFileSystem.getInstance().refreshAndFindFileByPath(myFilePath.getPath());
    }
    return ContentRevisionCache.getOrLoadAsString(myVcs.getProject(), myFilePath, getRevisionNumber(), myVcs.getKeyInstanceMethod(),
                                                  ContentRevisionCache.UniqueType.REPOSITORY_CONTENT,
                                                  new Throwable2Computable<byte[], VcsException, IOException>() {
                                                    @Override
                                                    public byte[] compute() throws VcsException, IOException {
                                                      return loadContent().toByteArray();
                                                    }
                                                  });
  }
  catch (IOException e) {
    throw new VcsException(e);
  }
}
项目:tools-idea    文件:GitContentRevision.java   
@Nullable
public String getContent() throws VcsException {
  if (myFile.isDirectory()) {
    return null;
  }
  try {
    return ContentRevisionCache
      .getOrLoadAsString(myProject, myFile, myRevision, GitVcs.getKey(), ContentRevisionCache.UniqueType.REPOSITORY_CONTENT,
                         new Throwable2Computable<byte[], VcsException, IOException>() {
                           @Override
                           public byte[] compute() throws VcsException, IOException {
                             return loadContent();
                           }
                         }, myCharset);
  }
  catch (IOException e) {
    throw new VcsException(e);
  }
}
项目:tools-idea    文件:SvnRepositoryContentRevision.java   
@Nullable
public String getContent() throws VcsException {
  try {
    myFilePath.hardRefresh();
    return ContentRevisionCache.getOrLoadAsString(myVcs.getProject(), myFilePath, getRevisionNumber(), myVcs.getKeyInstanceMethod(),
                                           ContentRevisionCache.UniqueType.REPOSITORY_CONTENT, new Throwable2Computable<byte[], VcsException, IOException>() {
      @Override
      public byte[] compute() throws VcsException, IOException {
        final ByteArrayOutputStream buffer = loadContent();
        return buffer.toByteArray();
      }
    });
  }
  catch (IOException e) {
    throw new VcsException(e);
  }
}
项目:intellij-ce-playground    文件:ContentRevisionCache.java   
@Nullable
public static String getOrLoadAsString(Project project,
                                       FilePath file,
                                       VcsRevisionNumber number,
                                       VcsKey key,
                                       UniqueType type,
                                       Throwable2Computable<byte[], VcsException, IOException> loader, @Nullable Charset charset)
  throws VcsException, IOException {
  if (charset == null) {
    return getOrLoadAsString(project, file, number, key, type, loader);
  }
  final byte[] bytes = getOrLoadAsBytes(project, file, number, key, type, loader);
  return CharsetToolkit.bytesToString(bytes, charset);
}
项目:intellij-ce-playground    文件:ContentRevisionCache.java   
public static byte[] getOrLoadAsBytes(final Project project, FilePath path, VcsRevisionNumber number, @NotNull VcsKey vcsKey,
                                      @NotNull UniqueType type, final Throwable2Computable<byte[], VcsException, IOException> loader)
  throws VcsException, IOException {
  ContentRevisionCache cache = ProjectLevelVcsManager.getInstance(project).getContentRevisionCache();
  byte[] bytes = cache.getBytes(path, number, vcsKey, type);
  if (bytes != null) return bytes;

  checkLocalFileSize(path);
  bytes = loader.compute();
  cache.put(path, number, vcsKey, type, bytes);
  return bytes;
}
项目:intellij-ce-playground    文件:ContentRevisionCache.java   
@Nullable
public static String getOrLoadAsString(final Project project, FilePath path, VcsRevisionNumber number, @NotNull VcsKey vcsKey,
                                      @NotNull UniqueType type, final Throwable2Computable<byte[], VcsException, IOException> loader)
  throws VcsException, IOException {
  byte[] bytes = getOrLoadAsBytes(project, path, number, vcsKey, type, loader);
  if (bytes == null) return null;

  return bytesToString(path, bytes);
}
项目:intellij-ce-playground    文件:SvnContentRevision.java   
@Nullable
public String getContent() throws VcsException {
  try {
    if (myUseBaseRevision) {
      return ContentRevisionCache.getOrLoadCurrentAsString(myVcs.getProject(), myFile, myVcs.getKeyInstanceMethod(),
                                                           new CurrentRevisionProvider() {
                                                             @Override
                                                             public VcsRevisionNumber getCurrentRevision() throws VcsException {
                                                               return getRevisionNumber();
                                                             }

                                                             @Override
                                                             public Pair<VcsRevisionNumber, byte[]> get()
                                                               throws VcsException, IOException {
                                                               return Pair.create(getRevisionNumber(), getUpToDateBinaryContent());
                                                             }
                                                           }).getSecond();
    } else {
      return ContentRevisionCache.getOrLoadAsString(myVcs.getProject(), myFile, getRevisionNumber(), myVcs.getKeyInstanceMethod(),
                                                    ContentRevisionCache.UniqueType.REPOSITORY_CONTENT,
                                                    new Throwable2Computable<byte[], VcsException, IOException>() {
                                                      @Override
                                                      public byte[] compute() throws VcsException, IOException {
                                                        return getUpToDateBinaryContent();
                                                      }
                                                    });
    }
  }
  catch (IOException e) {
    throw new VcsException(e);
  }
}
项目:fossil4idea    文件:FossilContentRevision.java   
@Nullable
@Override
public String getContent() throws VcsException {
  try {
    return ContentRevisionCache.getOrLoadAsString(myProject, myFilePath, myNumber, FossilVcs.getVcsKey(),
        ContentRevisionCache.UniqueType.REPOSITORY_CONTENT, new Throwable2Computable<byte[], VcsException, IOException>() {
      @Override
      public byte[] compute() throws VcsException, IOException {
        return new CatWorker(myProject).cat(myFilePath.getIOFile(), myNumber.getHash()).getBytes();
      }
    });
  } catch (IOException e) {
    throw new FossilException(e);
  }
}
项目:tools-idea    文件:ContentRevisionCache.java   
@Nullable
public static String getOrLoadAsString(Project project,
                                       FilePath file,
                                       VcsRevisionNumber number,
                                       VcsKey key,
                                       UniqueType type,
                                       Throwable2Computable<byte[], VcsException, IOException> loader, @Nullable Charset charset)
  throws VcsException, IOException {
  if (charset == null) {
    return getOrLoadAsString(project, file, number, key, type, loader);
  }
  final byte[] bytes = getOrLoadAsBytes(project, file, number, key, type, loader);
  return CharsetToolkit.bytesToString(bytes, charset);
}
项目:tools-idea    文件:ContentRevisionCache.java   
public static byte[] getOrLoadAsBytes(final Project project, FilePath path, VcsRevisionNumber number, @NotNull VcsKey vcsKey,
                                      @NotNull UniqueType type, final Throwable2Computable<byte[], VcsException, IOException> loader)
  throws VcsException, IOException {
  ContentRevisionCache cache = ProjectLevelVcsManager.getInstance(project).getContentRevisionCache();
  byte[] bytes = cache.getBytes(path, number, vcsKey, type);
  if (bytes != null) return bytes;

  checkLocalFileSize(path);
  bytes = loader.compute();
  cache.put(path, number, vcsKey, type, bytes);
  return bytes;
}
项目:tools-idea    文件:ContentRevisionCache.java   
@Nullable
public static String getOrLoadAsString(final Project project, FilePath path, VcsRevisionNumber number, @NotNull VcsKey vcsKey,
                                      @NotNull UniqueType type, final Throwable2Computable<byte[], VcsException, IOException> loader)
  throws VcsException, IOException {
  byte[] bytes = getOrLoadAsBytes(project, path, number, vcsKey, type, loader);
  if (bytes == null) return null;

  return bytesToString(path, bytes);
}
项目:tools-idea    文件:SvnContentRevision.java   
@Nullable
public String getContent() throws VcsException {
  try {
    if (myUseBaseRevision) {
      return ContentRevisionCache.getOrLoadCurrentAsString(myVcs.getProject(), myFile, myVcs.getKeyInstanceMethod(),
                                                           new CurrentRevisionProvider() {
                                                             @Override
                                                             public VcsRevisionNumber getCurrentRevision() throws VcsException {
                                                               return getRevisionNumber();
                                                             }

                                                             @Override
                                                             public Pair<VcsRevisionNumber, byte[]> get()
                                                               throws VcsException, IOException {
                                                               return new Pair<VcsRevisionNumber, byte[]>(getRevisionNumber(), getUpToDateBinaryContent());
                                                             }
                                                           }).getSecond();
    } else {
      return ContentRevisionCache.getOrLoadAsString(myVcs.getProject(), myFile, getRevisionNumber(), myVcs.getKeyInstanceMethod(),
                                                    ContentRevisionCache.UniqueType.REPOSITORY_CONTENT,
                                                    new Throwable2Computable<byte[], VcsException, IOException>() {
                                                      @Override
                                                      public byte[] compute() throws VcsException, IOException {
                                                        return getUpToDateBinaryContent();
                                                      }
                                                    });
    }
  }
  catch (IOException e) {
    throw new VcsException(e);
  }
}
项目:tools-idea    文件:SvnFileRevision.java   
public byte[] getContent() throws IOException, VcsException {
  return ContentRevisionCache.getOrLoadAsBytes(myVCS.getProject(), VcsContextFactory.SERVICE.getInstance()
                                                 .createFilePathOnNonLocal(myURL, false),
                                               getRevisionNumber(), myVCS.getKeyInstanceMethod(), ContentRevisionCache.UniqueType.REMOTE_CONTENT,
                                               new Throwable2Computable<byte[], VcsException, IOException>() {
                                                 @Override
                                                 public byte[] compute() throws VcsException, IOException {
                                                   byte[] bytes = loadContent();
                                                   return bytes;
                                                   //return SvnUtil.decode(myCharset, bytes);
                                                 }
                                               });
}
项目:consulo    文件:ContentRevisionCache.java   
@Nullable
public static String getOrLoadAsString(@Nonnull Project project,
                                       @Nonnull FilePath file,
                                       VcsRevisionNumber number,
                                       @Nonnull VcsKey key,
                                       @Nonnull UniqueType type,
                                       @Nonnull Throwable2Computable<byte[], VcsException, IOException> loader,
                                       @Nullable Charset charset)
        throws VcsException, IOException {
  final byte[] bytes = getOrLoadAsBytes(project, file, number, key, type, loader);
  if (bytes == null) return null;
  return getAsString(bytes, file, charset);
}
项目:consulo    文件:ContentRevisionCache.java   
public static byte[] getOrLoadAsBytes(final Project project, FilePath path, VcsRevisionNumber number, @Nonnull VcsKey vcsKey,
                                      @Nonnull UniqueType type, final Throwable2Computable<byte[], VcsException, IOException> loader)
        throws VcsException, IOException {
  ContentRevisionCache cache = ProjectLevelVcsManager.getInstance(project).getContentRevisionCache();
  byte[] bytes = cache.getBytes(path, number, vcsKey, type);
  if (bytes != null) return bytes;

  checkLocalFileSize(path);
  bytes = loader.compute();
  cache.put(path, number, vcsKey, type, bytes);
  return bytes;
}
项目:consulo    文件:ContentRevisionCache.java   
@Nullable
public static String getOrLoadAsString(final Project project, FilePath path, VcsRevisionNumber number, @Nonnull VcsKey vcsKey,
                                       @Nonnull UniqueType type, final Throwable2Computable<byte[], VcsException, IOException> loader)
        throws VcsException, IOException {
  return getOrLoadAsString(project, path, number, vcsKey, type, loader, null);
}