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

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

java 1次浏览

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

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

示例1: setTodoHighlighting

点赞 3

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
private void setTodoHighlighting(final Document oldDocument, final Document document) {
  final ContentRevisionCache cache = ProjectLevelVcsManager.getInstance(myProject).getContentRevisionCache();
  final List<Pair<TextRange,TextAttributes>> beforeTodoRanges = myBeforeNumber == null ? Collections.<Pair<TextRange,TextAttributes>>emptyList() :
    new TodoForBaseRevision(myProject, getBeforeFragments(), 1, myFileName, oldDocument.getText(), true, myFileType, new Getter<Object>() {
    @Override
    public Object get() {
      return cache.getCustom(myFilePath, myBeforeNumber);
    }
  }, new Consumer<Object>() {
    @Override
    public void consume(Object items) {
      cache.putCustom(myFilePath, myBeforeNumber, items);
    }
  }).execute();

  final List<Pair<TextRange, TextAttributes>> afterTodoRanges = new TodoForExistingFile(myProject, getAfterFragments(), 1,
    myFileName, document.getText(), false, myFileType, myFile).execute();
  setBeforeTodoRanges(beforeTodoRanges);
  setAfterTodoRanges(afterTodoRanges);
}
 

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

示例2: getContent

点赞 3

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
@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);
  }
}
 

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

示例3: loadContent

点赞 3

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
public byte[] loadContent() throws IOException, VcsException {
  ContentLoader loader = new ContentLoader(myURL, myRevision, myPegRevision);
  if (ApplicationManager.getApplication().isDispatchThread() &&
      !myRevision.isLocal()) {
    ProgressManager.getInstance().runProcessWithProgressSynchronously(loader, SvnBundle.message("progress.title.loading.file.content"),
                                                                      false, myVCS.getProject());
  }
  else {
    loader.run();
  }

  VcsException exception = loader.getException();
  if (exception == null) {
    final byte[] contents = loader.getContents();
    ContentRevisionCache.checkContentsSize(myURL, contents.length);
    return contents;
  }
  else {
    LOG.info("Failed to load file '" + myURL + "' content at revision: " + myRevision + "\n" + exception.getMessage(), exception);
    throw exception;
  }
}
 

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

示例4: getContent

点赞 3

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
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;
}
 

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

示例5: getContent

点赞 3

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
@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);
  }
}
 

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

示例6: loadContent

点赞 3

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
@NotNull
protected ByteArrayOutputStream loadContent() throws VcsException {
  final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  ContentLoader loader = new ContentLoader(myPath, buffer, myRevision);
  if (ApplicationManager.getApplication().isDispatchThread()) {
    ProgressManager.getInstance()
      .runProcessWithProgressSynchronously(loader, SvnBundle.message("progress.title.loading.file.content"), false, null);
  }
  else {
    loader.run();
  }
  final Exception exception = loader.getException();
  if (exception != null) {
    throw new VcsException(exception);
  }
  ContentRevisionCache.checkContentsSize(myPath, buffer.size());
  return buffer;
}
 

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

示例7: loadContent

点赞 3

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
public byte[] loadContent() throws IOException, VcsException {
  ContentLoader loader = new ContentLoader(myURL, myRevision, myPegRevision);
  if (ApplicationManager.getApplication().isDispatchThread() &&
      !myRevision.isLocal()) {
    ProgressManager.getInstance().runProcessWithProgressSynchronously(loader, SvnBundle.message("progress.title.loading.file.content"),
                                                                      false, myVCS.getProject());
  }
  else {
    loader.run();
  }
  if (loader.getException() == null) {
    final byte[] contents = loader.getContents();
    ContentRevisionCache.checkContentsSize(myURL, contents.length);
    return contents;
  }
  else {
    final VcsException vcsException = loader.getException();
    LOG.info("Failed to load file '" + myURL + "' content at revision: " + myRevision + "\n" + vcsException.getMessage(), vcsException);
    throw vcsException;
  }
}
 

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

示例8: getContent

点赞 3

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
@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);
  }
}
 

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

示例9: loadContent

点赞 3

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
protected ByteArrayOutputStream loadContent() throws VcsException {
  final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  ContentLoader loader = new ContentLoader(myPath, buffer, myRevision);
  if (ApplicationManager.getApplication().isDispatchThread()) {
    ProgressManager.getInstance()
      .runProcessWithProgressSynchronously(loader, SvnBundle.message("progress.title.loading.file.content"), false, null);
  }
  else {
    loader.run();
  }
  final SVNException exception = loader.getException();
  if (exception != null) {
    throw new VcsException(exception);
  }
  ContentRevisionCache.checkContentsSize(myPath, buffer.size());
  return buffer;
}
 

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

示例10: getVcsRevision

点赞 2

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
private ContentRevision getVcsRevision() throws VcsException {
  final FilePath file = getFile();
  final Pair<VcsRevisionNumber, String> pair;
  try {
    pair = ContentRevisionCache.getOrLoadCurrentAsString(myProject, file, myVcsKey,
                                                         new CurrentRevisionProvider() {
                                                           @Override
                                                           public VcsRevisionNumber getCurrentRevision() throws VcsException {
                                                             return getCurrentRevisionNumber();
                                                           }

                                                           @Override
                                                           public Pair<VcsRevisionNumber, byte[]> get() throws VcsException, IOException {
                                                             return loadContent();
                                                           }
                                                         });
  }
  catch (IOException e) {
    throw new VcsException(e);
  }

  return new ContentRevision() {
    @Override
    public String getContent() throws VcsException {
      return pair.getSecond();
    }

    @NotNull
    @Override
    public FilePath getFile() {
      return file;
    }

    @NotNull
    @Override
    public VcsRevisionNumber getRevisionNumber() {
      return pair.getFirst();
    }
  };
}
 

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

示例11: getContent

点赞 2

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
@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);
  }
}
 

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

示例12: getContent

点赞 2

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
@Override
public byte[] getContent(@NotNull SvnTarget target, @Nullable SVNRevision revision, @Nullable SVNRevision pegRevision)
  throws VcsException, FileTooBigRuntimeException {
  // TODO: rewrite this to provide output as Stream
  // TODO: Also implement max size constraint like in SvnKitContentClient
  // NOTE: Export could not be used to get content of scheduled for deletion file

  List<String> parameters = new ArrayList<String>();
  CommandUtil.put(parameters, target.getPathOrUrlString(), pegRevision);
  CommandUtil.put(parameters, revision);

  CommandExecutor command = null;
  try {
    command = execute(myVcs, target, SvnCommandName.cat, parameters, null);
  }
  catch (SvnBindException e) {
    // "no pristine version" error is thrown, for instance, for locally replaced files (not committed yet)
    if (StringUtil.containsIgnoreCase(e.getMessage(), NO_PRISTINE_VERSION_FOR_FILE)) {
      LOG.debug(e);
    }
    else {
      throw e;
    }
  }

  byte[] bytes = command != null ? command.getBinaryOutput().toByteArray() : ArrayUtil.EMPTY_BYTE_ARRAY;
  ContentRevisionCache.checkContentsSize(target.getPathOrUrlString(), bytes.length);

  return bytes;
}
 

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

示例13: getContent

点赞 2

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
@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);
  }
}
 

开发者ID:irengrig,
项目名称:fossil4idea,
代码行数:16,
代码来源:FossilContentRevision.java

示例14: getContent

点赞 2

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
@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);
  }
}
 

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

示例15: getContent

点赞 2

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
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);
                                                 }
                                               });
}
 

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

示例16: getVcsRevision

点赞 2

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
@Nonnull
private ContentRevision getVcsRevision() throws VcsException {
  final FilePath file = getFile();
  final Pair<VcsRevisionNumber, byte[]> pair;
  try {
    pair = ContentRevisionCache.getOrLoadCurrentAsBytes(myProject, file, myVcsKey,
                                                        new CurrentRevisionProvider() {
                                                          @Override
                                                          public VcsRevisionNumber getCurrentRevision() throws VcsException {
                                                            return getCurrentRevisionNumber();
                                                          }

                                                          @Override
                                                          public Pair<VcsRevisionNumber, byte[]> get() throws VcsException, IOException {
                                                            return loadContent();
                                                          }
                                                        });
  }
  catch (IOException e) {
    throw new VcsException(e);
  }

  return new ByteBackedContentRevision() {
    @Override
    public String getContent() throws VcsException {
      return ContentRevisionCache.getAsString(getContentAsBytes(), file, null);
    }

    @Nullable
    @Override
    public byte[] getContentAsBytes() throws VcsException {
      return pair.getSecond();
    }

    @Nonnull
    @Override
    public FilePath getFile() {
      return file;
    }

    @Nonnull
    @Override
    public VcsRevisionNumber getRevisionNumber() {
      return pair.getFirst();
    }
  };
}
 

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

示例17: getContentRevisionCache

点赞 1

import com.intellij.openapi.vcs.impl.ContentRevisionCache; //导入依赖的package包/类
public abstract ContentRevisionCache getContentRevisionCache(); 

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


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