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


Java Change.getType方法代码示例

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


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

示例1: assertChange

import com.intellij.openapi.vcs.changes.Change; //导入方法依赖的package包/类
private void assertChange(Change actualChange, GitTestChange expectedChange) {
  assertEquals(actualChange.getType(), expectedChange.myType);
  switch (actualChange.getType()) {
    case MODIFICATION:
    case MOVED:
      assertEquals(getBeforePath(actualChange), FileUtil.toSystemDependentName(expectedChange.myBeforePath));
      assertEquals(getAfterPath(actualChange), FileUtil.toSystemDependentName(expectedChange.myAfterPath));
      return;
    case NEW:
      assertEquals(getAfterPath(actualChange), FileUtil.toSystemDependentName(expectedChange.myAfterPath));
      return;
    case DELETED:
      assertEquals(getBeforePath(actualChange), FileUtil.toSystemDependentName(expectedChange.myBeforePath));
      return;
    default:
      throw new AssertionError();
  } 
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GitLogParserTest.java

示例2: getChangedTextRanges

import com.intellij.openapi.vcs.changes.Change; //导入方法依赖的package包/类
@Override
@NotNull
public List<TextRange> getChangedTextRanges(@NotNull Project project, @NotNull PsiFile file) throws FilesTooBigForDiffException {
  Document document = PsiDocumentManager.getInstance(project).getDocument(file);
  if (document == null) return ContainerUtil.emptyList();

  List<TextRange> cachedChangedLines = getCachedChangedLines(project, document);
  if (cachedChangedLines != null) {
    return cachedChangedLines;
  }

  if (ApplicationManager.getApplication().isUnitTestMode()) {
    CharSequence testContent = file.getUserData(TEST_REVISION_CONTENT);
    if (testContent != null) {
      return calculateChangedTextRanges(document, testContent);
    }
  }

  Change change = ChangeListManager.getInstance(project).getChange(file.getVirtualFile());
  if (change == null) {
    return ContainerUtilRt.emptyList();
  }
  if (change.getType() == Change.Type.NEW) {
    return ContainerUtil.newArrayList(file.getTextRange());
  }

  String contentFromVcs = getRevisionedContentFrom(change);
  return contentFromVcs != null ? calculateChangedTextRanges(document, contentFromVcs)
                                : ContainerUtil.<TextRange>emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:VcsAwareFormatChangedTextUtil.java

示例3: updateLabelText

import com.intellij.openapi.vcs.changes.Change; //导入方法依赖的package包/类
private void updateLabelText(final Change c) {
  String comment = myChangeList.getComment();
  int pos = comment.indexOf("\n");
  if (pos >= 0) {
    comment = comment.substring(0, pos).trim() + "...";
  }
  final String formattedDate = DateFormatUtil.formatPrettyDateTime(myChangeList.getCommitDate());
  final boolean dateIsPretty = ! formattedDate.contains("/");
  final String key = c.getType() == Change.Type.DELETED ? "outdated.version.text.deleted" :
                     (dateIsPretty ? "outdated.version.pretty.date.text" : "outdated.version.text");
  myLabel.setText(VcsBundle.message(key, myChangeList.getCommitterName(), formattedDate, comment));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:OutdatedVersionNotifier.java

示例4: hasChanges

import com.intellij.openapi.vcs.changes.Change; //导入方法依赖的package包/类
/**
 * Allows to answer if given file or any file below the given directory (any level of nesting) has changes in comparison with VCS.
 * 
 * @param file     target directory to check
 * @param project  target project
 * @return         <code>true</code> if given file or any file below the given directory has changes in comparison with VCS;
 *                 <code>false</code> otherwise
 */
public static boolean hasChanges(@NotNull VirtualFile file, @NotNull Project project) {
  final Collection<Change> changes = ChangeListManager.getInstance(project).getChangesIn(file);
  for (Change change : changes) {
    if (change.getType() == Change.Type.NEW || change.getType() == Change.Type.MODIFICATION) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:FormatChangedTextUtil.java

示例5: update

import com.intellij.openapi.vcs.changes.Change; //导入方法依赖的package包/类
@Override
public void update(final AnActionEvent e) {
  Project project = e.getData(CommonDataKeys.PROJECT);
  VirtualFile virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
  if (project == null || project.isDefault() || virtualFile == null) {
    setVisibleEnabled(e, false, false);
    return;
  }
  GitRepositoryManager manager = GitUtil.getRepositoryManager(project);

  final GitRepository gitRepository = manager.getRepositoryForFile(virtualFile);
  if (gitRepository == null) {
    setVisibleEnabled(e, false, false);
    return;
  }

  if (!GithubUtil.isRepositoryOnGitHub(gitRepository)) {
    setVisibleEnabled(e, false, false);
    return;
  }

  ChangeListManager changeListManager = ChangeListManager.getInstance(project);
  if (changeListManager.isUnversioned(virtualFile)) {
    setVisibleEnabled(e, true, false);
    return;
  }

  Change change = changeListManager.getChange(virtualFile);
  if (change != null && change.getType() == Change.Type.NEW) {
    setVisibleEnabled(e, true, false);
    return;
  }

  setVisibleEnabled(e, true, true);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:GithubOpenInBrowserAction.java

示例6: tos

import com.intellij.openapi.vcs.changes.Change; //导入方法依赖的package包/类
protected String tos(Change change) {
  switch (change.getType()) {
    case NEW: return "A: " + tos(change.getAfterRevision());
    case DELETED: return "D: " + tos(change.getBeforeRevision());
    case MOVED: return "M: " + tos(change.getBeforeRevision()) + " -> " + tos(change.getAfterRevision());
    case MODIFICATION: return "M: " + tos(change.getAfterRevision());
    default: return "~: " +  tos(change.getBeforeRevision()) + " -> " + tos(change.getAfterRevision());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GitChangeProviderTest.java

示例7: rollbackChanges

import com.intellij.openapi.vcs.changes.Change; //导入方法依赖的package包/类
public void rollbackChanges(List<Change> changes, final List<VcsException> exceptions,
                            @NotNull final RollbackProgressListener listener) {
  listener.determinate();
  for (Change change : changes) {
    final FilePath filePath = ChangesUtil.getFilePath(change);
    listener.accept(change);
    final VirtualFile parent = filePath.getVirtualFileParent();
    final String name = filePath.getName();

    switch (change.getType()) {
      case DELETED:
        restoreFile(parent, name);
        break;

      case MODIFICATION:
        restoreFile(parent, name);
        break;

      case MOVED:
        CvsUtil.removeEntryFor(CvsVfsUtil.getFileFor(parent, name));
        break;

      case NEW:
        CvsUtil.removeEntryFor(CvsVfsUtil.getFileFor(parent, name));
        break;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:CvsRollbackEnvironment.java

示例8: process

import com.intellij.openapi.vcs.changes.Change; //导入方法依赖的package包/类
public boolean process(final Change item) {
  return item.getType() == Change.Type.MODIFICATION || item.getType() == Change.Type.MOVED;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:ChangeInfoCalculator.java

示例9: rollbackChanges

import com.intellij.openapi.vcs.changes.Change; //导入方法依赖的package包/类
public void rollbackChanges(List<Change> changes, List<VcsException> vcsExceptions,
  @NotNull RollbackProgressListener listener) {
  if (changes == null || changes.isEmpty()) {
    return;
  }
  List<FilePath> toDelete = new ArrayList<FilePath>();
  List<FilePath> filePaths = new LinkedList<FilePath>();
  for (Change change : changes) {
    ContentRevision contentRevision;
    if (Change.Type.DELETED == change.getType()) {
      contentRevision = change.getBeforeRevision();
    }
    else {
      contentRevision = change.getAfterRevision();
    }
    if (contentRevision != null) {
      filePaths.add(contentRevision.getFile());
      if (Change.Type.MOVED == change.getType()) {
        toDelete.add(contentRevision.getFile());
      }
    }
  }
  AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
  try {
    revert(filePaths);
    for (FilePath file : toDelete) {
      listener.accept(file);
      try {
        final File ioFile = file.getIOFile();
        if (ioFile.exists()) {
          if (!ioFile.delete()) {
            //noinspection ThrowableInstanceNeverThrown
            vcsExceptions.add(new VcsException("Unable to delete file: " + file));
          }
        }
      }
      catch (Exception e) {
        //noinspection ThrowableInstanceNeverThrown
        vcsExceptions.add(new VcsException("Unable to delete file: " + file, e));
      }
    }
  }
  finally {
    DvcsUtil.workingTreeChangeFinished(project, token);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:47,代码来源:HgRollbackEnvironment.java


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