Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2016-08-30 20:06:55 -0400
committerSergey Prigogin2016-08-30 20:08:11 -0400
commitcb2a038fb522881890e65f94cb469acb242f3b30 (patch)
treecf82e4cbb432e429572f3dc7c537cff92bcf6fec
parentd123d8ceecaefa3b677f09e81c09e642a4e988cd (diff)
downloadeclipse.platform.team-cb2a038fb522881890e65f94cb469acb242f3b30.tar.gz
eclipse.platform.team-cb2a038fb522881890e65f94cb469acb242f3b30.tar.xz
eclipse.platform.team-cb2a038fb522881890e65f94cb469acb242f3b30.zip
Fixed compiler warnings.Y20160901-1000I20160906-0800
-rw-r--r--bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/DiffProject.java5
-rw-r--r--bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FileDiffResult.java57
-rw-r--r--bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FilePatch2.java25
-rw-r--r--bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/Hunk.java51
-rw-r--r--bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/HunkResult.java6
-rw-r--r--bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/LineReader.java36
-rw-r--r--bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/PatchReader.java71
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java33
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java6
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java6
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffContainer.java27
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffElement.java17
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java17
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java55
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/Differencer.java51
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java66
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureComparator.java2
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/SharedDocumentAdapterWrapper.java24
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureCreator.java37
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java84
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureRootNode.java22
21 files changed, 385 insertions, 313 deletions
diff --git a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/DiffProject.java b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/DiffProject.java
index f0c73f2d9..4d850f6d4 100644
--- a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/DiffProject.java
+++ b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/DiffProject.java
@@ -19,9 +19,8 @@ import java.util.Set;
* in the patch file.
*/
public class DiffProject {
-
private String project;
- private Set fDiffs= new HashSet();
+ private Set<FilePatch2> fDiffs= new HashSet<>();
/**
* Create a diff project for the given workspace project.
@@ -71,6 +70,6 @@ public class DiffProject {
* @return the file diffs associated with this project
*/
public FilePatch2[] getFileDiffs() {
- return (FilePatch2[]) this.fDiffs.toArray(new FilePatch2[this.fDiffs.size()]);
+ return this.fDiffs.toArray(new FilePatch2[this.fDiffs.size()]);
}
}
diff --git a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FileDiffResult.java b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FileDiffResult.java
index da5363b7f..878e2fc51 100644
--- a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FileDiffResult.java
+++ b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FileDiffResult.java
@@ -31,13 +31,12 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.osgi.util.NLS;
public class FileDiffResult implements IFilePatchResult {
-
private FilePatch2 fDiff;
private boolean fMatches= false;
private boolean fDiffProblem;
private String fErrorMessage;
- private Map fHunkResults = new HashMap();
- private List fBeforeLines, fAfterLines;
+ private Map<Hunk, HunkResult> fHunkResults = new HashMap<Hunk, HunkResult>();
+ private List<String> fBeforeLines, fAfterLines;
private final PatchConfiguration configuration;
private String charset;
@@ -97,8 +96,8 @@ public class FileDiffResult implements IFilePatchResult {
// We couldn't find the target file or the patch is trying to add a
// file that already exists but we need to initialize the hunk
// results for display
- this.fBeforeLines = new ArrayList(getLines(content, false));
- this.fAfterLines = this.fMatches ? new ArrayList() : this.fBeforeLines;
+ this.fBeforeLines = new ArrayList<>(getLines(content, false));
+ this.fAfterLines = this.fMatches ? new ArrayList<>() : this.fBeforeLines;
IHunk[] hunks = this.fDiff.getHunks();
for (int i = 0; i < hunks.length; i++) {
Hunk hunk = (Hunk) hunks[i];
@@ -136,8 +135,8 @@ public class FileDiffResult implements IFilePatchResult {
return content != null && content.canCreateReader();
}
- protected List getLines(ReaderCreator content, boolean create) {
- List lines = LineReader.load(content, create);
+ protected List<String> getLines(ReaderCreator content, boolean create) {
+ List<String> lines = LineReader.load(content, create);
return lines;
}
@@ -151,8 +150,8 @@ public class FileDiffResult implements IFilePatchResult {
* Tries to patch the given lines with the specified Diff.
* Any hunk that couldn't be applied is returned in the list failedHunks.
*/
- public void patch(List lines, IProgressMonitor monitor) {
- this.fBeforeLines = new ArrayList();
+ public void patch(List<String> lines, IProgressMonitor monitor) {
+ this.fBeforeLines = new ArrayList<>();
this.fBeforeLines.addAll(lines);
if (getConfiguration().getFuzz() != 0) {
calculateFuzz(this.fBeforeLines, monitor);
@@ -182,8 +181,8 @@ public class FileDiffResult implements IFilePatchResult {
public boolean containsProblems() {
if (this.fDiffProblem)
return true;
- for (Iterator iterator = this.fHunkResults.values().iterator(); iterator.hasNext();) {
- HunkResult result = (HunkResult) iterator.next();
+ for (Iterator<HunkResult> iterator = this.fHunkResults.values().iterator(); iterator.hasNext();) {
+ HunkResult result = iterator.next();
if (!result.isOK())
return true;
}
@@ -197,6 +196,7 @@ public class FileDiffResult implements IFilePatchResult {
return label;
}
+ @Override
public boolean hasMatches() {
return this.fMatches;
}
@@ -205,7 +205,7 @@ public class FileDiffResult implements IFilePatchResult {
* Return the lines of the target file with all matched hunks applied.
* @return the lines of the target file with all matched hunks applied
*/
- public List getLines() {
+ public List<String> getLines() {
return this.fAfterLines;
}
@@ -215,10 +215,10 @@ public class FileDiffResult implements IFilePatchResult {
* @param monitor a progress monitor
* @return the fuzz factor or <code>-1</code> if no hunks could be matched
*/
- public int calculateFuzz(List lines, IProgressMonitor monitor) {
+ public int calculateFuzz(List<String> lines, IProgressMonitor monitor) {
if (monitor == null)
monitor = new NullProgressMonitor();
- this.fBeforeLines = new ArrayList(lines);
+ this.fBeforeLines = new ArrayList<String>(lines);
// TODO: What about deletions?
if (this.fDiff.getDiffType(getConfiguration().isReversed()) == FilePatch2.ADDITION) {
// Additions don't need to adjust the fuzz factor
@@ -249,19 +249,19 @@ public class FileDiffResult implements IFilePatchResult {
}
private HunkResult getHunkResult(Hunk hunk) {
- HunkResult result = (HunkResult)this.fHunkResults.get(hunk);
+ HunkResult result = this.fHunkResults.get(hunk);
if (result == null) {
result = new HunkResult(this, hunk);
- this.fHunkResults .put(hunk, result);
+ this.fHunkResults.put(hunk, result);
}
return result;
}
- public List getFailedHunks() {
- List failedHunks = new ArrayList();
+ public List<Hunk> getFailedHunks() {
+ List<Hunk> failedHunks = new ArrayList<Hunk>();
IHunk[] hunks = this.fDiff.getHunks();
for (int i = 0; i < hunks.length; i++) {
- HunkResult result = (HunkResult) this.fHunkResults.get(hunks[i]);
+ HunkResult result = this.fHunkResults.get(hunks[i]);
if (result != null && !result.isOK())
failedHunks.add(result.getHunk());
}
@@ -272,37 +272,40 @@ public class FileDiffResult implements IFilePatchResult {
return this.fDiff;
}
- public List getBeforeLines() {
+ public List<String> getBeforeLines() {
return this.fBeforeLines;
}
- public List getAfterLines() {
+ public List<String> getAfterLines() {
return this.fAfterLines;
}
public HunkResult[] getHunkResults() {
// return hunk results in the same order as hunks are placed in file diff
- List results = new ArrayList();
+ List<HunkResult> results = new ArrayList<HunkResult>();
IHunk[] hunks = this.fDiff.getHunks();
for (int i = 0; i < hunks.length; i++) {
- HunkResult result = (HunkResult) this.fHunkResults.get(hunks[i]);
+ HunkResult result = this.fHunkResults.get(hunks[i]);
if (result != null) {
results.add(result);
}
}
- return (HunkResult[]) results.toArray(new HunkResult[results.size()]);
+ return results.toArray(new HunkResult[results.size()]);
}
+ @Override
public InputStream getOriginalContents() {
String contents = LineReader.createString(isPreserveLineDelimeters(), getBeforeLines());
return asInputStream(contents, getCharset());
}
+ @Override
public InputStream getPatchedContents() {
String contents = LineReader.createString(isPreserveLineDelimeters(), getLines());
return asInputStream(contents, getCharset());
}
+ @Override
public String getCharset() {
return this.charset;
}
@@ -311,11 +314,13 @@ public class FileDiffResult implements IFilePatchResult {
return false;
}
+ @Override
public IHunk[] getRejects() {
- List failedHunks = getFailedHunks();
- return (IHunk[]) failedHunks.toArray(new IHunk[failedHunks.size()]);
+ List<Hunk> failedHunks = getFailedHunks();
+ return failedHunks.toArray(new IHunk[failedHunks.size()]);
}
+ @Override
public boolean hasRejects() {
return getFailedHunks().size() > 0;
}
diff --git a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FilePatch2.java b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FilePatch2.java
index f171acb95..f15997db9 100644
--- a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FilePatch2.java
+++ b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FilePatch2.java
@@ -28,7 +28,6 @@ import org.eclipse.core.runtime.Path;
* same path in a patch file.
*/
public class FilePatch2 implements IFilePatch2 {
-
/**
* Difference constant (value 1) indicating one side was added.
*/
@@ -44,7 +43,7 @@ public class FilePatch2 implements IFilePatch2 {
private IPath fOldPath, fNewPath;
private long oldDate, newDate;
- private List fHunks= new ArrayList();
+ private List<Hunk> fHunks= new ArrayList<Hunk>();
private DiffProject fProject; //the project that contains this diff
private String header;
private int addedLines, removedLines;
@@ -122,15 +121,16 @@ public class FilePatch2 implements IFilePatch2 {
}
/**
- * Return the hunks associated with this file diff.
+ * Returns the hunks associated with this file diff.
* @return the hunks associated with this file diff
*/
+ @Override
public IHunk[] getHunks() {
- return (IHunk[]) this.fHunks.toArray(new IHunk[this.fHunks.size()]);
+ return this.fHunks.toArray(new IHunk[this.fHunks.size()]);
}
/**
- * Return the number of hunks associated with this file diff.
+ * Returns the number of hunks associated with this file diff.
* @return the number of hunks associated with this file diff
*/
public int getHunkCount() {
@@ -138,7 +138,7 @@ public class FilePatch2 implements IFilePatch2 {
}
/**
- * Return the difference type of this file diff.
+ * Returns the difference type of this file diff.
* @param reverse whether the patch is being reversed
* @return the type of this file diff
*/
@@ -146,9 +146,9 @@ public class FilePatch2 implements IFilePatch2 {
if (this.fHunks.size() == 1) {
boolean add = false;
boolean delete = false;
- Iterator iter = this.fHunks.iterator();
+ Iterator<Hunk> iter = this.fHunks.iterator();
while (iter.hasNext()){
- Hunk hunk = (Hunk) iter.next();
+ Hunk hunk = iter.next();
int type =hunk.getHunkType(reverse);
if (type == ADDITION){
add = true;
@@ -195,6 +195,7 @@ public class FilePatch2 implements IFilePatch2 {
return length;
}
+ @Override
public IFilePatchResult apply(ReaderCreator content,
PatchConfiguration configuration, IProgressMonitor monitor) {
FileDiffResult result = new FileDiffResult(this, configuration);
@@ -202,6 +203,7 @@ public class FilePatch2 implements IFilePatch2 {
return result;
}
+ @Override
public IPath getTargetPath(PatchConfiguration configuration) {
return getStrippedPath(configuration.getPrefixSegmentStripCount(), configuration.isReversed());
}
@@ -218,8 +220,8 @@ public class FilePatch2 implements IFilePatch2 {
adjustedNewPath = new Path(null, this.fProject.getName()).append(this.fNewPath);
}
FilePatch2 diff = create(adjustedOldPath, 0, adjustedNewPath, 0);
- for (Iterator iterator = this.fHunks.iterator(); iterator.hasNext();) {
- Hunk hunk = (Hunk) iterator.next();
+ for (Iterator<Hunk> iterator = this.fHunks.iterator(); iterator.hasNext();) {
+ Hunk hunk = iterator.next();
// Creating the hunk adds it to the parent diff
new Hunk(diff, hunk);
}
@@ -235,14 +237,17 @@ public class FilePatch2 implements IFilePatch2 {
this.header = header;
}
+ @Override
public String getHeader() {
return this.header;
}
+ @Override
public long getBeforeDate() {
return this.oldDate;
}
+ @Override
public long getAfterDate() {
return this.newDate;
}
diff --git a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/Hunk.java b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/Hunk.java
index 2a8d45b89..358d2750d 100644
--- a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/Hunk.java
+++ b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/Hunk.java
@@ -14,17 +14,15 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.runtime.Assert;
-
import org.eclipse.compare.patch.IFilePatchResult;
import org.eclipse.compare.patch.IHunk;
import org.eclipse.compare.patch.PatchConfiguration;
+import org.eclipse.core.runtime.Assert;
/**
* A Hunk describes a range of changed lines and some context lines.
*/
public class Hunk implements IHunk {
-
private FilePatch2 fParent;
private int fOldStart, fOldLength;
private int fNewStart, fNewLength;
@@ -32,7 +30,8 @@ public class Hunk implements IHunk {
private int hunkType;
private String charset = null;
- public static Hunk createHunk(FilePatch2 parent, int[] oldRange, int[] newRange, List lines, boolean hasLineAdditions, boolean hasLineDeletions, boolean hasContextLines) {
+ public static Hunk createHunk(FilePatch2 parent, int[] oldRange, int[] newRange,
+ List<String> lines, boolean hasLineAdditions, boolean hasLineDeletions, boolean hasContextLines) {
int oldStart = 0;
int oldLength = 0;
int newStart = 0;
@@ -55,7 +54,7 @@ public class Hunk implements IHunk {
hunkType = FilePatch2.DELETION;
}
}
- return new Hunk(parent, hunkType, oldStart, oldLength, newStart, newLength, (String[]) lines.toArray(new String[lines.size()]));
+ return new Hunk(parent, hunkType, oldStart, oldLength, newStart, newLength, lines.toArray(new String[lines.size()]));
}
public Hunk(FilePatch2 parent, int hunkType, int oldStart, int oldLength,
@@ -146,6 +145,7 @@ public class Hunk implements IHunk {
return this.fLines;
}
+ @Override
public String[] getUnifiedLines() {
String[] ret = new String[this.fLines.length];
System.arraycopy(this.fLines, 0, ret, 0, this.fLines.length);
@@ -174,10 +174,10 @@ public class Hunk implements IHunk {
* The parameter shift is added to the line numbers given
* in the hunk.
*/
- public boolean tryPatch(PatchConfiguration configuration, List lines, int shift, int fuzz) {
+ public boolean tryPatch(PatchConfiguration configuration, List<String> lines, int shift, int fuzz) {
boolean reverse = configuration.isReversed();
int pos = getStart(reverse) + shift;
- List contextLines = new ArrayList();
+ List<String> contextLines = new ArrayList<>();
boolean contextLinesMatched = true;
boolean precedingLinesChecked = false;
for (int i= 0; i < this.fLines.length; i++) {
@@ -191,7 +191,7 @@ public class Hunk implements IHunk {
if (pos < 0 || pos >= lines.size())
return false;
contextLines.add(line);
- if (linesMatch(configuration, line, (String) lines.get(pos))) {
+ if (linesMatch(configuration, line, lines.get(pos))) {
pos++;
continue;
} else if (fuzz > 0) {
@@ -225,7 +225,7 @@ public class Hunk implements IHunk {
if (pos < 0 || pos >= lines.size()) // out of the file
return false;
- if (linesMatch(configuration, line, (String) lines.get(pos))) {
+ if (linesMatch(configuration, line, lines.get(pos))) {
pos++;
continue; // line matched, continue with the next one
}
@@ -267,26 +267,25 @@ public class Hunk implements IHunk {
}
private boolean checkPrecedingContextLines(
- PatchConfiguration configuration, List lines, int fuzz, int pos,
- List contextLines) {
-
+ PatchConfiguration configuration, List<String> lines, int fuzz, int pos,
+ List<String> contextLines) {
// ignore from the beginning
for (int j = fuzz; j < contextLines.size(); j++) {
- if (!linesMatch(configuration, (String) contextLines.get(j),
- (String) lines.get(pos - contextLines.size() + j)))
+ if (!linesMatch(configuration, contextLines.get(j),
+ lines.get(pos - contextLines.size() + j)))
return false;
}
return true;
}
private boolean checkFollowingContextLines(
- PatchConfiguration configuration, List lines, int fuzz, int pos,
- List contextLines) {
+ PatchConfiguration configuration, List<String> lines, int fuzz, int pos,
+ List<String> contextLines) {
if (!contextLines.isEmpty()) {
// ignore from the end
for (int j = 0; j < contextLines.size() - fuzz; j++) {
- if (!linesMatch(configuration, (String) contextLines.get(j),
- (String) lines.get(pos - contextLines.size() + j)))
+ if (!linesMatch(configuration, contextLines.get(j),
+ lines.get(pos - contextLines.size() + j)))
return false;
}
}
@@ -322,10 +321,10 @@ public class Hunk implements IHunk {
return this.fNewLength - this.fOldLength;
}
- int doPatch(PatchConfiguration configuration, List lines, int shift, int fuzz) {
+ int doPatch(PatchConfiguration configuration, List<String> lines, int shift, int fuzz) {
boolean reverse = configuration.isReversed();
int pos = getStart(reverse) + shift;
- List contextLines = new ArrayList();
+ List<String> contextLines = new ArrayList<>();
boolean contextLinesMatched = true;
boolean precedingLinesChecked = false;
String lineDelimiter = getLineDelimiter(lines);
@@ -339,7 +338,7 @@ public class Hunk implements IHunk {
// context lines
Assert.isTrue(pos < lines.size(), "doPatch: inconsistency in context"); //$NON-NLS-1$
contextLines.add(line);
- if (linesMatch(configuration, line, (String) lines.get(pos))) {
+ if (linesMatch(configuration, line, lines.get(pos))) {
pos++;
continue;
} else if (fuzz > 0) {
@@ -432,10 +431,10 @@ public class Hunk implements IHunk {
return true;
}
- private String getLineDelimiter(List lines) {
+ private String getLineDelimiter(List<String> lines) {
if (lines.size() > 0) {
// get a line separator from the file being patched
- String line0 = (String) lines.get(0);
+ String line0 = lines.get(0);
return line0.substring(LineReader.length(line0));
} else if (this.fLines.length > 0) {
// if the file doesn't exist use a line separator from the patch
@@ -476,19 +475,23 @@ public class Hunk implements IHunk {
return result.toString();
}
+ @Override
public String getLabel() {
return getDescription();
}
+ @Override
public int getStartPosition() {
return getStart(false);
}
+ @Override
public InputStream getOriginalContents() {
String contents = getContents(false, false);
return asInputStream(contents);
}
+ @Override
public InputStream getPatchedContents() {
String contents = getContents(true, false);
return asInputStream(contents);
@@ -511,6 +514,8 @@ public class Hunk implements IHunk {
* {@link IFilePatchResult#getCharset()} as a proper way to
* obtain charset.
*/
+ @Deprecated
+ @Override
public String getCharset() {
return this.charset;
}
diff --git a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/HunkResult.java b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/HunkResult.java
index a488540f8..6b37d90dc 100644
--- a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/HunkResult.java
+++ b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/HunkResult.java
@@ -51,7 +51,7 @@ public class HunkResult {
* @param lines the lines to be patched
* @return whether the hunk could be applied
*/
- public boolean patch(List lines) {
+ public boolean patch(List<String> lines) {
this.fMatches = false;
PatchConfiguration configuration = getConfiguration();
// if the fuzz is not set for the current hunk use the one from fDiffResult
@@ -115,7 +115,7 @@ public class HunkResult {
* a progress monitor
* @return the fuzz factor or -1 if the hunk could not be matched
*/
- public int calculateFuzz(List lines, IProgressMonitor monitor) {
+ public int calculateFuzz(List<String> lines, IProgressMonitor monitor) {
this.fMatches = false;
PatchConfiguration configuration = getConfiguration();
int fuzz = 0;
@@ -228,7 +228,7 @@ public class HunkResult {
public String getContents(boolean afterState, boolean fullContext) {
if (fullContext) {
boolean problemFound = false;
- List lines = getDiffResult().getBeforeLines();
+ List<String> lines = getDiffResult().getBeforeLines();
if (afterState) {
if (isOK()) {
int oldShift = this.fShift;
diff --git a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/LineReader.java b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/LineReader.java
index 37b02420c..019874b29 100644
--- a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/LineReader.java
+++ b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/LineReader.java
@@ -24,12 +24,11 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
public class LineReader {
-
- /*
+ /**
* Reads the contents and returns them as a List of lines.
*/
- public static List load(ReaderCreator content, boolean create) {
- List lines = null;
+ public static List<String> load(ReaderCreator content, boolean create) {
+ List<String> lines = null;
BufferedReader bufferedReader = null;
if (!create && content != null && content.canCreateReader()) {
// read current contents
@@ -39,22 +38,23 @@ public class LineReader {
} catch (CoreException ex) {
ComparePlugin.log(ex);
} finally {
- if (bufferedReader != null)
+ if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException ex) {
// silently ignored
}
+ }
}
}
if (lines == null)
- lines = new ArrayList();
+ lines = new ArrayList<>();
return lines;
}
- public static List readLines(BufferedReader reader) {
- List lines;
+ public static List<String> readLines(BufferedReader reader) {
+ List<String> lines;
LineReader lr= new LineReader(reader);
if (!Platform.WS_CARBON.equals(Platform.getWS()))
lr.ignoreSingleCR(); // Don't treat single CRs as line feeds to be consistent with command line patch
@@ -65,16 +65,16 @@ public class LineReader {
/*
* Concatenates all strings found in the given List.
*/
- public static String createString(boolean preserveLineDelimeters, List lines) {
+ public static String createString(boolean preserveLineDelimeters, List<String> lines) {
StringBuffer sb= new StringBuffer();
- Iterator iter= lines.iterator();
+ Iterator<String> iter= lines.iterator();
if (preserveLineDelimeters) {
while (iter.hasNext())
- sb.append((String)iter.next());
+ sb.append(iter.next());
} else {
String lineSeparator= System.getProperty("line.separator"); //$NON-NLS-1$
while (iter.hasNext()) {
- String line= (String)iter.next();
+ String line= iter.next();
int l= length(line);
if (l < line.length()) { // line has delimiter
sb.append(line.substring(0, l));
@@ -91,7 +91,7 @@ public class LineReader {
* Returns the length (excluding a line delimiter CR, LF, CR/LF)
* of the given string.
*/
- /* package */ static int length(String s) {
+ static int length(String s) {
int l= s.length();
if (l > 0) {
char c= s.charAt(l-1);
@@ -131,7 +131,7 @@ public class LineReader {
* stream has been reached
* @exception IOException If an I/O error occurs
*/
- /* package */ String readLine() throws IOException {
+ String readLine() throws IOException {
try {
while (!this.fSawEOF) {
int c= readChar();
@@ -170,7 +170,7 @@ public class LineReader {
}
}
- /* package */ void close() {
+ void close() {
try {
this.fReader.close();
} catch (IOException ex) {
@@ -178,9 +178,9 @@ public class LineReader {
}
}
- public List readLines() {
+ public List<String> readLines() {
try {
- List lines= new ArrayList();
+ List<String> lines= new ArrayList<>();
String line;
while ((line= readLine()) != null)
lines.add(line);
@@ -198,7 +198,7 @@ public class LineReader {
* Returns the number of characters in the given string without
* counting a trailing line separator.
*/
- /* package */ int lineContentLength(String line) {
+ int lineContentLength(String line) {
if (line == null)
return 0;
int length= line.length();
diff --git a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/PatchReader.java b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/PatchReader.java
index c103e1b8a..255f50382 100644
--- a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/PatchReader.java
+++ b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/PatchReader.java
@@ -22,18 +22,16 @@ import java.util.Locale;
import java.util.StringTokenizer;
import java.util.regex.Pattern;
-import com.ibm.icu.text.DateFormat;
-import com.ibm.icu.text.SimpleDateFormat;
-
+import org.eclipse.compare.patch.IFilePatch2;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.compare.patch.IFilePatch2;
+import com.ibm.icu.text.DateFormat;
+import com.ibm.icu.text.SimpleDateFormat;
public class PatchReader {
-
private static final boolean DEBUG= false;
private static final String DEV_NULL= "/dev/null"; //$NON-NLS-1$
@@ -87,8 +85,8 @@ public class PatchReader {
}
public void parse(BufferedReader reader) throws IOException {
- List diffs= new ArrayList();
- HashMap diffProjects= new HashMap(4);
+ List<FilePatch2> diffs= new ArrayList<FilePatch2>();
+ HashMap<String, DiffProject> diffProjects= new HashMap<String, DiffProject>(4);
String line= null;
boolean reread= false;
String diffArgs= null;
@@ -146,7 +144,7 @@ public class PatchReader {
diffProject= new DiffProject(projectName);
diffProjects.put(projectName, diffProject);
} else {
- diffProject= (DiffProject) diffProjects.get(projectName);
+ diffProject= diffProjects.get(projectName);
}
line= readUnifiedDiff(diffs, lr, line, diffArgs, fileName, diffProject);
@@ -157,8 +155,8 @@ public class PatchReader {
lr.close();
- this.fDiffProjects= (DiffProject[]) diffProjects.values().toArray(new DiffProject[diffProjects.size()]);
- this.fDiffs = (FilePatch2[]) diffs.toArray(new FilePatch2[diffs.size()]);
+ this.fDiffProjects= diffProjects.values().toArray(new DiffProject[diffProjects.size()]);
+ this.fDiffs = diffs.toArray(new FilePatch2[diffs.size()]);
}
protected FilePatch2 createFileDiff(IPath oldPath, long oldDate,
@@ -166,11 +164,11 @@ public class PatchReader {
return new FilePatch2(oldPath, oldDate, newPath, newDate);
}
- private String readUnifiedDiff(List diffs, LineReader lr, String line, String diffArgs, String fileName, DiffProject diffProject) throws IOException {
- List newDiffs= new ArrayList();
+ private String readUnifiedDiff(List<FilePatch2> diffs, LineReader lr, String line, String diffArgs, String fileName, DiffProject diffProject) throws IOException {
+ List<FilePatch2> newDiffs= new ArrayList<FilePatch2>();
String nextLine= readUnifiedDiff(newDiffs, lr, line, diffArgs, fileName);
- for (Iterator iter= newDiffs.iterator(); iter.hasNext();) {
- FilePatch2 diff= (FilePatch2) iter.next();
+ for (Iterator<FilePatch2> iter= newDiffs.iterator(); iter.hasNext();) {
+ FilePatch2 diff= iter.next();
diffProject.add(diff);
diffs.add(diff);
}
@@ -178,11 +176,11 @@ public class PatchReader {
}
public void parse(LineReader lr, String line) throws IOException {
- List diffs= new ArrayList();
+ List<FilePatch2> diffs= new ArrayList<FilePatch2>();
boolean reread= false;
String diffArgs= null;
String fileName= null;
- List headerLines = new ArrayList();
+ List<String> headerLines = new ArrayList<String>();
boolean foundDiff= false;
// read leading garbage
@@ -205,13 +203,13 @@ public class PatchReader {
} else if (line.startsWith("--- ")) { //$NON-NLS-1$
line= readUnifiedDiff(diffs, lr, line, diffArgs, fileName);
if (!headerLines.isEmpty())
- setHeader((FilePatch2)diffs.get(diffs.size() - 1), headerLines);
+ setHeader(diffs.get(diffs.size() - 1), headerLines);
diffArgs= fileName= null;
reread= true;
} else if (line.startsWith("*** ")) { //$NON-NLS-1$
line= readContextDiff(diffs, lr, line, diffArgs, fileName);
if (!headerLines.isEmpty())
- setHeader((FilePatch2)diffs.get(diffs.size() - 1), headerLines);
+ setHeader(diffs.get(diffs.size() - 1), headerLines);
diffArgs= fileName= null;
reread= true;
}
@@ -225,10 +223,10 @@ public class PatchReader {
lr.close();
- this.fDiffs = (FilePatch2[]) diffs.toArray(new FilePatch2[diffs.size()]);
+ this.fDiffs = diffs.toArray(new FilePatch2[diffs.size()]);
}
- private void setHeader(FilePatch2 diff, List headerLines) {
+ private void setHeader(FilePatch2 diff, List<String> headerLines) {
String header = LineReader.createString(false, headerLines);
diff.setHeader(header);
headerLines.clear();
@@ -237,7 +235,7 @@ public class PatchReader {
/*
* Returns the next line that does not belong to this diff
*/
- protected String readUnifiedDiff(List diffs, LineReader reader, String line, String args, String fileName) throws IOException {
+ protected String readUnifiedDiff(List<FilePatch2> diffs, LineReader reader, String line, String args, String fileName) throws IOException {
String[] oldArgs= split(line.substring(4));
@@ -257,7 +255,7 @@ public class PatchReader {
int[] newRange= new int[2];
int remainingOld= -1; // remaining old lines for current hunk
int remainingNew= -1; // remaining new lines for current hunk
- List lines= new ArrayList();
+ List<String> lines= new ArrayList<String>();
boolean encounteredPlus = false;
boolean encounteredMinus = false;
@@ -319,7 +317,7 @@ public class PatchReader {
if (line.indexOf("newline at end") > 0) { //$NON-NLS-1$
int lastIndex= lines.size();
if (lastIndex > 0) {
- line= (String)lines.get(lastIndex - 1);
+ line= lines.get(lastIndex - 1);
int end= line.length() - 1;
char lc= line.charAt(end);
if (lc == '\n') {
@@ -363,7 +361,7 @@ public class PatchReader {
/*
* Returns the next line that does not belong to this diff
*/
- private String readContextDiff(List diffs, LineReader reader, String line, String args, String fileName) throws IOException {
+ private String readContextDiff(List<FilePatch2> diffs, LineReader reader, String line, String args, String fileName) throws IOException {
String[] oldArgs= split(line.substring(4));
@@ -381,9 +379,9 @@ public class PatchReader {
int[] oldRange= new int[2];
int[] newRange= new int[2];
- List oldLines= new ArrayList();
- List newLines= new ArrayList();
- List lines= oldLines;
+ List<String> oldLines= new ArrayList<String>();
+ List<String> newLines= new ArrayList<String>();
+ List<String> lines= oldLines;
boolean encounteredPlus = false;
@@ -480,11 +478,11 @@ public class PatchReader {
* Creates a List of lines in the unified format from
* two Lists of lines in the 'classic' format.
*/
- private List unifyLines(List oldLines, List newLines) {
- List result= new ArrayList();
+ private List<String> unifyLines(List<String> oldLines, List<String> newLines) {
+ List<String> result= new ArrayList<String>();
- String[] ol= (String[]) oldLines.toArray(new String[oldLines.size()]);
- String[] nl= (String[]) newLines.toArray(new String[newLines.size()]);
+ String[] ol= oldLines.toArray(new String[oldLines.size()]);
+ String[] nl= newLines.toArray(new String[newLines.size()]);
int oi= 0, ni= 0;
@@ -670,21 +668,20 @@ public class PatchReader {
pair[1]= 1;
}
}
-
-
+
/*
* Breaks the given string into tab separated substrings.
* Leading and trailing whitespace is removed from each token.
*/
private String[] split(String line) {
- List l= new ArrayList();
+ List<String> l= new ArrayList<>();
StringTokenizer st= new StringTokenizer(line, "\t"); //$NON-NLS-1$
while (st.hasMoreElements()) {
String token= st.nextToken().trim();
if (token.length() > 0)
l.add(token);
}
- return (String[]) l.toArray(new String[l.size()]);
+ return l.toArray(new String[l.size()]);
}
public boolean isWorkspacePatch() {
@@ -706,12 +703,12 @@ public class PatchReader {
public FilePatch2[] getAdjustedDiffs() {
if (!isWorkspacePatch() || this.fDiffs.length == 0)
return this.fDiffs;
- List result = new ArrayList();
+ List<FilePatch2> result = new ArrayList<FilePatch2>();
for (int i = 0; i < this.fDiffs.length; i++) {
FilePatch2 diff = this.fDiffs[i];
result.add(diff.asRelativeDiff());
}
- return (FilePatch2[]) result.toArray(new FilePatch2[result.size()]);
+ return result.toArray(new FilePatch2[result.size()]);
}
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java
index ae029457c..578c0e187 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java
@@ -29,13 +29,12 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
public class LineReader {
-
- /*
+ /**
* Reads the contents from the given file and returns them as a List of
* lines.
*/
- public static List load(IStorage file, boolean create) {
- List lines = null;
+ public static List<String> load(IStorage file, boolean create) {
+ List <String> lines = null;
if (!create && file != null && exists(file)) {
// read current contents
String charset = Utilities.getCharset(file);
@@ -67,7 +66,7 @@ public class LineReader {
}
if (lines == null)
- lines = new ArrayList();
+ lines = new ArrayList<>();
return lines;
}
@@ -78,8 +77,8 @@ public class LineReader {
return true;
}
- public static List readLines(BufferedReader reader) {
- List lines;
+ public static List<String> readLines(BufferedReader reader) {
+ List<String> lines;
LineReader lr = new LineReader(reader);
if (!Platform.WS_CARBON.equals(Platform.getWS()))
// Don't treat single CRs as line feeds to be consistent with command line patch
@@ -91,16 +90,16 @@ public class LineReader {
/*
* Concatenates all strings found in the given List.
*/
- public static String createString(boolean preserveLineDelimeters, List lines) {
+ public static String createString(boolean preserveLineDelimeters, List<String> lines) {
StringBuffer sb = new StringBuffer();
- Iterator iter = lines.iterator();
+ Iterator<String> iter = lines.iterator();
if (preserveLineDelimeters) {
while (iter.hasNext())
- sb.append((String) iter.next());
+ sb.append(iter.next());
} else {
String lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$
while (iter.hasNext()) {
- String line = (String) iter.next();
+ String line = iter.next();
int l = length(line);
if (l < line.length()) { // line has delimiter
sb.append(line.substring(0, l));
@@ -117,7 +116,7 @@ public class LineReader {
* Returns the length (excluding a line delimiter CR, LF, CR/LF) of the
* given string.
*/
- /* package */static int length(String s) {
+ static int length(String s) {
int l = s.length();
if (l > 0) {
char c = s.charAt(l - 1);
@@ -159,7 +158,7 @@ public class LineReader {
* @exception IOException
* If an I/O error occurs
*/
- /* package */String readLine() throws IOException {
+ String readLine() throws IOException {
try {
while (!fSawEOF) {
int c = readChar();
@@ -198,7 +197,7 @@ public class LineReader {
}
}
- /* package */void close() {
+ void close() {
try {
fReader.close();
} catch (IOException ex) {
@@ -206,9 +205,9 @@ public class LineReader {
}
}
- public List readLines() {
+ public List<String> readLines() {
try {
- List lines = new ArrayList();
+ List<String> lines = new ArrayList<>();
String line;
while ((line = readLine()) != null)
lines.add(line);
@@ -227,7 +226,7 @@ public class LineReader {
* Returns the number of characters in the given string without counting a
* trailing line separator.
*/
- /* package */int lineContentLength(String line) {
+ int lineContentLength(String line) {
if (line == null)
return 0;
int length = line.length();
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java
index 12d959cfc..ed468befa 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java
@@ -39,6 +39,7 @@ public class PatchFileTypedElement implements ITypedElement,
this.isAfterState = isAfterState;
}
+ @Override
public Image getImage() {
IFile file = getPatcher().getTargetFile(result.getDiff());
if (file == null) {
@@ -75,6 +76,7 @@ public class PatchFileTypedElement implements ITypedElement,
*
* @see org.eclipse.compare.ITypedElement#getName()
*/
+ @Override
public String getName() {
return result.getTargetPath().toString();
}
@@ -84,14 +86,17 @@ public class PatchFileTypedElement implements ITypedElement,
*
* @see org.eclipse.compare.ITypedElement#getType()
*/
+ @Override
public String getType() {
return result.getTargetPath().getFileExtension();
}
+ @Override
public String getCharset() throws CoreException {
return result.getCharset();
}
+ @Override
public InputStream getContents() throws CoreException {
// If there are cached contents, use them
if (isAfterState && getPatcher().hasCachedContents(result.getDiff()))
@@ -124,5 +129,4 @@ public class PatchFileTypedElement implements ITypedElement,
private Patcher getPatcher() {
return Patcher.getPatcher(result.getConfiguration());
}
-
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
index 651d0443d..17d5afac0 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
@@ -184,6 +184,7 @@ public class Patcher implements IHunkFilter {
public void parse(BufferedReader reader) throws IOException {
PatchReader patchReader = new PatchReader() {
+ @Override
protected FilePatch2 createFileDiff(IPath oldPath, long oldDate,
IPath newPath, long newDate) {
return new FilePatch(oldPath, oldDate, newPath, newDate);
@@ -342,7 +343,7 @@ public class Patcher implements IHunkFilter {
List apply(FilePatch2 diff, IFile file, boolean create, List failedHunks) {
FileDiffResult result = getDiffResult(diff);
- List lines = LineReader.load(file, create);
+ List<String> lines = LineReader.load(file, create);
result.patch(lines, null);
failedHunks.addAll(result.getFailedHunks());
if (hasCachedContents(diff)) {
@@ -713,7 +714,7 @@ public class Patcher implements IHunkFilter {
* @param diff the file diff
* @return the content lines that are cached for the file diff
*/
- public List getCachedLines(FilePatch2 diff) {
+ public List<String> getCachedLines(FilePatch2 diff) {
byte[] contents = (byte[])contentCache.get(diff);
if (contents != null) {
BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(contents)));
@@ -793,6 +794,7 @@ public class Patcher implements IHunkFilter {
return false;
}
+ @Override
public boolean select(IHunk hunk) {
return isEnabled(hunk);
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffContainer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffContainer.java
index 7599f540f..95a14d3f7 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffContainer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffContainer.java
@@ -19,9 +19,8 @@ import java.util.ArrayList;
* </p>
*/
public abstract class DiffContainer extends DiffElement implements IDiffContainer {
-
private static IDiffElement[] fgEmptyArray= new IDiffElement[0];
- private ArrayList fChildren;
+ private ArrayList<IDiffElement> fChildren;
/**
* Creates a new container with the specified kind under the given parent.
@@ -50,25 +49,20 @@ public abstract class DiffContainer extends DiffElement implements IDiffContaine
return null;
}
- /* (non Javadoc)
- * see IDiffContainer.add
- */
+ @Override
public void add(IDiffElement diff) {
if (fChildren == null)
- fChildren= new ArrayList();
+ fChildren= new ArrayList<>();
fChildren.add(diff);
diff.setParent(this);
}
- /*
- * Removes the given child from this container.
- * If the container becomes empty it is removed from its container.
- */
+ @Override
public void removeToRoot(IDiffElement child) {
if (fChildren != null) {
fChildren.remove(child);
child.setParent(null);
- if (fChildren.size() == 0) {
+ if (fChildren.isEmpty()) {
IDiffContainer p= getParent();
if (p != null)
p.removeToRoot(this);
@@ -88,20 +82,15 @@ public abstract class DiffContainer extends DiffElement implements IDiffContaine
}
}
- /* (non Javadoc)
- * see IDiffContainer.hasChildren
- */
+ @Override
public boolean hasChildren() {
return fChildren != null && fChildren.size() > 0;
}
- /* (non Javadoc)
- * see IDiffContainer.getChildren
- */
+ @Override
public IDiffElement[] getChildren() {
if (fChildren != null)
- return (IDiffElement[]) fChildren.toArray(fgEmptyArray);
+ return fChildren.toArray(fgEmptyArray);
return fgEmptyArray;
}
}
-
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffElement.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffElement.java
index e69764a65..0cd40eda3 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffElement.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffElement.java
@@ -10,8 +10,8 @@
*******************************************************************************/
package org.eclipse.compare.structuremergeviewer;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.compare.ITypedElement;
+import org.eclipse.swt.graphics.Image;
/**
* An abstract base implementation of the <code>IDiffElement</code> interface.
@@ -21,7 +21,6 @@ import org.eclipse.compare.ITypedElement;
* </p>
*/
public abstract class DiffElement implements IDiffElement {
-
private int fKind;
private IDiffContainer fParent;
@@ -45,6 +44,7 @@ public abstract class DiffElement implements IDiffElement {
* an image for this element.
* @return <code>null</code>.
*/
+ @Override
public Image getImage() {
return null;
}
@@ -55,6 +55,7 @@ public abstract class DiffElement implements IDiffElement {
* re-implement to provide a type for this element.
* @return <code>ITypedElement.UNKNOWN_TYPE</code>.
*/
+ @Override
public String getType() {
return ITypedElement.UNKNOWN_TYPE;
}
@@ -69,23 +70,17 @@ public abstract class DiffElement implements IDiffElement {
fKind= kind;
}
- /* (non Javadoc)
- * see IDiffElement.getKind
- */
+ @Override
public int getKind() {
return fKind;
}
- /* (non Javadoc)
- * see IDiffElement.getParent
- */
+ @Override
public IDiffContainer getParent() {
return fParent;
}
- /* (non Javadoc)
- * see IDiffElement.setParent
- */
+ @Override
public void setParent(IDiffContainer parent) {
fParent= parent;
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java
index b1775f0f1..4f6d3316e 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java
@@ -34,14 +34,12 @@ import com.ibm.icu.text.MessageFormat;
* @see Differencer
*/
public class DiffNode extends DiffContainer implements ICompareInput {
-
private ITypedElement fAncestor;
private ITypedElement fLeft;
private ITypedElement fRight;
private boolean fDontExpand;
- private ListenerList fListener;
+ private ListenerList<ICompareInputChangeListener> fListener;
private boolean fSwapSides;
-
/**
* Creates a new <code>DiffNode</code> and initializes with the given values.
@@ -107,9 +105,10 @@ public class DiffNode extends DiffContainer implements ICompareInput {
*
* @param listener the listener to add
*/
+ @Override
public void addCompareInputChangeListener(ICompareInputChangeListener listener) {
if (fListener == null)
- fListener= new ListenerList();
+ fListener= new ListenerList<>();
fListener.add(listener);
}
@@ -119,6 +118,7 @@ public class DiffNode extends DiffContainer implements ICompareInput {
*
* @param listener the listener to remove
*/
+ @Override
public void removeCompareInputChangeListener(ICompareInputChangeListener listener) {
if (fListener != null) {
fListener.remove(listener);
@@ -181,6 +181,7 @@ public class DiffNode extends DiffContainer implements ICompareInput {
* Subclasses may re-implement to provide a different name for this node.
* @return the name of this node.
*/
+ @Override
public String getName() {
String right= null;
if (fRight != null)
@@ -226,6 +227,7 @@ public class DiffNode extends DiffContainer implements ICompareInput {
/* (non Javadoc)
* see ITypedElement.getImage
*/
+ @Override
public Image getImage() {
ITypedElement id= getId();
if (id != null)
@@ -236,6 +238,7 @@ public class DiffNode extends DiffContainer implements ICompareInput {
/* (non Javadoc)
* see ITypedElement.getType
*/
+ @Override
public String getType() {
ITypedElement id= getId();
if (id != null)
@@ -256,6 +259,7 @@ public class DiffNode extends DiffContainer implements ICompareInput {
/* (non Javadoc)
* see ICompareInput.getAncestor
*/
+ @Override
public ITypedElement getAncestor() {
return fAncestor;
}
@@ -272,6 +276,7 @@ public class DiffNode extends DiffContainer implements ICompareInput {
/* (non Javadoc)
* see ICompareInput.getLeft
*/
+ @Override
public ITypedElement getLeft() {
return fLeft;
}
@@ -288,6 +293,7 @@ public class DiffNode extends DiffContainer implements ICompareInput {
/* (non Javadoc)
* see ICompareInput.getRight
*/
+ @Override
public ITypedElement getRight() {
return fRight;
}
@@ -295,6 +301,7 @@ public class DiffNode extends DiffContainer implements ICompareInput {
/* (non Javadoc)
* see ICompareInput.copy
*/
+ @Override
public void copy(boolean leftToRight) {
//System.out.println("DiffNode.copy: " + leftToRight);
@@ -322,6 +329,7 @@ public class DiffNode extends DiffContainer implements ICompareInput {
/* (non Javadoc)
* see Object.hashCode
*/
+ @Override
public int hashCode() {
String[] path= getPath(this, 0);
int hashCode= 1;
@@ -335,6 +343,7 @@ public class DiffNode extends DiffContainer implements ICompareInput {
/* (non Javadoc)
* see Object.equals
*/
+ @Override
public boolean equals(Object other) {
if (other != null && getClass() == other.getClass()) {
String[] path1= getPath(this, 0);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java
index d5df14bd0..b59aa5115 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java
@@ -13,17 +13,38 @@ package org.eclipse.compare.structuremergeviewer;
import java.util.Iterator;
import java.util.ResourceBundle;
-import org.eclipse.compare.*;
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareUI;
+import org.eclipse.compare.CompareViewerPane;
+import org.eclipse.compare.INavigatable;
import org.eclipse.compare.internal.Utilities;
import org.eclipse.compare.internal.patch.DiffViewerComparator;
-import org.eclipse.jface.action.*;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swt.widgets.Widget;
/**
* A tree viewer that works on objects implementing
@@ -40,7 +61,7 @@ import org.eclipse.swt.widgets.*;
public class DiffTreeViewer extends TreeViewer {
class DiffViewerContentProvider implements ITreeContentProvider {
-
+ @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// empty implementation
}
@@ -49,22 +70,26 @@ public class DiffTreeViewer extends TreeViewer {
return false;
}
+ @Override
public void dispose() {
inputChanged(DiffTreeViewer.this, getInput(), null);
}
+ @Override
public Object getParent(Object element) {
if (element instanceof IDiffElement)
return ((IDiffElement)element).getParent();
return null;
}
+ @Override
public final boolean hasChildren(Object element) {
if (element instanceof IDiffContainer)
return ((IDiffContainer)element).hasChildren();
return false;
}
+ @Override
public final Object[] getChildren(Object element) {
if (element instanceof IDiffContainer)
return ((IDiffContainer)element).getChildren();
@@ -84,7 +109,6 @@ public class DiffTreeViewer extends TreeViewer {
class DiffViewerLabelProvider extends LabelProvider {
@Override
public String getText(Object element) {
-
if (element instanceof IDiffElement)
return ((IDiffElement)element).getName();
@@ -130,6 +154,7 @@ public class DiffTreeViewer extends TreeViewer {
}
static class FilterSame extends ViewerFilter {
+ @Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IDiffElement)
return (((IDiffElement)element).getKind() & Differencer.PSEUDO_CONFLICT) == 0;
@@ -171,10 +196,10 @@ public class DiffTreeViewer extends TreeViewer {
}
private void initialize(CompareConfiguration configuration) {
-
Control tree= getControl();
INavigatable nav= new INavigatable() {
+ @Override
public boolean selectChange(int flag) {
if (flag == INavigatable.FIRST_CHANGE) {
setSelection(StructuredSelection.EMPTY);
@@ -186,12 +211,15 @@ public class DiffTreeViewer extends TreeViewer {
// Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106
return internalNavigate(flag == INavigatable.NEXT_CHANGE, true);
}
+ @Override
public Object getInput() {
return DiffTreeViewer.this.getInput();
}
+ @Override
public boolean openSelectedChange() {
return internalOpen();
}
+ @Override
public boolean hasChange(int changeFlag) {
return getNextItem(changeFlag == INavigatable.NEXT_CHANGE, false) != null;
}
@@ -235,6 +263,7 @@ public class DiffTreeViewer extends TreeViewer {
mm.setRemoveAllWhenShown(true);
mm.addMenuListener(
new IMenuListener() {
+ @Override
public void menuAboutToShow(IMenuManager mm2) {
fillContextMenu(mm2);
if (mm2.isEmpty()) {
@@ -288,8 +317,8 @@ public class DiffTreeViewer extends TreeViewer {
* Clients may extend if they have to do additional cleanup.
* @param event dispose event that triggered call to this method
*/
+ @Override
protected void handleDispose(DisposeEvent event) {
-
if (fCompareConfiguration != null) {
if (fPropertyChangeListener != null)
fCompareConfiguration.removePropertyChangeListener(fPropertyChangeListener);
@@ -341,8 +370,8 @@ public class DiffTreeViewer extends TreeViewer {
* @param node the node to expand
* @param level non-negative level, or <code>ALL_LEVELS</code> to collapse all levels of the tree
*/
+ @Override
protected void internalExpandToLevel(Widget node, int level) {
-
Object data= node.getData();
if (dontExpand(data))
@@ -394,6 +423,7 @@ public class DiffTreeViewer extends TreeViewer {
protected void fillContextMenu(IMenuManager manager) {
if (fExpandAllAction == null) {
fExpandAllAction= new Action() {
+ @Override
public void run() {
expandSelection();
}
@@ -404,7 +434,7 @@ public class DiffTreeViewer extends TreeViewer {
boolean enable= false;
ISelection selection= getSelection();
if (selection instanceof IStructuredSelection) {
- Iterator elements= ((IStructuredSelection)selection).iterator();
+ Iterator<?> elements= ((IStructuredSelection) selection).iterator();
while (elements.hasNext()) {
Object element= elements.next();
if (element instanceof IDiffContainer) {
@@ -427,7 +457,7 @@ public class DiffTreeViewer extends TreeViewer {
protected void expandSelection() {
ISelection selection= getSelection();
if (selection instanceof IStructuredSelection) {
- Iterator elements= ((IStructuredSelection)selection).iterator();
+ Iterator<?> elements= ((IStructuredSelection)selection).iterator();
while (elements.hasNext()) {
Object next= elements.next();
expandToLevel(next, ALL_LEVELS);
@@ -446,7 +476,7 @@ public class DiffTreeViewer extends TreeViewer {
protected void copySelected(boolean leftToRight) {
ISelection selection= getSelection();
if (selection instanceof IStructuredSelection) {
- Iterator e= ((IStructuredSelection) selection).iterator();
+ Iterator<?> e= ((IStructuredSelection) selection).iterator();
while (e.hasNext()) {
Object element= e.next();
if (element instanceof ICompareInput)
@@ -464,7 +494,6 @@ public class DiffTreeViewer extends TreeViewer {
* If <code>false</code> the right side is copied to the left side
*/
protected void copyOne(ICompareInput node, boolean leftToRight) {
-
node.copy(leftToRight);
// update node's image
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/Differencer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/Differencer.java
index 182790e3e..e42185a4c 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/Differencer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/Differencer.java
@@ -15,7 +15,6 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -58,7 +57,6 @@ import com.ibm.icu.text.MessageFormat;
* LEFT, RIGHT, and CONFLICTING.
*/
public class Differencer {
-
// The kind of differences.
/**
* Difference constant (value 0) indicating no difference.
@@ -112,7 +110,7 @@ public class Differencer {
static class Node {
- List fChildren;
+ List<Node> fChildren;
int fCode;
Object fAncestor;
Object fLeft;
@@ -121,31 +119,33 @@ public class Differencer {
Node() {
// nothing to do
}
+
Node(Node parent, Object ancestor, Object left, Object right) {
parent.add(this);
fAncestor= ancestor;
fLeft= left;
fRight= right;
}
+
void add(Node child) {
if (fChildren == null)
- fChildren= new ArrayList();
+ fChildren= new ArrayList<>();
fChildren.add(child);
}
+
Object visit(Differencer d, Object parent, int level) {
if (fCode == NO_CHANGE)
return null;
//dump(level);
Object data= d.visit(parent, fCode, fAncestor, fLeft, fRight);
if (fChildren != null) {
- Iterator i= fChildren.iterator();
- while (i.hasNext()) {
- Node n= (Node) i.next();
- n.visit(d, data, level+1);
+ for (Node n : fChildren) {
+ n.visit(d, data, level + 1);
}
}
return data;
}
+
// private void dump(int level) {
// String name= null;
// if (fAncestor instanceof ITypedElement)
@@ -216,15 +216,14 @@ public class Differencer {
* possibly <code>null</code>
*/
public Object findDifferences(boolean threeWay, IProgressMonitor pm, Object data, Object ancestor, Object left, Object right) {
-
Node root= new Node();
int code= traverse(threeWay, root, pm, threeWay ? ancestor : null, left, right);
if (code != NO_CHANGE) {
- List l= root.fChildren;
- if (l.size() > 0) {
- Node first= (Node)l.get(0);
+ List<Node> l= root.fChildren;
+ if (!l.isEmpty()) {
+ Node first= l.get(0);
return first.visit(this, data, 0);
}
}
@@ -234,8 +233,8 @@ public class Differencer {
/*
* Traverse tree in postorder.
*/
- private int traverse(boolean threeWay, Node parent, IProgressMonitor pm, Object ancestor, Object left, Object right) {
-
+ private int traverse(boolean threeWay, Node parent, IProgressMonitor pm,
+ Object ancestor, Object left, Object right) {
Object[] ancestorChildren= getChildren(ancestor);
Object[] rightChildren= getChildren(right);
Object[] leftChildren= getChildren(left);
@@ -251,13 +250,13 @@ public class Differencer {
// we only recurse down if no leg is null
// a node
- Set allSet= new HashSet(20);
- Map ancestorSet= null;
- Map rightSet= null;
- Map leftSet= null;
+ Set<Object> allSet= new HashSet<>(20);
+ Map<Object, Object> ancestorSet= null;
+ Map<Object, Object> rightSet= null;
+ Map<Object, Object> leftSet= null;
if (ancestorChildren != null) {
- ancestorSet= new HashMap(10);
+ ancestorSet= new HashMap<>(10);
for (int i= 0; i < ancestorChildren.length; i++) {
Object ancestorChild= ancestorChildren[i];
ancestorSet.put(ancestorChild, ancestorChild);
@@ -266,7 +265,7 @@ public class Differencer {
}
if (rightChildren != null) {
- rightSet= new HashMap(10);
+ rightSet= new HashMap<>(10);
for (int i= 0; i < rightChildren.length; i++) {
Object rightChild= rightChildren[i];
rightSet.put(rightChild, rightChild);
@@ -275,7 +274,7 @@ public class Differencer {
}
if (leftChildren != null) {
- leftSet= new HashMap(10);
+ leftSet= new HashMap<>(10);
for (int i= 0; i < leftChildren.length; i++) {
Object leftChild= leftChildren[i];
leftSet.put(leftChild, leftChild);
@@ -283,12 +282,8 @@ public class Differencer {
}
}
- Iterator e= allSet.iterator();
- while (e.hasNext()) {
- Object keyChild= e.next();
-
+ for (Object keyChild : allSet) {
if (pm != null) {
-
if (pm.isCanceled())
throw new OperationCanceledException();
@@ -533,7 +528,7 @@ public class Differencer {
*/
protected Object[] getChildren(Object input) {
if (input instanceof IStructureComparator)
- return ((IStructureComparator)input).getChildren();
+ return ((IStructureComparator) input).getChildren();
return null;
}
@@ -549,7 +544,7 @@ public class Differencer {
*/
protected void updateProgress(IProgressMonitor progressMonitor, Object node) {
if (node instanceof ITypedElement) {
- String name= ((ITypedElement)node).getName();
+ String name= ((ITypedElement) node).getName();
String fmt= Utilities.getString("Differencer.progressFormat"); //$NON-NLS-1$
String msg= MessageFormat.format(fmt, name );
progressMonitor.subTask(msg);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java
index 58aa841f3..5a0601cc6 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java
@@ -14,12 +14,24 @@ import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.ArrayList;
-import org.eclipse.compare.*;
+import org.eclipse.compare.IEditableContent;
+import org.eclipse.compare.IEditableContentExtension;
+import org.eclipse.compare.IEncodedStreamContentAccessor;
+import org.eclipse.compare.ISharedDocumentAdapter;
+import org.eclipse.compare.IStreamContentAccessor;
+import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.contentmergeviewer.IDocumentRange;
import org.eclipse.compare.internal.CompareUIPlugin;
import org.eclipse.compare.internal.Utilities;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.text.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
import org.eclipse.swt.widgets.Shell;
@@ -48,8 +60,8 @@ import org.eclipse.swt.widgets.Shell;
* @see Differencer
*/
public class DocumentRangeNode
- implements IDocumentRange, IStructureComparator, IEditableContent, IEncodedStreamContentAccessor, IAdaptable, IEditableContentExtension {
-
+ implements IDocumentRange, IStructureComparator, IEditableContent,
+ IEncodedStreamContentAccessor, IAdaptable, IEditableContentExtension {
private static final String UTF_16= "UTF-16"; //$NON-NLS-1$
private IDocument fBaseDocument;
@@ -57,7 +69,7 @@ public class DocumentRangeNode
private int fTypeCode;
private String fID;
private Position fAppendPosition; // a position where to insert a child textually
- private ArrayList fChildren;
+ private ArrayList<DocumentRangeNode> fChildren;
private final DocumentRangeNode fParent;
/**
@@ -113,6 +125,7 @@ public class DocumentRangeNode
/* (non Javadoc)
* see IDocumentRange.getDocument
*/
+ @Override
public IDocument getDocument() {
return fBaseDocument;
}
@@ -120,6 +133,7 @@ public class DocumentRangeNode
/* (non Javadoc)
* see IDocumentRange.getRange
*/
+ @Override
public Position getRange() {
return fRange;
}
@@ -161,13 +175,11 @@ public class DocumentRangeNode
*/
public void addChild(DocumentRangeNode node) {
if (fChildren == null)
- fChildren= new ArrayList();
+ fChildren= new ArrayList<>();
fChildren.add(node);
}
- /* (non Javadoc)
- * see IStructureComparator.getChildren
- */
+ @Override
public Object[] getChildren() {
if (fChildren != null)
return fChildren.toArray();
@@ -243,6 +255,7 @@ public class DocumentRangeNode
* @param other the object to compare this <code>DocumentRangeNode</code> against.
* @return <code>true</code> if the <code>DocumentRangeNodes</code>are equal; <code>false</code> otherwise.
*/
+ @Override
public boolean equals(Object other) {
if (other != null && other.getClass() == getClass()) {
DocumentRangeNode tn= (DocumentRangeNode) other;
@@ -255,6 +268,7 @@ public class DocumentRangeNode
* Implementation based on <code>getID</code>.
* @return a hash code for this object.
*/
+ @Override
public int hashCode() {
return fID.hashCode();
}
@@ -271,10 +285,10 @@ public class DocumentRangeNode
if (ix >= 0) {
for (int i= ix - 1; i >= 0; i--) {
- DocumentRangeNode c1= (DocumentRangeNode) otherParent.fChildren.get(i);
+ DocumentRangeNode c1= otherParent.fChildren.get(i);
int i2= fChildren.indexOf(c1);
if (i2 >= 0) {
- DocumentRangeNode c= (DocumentRangeNode) fChildren.get(i2);
+ DocumentRangeNode c= fChildren.get(i2);
//System.out.println(" found corresponding: " + i2 + " " + c);
Position p= c.fRange;
@@ -289,10 +303,10 @@ public class DocumentRangeNode
}
for (int i= ix; i < otherParent.fChildren.size(); i++) {
- DocumentRangeNode c1= (DocumentRangeNode) otherParent.fChildren.get(i);
+ DocumentRangeNode c1= otherParent.fChildren.get(i);
int i2= fChildren.indexOf(c1);
if (i2 >= 0) {
- DocumentRangeNode c= (DocumentRangeNode) fChildren.get(i2);
+ DocumentRangeNode c= fChildren.get(i2);
//System.out.println(" found corresponding: " + i2 + " " + c);
Position p= c.fRange;
//try {
@@ -325,6 +339,7 @@ public class DocumentRangeNode
/* (non Javadoc)
* see IStreamContentAccessor.getContents
*/
+ @Override
public InputStream getContents() {
String s;
try {
@@ -341,17 +356,15 @@ public class DocumentRangeNode
* Otherwise return <code>true</code>. Subclasses may override.
* @see org.eclipse.compare.IEditableContent#isEditable()
*/
+ @Override
public boolean isEditable() {
if (fParent != null)
return fParent.isEditable();
return true;
}
- /* (non Javadoc)
- * see IEditableContent.replace
- */
+ @Override
public ITypedElement replace(ITypedElement child, ITypedElement other) {
-
if (fParent == null) {
// TODO: I don't believe this code does anything useful but just in case
// I'm leaving it in but disabling it for the shared document case
@@ -386,6 +399,7 @@ public class DocumentRangeNode
* after the contents have been set.
* @see org.eclipse.compare.IEditableContent#setContent(byte[])
*/
+ @Override
public void setContent(byte[] content) {
internalSetContents(content);
nodeChanged(this);
@@ -399,12 +413,9 @@ public class DocumentRangeNode
*/
protected void internalSetContents(byte[] content) {
// By default, do nothing
-
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.IStreamContentAccessor#getEncoding()
- */
+ @Override
public String getCharset() {
return UTF_16;
}
@@ -431,25 +442,22 @@ public class DocumentRangeNode
* @see IAdaptable#getAdapter(Class)
* @since 3.3
*/
- public Object getAdapter(Class adapter) {
+ @Override
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == ISharedDocumentAdapter.class && fParent != null)
return fParent.getAdapter(adapter);
return Platform.getAdapterManager().getAdapter(this, adapter);
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.IEditableContentExtension#isReadOnly()
- */
+ @Override
public boolean isReadOnly() {
if (fParent != null)
return fParent.isReadOnly();
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.IEditableContentExtension#validateEdit(org.eclipse.swt.widgets.Shell)
- */
+ @Override
public IStatus validateEdit(Shell shell) {
if (fParent != null)
return fParent.validateEdit(shell);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureComparator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureComparator.java
index 4740bdadf..bbfd40dee 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureComparator.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/IStructureComparator.java
@@ -21,7 +21,6 @@ package org.eclipse.compare.structuremergeviewer;
* @see Differencer
*/
public interface IStructureComparator {
-
/**
* Returns an iterator for all children of this object or <code>null</code>
* if there are no children.
@@ -41,5 +40,6 @@ public interface IStructureComparator {
* @return <code>true</code> if this object is the same as the other argument; <code>false</code> otherwise
* @see java.lang.Object#equals
*/
+ @Override
boolean equals(Object other);
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/SharedDocumentAdapterWrapper.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/SharedDocumentAdapterWrapper.java
index c3a379ff9..c240a4533 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/SharedDocumentAdapterWrapper.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/SharedDocumentAdapterWrapper.java
@@ -13,7 +13,7 @@ package org.eclipse.compare.structuremergeviewer;
import org.eclipse.compare.ISharedDocumentAdapter;
import org.eclipse.compare.SharedDocumentAdapter;
import org.eclipse.compare.internal.Utilities;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.texteditor.IDocumentProvider;
@@ -27,7 +27,6 @@ import org.eclipse.ui.texteditor.IDocumentProvider;
* @since 3.3
*/
public class SharedDocumentAdapterWrapper implements ISharedDocumentAdapter {
-
private ISharedDocumentAdapter wrappedAdapter;
/**
@@ -50,31 +49,23 @@ public class SharedDocumentAdapterWrapper implements ISharedDocumentAdapter {
this.wrappedAdapter = wrappedAdapter;
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.ISharedDocumentAdapter#connect(org.eclipse.ui.texteditor.IDocumentProvider, org.eclipse.ui.IEditorInput)
- */
+ @Override
public void connect(IDocumentProvider provider, IEditorInput documentKey)
throws CoreException {
wrappedAdapter.connect(provider, documentKey);
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.ISharedDocumentAdapter#disconnect(org.eclipse.ui.texteditor.IDocumentProvider, org.eclipse.ui.IEditorInput)
- */
+ @Override
public void disconnect(IDocumentProvider provider, IEditorInput documentKey) {
wrappedAdapter.disconnect(provider, documentKey);
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.ISharedDocumentAdapter#getDocumentKey(java.lang.Object)
- */
+ @Override
public IEditorInput getDocumentKey(Object element) {
return wrappedAdapter.getDocumentKey(element);
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.ISharedDocumentAdapter#saveDocument(org.eclipse.ui.texteditor.IDocumentProvider, org.eclipse.ui.IEditorInput, org.eclipse.jface.text.IDocument, boolean, org.eclipse.core.runtime.IProgressMonitor)
- */
+ @Override
public void flushDocument(IDocumentProvider provider,
IEditorInput documentKey, IDocument document, boolean overwrite) throws CoreException {
wrappedAdapter.flushDocument(provider, documentKey, document, overwrite);
@@ -88,9 +79,7 @@ public class SharedDocumentAdapterWrapper implements ISharedDocumentAdapter {
return wrappedAdapter;
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.ISharedDocumentAdapter#disconnect(java.lang.Object)
- */
+ @Override
public void disconnect(Object element) {
IEditorInput input = getDocumentKey(element);
if (input == null)
@@ -100,5 +89,4 @@ public class SharedDocumentAdapterWrapper implements ISharedDocumentAdapter {
return;
disconnect(provider, input);
}
-
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureCreator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureCreator.java
index f978ef0a2..e7fd54315 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureCreator.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureCreator.java
@@ -49,10 +49,7 @@ import org.eclipse.ui.texteditor.IDocumentProvider;
* @since 3.3
*/
public abstract class StructureCreator implements IStructureCreator2 {
-
- /* (non-Javadoc)
- * @see org.eclipse.compare.structuremergeviewer.IStructureCreator#getStructure(java.lang.Object)
- */
+ @Override
public IStructureComparator getStructure(Object input) {
String contents= null;
IDocument doc= CompareUI.getDocument(input);
@@ -85,12 +82,12 @@ public abstract class StructureCreator implements IStructureCreator2 {
}
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.structuremergeviewer.IStructureCreator2#createStructure(java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStructureComparator createStructure(final Object element, final IProgressMonitor monitor) throws CoreException {
+ @Override
+ public IStructureComparator createStructure(final Object element,
+ final IProgressMonitor monitor) throws CoreException {
final IStructureComparator[] result = new IStructureComparator[] { null };
Runnable runnable = new Runnable() {
+ @Override
public void run() {
try {
result[0]= internalCreateStructure(element, monitor);
@@ -131,7 +128,7 @@ public abstract class StructureCreator implements IStructureCreator2 {
}
/**
- * Create an {@link IStructureComparator} for the given element using the
+ * Creates an {@link IStructureComparator} for the given element using the
* contents available in the given document. If the provided
* {@link ISharedDocumentAdapter} is not <code>null</code> then the
* {@link IStructureComparator} returned by this method must implement the
@@ -163,7 +160,7 @@ public abstract class StructureCreator implements IStructureCreator2 {
IProgressMonitor monitor) throws CoreException;
/**
- * Setup the newly created document as appropriate. Any document partitioners
+ * Sets up the newly created document as appropriate. Any document partitioners
* should be added to a custom slot using the {@link IDocumentExtension3} interface
* in case the document is shared via a file buffer.
* @param document a document
@@ -191,7 +188,7 @@ public abstract class StructureCreator implements IStructureCreator2 {
}
/**
- * Return the partitioner to be associated with the document or
+ * Returns the partitioner to be associated with the document or
* <code>null</code> is partitioning is not needed or if the subclass
* overrode {@link #setupDocument(IDocument)} directly.
* @return a partitioner
@@ -201,7 +198,7 @@ public abstract class StructureCreator implements IStructureCreator2 {
}
/**
- * Return the partitioning to which the partitioner returned from
+ * Returns the partitioning to which the partitioner returned from
* {@link #getDocumentPartitioner()} is to be associated. Return <code>null</code>
* only if partitioning is not needed or if the subclass
* overrode {@link #setupDocument(IDocument)} directly.
@@ -222,6 +219,7 @@ public abstract class StructureCreator implements IStructureCreator2 {
* input, then the save is issued through the shared document adapter.
* @see org.eclipse.compare.structuremergeviewer.IStructureCreator#save(org.eclipse.compare.structuremergeviewer.IStructureComparator, java.lang.Object)
*/
+ @Override
public void save(IStructureComparator node, Object input) {
if (node instanceof IDocumentRange && input instanceof IEditableContent) {
IDocument document= ((IDocumentRange)node).getDocument();
@@ -285,6 +283,7 @@ public abstract class StructureCreator implements IStructureCreator2 {
private final ISharedDocumentAdapter wrapSharedDocumentAdapter(ISharedDocumentAdapter elementAdapter, final Object input, final IDocument document) {
// We need to wrap the adapter so that the proper document key gets returned
return new SharedDocumentAdapterWrapper(elementAdapter) {
+ @Override
public IEditorInput getDocumentKey(Object element) {
if (hasSameDocument(element)) {
return super.getDocumentKey(input);
@@ -313,6 +312,7 @@ public abstract class StructureCreator implements IStructureCreator2 {
* @return the sub-structure element in the input for the given element
* @throws CoreException if a parse error occurred
*/
+ @Override
public ITypedElement createElement(Object element, Object input, IProgressMonitor monitor)
throws CoreException {
String[] path= getPath(element, input);
@@ -344,6 +344,7 @@ public abstract class StructureCreator implements IStructureCreator2 {
* @param input the containing input
* @return the sub-structure element in the input for the given element
*/
+ @Override
public IStructureComparator locate(Object element, Object input) {
String[] path= getPath(element, input);
if (path == null)
@@ -358,7 +359,7 @@ public abstract class StructureCreator implements IStructureCreator2 {
}
/**
- * Find the element at the given path in the given structure.
+ * Finds the element at the given path in the given structure.
* This method is invoked from the {@link #createElement(Object, Object, IProgressMonitor)}
* and {@link #locate(Object, Object)} methods to find the element for
* the given path.
@@ -401,7 +402,7 @@ public abstract class StructureCreator implements IStructureCreator2 {
}
/**
- * Return the path of the element in the structure of it's containing input
+ * Returns the path of the element in the structure of it's containing input
* or <code>null</code> if the element is not contained in the input. This method is
* invoked from {@link #createElement(Object, Object, IProgressMonitor)} and
* {@link #locate(Object, Object)} methods to determine
@@ -416,9 +417,7 @@ public abstract class StructureCreator implements IStructureCreator2 {
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.structuremergeviewer.IStructureCreator2#destroy(java.lang.Object)
- */
+ @Override
public void destroy(Object object) {
IDisposable disposable = getDisposable(object);
if (disposable != null)
@@ -464,9 +463,9 @@ public abstract class StructureCreator implements IStructureCreator2 {
Object node2, char contributor2, boolean ignoreWhitespace,
ICompareFilter[] compareFilters) {
- List lines1 = LineReader.readLines(new BufferedReader(new StringReader(
+ List<String> lines1 = LineReader.readLines(new BufferedReader(new StringReader(
getContents(node1, false))));
- List lines2 = LineReader.readLines(new BufferedReader(new StringReader(
+ List<String> lines2 = LineReader.readLines(new BufferedReader(new StringReader(
getContents(node2, false))));
StringBuffer buffer1 = new StringBuffer();
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java
index 7df336d0c..a6520ec3d 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java
@@ -12,17 +12,33 @@ package org.eclipse.compare.structuremergeviewer;
import java.lang.reflect.InvocationTargetException;
-import org.eclipse.compare.*;
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareUI;
+import org.eclipse.compare.CompareViewerSwitchingPane;
+import org.eclipse.compare.ICompareFilter;
+import org.eclipse.compare.IContentChangeListener;
+import org.eclipse.compare.IContentChangeNotifier;
+import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.contentmergeviewer.IDocumentRange;
-import org.eclipse.compare.internal.*;
-import org.eclipse.core.runtime.*;
+import org.eclipse.compare.internal.ChangeCompareFilterPropertyAction;
+import org.eclipse.compare.internal.CompareMessages;
+import org.eclipse.compare.internal.CompareUIPlugin;
+import org.eclipse.compare.internal.Utilities;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.services.IDisposable;
@@ -58,6 +74,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
* A set of background tasks for updating the structure
*/
private IRunnableWithProgress diffTask = new IRunnableWithProgress() {
+ @Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
monitor.beginTask(CompareMessages.StructureDiffViewer_0, 100);
@@ -67,6 +84,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
};
private IRunnableWithProgress inputChangedTask = new IRunnableWithProgress() {
+ @Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
monitor.beginTask(CompareMessages.StructureDiffViewer_1, 100);
@@ -84,6 +102,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
private ITypedElement fInput;
private IStructureComparator fStructureComparator;
private IRunnableWithProgress refreshTask = new IRunnableWithProgress() {
+ @Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
refresh(monitor);
@@ -204,11 +223,13 @@ public class StructureDiffViewer extends DiffTreeViewer {
setAutoExpandLevel(3);
fContentChangedListener= new IContentChangeListener() {
+ @Override
public void contentChanged(IContentChangeNotifier changed) {
StructureDiffViewer.this.contentChanged(changed);
}
};
fCompareInputChangeListener = new ICompareInputChangeListener() {
+ @Override
public void compareInputChanged(ICompareInput input) {
StructureDiffViewer.this.compareInputChanged(input, true);
}
@@ -245,6 +266,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
* Reimplemented to get the descriptive title for this viewer from the <code>IStructureCreator</code>.
* @return the viewer's name
*/
+ @Override
public String getTitle() {
if (fStructureCreator != null)
return fStructureCreator.getName();
@@ -257,6 +279,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
*
* @return the root of the diff tree produced by method <code>diff</code>
*/
+ @Override
protected Object getRoot() {
return fRoot;
}
@@ -267,6 +290,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
* and to feed them through the differencing engine. Note: for this viewer
* the value from <code>getInput</code> is not identical to <code>getRoot</code>.
*/
+ @Override
protected void inputChanged(Object input, Object oldInput) {
if (oldInput instanceof ICompareInput) {
ICompareInput old = (ICompareInput) oldInput;
@@ -281,6 +305,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
}
}
+ @Override
protected void initialSelection() {
expandToLevel(2);
}
@@ -288,6 +313,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
/* (non Javadoc)
* Overridden to unregister all listeners.
*/
+ @Override
protected void handleDispose(DisposeEvent event) {
Object input = getInput();
if (input instanceof ICompareInput) {
@@ -317,6 +343,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
// The compare configuration is nulled when the viewer is disposed
if (cc != null) {
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
+ @Override
public void run() {
try {
inputChangedTask.run(new NullProgressMonitor());
@@ -385,7 +412,6 @@ public class StructureDiffViewer extends DiffTreeViewer {
* @param changed the object that sent out the notification
*/
protected void contentChanged(final IContentChangeNotifier changed) {
-
if (fStructureCreator == null)
return;
@@ -418,6 +444,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
* @deprecated Clients should override
* {@link #preDiffHook(IStructureComparator, IStructureComparator, IStructureComparator, IProgressMonitor)}
*/
+ @Deprecated
protected void preDiffHook(IStructureComparator ancestor, IStructureComparator left, IStructureComparator right) {
// we do nothing here
}
@@ -440,6 +467,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
*/
protected void preDiffHook(final IStructureComparator ancestor, final IStructureComparator left, final IStructureComparator right, IProgressMonitor monitor) {
syncExec(new Runnable() {
+ @Override
public void run() {
preDiffHook(ancestor, left, right);
}
@@ -470,16 +498,16 @@ public class StructureDiffViewer extends DiffTreeViewer {
// could not get structure of one (or more) of the legs
fRoot= null;
message= CompareMessages.StructureDiffViewer_StructureError;
-
} else { // calculate difference of the two (or three) structures
-
if (fDifferencer == null)
fDifferencer= new Differencer() {
+ @Override
protected boolean contentsEqual(Object o1,
char contributor1, Object o2, char contributor2) {
return StructureDiffViewer.this.contentsEqual(o1,
contributor1, o2, contributor2);
}
+ @Override
protected Object visit(Object data, int result, Object ancestor, Object left, Object right) {
Object o= super.visit(data, result, ancestor, left, right);
if (!getCompareConfiguration().isMirrored() && o instanceof DiffNode)
@@ -498,11 +526,12 @@ public class StructureDiffViewer extends DiffTreeViewer {
}
}
- if (Display.getCurrent() != null)
+ if (Display.getCurrent() != null) {
refreshAfterDiff(message);
- else {
+ } else {
final String theMessage = message;
Display.getDefault().asyncExec(new Runnable() {
+ @Override
public void run() {
refreshAfterDiff(theMessage);
}
@@ -533,6 +562,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
// A null compare configuration indicates that the viewer was disposed
if (compareConfiguration != null) {
compareConfiguration.getContainer().run(true, true, new IRunnableWithProgress() {
+ @Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(CompareMessages.StructureDiffViewer_2, 100);
diffTask.run(new SubProgressMonitor(monitor, 100));
@@ -552,16 +582,18 @@ public class StructureDiffViewer extends DiffTreeViewer {
private void handleFailedRefresh(final String message) {
Runnable runnable = new Runnable() {
+ @Override
public void run() {
if (getControl().isDisposed())
return;
refreshAfterDiff(message);
}
};
- if (Display.getCurrent() != null)
+ if (Display.getCurrent() != null) {
runnable.run();
- else
+ } else {
Display.getDefault().asyncExec(runnable);
+ }
}
/**
@@ -577,6 +609,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
* {@link #postDiffHook(Differencer, IDiffContainer, IProgressMonitor)}
* instead
*/
+ @Deprecated
protected void postDiffHook(Differencer differencer, IDiffContainer root) {
// we do nothing here
}
@@ -599,6 +632,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
*/
protected void postDiffHook(final Differencer differencer, final IDiffContainer root, IProgressMonitor monitor) {
syncExec(new Runnable() {
+ @Override
public void run() {
postDiffHook(differencer, root);
}
@@ -616,18 +650,18 @@ public class StructureDiffViewer extends DiffTreeViewer {
boolean ignoreWhiteSpace = Utilities.getBoolean(
getCompareConfiguration(),
CompareConfiguration.IGNORE_WHITESPACE, false);
- ICompareFilter[] compareFilters = Utilities
- .getCompareFilters(getCompareConfiguration());
+ ICompareFilter[] compareFilters =
+ Utilities.getCompareFilters(getCompareConfiguration());
String s1, s2;
if (compareFilters != null && compareFilters.length > 0
&& fStructureCreator instanceof StructureCreator) {
return ((StructureCreator) fStructureCreator).contentsEquals(
o1, contributor1, o2, contributor2, ignoreWhiteSpace,
compareFilters);
- } else {
- s1 = fStructureCreator.getContents(o1, ignoreWhiteSpace);
- s2 = fStructureCreator.getContents(o2, ignoreWhiteSpace);
}
+
+ s1 = fStructureCreator.getContents(o1, ignoreWhiteSpace);
+ s2 = fStructureCreator.getContents(o2, ignoreWhiteSpace);
if (s1 == null || s2 == null)
return false;
return s1.equals(s2);
@@ -641,15 +675,14 @@ public class StructureDiffViewer extends DiffTreeViewer {
* In this case they must call the inherited method.
* @param event the property changed event that triggered the call to this method
*/
+ @Override
protected void propertyChange(PropertyChangeEvent event) {
String key= event.getProperty();
if (key.equals(CompareConfiguration.IGNORE_WHITESPACE)) {
diff();
- } else if (key
- .equals(ChangeCompareFilterPropertyAction.COMPARE_FILTERS)
- && getCompareConfiguration()
- .getProperty(
- ChangeCompareFilterPropertyAction.COMPARE_FILTERS_INITIALIZING) == null) {
+ } else if (key.equals(ChangeCompareFilterPropertyAction.COMPARE_FILTERS)
+ && getCompareConfiguration().getProperty(
+ ChangeCompareFilterPropertyAction.COMPARE_FILTERS_INITIALIZING) == null) {
diff();
} else if (key.equals("ANCESTOR_STRUCTURE_REFRESH")) { //$NON-NLS-1$
fAncestorStructure.refresh(new NullProgressMonitor());
@@ -677,24 +710,27 @@ public class StructureDiffViewer extends DiffTreeViewer {
* @param leftToRight if <code>true</code> the left side is copied to the right side.
* If <code>false</code> the right side is copied to the left side
*/
+ @Override
protected void copySelected(boolean leftToRight) {
super.copySelected(leftToRight);
- if (fStructureCreator != null)
+ if (fStructureCreator != null) {
fStructureCreator.save(
leftToRight ? fRightStructure.getStructureComparator() : fLeftStructure.getStructureComparator(),
leftToRight ? fRightStructure.getInput() : fLeftStructure.getInput());
+ }
}
private void syncExec(final Runnable runnable) {
if (getControl().isDisposed())
return;
- if (Display.getCurrent() != null)
+ if (Display.getCurrent() != null) {
runnable.run();
- else
+ } else {
getControl().getDisplay().syncExec(() -> {
if (!getControl().isDisposed()) runnable.run();
});
+ }
}
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureRootNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureRootNode.java
index 3ea3f04d5..57056b617 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureRootNode.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureRootNode.java
@@ -10,7 +10,9 @@
*******************************************************************************/
package org.eclipse.compare.structuremergeviewer;
-import org.eclipse.compare.*;
+import org.eclipse.compare.IEditableContentExtension;
+import org.eclipse.compare.ISharedDocumentAdapter;
+import org.eclipse.compare.ITypedElement;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.text.IDocument;
@@ -35,7 +37,6 @@ import org.eclipse.ui.services.IDisposable;
* @since 3.3
*/
public class StructureRootNode extends DocumentRangeNode implements IDisposable, ITypedElement {
-
/**
* The integer constant (value <code>0</code>) that is used as the type code of the root node.
* @see #getTypeCode()
@@ -70,6 +71,7 @@ public class StructureRootNode extends DocumentRangeNode implements IDisposable,
/* (non-Javadoc)
* @see org.eclipse.ui.services.IDisposable#dispose()
*/
+ @Override
public void dispose() {
if (fAdapter != null) {
fAdapter.disconnect(fInput);
@@ -84,9 +86,11 @@ public class StructureRootNode extends DocumentRangeNode implements IDisposable,
* @return the object adapted to the given class or <code>null</code>
* @see IAdaptable#getAdapter(Class)
*/
- public Object getAdapter(Class adapter) {
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == ISharedDocumentAdapter.class) {
- return fAdapter;
+ return (T) fAdapter;
}
return super.getAdapter(adapter);
}
@@ -96,13 +100,12 @@ public class StructureRootNode extends DocumentRangeNode implements IDisposable,
* contents of a node have changed.
* @param node the changed node
*/
+ @Override
protected void nodeChanged(DocumentRangeNode node) {
fCreator.save(this, fInput);
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.structuremergeviewer.DocumentRangeNode#replace(org.eclipse.compare.ITypedElement, org.eclipse.compare.ITypedElement)
- */
+ @Override
public ITypedElement replace(ITypedElement child, ITypedElement other) {
// TODO: I believe the parent implementation is flawed but didn't to remove
// it in case I was missing something so I overrode it instead
@@ -113,6 +116,7 @@ public class StructureRootNode extends DocumentRangeNode implements IDisposable,
/* (non-Javadoc)
* @see org.eclipse.compare.ITypedElement#getImage()
*/
+ @Override
public Image getImage() {
return null;
}
@@ -120,6 +124,7 @@ public class StructureRootNode extends DocumentRangeNode implements IDisposable,
/* (non-Javadoc)
* @see org.eclipse.compare.ITypedElement#getName()
*/
+ @Override
public String getName() {
return getId();
}
@@ -127,6 +132,7 @@ public class StructureRootNode extends DocumentRangeNode implements IDisposable,
/* (non-Javadoc)
* @see org.eclipse.compare.ITypedElement#getType()
*/
+ @Override
public String getType() {
return FOLDER_TYPE;
}
@@ -134,6 +140,7 @@ public class StructureRootNode extends DocumentRangeNode implements IDisposable,
/* (non-Javadoc)
* @see org.eclipse.compare.structuremergeviewer.DocumentRangeNode#isReadOnly()
*/
+ @Override
public boolean isReadOnly() {
if (fInput instanceof IEditableContentExtension) {
IEditableContentExtension ext = (IEditableContentExtension) fInput;
@@ -145,6 +152,7 @@ public class StructureRootNode extends DocumentRangeNode implements IDisposable,
/* (non-Javadoc)
* @see org.eclipse.compare.structuremergeviewer.DocumentRangeNode#validateEdit(org.eclipse.swt.widgets.Shell)
*/
+ @Override
public IStatus validateEdit(Shell shell) {
if (fInput instanceof IEditableContentExtension) {
IEditableContentExtension ext = (IEditableContentExtension) fInput;

Back to the top