Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.team.ui')
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RangeDifferenceComparator.java150
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffComparator.java146
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffFilter.java128
3 files changed, 212 insertions, 212 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RangeDifferenceComparator.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RangeDifferenceComparator.java
index db893fc7d..467a4d616 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RangeDifferenceComparator.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RangeDifferenceComparator.java
@@ -1,78 +1,78 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ui.synchronize;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.compare.internal.DocLineComparator;
-import org.eclipse.compare.internal.Utilities;
-import org.eclipse.compare.rangedifferencer.RangeDifference;
-import org.eclipse.compare.rangedifferencer.RangeDifferencer;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Region;
-import org.eclipse.team.internal.core.subscribers.AbstractContentComparator;
-
-/**
- * Compare differences between local and remote contents.
- * <p>
- * Subclass to specify a criterion for comparison.
- */
-public abstract class RangeDifferenceComparator extends
- AbstractContentComparator {
-
- public RangeDifferenceComparator(boolean ignoreWhitespace) {
- super(ignoreWhitespace);
- }
-
- /**
- * Return <code>true</code> if the provided differences match a criterion.
- *
- * @param ranges the differences found
- * @param lDoc the left document
- * @param rDoc the right document
- * @return <code>true</code> if all differences match a criterion
- */
- abstract protected boolean compareRangeDifferences(RangeDifference[] ranges,
- IDocument lDoc, IDocument rDoc);
-
- @Override
- protected boolean contentsEqual(IProgressMonitor monitor, InputStream is1,
- InputStream is2, boolean ignoreWhitespace) {
- try {
- final String left = Utilities.readString(is1, ResourcesPlugin.getEncoding());
- final String right = Utilities.readString(is2, ResourcesPlugin.getEncoding());
- return compareStrings(left, right, monitor);
- } catch (IOException e) {
- // ignore
- }
- return false;
- }
-
- private boolean compareStrings(String left, String right,
- IProgressMonitor monitor) {
- IDocument lDoc = new Document(left);
- IDocument rDoc = new Document(right);
- DocLineComparator sleft = new DocLineComparator(lDoc, new Region(0,
- lDoc.getLength()), shouldIgnoreWhitespace());
- DocLineComparator sright = new DocLineComparator(rDoc, new Region(0,
- rDoc.getLength()), shouldIgnoreWhitespace());
- final DocLineComparator sl = sleft, sr = sright;
- RangeDifference[] ranges = RangeDifferencer.findRanges(monitor, sl, sr);
- return compareRangeDifferences(ranges, lDoc, rDoc);
- }
-}
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.compare.internal.DocLineComparator;
+import org.eclipse.compare.internal.Utilities;
+import org.eclipse.compare.rangedifferencer.RangeDifference;
+import org.eclipse.compare.rangedifferencer.RangeDifferencer;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Region;
+import org.eclipse.team.internal.core.subscribers.AbstractContentComparator;
+
+/**
+ * Compare differences between local and remote contents.
+ * <p>
+ * Subclass to specify a criterion for comparison.
+ */
+public abstract class RangeDifferenceComparator extends
+ AbstractContentComparator {
+
+ public RangeDifferenceComparator(boolean ignoreWhitespace) {
+ super(ignoreWhitespace);
+ }
+
+ /**
+ * Return <code>true</code> if the provided differences match a criterion.
+ *
+ * @param ranges the differences found
+ * @param lDoc the left document
+ * @param rDoc the right document
+ * @return <code>true</code> if all differences match a criterion
+ */
+ abstract protected boolean compareRangeDifferences(RangeDifference[] ranges,
+ IDocument lDoc, IDocument rDoc);
+
+ @Override
+ protected boolean contentsEqual(IProgressMonitor monitor, InputStream is1,
+ InputStream is2, boolean ignoreWhitespace) {
+ try {
+ final String left = Utilities.readString(is1, ResourcesPlugin.getEncoding());
+ final String right = Utilities.readString(is2, ResourcesPlugin.getEncoding());
+ return compareStrings(left, right, monitor);
+ } catch (IOException e) {
+ // ignore
+ }
+ return false;
+ }
+
+ private boolean compareStrings(String left, String right,
+ IProgressMonitor monitor) {
+ IDocument lDoc = new Document(left);
+ IDocument rDoc = new Document(right);
+ DocLineComparator sleft = new DocLineComparator(lDoc, new Region(0,
+ lDoc.getLength()), shouldIgnoreWhitespace());
+ DocLineComparator sright = new DocLineComparator(rDoc, new Region(0,
+ rDoc.getLength()), shouldIgnoreWhitespace());
+ final DocLineComparator sl = sleft, sr = sright;
+ RangeDifference[] ranges = RangeDifferencer.findRanges(monitor, sl, sr);
+ return compareRangeDifferences(ranges, lDoc, rDoc);
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffComparator.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffComparator.java
index b7bedc8ab..9176a40c1 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffComparator.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffComparator.java
@@ -1,77 +1,77 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ui.synchronize;
-
-import java.util.regex.Pattern;
-
-import org.eclipse.compare.internal.DocLineComparator;
-import org.eclipse.compare.rangedifferencer.RangeDifference;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-
-/**
- * Compute differences between local and remote contents and checks if all match
- * the given regex pattern. If there is at least one diff whose either left or
- * right side don't match the pattern
- * <code>{@link #compareRangeDifferences(RangeDifference[], IDocument, IDocument)}</code>
- * returns <code>false</code>.
- */
-public class RegexDiffComparator extends RangeDifferenceComparator {
-
- private Pattern pattern;
-
- public RegexDiffComparator(Pattern pattern, boolean ignoreWhitespace) {
- super(ignoreWhitespace);
- this.pattern = pattern;
- }
-
- @Override
- protected boolean compareRangeDifferences(RangeDifference[] ranges,
- IDocument lDoc, IDocument rDoc) {
- try {
- for (int i = 0; i < ranges.length; i++) {
- RangeDifference diff = ranges[i];
- if (diff.kind() == RangeDifference.NOCHANGE)
- continue;
-
- DocLineComparator sleft = new DocLineComparator(lDoc, null,
- shouldIgnoreWhitespace());
- DocLineComparator sright = new DocLineComparator(rDoc, null,
- shouldIgnoreWhitespace());
-
- IRegion lRegion = lDoc.getLineInformation(diff.leftStart());
- int leftEnd = sleft.getTokenStart(diff.leftStart()
- + diff.leftLength());
- String left = lDoc.get(lRegion.getOffset(),
- leftEnd - lRegion.getOffset());
- IRegion rRegion = rDoc.getLineInformation(diff.rightStart());
- int rightEnd = sright.getTokenStart(diff.rightStart()
- + diff.rightLength());
- String right = rDoc.get(rRegion.getOffset(),
- rightEnd - rRegion.getOffset());
-
- boolean m1 = pattern.matcher(left).matches();
- boolean m2 = pattern.matcher(right).matches();
-
- if (!m1 && !m2)
- // it's false that all diffs match the pattern
- return false;
- }
- } catch (BadLocationException e) {
- // ignore
- }
- return true;
- }
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize;
+
+import java.util.regex.Pattern;
+
+import org.eclipse.compare.internal.DocLineComparator;
+import org.eclipse.compare.rangedifferencer.RangeDifference;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+
+/**
+ * Compute differences between local and remote contents and checks if all match
+ * the given regex pattern. If there is at least one diff whose either left or
+ * right side don't match the pattern
+ * <code>{@link #compareRangeDifferences(RangeDifference[], IDocument, IDocument)}</code>
+ * returns <code>false</code>.
+ */
+public class RegexDiffComparator extends RangeDifferenceComparator {
+
+ private Pattern pattern;
+
+ public RegexDiffComparator(Pattern pattern, boolean ignoreWhitespace) {
+ super(ignoreWhitespace);
+ this.pattern = pattern;
+ }
+
+ @Override
+ protected boolean compareRangeDifferences(RangeDifference[] ranges,
+ IDocument lDoc, IDocument rDoc) {
+ try {
+ for (int i = 0; i < ranges.length; i++) {
+ RangeDifference diff = ranges[i];
+ if (diff.kind() == RangeDifference.NOCHANGE)
+ continue;
+
+ DocLineComparator sleft = new DocLineComparator(lDoc, null,
+ shouldIgnoreWhitespace());
+ DocLineComparator sright = new DocLineComparator(rDoc, null,
+ shouldIgnoreWhitespace());
+
+ IRegion lRegion = lDoc.getLineInformation(diff.leftStart());
+ int leftEnd = sleft.getTokenStart(diff.leftStart()
+ + diff.leftLength());
+ String left = lDoc.get(lRegion.getOffset(),
+ leftEnd - lRegion.getOffset());
+ IRegion rRegion = rDoc.getLineInformation(diff.rightStart());
+ int rightEnd = sright.getTokenStart(diff.rightStart()
+ + diff.rightLength());
+ String right = rDoc.get(rRegion.getOffset(),
+ rightEnd - rRegion.getOffset());
+
+ boolean m1 = pattern.matcher(left).matches();
+ boolean m2 = pattern.matcher(right).matches();
+
+ if (!m1 && !m2)
+ // it's false that all diffs match the pattern
+ return false;
+ }
+ } catch (BadLocationException e) {
+ // ignore
+ }
+ return true;
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffFilter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffFilter.java
index 90076303d..9a01c1135 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffFilter.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffFilter.java
@@ -1,68 +1,68 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ui.synchronize;
-
-import java.util.regex.Pattern;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.diff.DiffFilter;
-import org.eclipse.team.core.diff.IDiff;
-import org.eclipse.team.core.history.IFileRevision;
-import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
-import org.eclipse.team.internal.core.mapping.SyncInfoToDiffConverter;
-import org.eclipse.team.internal.core.subscribers.AbstractContentComparator;
-
-public class RegexDiffFilter extends DiffFilter {
-
- AbstractContentComparator criteria;
-
- boolean ignoreWhiteSpace;
-
- /**
- * Create a filter that does not ignore whitespace.
- *
- * @param pattern
- * regex pattern
- */
- public RegexDiffFilter(String pattern) {
- this(false, pattern);
- }
-
- /**
- * Create a filter and configure how whitespace is handled.
- *
- * @param ignoreWhitespace
- * whether whitespace should be ignored
- * @param pattern
- * regex pattern
- */
- public RegexDiffFilter(boolean ignoreWhitespace, String pattern) {
- criteria = new RegexDiffComparator(Pattern.compile(pattern,
- Pattern.DOTALL), ignoreWhitespace);
- }
-
- @Override
- public boolean select(IDiff diff, IProgressMonitor monitor) {
- IFileRevision remote = SyncInfoToDiffConverter.getRemote(diff);
- IResource local = ResourceDiffTree.getResourceFor(diff);
- if (local == null || local.getType() != IResource.FILE)
- return true;
- if (remote == null)
- return !local.exists();
- if (!local.exists())
- return false;
- return criteria.compare(local, remote, monitor);
- }
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize;
+
+import java.util.regex.Pattern;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.diff.DiffFilter;
+import org.eclipse.team.core.diff.IDiff;
+import org.eclipse.team.core.history.IFileRevision;
+import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
+import org.eclipse.team.internal.core.mapping.SyncInfoToDiffConverter;
+import org.eclipse.team.internal.core.subscribers.AbstractContentComparator;
+
+public class RegexDiffFilter extends DiffFilter {
+
+ AbstractContentComparator criteria;
+
+ boolean ignoreWhiteSpace;
+
+ /**
+ * Create a filter that does not ignore whitespace.
+ *
+ * @param pattern
+ * regex pattern
+ */
+ public RegexDiffFilter(String pattern) {
+ this(false, pattern);
+ }
+
+ /**
+ * Create a filter and configure how whitespace is handled.
+ *
+ * @param ignoreWhitespace
+ * whether whitespace should be ignored
+ * @param pattern
+ * regex pattern
+ */
+ public RegexDiffFilter(boolean ignoreWhitespace, String pattern) {
+ criteria = new RegexDiffComparator(Pattern.compile(pattern,
+ Pattern.DOTALL), ignoreWhitespace);
+ }
+
+ @Override
+ public boolean select(IDiff diff, IProgressMonitor monitor) {
+ IFileRevision remote = SyncInfoToDiffConverter.getRemote(diff);
+ IResource local = ResourceDiffTree.getResourceFor(diff);
+ if (local == null || local.getType() != IResource.FILE)
+ return true;
+ if (remote == null)
+ return !local.exists();
+ if (!local.exists())
+ return false;
+ return criteria.compare(local, remote, monitor);
+ }
} \ No newline at end of file

Back to the top