• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LocalHistory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: deleteElement

import com.intellij.history.LocalHistory; //导入依赖的package包/类
@Override
public void deleteElement(@NotNull DataContext dataContext) {
  List<PsiDirectory> allElements = Arrays.asList(getSelectedDirectories());
  List<PsiElement> validElements = new ArrayList<PsiElement>();
  for (PsiElement psiElement : allElements) {
    if (psiElement != null && psiElement.isValid()) validElements.add(psiElement);
  }
  final PsiElement[] elements = PsiUtilCore.toPsiElementArray(validElements);

  LocalHistoryAction a = LocalHistory.getInstance().startAction(IdeBundle.message("progress.deleting"));
  try {
    DeleteHandler.deletePsiElement(elements, myProject);
  }
  finally {
    a.finish();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PackageViewPane.java


示例2: performRefactoring

import com.intellij.history.LocalHistory; //导入依赖的package包/类
protected void performRefactoring(@NotNull UsageInfo[] usages) {
  final PsiMigration psiMigration = PsiMigrationManager.getInstance(myProject).startMigration();
  LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());

  try {
    for (int i = 0; i < myMigrationMap.getEntryCount(); i++) {
      MigrationMapEntry entry = myMigrationMap.getEntryAt(i);
      if (entry.getType() == MigrationMapEntry.PACKAGE) {
        MigrationUtil.doPackageMigration(myProject, psiMigration, entry.getNewName(), usages);
      }
      if (entry.getType() == MigrationMapEntry.CLASS) {
        MigrationUtil.doClassMigration(myProject, psiMigration, entry.getNewName(), usages);
      }
    }

    for(RefactoringHelper helper: Extensions.getExtensions(RefactoringHelper.EP_NAME)) {
      Object preparedData = helper.prepareOperation(usages);
      //noinspection unchecked
      helper.performOperation(myProject, preparedData);
    }
  }
  finally {
    a.finish();
    psiMigration.finish();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:MigrationProcessor.java


示例3: doRefactoring

import com.intellij.history.LocalHistory; //导入依赖的package包/类
private void doRefactoring() throws IncorrectOperationException {
  LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());
  final PsiClass anInterface;
  try {
    anInterface = extractInterface(myTargetDir, myClass, myInterfaceName, mySelectedMembers, myJavaDocPolicy);
  }
  finally {
    a.finish();
  }

  if (anInterface != null) {
    final SmartPsiElementPointer<PsiClass> classPointer = SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(myClass);
    final SmartPsiElementPointer<PsiClass> interfacePointer = SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(anInterface);
    final Runnable turnRefsToSuperRunnable = new Runnable() {
      @Override
      public void run() {
        ExtractClassUtil.askAndTurnRefsToSuper(myProject, classPointer, interfacePointer);
      }
    };
    SwingUtilities.invokeLater(turnRefsToSuperRunnable);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ExtractInterfaceHandler.java


示例4: performRefactoring

import com.intellij.history.LocalHistory; //导入依赖的package包/类
protected void performRefactoring(@NotNull UsageInfo[] usages) {
  RangeMarker position = null;
  if (myEditor != null) {
    final int offset = myEditor.getCaretModel().getOffset();
    position = myEditor.getDocument().createRangeMarker(offset, offset + 1);
  }

  LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());
  try {
    doRefactoring(usages);
  }
  finally {
    a.finish();
  }

  if (position != null) {
    if (position.isValid()) {
      myEditor.getCaretModel().moveToOffset(position.getStartOffset());
    }
    position.dispose();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:InlineMethodProcessor.java


示例5: visit

import com.intellij.history.LocalHistory; //导入依赖的package包/类
@Override
public void visit(CreateEntryChange c) throws StopVisitingException {
  if (shouldRevert(c)) {
    VirtualFile f = myGateway.findVirtualFile(c.getPath());
    if (f != null) {
      unregisterDelayedApplies(f);
      try {
        f.delete(LocalHistory.VFS_EVENT_REQUESTOR);
      }
      catch (IOException e) {
        throw new RuntimeIOException(e);
      }
    }
  }
  checkShouldStop(c);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:UndoChangeRevertingVisitor.java


示例6: undoOrRedo

import com.intellij.history.LocalHistory; //导入依赖的package包/类
private void undoOrRedo(boolean isUndo) {
  LocalHistoryAction action;
  if (myProject != null && isGlobal()) {
    String actionName = CommonBundle.message(isUndo ? "local.vcs.action.name.undo.command" : "local.vcs.action.name.redo.command", myCommandName);
    action = LocalHistory.getInstance().startAction(actionName);
  }
  else {
    action = LocalHistoryAction.NULL;
  }

  try {
    doUndoOrRedo(isUndo);
  }
  finally {
    action.finish();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:UndoableGroup.java


示例7: testPuttingUserLabel

import com.intellij.history.LocalHistory; //导入依赖的package包/类
public void testPuttingUserLabel() throws Exception {
  VirtualFile f = myRoot.createChildData(null, "f.txt");

  LocalHistory.getInstance().putUserLabel(myProject, "global");

  assertEquals(3, getRevisionsFor(f).size());
  assertEquals(3, getRevisionsFor(myRoot).size());

  LocalHistory.getInstance().putUserLabel(myProject, "file");

  List<Revision> rr = getRevisionsFor(f);
  assertEquals(4, rr.size());
  assertEquals("file", rr.get(1).getLabel());
  assertEquals(-1, rr.get(1).getLabelColor());
  assertEquals("global", rr.get(2).getLabel());
  assertEquals(-1, rr.get(2).getLabelColor());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:BasicsTest.java


示例8: testPuttingSystemLabel

import com.intellij.history.LocalHistory; //导入依赖的package包/类
public void testPuttingSystemLabel() throws IOException {
  VirtualFile f = myRoot.createChildData(null, "file.txt");

  assertEquals(2, getRevisionsFor(f).size());
  assertEquals(2, getRevisionsFor(myRoot).size());

  LocalHistory.getInstance().putSystemLabel(myProject, "label");

  List<Revision> rr = getRevisionsFor(f);
  assertEquals(3, rr.size());
  assertEquals("label", rr.get(1).getLabel());

  rr = getRevisionsFor(myRoot);
  assertEquals(3, rr.size());
  assertEquals("label", rr.get(1).getLabel());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:BasicsTest.java


示例9: testPuttingLabelWithUnsavedDocuments

import com.intellij.history.LocalHistory; //导入依赖的package包/类
public void testPuttingLabelWithUnsavedDocuments() throws Exception {
  VirtualFile f = myRoot.createChildData(null, "f.txt");
  setContent(f, "1");

  setDocumentTextFor(f, "2");
  LocalHistory.getInstance().putSystemLabel(myProject, "label");

  setDocumentTextFor(f, "3");
  LocalHistory.getInstance().putUserLabel(myProject, "label");

  setDocumentTextFor(f, "4");
  LocalHistory.getInstance().putUserLabel(myProject, "label");

  List<Revision> rr = getRevisionsFor(f);
  assertEquals(9, rr.size()); // 5 changes + 3 labels
  assertEquals("4", new String(rr.get(0).findEntry().getContent().getBytes()));
  assertEquals("4", new String(rr.get(1).findEntry().getContent().getBytes()));
  assertEquals("3", new String(rr.get(2).findEntry().getContent().getBytes()));
  assertEquals("3", new String(rr.get(3).findEntry().getContent().getBytes()));
  assertEquals("2", new String(rr.get(4).findEntry().getContent().getBytes()));
  assertEquals("2", new String(rr.get(5).findEntry().getContent().getBytes()));
  assertEquals("1", new String(rr.get(6).findEntry().getContent().getBytes()));
  assertEquals("", new String(rr.get(7).findEntry().getContent().getBytes()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:BasicsTest.java


示例10: testDoNotRegisterSameUnsavedDocumentContentTwice

import com.intellij.history.LocalHistory; //导入依赖的package包/类
public void testDoNotRegisterSameUnsavedDocumentContentTwice() throws Exception {
  VirtualFile f = myRoot.createChildData(null, "f.txt");
  setContent(f, "1");

  setDocumentTextFor(f, "2");
  LocalHistory.getInstance().putSystemLabel(myProject, "label");
  LocalHistory.getInstance().putUserLabel(myProject, "label");

  List<Revision> rr = getRevisionsFor(f);
  assertEquals(6, rr.size()); // 3 changes + 2 labels
  assertEquals("2", new String(rr.get(0).findEntry().getContent().getBytes()));
  assertEquals("2", new String(rr.get(1).findEntry().getContent().getBytes()));
  assertEquals("2", new String(rr.get(2).findEntry().getContent().getBytes()));
  assertEquals("1", new String(rr.get(3).findEntry().getContent().getBytes()));
  assertEquals("", new String(rr.get(4).findEntry().getContent().getBytes()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:BasicsTest.java


示例11: testSavingDocumentBeforeAndAfterAction

import com.intellij.history.LocalHistory; //导入依赖的package包/类
public void testSavingDocumentBeforeAndAfterAction() throws Exception {
  VirtualFile f = createFile("f.txt", "file1");
  loadContent(f);
  setContent(f, "file2");

  setDocumentTextFor(f, "doc1");

  LocalHistoryAction a = LocalHistory.getInstance().startAction("name");
  setDocumentTextFor(f, "doc2");
  a.finish();

  List<Revision> rr = getRevisionsFor(f);
  assertEquals(5, rr.size());
  assertContent("doc2", rr.get(0).findEntry());
  assertEquals("name", rr.get(1).getChangeSetName());
  assertContent("doc1", rr.get(1).findEntry());
  assertContent("file2", rr.get(2).findEntry());
  assertContent("file1", rr.get(3).findEntry());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ActionsTest.java


示例12: testActionInsideCommand

import com.intellij.history.LocalHistory; //导入依赖的package包/类
/**
 * <strong>This is very important test.</strong>
 * Almost all actions are performed inside surrounding command.
 * Therefore we have to correctly handle such situations.
 */
public void testActionInsideCommand() throws Exception {
  final VirtualFile f = createFile("f.txt");
  setContent(f, "file");
  setDocumentTextFor(f, "doc1");

  CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
    @Override
    public void run() {
      LocalHistoryAction a = LocalHistory.getInstance().startAction("action");
      setDocumentTextFor(f, "doc2");
      a.finish();
    }
  }, "command", null);

  List<Revision> rr = getRevisionsFor(f);
  assertEquals(5, rr.size());
  assertContent("doc2", rr.get(0).findEntry());
  assertEquals("command", rr.get(1).getChangeSetName());
  assertContent("doc1", rr.get(1).findEntry());
  assertContent("file", rr.get(2).findEntry());
  assertContent("", rr.get(3).findEntry());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:ActionsTest.java


示例13: addLabel

import com.intellij.history.LocalHistory; //导入依赖的package包/类
public static void addLabel(final TestFrameworkRunningModel model) {
  String label;
  int color;

  if (model.getRoot().isDefect()) {
    color = RED.getRGB();
    label = ExecutionBundle.message("junit.runing.info.tests.failed.label");
  }
  else {
    color = GREEN.getRGB();
    label = ExecutionBundle.message("junit.runing.info.tests.passed.label");
  }
  final TestConsoleProperties consoleProperties = model.getProperties();
  String name = label + " " + consoleProperties.getConfiguration().getName();

  Project project = consoleProperties.getProject();
  if (project.isDisposed()) return;

  LocalHistory.getInstance().putSystemLabel(project, name, color);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:LvcsHelper.java


示例14: deleteElement

import com.intellij.history.LocalHistory; //导入依赖的package包/类
@Override
public void deleteElement(@NotNull DataContext dataContext) {
  List<PsiElement> allElements = Arrays.asList(getElementsToDelete());
  List<PsiElement> validElements = new ArrayList<PsiElement>();
  for (PsiElement psiElement : allElements) {
    if (psiElement != null && psiElement.isValid()) validElements.add(psiElement);
  }
  final PsiElement[] elements = PsiUtilCore.toPsiElementArray(validElements);

  LocalHistoryAction a = LocalHistory.getInstance().startAction(IdeBundle.message("progress.deleting"));
  try {
    DeleteHandler.deletePsiElement(elements, myProject);
  }
  finally {
    a.finish();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ProjectViewImpl.java


示例15: deleteElement

import com.intellij.history.LocalHistory; //导入依赖的package包/类
@Override
public void deleteElement(@NotNull DataContext dataContext) {
  List<PsiElement> allElements = Arrays.asList(getSelectedPsiElements());
  ArrayList<PsiElement> validElements = new ArrayList<PsiElement>();
  for (PsiElement psiElement : allElements) {
    if (psiElement != null && psiElement.isValid()) validElements.add(psiElement);
  }
  final PsiElement[] elements = PsiUtilCore.toPsiElementArray(validElements);

  LocalHistoryAction a = LocalHistory.getInstance().startAction(IdeBundle.message("progress.deleting"));
  try {
    DeleteHandler.deletePsiElement(elements, myProject);
  }
  finally {
    a.finish();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ScopeTreeViewPanel.java


示例16: renameElement

import com.intellij.history.LocalHistory; //导入依赖的package包/类
@Override
public void renameElement(PsiElement element, final String newName, UsageInfo[] usages, @Nullable RefactoringElementListener listener)
  throws IncorrectOperationException {
  if (element instanceof PsiField) {
    new RenameJavaVariableProcessor().renameElement(element, newName, usages, listener);
  }
  else {
    if (element instanceof PsiNamedElement) {
      super.renameElement(element, newName, usages, listener);

      if (element instanceof PsiFile) {
        VirtualFile virtualFile = ((PsiFile)element).getVirtualFile();
        if (virtualFile != null && !LocalHistory.getInstance().isUnderControl(virtualFile)) {
          DocumentReference ref = DocumentReferenceManager.getInstance().create(virtualFile);
          UndoManager.getInstance(element.getProject()).nonundoableActionPerformed(ref, false);
        }
      }
    }
    else if (element instanceof XmlAttributeValue) {
      new RenameXmlAttributeProcessor().renameElement(element, newName, usages, listener);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AndroidResourceRenameResourceProcessor.java


示例17: doRefactoring

import com.intellij.history.LocalHistory; //导入依赖的package包/类
private void doRefactoring() throws IncorrectOperationException {
  LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());
  final PsiClass anInterface;
  try {
    anInterface = extractInterface(myTargetDir, myClass, myInterfaceName, mySelectedMembers, myJavaDocPolicy);
  }
  finally {
    a.finish();
  }


  if (anInterface != null) {
    final SmartPsiElementPointer<PsiClass> classPointer =
      SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(myClass);
    final SmartPsiElementPointer<PsiClass> interfacePointer =
      SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(anInterface);
    final Runnable turnRefsToSuperRunnable = new Runnable() {
      @Override
      public void run() {
        ExtractClassUtil.askAndTurnRefsToSuper(myProject, classPointer, interfacePointer);
      }
    };
    SwingUtilities.invokeLater(turnRefsToSuperRunnable);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:GrExtractInterfaceHandler.java


示例18: beforeMerge

import com.intellij.history.LocalHistory; //导入依赖的package包/类
@NotNull
public MergeState beforeMerge() {
    //record the starting revision number
    GitRevisionNumber start;
    try {
        start = GitRevisionNumber.resolve(project, root, "HEAD");
    } catch (Exception e) {
        //we failed to get a revision number, that shouldn't stop us from updating the branch
        start = null;
    }

    final String beforeLabel = getBeforeLocalHistoryLabel();
    Label before = LocalHistory.getInstance().putSystemLabel(project, beforeLabel);
    LocalHistoryAction myLocalHistoryAction = LocalHistory.getInstance().startAction(beforeLabel);

    //keep track of all updated files
    UpdatedFiles updatedFiles = UpdatedFiles.create();
    return new MergeState(project, root, repoName, localBranchName, remoteBranchName,
            start, before, myLocalHistoryAction, updatedFiles);
}
 
开发者ID:JChrist,项目名称:gitextender,代码行数:21,代码来源:BeforeMergeHandler.java


示例19: performRefactoring

import com.intellij.history.LocalHistory; //导入依赖的package包/类
protected void performRefactoring(UsageInfo[] usages) {
  final PsiMigration psiMigration = PsiMigrationManager.getInstance(myProject).startMigration();
  LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());

  try {
    for (int i = 0; i < myMigrationMap.getEntryCount(); i++) {
      MigrationMapEntry entry = myMigrationMap.getEntryAt(i);
      if (entry.getType() == MigrationMapEntry.PACKAGE) {
        MigrationUtil.doPackageMigration(myProject, psiMigration, entry.getNewName(), usages);
      }
      if (entry.getType() == MigrationMapEntry.CLASS) {
        MigrationUtil.doClassMigration(myProject, psiMigration, entry.getNewName(), usages);
      }
    }

    for(RefactoringHelper helper: Extensions.getExtensions(RefactoringHelper.EP_NAME)) {
      Object preparedData = helper.prepareOperation(usages);
      //noinspection unchecked
      helper.performOperation(myProject, preparedData);
    }
  }
  finally {
    a.finish();
    psiMigration.finish();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:MigrationProcessor.java


示例20: testSavingDocumentBeforeAndAfterAction

import com.intellij.history.LocalHistory; //导入依赖的package包/类
public void testSavingDocumentBeforeAndAfterAction() throws Exception {
  VirtualFile f = createFile("f.txt", "file1");
  setContent(f, "file2");

  setDocumentTextFor(f, "doc1");
  LocalHistoryAction a = LocalHistory.getInstance().startAction("name");

  setDocumentTextFor(f, "doc2");
  a.finish();

  List<Revision> rr = getRevisionsFor(f);
  assertEquals(5, rr.size());
  assertContent("doc2", rr.get(0).findEntry());
  assertEquals("name", rr.get(1).getChangeSetName());
  assertContent("doc1", rr.get(1).findEntry());
  assertContent("file2", rr.get(2).findEntry());
  assertContent("file1", rr.get(3).findEntry());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:ActionsTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XSNamespaceItem类代码示例发布时间:2022-05-23
下一篇:
Java Opcodes类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap