本文整理汇总了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;
}
示例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) {
}
}
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}