Skip to content

Commit af1f8ef

Browse files
Replace UnifiedDiffMode enum with type-safe constant class
1 parent b1db4f4 commit af1f8ef

15 files changed

Lines changed: 168 additions & 26 deletions

team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
import org.eclipse.compare.structuremergeviewer.SharedDocumentAdapterWrapper;
5757
import org.eclipse.compare.structuremergeviewer.StructureDiffViewer;
5858
import org.eclipse.compare.unifieddiff.UnifiedDiff;
59-
import org.eclipse.compare.unifieddiff.UnifiedDiff.UnifiedDiffMode;
59+
import org.eclipse.compare.unifieddiff.UnifiedDiffMode;
6060
import org.eclipse.core.resources.IFile;
6161
import org.eclipse.core.resources.IResource;
6262
import org.eclipse.core.runtime.Adapters;

team/bundles/org.eclipse.compare/compare/org/eclipse/compare/unifieddiff/UnifiedDiff.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 SAP
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* SAP - initial implementation
13+
*******************************************************************************/
114
package org.eclipse.compare.unifieddiff;
215

316
import java.util.List;
@@ -17,24 +30,6 @@ public final class UnifiedDiff {
1730
private UnifiedDiff() {
1831
}
1932

20-
public static enum UnifiedDiffMode {
21-
/**
22-
* Diffs are directly applied in the editor. Users have the possibility to keep
23-
* or undo the applied diffs.
24-
*/
25-
REPLACE_MODE,
26-
/**
27-
* The source in the editor is not modified. Diffs are shown as code mining and
28-
* users have the possibility to apply or cancel individual diffs.
29-
*/
30-
OVERLAY_MODE,
31-
/**
32-
* The source in the editor is not modified. Diffs are shown as code mining and
33-
* users cannot apply or dismiss the diffs (read-only mode).
34-
*/
35-
OVERLAY_READ_ONLY_MODE
36-
}
37-
3833
@FunctionalInterface
3934
public static interface TokenComparatorFactory extends Function<String, ITokenComparator> {
4035
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 SAP
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* SAP - initial implementation
13+
*******************************************************************************/
14+
package org.eclipse.compare.unifieddiff;
15+
16+
public class UnifiedDiffMode {
17+
/**
18+
* Diffs are directly applied in the editor. Users have the possibility to keep
19+
* or undo the applied diffs.
20+
*/
21+
public static final UnifiedDiffMode REPLACE_MODE = new UnifiedDiffMode("REPLACE_MODE"); //$NON-NLS-1$
22+
/**
23+
* The source in the editor is not modified. Diffs are shown as code mining and
24+
* users have the possibility to apply or cancel individual diffs.
25+
*/
26+
public static final UnifiedDiffMode OVERLAY_MODE = new UnifiedDiffMode("OVERLAY_MODE"); //$NON-NLS-1$
27+
/**
28+
* The source in the editor is not modified. Diffs are shown as code mining and
29+
* users cannot apply or dismiss the diffs (read-only mode).
30+
*/
31+
public static final UnifiedDiffMode OVERLAY_READ_ONLY_MODE = new UnifiedDiffMode("OVERLAY_READ_ONLY_MODE"); //$NON-NLS-1$
32+
33+
private final String name;
34+
35+
private UnifiedDiffMode(String name) {
36+
this.name = name;
37+
}
38+
39+
@Override
40+
public String toString() {
41+
return name;
42+
}
43+
}

team/bundles/org.eclipse.compare/compare/org/eclipse/compare/unifieddiff/internal/AcceptAllRunnable.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 SAP
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* SAP - initial implementation
13+
*******************************************************************************/
114
package org.eclipse.compare.unifieddiff.internal;
215

316
import static org.eclipse.compare.unifieddiff.internal.UnifiedDiffManager.disposeUnifiedDiff;

team/bundles/org.eclipse.compare/compare/org/eclipse/compare/unifieddiff/internal/CancelAllRunnable.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 SAP
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* SAP - initial implementation
13+
*******************************************************************************/
114
package org.eclipse.compare.unifieddiff.internal;
215

316
import static org.eclipse.compare.unifieddiff.internal.UnifiedDiffManager.disposeUnifiedDiff;

team/bundles/org.eclipse.compare/compare/org/eclipse/compare/unifieddiff/internal/KeepAllRunnable.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 SAP
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* SAP - initial implementation
13+
*******************************************************************************/
114
package org.eclipse.compare.unifieddiff.internal;
215

316
import static org.eclipse.compare.unifieddiff.internal.UnifiedDiffManager.disposeUnifiedDiff;

team/bundles/org.eclipse.compare/compare/org/eclipse/compare/unifieddiff/internal/NextRunnable.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 SAP
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* SAP - initial implementation
13+
*******************************************************************************/
114
package org.eclipse.compare.unifieddiff.internal;
215

316
import static org.eclipse.compare.unifieddiff.internal.UnifiedDiffManager.get;

team/bundles/org.eclipse.compare/compare/org/eclipse/compare/unifieddiff/internal/PreviousRunnable.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 SAP
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* SAP - initial implementation
13+
*******************************************************************************/
114
package org.eclipse.compare.unifieddiff.internal;
215

316
import static org.eclipse.compare.unifieddiff.internal.UnifiedDiffManager.get;

team/bundles/org.eclipse.compare/compare/org/eclipse/compare/unifieddiff/internal/TestUnidiffCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.eclipse.compare.unifieddiff.internal;
22

33
import org.eclipse.compare.unifieddiff.UnifiedDiff;
4-
import org.eclipse.compare.unifieddiff.UnifiedDiff.UnifiedDiffMode;
4+
import org.eclipse.compare.unifieddiff.UnifiedDiffMode;
55
import org.eclipse.core.commands.AbstractHandler;
66
import org.eclipse.core.commands.ExecutionEvent;
77
import org.eclipse.core.commands.ExecutionException;

team/bundles/org.eclipse.compare/compare/org/eclipse/compare/unifieddiff/internal/TestUnidiffCommandOverlayMode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.eclipse.compare.unifieddiff.internal;
22

3-
import org.eclipse.compare.unifieddiff.UnifiedDiff.UnifiedDiffMode;
3+
import org.eclipse.compare.unifieddiff.UnifiedDiffMode;
44

55
// TODO (tm) used for manual testing which will later be removed
66
public class TestUnidiffCommandOverlayMode extends TestUnidiffCommand {

0 commit comments

Comments
 (0)