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


Java ComparisonPolicy类代码示例

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


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

示例1: createCenterPanel

import com.intellij.openapi.diff.impl.ComparisonPolicy; //导入依赖的package包/类
@Nullable
@Override
protected JComponent createCenterPanel() {
  final Project project = myOldMethod.getProject();
  final DiffPanelEx diffPanel = (DiffPanelEx)DiffManager.getInstance().createDiffPanel(null, project, getDisposable(), null);
  diffPanel.setComparisonPolicy(ComparisonPolicy.IGNORE_SPACE);
  diffPanel.setHighlightMode(HighlightMode.BY_WORD);
  DiffPanelOptions diffPanelOptions = diffPanel.getOptions();
  diffPanelOptions.setShowSourcePolicy(DiffPanelOptions.ShowSourcePolicy.OPEN_EDITOR);
  diffPanelOptions.setRequestFocusOnNewContent(false);
  SimpleDiffRequest request = new SimpleDiffRequest(project, null);
  final String oldContent = myOldMethod.getText() + "\n\n\nmethod call:\n " + myOldCall.getText();
  final String newContent = myNewMethod.getText() + "\n\n\nmethod call:\n " + myNewCall.getText();
  request.setContents(new SimpleContent(oldContent), new SimpleContent(newContent));
  request.setContentTitles("Before", "After");
  diffPanel.setDiffRequest(request);
  
  final JPanel panel = new JPanel(new BorderLayout());
  panel.add(diffPanel.getComponent(), BorderLayout.CENTER);
  panel.setBorder(IdeBorderFactory.createEmptyBorder(new Insets(5, 0, 0, 0)));
  return panel;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ExtractMethodSignatureSuggester.java

示例2: loadState

import com.intellij.openapi.diff.impl.ComparisonPolicy; //导入依赖的package包/类
@Override
public void loadState(Element state) {
  myProperties.readExternal(state);

  String policyName = state.getAttributeValue(COMPARISON_POLICY_ATTR_NAME);
  if (policyName != null) {
    for (ComparisonPolicy policy : ComparisonPolicy.getAllInstances()) {
      if (policy.getName().equals(policyName)) {
        myComparisonPolicy = policy;
        break;
      }
    }
  }

  String modeName = state.getAttributeValue(HIGHLIGHT_MODE_ATTR_NAME);
  if (modeName != null) {
    try {
      myHighlightMode = HighlightMode.valueOf(modeName);
    }
    catch (IllegalArgumentException ignore) {
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:DiffManagerImpl.java

示例3: checkNoDifferenceAndNotify

import com.intellij.openapi.diff.impl.ComparisonPolicy; //导入依赖的package包/类
private boolean checkNoDifferenceAndNotify(DiffPanel diffPanel, DiffRequest data, final Window window, final boolean showMessage) {
  if (diffPanel.hasDifferences() || data.getHints().contains(HINT_ALLOW_NO_DIFFERENCES)) {
    return false;
  }

  DiffManagerImpl manager = (DiffManagerImpl)DiffManager.getInstance();
  ComparisonPolicy oldPolicy = manager.getComparisonPolicy();
  if (oldPolicy != ComparisonPolicy.DEFAULT) {
    manager.setComparisonPolicy(ComparisonPolicy.DEFAULT);
    Disposable parentDisposable = Disposer.newDisposable();
    DiffPanel maybeDiffPanel = DiffManagerImpl.createDiffPanel(data, window, parentDisposable, this);
    manager.setComparisonPolicy(oldPolicy);

    boolean hasDiffs = maybeDiffPanel.hasDifferences();
    Disposer.dispose(parentDisposable);

    if (hasDiffs) {
      return false;
    }
  }

  return !showMessage || !askForceOpenDiff(data);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:FrameDiffTool.java

示例4: buildChanges

import com.intellij.openapi.diff.impl.ComparisonPolicy; //导入依赖的package包/类
private ArrayList<Change> buildChanges() throws FilesTooBigForDiffException {
  Document base = getDocument(FragmentSide.SIDE1);
  DiffString[] baseLines = DiffUtil.convertToLines(base.getText());
  Document version = getDocument(FragmentSide.SIDE2);
  DiffString[] versionLines = DiffUtil.convertToLines(version.getText());
  DiffFragment[] fragments = ComparisonPolicy.DEFAULT.buildDiffFragmentsFromLines(baseLines, versionLines);
  final ArrayList<Change> result = new ArrayList<Change>();
  new DiffFragmentsEnumerator(fragments) {
    @Override
    protected void process(DiffFragment fragment) {
      if (fragment.isEqual()) return;
      Context context = getContext();
      TextRange range1 = context.createRange(FragmentSide.SIDE1);
      TextRange range2 = context.createRange(FragmentSide.SIDE2);
      result.add(new SimpleChange(ChangeType.fromDiffFragment(context.getFragment()), range1, range2, ChangeList.this));
    }
  }.execute();
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ChangeList.java

示例5: testChangedSpaceCorrection

import com.intellij.openapi.diff.impl.ComparisonPolicy; //导入依赖的package包/类
public void testChangedSpaceCorrection() throws FilesTooBigForDiffException {
  DiffCorrection correction = new DiffCorrection.ChangedSpace(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = correction.correct(new DiffFragment[]{
      new DiffFragment("x", "y"),
      new DiffFragment(" ", "   "),
      new DiffFragment("ab", "ab"),
      new DiffFragment(" ", " "),
      new DiffFragment(" ", " w o r d"),
      new DiffFragment("   ", " w o r d")});
  CHECK.compareAll(new DiffFragment[]{
    new DiffFragment("x", "y"),
    new DiffFragment(null, "  "), new DiffFragment(" ", " "),
    new DiffFragment("ab", "ab"),
    new DiffFragment(" ", " "),
    new DiffFragment(" ", " "), new DiffFragment(null, "w o r d"),
    new DiffFragment("  ", null), new DiffFragment(" ", " "), new DiffFragment(null, "w o r d")}, fragments);

  fragments = correction.correct(new DiffFragment[]{new DiffFragment("\n  ", "\n ")});
  CHECK.compareAll(new DiffFragment[]{new DiffFragment("\n", "\n"),
                                      new DiffFragment(" ", null), new DiffFragment(" ", " ")}, fragments);
  fragments = correction.correct(new DiffFragment[]{new DiffFragment("\n", "\n\n")});
  CHECK.compareAll(new DiffFragment[]{new DiffFragment("\n", "\n"), new DiffFragment(null, "\n")}, fragments);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:CorrectionTest.java

示例6: checkNoDifferenceAndNotify

import com.intellij.openapi.diff.impl.ComparisonPolicy; //导入依赖的package包/类
private boolean checkNoDifferenceAndNotify(DiffPanel diffPanel, DiffRequest data, final Window window, final boolean showMessage) {
  if (!diffPanel.hasDifferences() && !data.getHints().contains(HINT_ALLOW_NO_DIFFERENCES)) {
    DiffManagerImpl manager = (DiffManagerImpl) DiffManager.getInstance();
    if (!Comparing.equal(manager.getComparisonPolicy(), ComparisonPolicy.DEFAULT)) {
      ComparisonPolicy oldPolicy = manager.getComparisonPolicy();
      manager.setComparisonPolicy(ComparisonPolicy.DEFAULT);
      Disposable parentDisposable = Disposer.newDisposable();
      DiffPanel maybeDiffPanel = DiffManagerImpl.createDiffPanel(data, window, parentDisposable, this);
      manager.setComparisonPolicy(oldPolicy);

      boolean hasDiffs = maybeDiffPanel.hasDifferences();
      Disposer.dispose(parentDisposable);

      if (hasDiffs) return false;
    }

    if (! showMessage) {
      return true;
    }
    return !askForceOpenDiff(data);
  }
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:FrameDiffTool.java

示例7: buildChanges

import com.intellij.openapi.diff.impl.ComparisonPolicy; //导入依赖的package包/类
private ArrayList<Change> buildChanges() throws FilesTooBigForDiffException {
  Document base = getDocument(FragmentSide.SIDE1);
  String[] baseLines = DiffUtil.convertToLines(base.getText());
  Document version = getDocument(FragmentSide.SIDE2);
  String[] versionLines = DiffUtil.convertToLines(version.getText());
  DiffFragment[] fragments = ComparisonPolicy.DEFAULT.buildDiffFragmentsFromLines(baseLines, versionLines);
  final ArrayList<Change> result = new ArrayList<Change>();
  new DiffFragmemntsEnumerator(fragments) {
    protected void process(DiffFragment fragment) {
      if (fragment.isEqual()) return;
      Context context = getContext();
      TextRange range1 = context.createRange(FragmentSide.SIDE1);
      TextRange range2 = context.createRange(FragmentSide.SIDE2);
      result.add(new SimpleChange(ChangeType.fromDiffFragment(context.getFragment()), range1, range2, ChangeList.this));
    }
  }.execute();
  return result;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:ChangeList.java

示例8: getState

import com.intellij.openapi.diff.impl.ComparisonPolicy; //导入依赖的package包/类
@Nullable
@Override
public Element getState() {
  Element state = new Element("state");
  myProperties.writeExternal(state);
  if (myComparisonPolicy != ComparisonPolicy.DEFAULT) {
    state.setAttribute(COMPARISON_POLICY_ATTR_NAME, myComparisonPolicy.getName());
  }
  if (myHighlightMode != HighlightMode.BY_WORD) {
    state.setAttribute(HIGHLIGHT_MODE_ATTR_NAME, myHighlightMode.name());
  }
  return state;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:DiffManagerImpl.java

示例9: testTrueLineBlock

import com.intellij.openapi.diff.impl.ComparisonPolicy; //导入依赖的package包/类
public void testTrueLineBlock() throws FilesTooBigForDiffException {
  DiffCorrection.TrueLineBlocks correction = new DiffCorrection.TrueLineBlocks(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = correction.correctAndNormalize(new DiffFragment[]{
    DiffFragment.unchanged(" 1\n  ab\n x\n", "  2\n ab\n x\n"),
    new DiffFragment("XXX\n111\n", "YYY\n222\n"),
    DiffFragment.unchanged(" a\n", "  a\n")});
  CHECK.compareAll(new DiffFragment[]{new DiffFragment(" 1\n", "  2\n"),
                                      new DiffFragment("  ab\n", " ab\n"),
                                      new DiffFragment(" x\n", " x\n"),
                                      new DiffFragment("XXX\n111\n", "YYY\n222\n"),
                                      new DiffFragment(" a\n", "  a\n")},
                   fragments);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:CorrectionTest.java

示例10: testTrueLineBlocksWithSameLines

import com.intellij.openapi.diff.impl.ComparisonPolicy; //导入依赖的package包/类
public void testTrueLineBlocksWithSameLines() throws FilesTooBigForDiffException {
  DiffCorrection.TrueLineBlocks correction = new DiffCorrection.TrueLineBlocks(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = correction.correctAndNormalize(new DiffFragment[]{
    DiffFragment.unchanged(" X\n  X\n  X", "  X\n X\n  X")});
  CHECK.compareAll(new DiffFragment[]{new DiffFragment(" X\n  X\n", "  X\n X\n"),
                                      new DiffFragment("  X", "  X")},
                   fragments);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:CorrectionTest.java

示例11: test1

import com.intellij.openapi.diff.impl.ComparisonPolicy; //导入依赖的package包/类
public void test1() throws FilesTooBigForDiffException {
  DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = byWord.buildFragments("abc def, 123", "ab def, 12");
  CHECK.compareAll(new DiffFragment[]{new DiffFragment("abc", "ab"),
                                      new DiffFragment(" def, ", " def, "),
                                      new DiffFragment("123", "12")}, fragments);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ByWordTest.java

示例12: test2

import com.intellij.openapi.diff.impl.ComparisonPolicy; //导入依赖的package包/类
public void test2() throws FilesTooBigForDiffException {
  DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = byWord.buildFragments(" a[xy]+1", ",a[]+1");
  CHECK.compareAll(new DiffFragment[]{new DiffFragment(" ", null),
                                      new DiffFragment(null, ","),
                                      new DiffFragment("a[", "a["),
                                      new DiffFragment("xy", null),
                                      new DiffFragment("]+1", "]+1")}, fragments);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ByWordTest.java

示例13: test4

import com.intellij.openapi.diff.impl.ComparisonPolicy; //导入依赖的package包/类
public void test4() throws FilesTooBigForDiffException {
  DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = byWord.buildFragments("  abc\n2222\n", "    x = abc\nzzzz\n");
  CHECK.compareAll(new DiffFragment[]{
    new DiffFragment(null, "  "), new DiffFragment("  ", "  "), new DiffFragment(null, "x"), new DiffFragment(null, " ="),
    new DiffFragment(null, " "),
    new DiffFragment("abc\n", "abc\n"),
    new DiffFragment("2222", "zzzz"),
    new DiffFragment("\n", "\n")}, fragments);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ByWordTest.java

示例14: testIdea58505

import com.intellij.openapi.diff.impl.ComparisonPolicy; //导入依赖的package包/类
public void testIdea58505() throws FilesTooBigForDiffException {
  DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = byWord.buildFragments("   if (eventMerger!=null && !dataSelection.getValueIsAdjusting()) {",
                                                   "   if (eventMerger!=null && (dataSelection==null || !dataSelection.getValueIsAdjusting())) {");
  CHECK.compareAll(new DiffFragment[] {
    new DiffFragment("   if (eventMerger!=null && ", "   if (eventMerger!=null && "),
    new DiffFragment("!", "("),
    new DiffFragment("dataSelection", "dataSelection"),
    new DiffFragment(null, "=="),
    new DiffFragment(null, "null || !dataSelection"),
    new DiffFragment(".getValueIsAdjusting())", ".getValueIsAdjusting())"),
    new DiffFragment(null, ")"),
    new DiffFragment(" {", " {")
  }, fragments);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ByWordTest.java

示例15: testIdea58505Trim

import com.intellij.openapi.diff.impl.ComparisonPolicy; //导入依赖的package包/类
public void testIdea58505Trim() throws FilesTooBigForDiffException {
  DiffPolicy byWord = new ByWord(ComparisonPolicy.TRIM_SPACE);
  DiffFragment[] fragments = byWord.buildFragments("   if (eventMerger!=null && !dataSelection.getValueIsAdjusting()) {",
                                                   "   if (eventMerger!=null && (dataSelection==null || !dataSelection.getValueIsAdjusting())) {");
  CHECK.compareAll(new DiffFragment[] {
    new DiffFragment("   if (eventMerger!=null && ", "   if (eventMerger!=null && "),
    new DiffFragment("!", "("),
    new DiffFragment("dataSelection", "dataSelection"),
    new DiffFragment(null, "=="),
    new DiffFragment(null, "null || !dataSelection"),
    new DiffFragment(".getValueIsAdjusting())", ".getValueIsAdjusting())"),
    new DiffFragment(null, ")"),
    new DiffFragment(" {", " {")
  }, fragments);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ByWordTest.java


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