本文整理汇总了Java中com.intellij.openapi.vcs.changes.ContentRevision.getFile方法的典型用法代码示例。如果您正苦于以下问题:Java ContentRevision.getFile方法的具体用法?Java ContentRevision.getFile怎么用?Java ContentRevision.getFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vcs.changes.ContentRevision
的用法示例。
在下文中一共展示了ContentRevision.getFile方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPresentableRelativePath
import com.intellij.openapi.vcs.changes.ContentRevision; //导入方法依赖的package包/类
@Override
public String getPresentableRelativePath(@NotNull final ContentRevision fromRevision, @NotNull final ContentRevision toRevision) {
// need to use parent path because the old file is already not there
FilePath fromPath = fromRevision.getFile();
FilePath toPath = toRevision.getFile();
if ((fromPath.getParentPath() == null) || (toPath.getParentPath() == null)) {
return null;
}
final VirtualFile oldFile = fromPath.getParentPath().getVirtualFile();
final VirtualFile newFile = toPath.getParentPath().getVirtualFile();
if (oldFile != null && newFile != null) {
Module oldModule = ModuleUtilCore.findModuleForFile(oldFile, myProject);
Module newModule = ModuleUtilCore.findModuleForFile(newFile, myProject);
if (oldModule != newModule) {
return getPresentableRelativePathFor(oldFile);
}
}
final RelativePathCalculator calculator =
new RelativePathCalculator(toPath.getIOFile().getAbsolutePath(), fromPath.getIOFile().getAbsolutePath());
calculator.execute();
final String result = calculator.getResult();
return (result == null) ? null : result.replace("/", File.separator);
}
示例2: getBig
import com.intellij.openapi.vcs.changes.ContentRevision; //导入方法依赖的package包/类
public static Set<Change> getBig(List<Change> changes) {
final Set<Change> exclude = new HashSet<Change>();
for (Change change : changes) {
ContentRevision beforeRevision = change.getBeforeRevision();
if (beforeRevision != null) {
try {
String content = beforeRevision.getContent();
if (content == null) {
final FilePath file = beforeRevision.getFile();
LOG.info("null content for " + (file.getPath()) + ", is dir: " + (file.isDirectory()));
continue;
}
if (content.length() > VcsConfiguration.ourMaximumFileForBaseRevisionSize) {
exclude.add(change);
}
}
catch (VcsException e) {
LOG.info(e);
}
}
}
return exclude;
}
示例3: createParentRevision
import com.intellij.openapi.vcs.changes.ContentRevision; //导入方法依赖的package包/类
@NotNull
private GitFileRevision createParentRevision(@NotNull GitRepository repository, @NotNull GitFileRevision currentRevision,
@NotNull String parentHash) throws VcsException {
FilePath currentRevisionPath = currentRevision.getPath();
if (currentRevisionPath.isDirectory()) {
// for directories the history doesn't follow renames
return makeRevisionFromHash(currentRevisionPath, parentHash);
}
// can't limit by the path: in that case rename information will be missed
Collection<Change> changes = GitChangeUtils.getDiff(myProject, repository.getRoot(), parentHash, currentRevision.getHash(), null);
for (Change change : changes) {
ContentRevision afterRevision = change.getAfterRevision();
ContentRevision beforeRevision = change.getBeforeRevision();
if (afterRevision != null && afterRevision.getFile().equals(currentRevisionPath)) {
// if the file was renamed, taking the path how it was in the parent; otherwise the path didn't change
FilePath path = (beforeRevision != null ? beforeRevision.getFile() : afterRevision.getFile());
return new GitFileRevision(myProject, path, new GitRevisionNumber(parentHash));
}
}
LOG.error(String.format("Could not find parent revision. Will use the path from parent revision. Current revision: %s, parent hash: %s",
currentRevision, parentHash));
return makeRevisionFromHash(currentRevisionPath, parentHash);
}
示例4: calculate
import com.intellij.openapi.vcs.changes.ContentRevision; //导入方法依赖的package包/类
private void calculate() throws VcsException {
// TODO: Seems that filePath detection could be replaced with "svn info -r <revisionBefore>" - and not call
// TODO: "svn log -r HEAD:<revisionBefore>" and track copies manually (which also is not correct for all cases).
if (!searchForUrl(svnRootUrl) && !(hasAccess(repositoryUrl) && searchForUrl(repositoryUrl))) {
filePath = searchFromHead(svnRootUrl);
}
else {
if (changeList[0].getChanges().size() == 1) {
final ContentRevision afterRevision = changeList[0].getChanges().iterator().next().getAfterRevision();
filePath = afterRevision != null ? afterRevision.getFile() : filePath;
}
else {
final Change targetChange = changeList[0].getByPath(repositoryRelativeUrl);
filePath = targetChange == null ? searchFromHead(svnRootUrl) : filePath;
}
}
}
示例5: getBig
import com.intellij.openapi.vcs.changes.ContentRevision; //导入方法依赖的package包/类
public static Set<Change> getBig(List<Change> changes) {
final Set<Change> exclude = new HashSet<Change>();
for (Change change : changes) {
ContentRevision beforeRevision = change.getBeforeRevision();
if (beforeRevision != null) {
try {
String content = beforeRevision.getContent();
if (content == null) {
final FilePath file = beforeRevision.getFile();
LOG.info("null content for " + (file == null ? null : file.getPath()) + ", is dir: " + (file == null ? null : file.isDirectory()));
continue;
}
if (content.length() > VcsConfiguration.ourMaximumFileForBaseRevisionSize) {
exclude.add(change);
}
}
catch (VcsException e) {
LOG.info(e);
}
}
}
return exclude;
}
示例6: getPresentableRelativePath
import com.intellij.openapi.vcs.changes.ContentRevision; //导入方法依赖的package包/类
@Override
public String getPresentableRelativePath(@Nonnull final ContentRevision fromRevision, @Nonnull final ContentRevision toRevision) {
// need to use parent path because the old file is already not there
FilePath fromPath = fromRevision.getFile();
FilePath toPath = toRevision.getFile();
if ((fromPath.getParentPath() == null) || (toPath.getParentPath() == null)) {
return null;
}
final VirtualFile oldFile = fromPath.getParentPath().getVirtualFile();
final VirtualFile newFile = toPath.getParentPath().getVirtualFile();
if (oldFile != null && newFile != null) {
Module oldModule = ModuleUtilCore.findModuleForFile(oldFile, myProject);
Module newModule = ModuleUtilCore.findModuleForFile(newFile, myProject);
if (oldModule != newModule) {
return getPresentableRelativePathFor(oldFile);
}
}
final RelativePathCalculator calculator =
new RelativePathCalculator(toPath.getIOFile().getAbsolutePath(), fromPath.getIOFile().getAbsolutePath());
calculator.execute();
final String result = calculator.getResult();
return (result == null) ? null : result.replace("/", File.separator);
}
示例7: fillCompletionVariants
import com.intellij.openapi.vcs.changes.ContentRevision; //导入方法依赖的package包/类
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
PsiFile file = parameters.getOriginalFile();
Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
if (document != null) {
DataContext dataContext = document.getUserData(CommitMessage.DATA_CONTEXT_KEY);
if (dataContext != null) {
result.stopHere();
if (parameters.getInvocationCount() > 0) {
ChangeList[] lists = VcsDataKeys.CHANGE_LISTS.getData(dataContext);
if (lists != null) {
String prefix = TextFieldWithAutoCompletionListProvider.getCompletionPrefix(parameters);
CompletionResultSet insensitive = result.caseInsensitive().withPrefixMatcher(new CamelHumpMatcher(prefix));
for (ChangeList list : lists) {
for (Change change : list.getChanges()) {
ContentRevision revision = change.getAfterRevision() == null ? change.getBeforeRevision() : change.getAfterRevision();
if (revision != null) {
FilePath filePath = revision.getFile();
LookupElementBuilder element = LookupElementBuilder.create(filePath.getName()).
withIcon(filePath.getFileType().getIcon());
insensitive.addElement(element);
}
}
}
}
}
}
}
}
示例8: getPresentableRelativePath
import com.intellij.openapi.vcs.changes.ContentRevision; //导入方法依赖的package包/类
public String getPresentableRelativePath(final ContentRevision fromRevision, final ContentRevision toRevision) {
FilePath fromPath = fromRevision.getFile();
FilePath toPath = toRevision.getFile();
final RelativePathCalculator calculator =
new RelativePathCalculator(toPath.getIOFile().getAbsolutePath(), fromPath.getIOFile().getAbsolutePath());
calculator.execute();
final String result = calculator.getResult();
return (result == null) ? null : result.replace("/", File.separator);
}
示例9: getChanges
import com.intellij.openapi.vcs.changes.ContentRevision; //导入方法依赖的package包/类
private List<Change> getChanges(Project project, VirtualFile[] vFiles) {
List<Change> changes = new ArrayList<Change>();
final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
for (VirtualFile vf : vFiles) {
if (vf != null) {
vf.refresh(false, true);
Change change = changeListManager.getChange(vf);
if (change != null && change.getType().equals(Change.Type.NEW)) {
final ContentRevision afterRevision = change.getAfterRevision();
change = new Change(null, new ContentRevision() {
@Override
public String getContent() throws VcsException {
return afterRevision.getContent();
}
@NotNull
@Override
public FilePath getFile() {
return afterRevision.getFile();
}
@NotNull
@Override
public VcsRevisionNumber getRevisionNumber() {
return new VcsRevisionNumber.Int(0);
}
}, change.getFileStatus()
);
}
changes.add(change);
}
}
return changes;
}
示例10: fillCompletionVariants
import com.intellij.openapi.vcs.changes.ContentRevision; //导入方法依赖的package包/类
@Override
public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) {
PsiFile file = parameters.getOriginalFile();
Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
if (document != null) {
DataContext dataContext = document.getUserData(CommitMessage.DATA_CONTEXT_KEY);
if (dataContext != null) {
result.stopHere();
if (parameters.getInvocationCount() > 0) {
ChangeList[] lists = VcsDataKeys.CHANGE_LISTS.getData(dataContext);
if (lists != null) {
String prefix = TextFieldWithAutoCompletionListProvider.getCompletionPrefix(parameters);
CompletionResultSet insensitive = result.caseInsensitive().withPrefixMatcher(new CamelHumpMatcher(prefix));
for (ChangeList list : lists) {
for (Change change : list.getChanges()) {
ContentRevision revision = change.getAfterRevision() == null ? change.getBeforeRevision() : change.getAfterRevision();
if (revision != null) {
FilePath filePath = revision.getFile();
LookupElementBuilder element = LookupElementBuilder.create(filePath.getName()).
withIcon(filePath.getFileType().getIcon());
insensitive.addElement(element);
}
}
}
}
}
}
}
}
示例11: getBig
import com.intellij.openapi.vcs.changes.ContentRevision; //导入方法依赖的package包/类
public static Set<Change> getBig(List<Change> changes) {
final Set<Change> exclude = new HashSet<>();
for (Change change : changes) {
// try to estimate size via VF: we assume that base content hasn't been changed much
VirtualFile virtualFile = getVfFromChange(change);
if (virtualFile != null) {
if (isBig(virtualFile)) {
exclude.add(change);
}
continue;
}
// otherwise, to avoid regression we have to process context length
ContentRevision beforeRevision = change.getBeforeRevision();
if (beforeRevision != null) {
try {
String content = beforeRevision.getContent();
if (content == null) {
final FilePath file = beforeRevision.getFile();
LOG.info("null content for " + (file.getPath()) + ", is dir: " + (file.isDirectory()));
continue;
}
if (content.length() > VcsConfiguration.ourMaximumFileForBaseRevisionSize) {
exclude.add(change);
}
}
catch (VcsException e) {
LOG.info(e);
}
}
}
return exclude;
}
示例12: seemsToBeMoved
import com.intellij.openapi.vcs.changes.ContentRevision; //导入方法依赖的package包/类
private static boolean seemsToBeMoved(Change change, VirtualFile toSelect) {
ContentRevision afterRevision = change.getAfterRevision();
if (afterRevision == null) return false;
FilePath file = afterRevision.getFile();
return FileUtil.pathsEqual(file.getPath(), toSelect.getPath());
}
示例13: CachedContentRevision
import com.intellij.openapi.vcs.changes.ContentRevision; //导入方法依赖的package包/类
public CachedContentRevision(ContentRevision contentRevision) throws VcsException {
myFile = contentRevision.getFile();
myContent = myFile.isDirectory() ? null : contentRevision.getContent();
myRevisionNumber = contentRevision.getRevisionNumber();
}
示例14: seemsToBeMoved
import com.intellij.openapi.vcs.changes.ContentRevision; //导入方法依赖的package包/类
private static boolean seemsToBeMoved(Change change, VirtualFile toSelect) {
ContentRevision afterRevision = change.getAfterRevision();
if (afterRevision == null) return false;
FilePath file = afterRevision.getFile();
return file.getName().equals(toSelect.getName());
}