Skip to content

Commit b0d11dd

Browse files
Perform clean code of team/bundles/org.eclipse.compare.core
1 parent d66de99 commit b0d11dd

File tree

14 files changed

+249
-132
lines changed

14 files changed

+249
-132
lines changed

team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/LCS.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@ private int lcs_rec(
168168
}
169169

170170
private void worked(SubMonitor subMonitor, int work) {
171-
if (subMonitor.isCanceled())
171+
if (subMonitor.isCanceled()) {
172172
throw new OperationCanceledException();
173+
}
173174
subMonitor.worked(work);
174175
}
175176

team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/TextLineLCS.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ public TextLineLCS(TextLine[] lines1, TextLine[] lines2) {
3030

3131
public TextLine[][] getResult() {
3232
int length = getLength();
33-
if (length == 0)
33+
if (length == 0) {
3434
return new TextLine[2][0];
35+
}
3536
TextLine[][] result = new TextLine[2][];
3637

3738
// compact and shift the result

team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/DiffProject.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ public DiffProject(String project) {
3939
*/
4040
public void add(FilePatch2 diff) {
4141
this.fDiffs.add(diff);
42-
if (diff.getProject() != this)
42+
if (diff.getProject() != this) {
4343
diff.setProject(this);
44+
}
4445
}
4546

4647
/**

team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FileDiffResult.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ protected List<String> getLines(ReaderCreator content, boolean create) {
132132
}
133133

134134
protected boolean isEmpty(ReaderCreator content) {
135-
if (content == null)
135+
if (content == null) {
136136
return true;
137+
}
137138
return LineReader.load(content, false).isEmpty();
138139
}
139140

@@ -170,19 +171,22 @@ public boolean getDiffProblem() {
170171
* @return true if this Diff or any of its children Hunks have a problem, false if it doesn't
171172
*/
172173
public boolean containsProblems() {
173-
if (this.fDiffProblem)
174+
if (this.fDiffProblem) {
174175
return true;
176+
}
175177
for (HunkResult result : this.fHunkResults.values()) {
176-
if (!result.isOK())
178+
if (!result.isOK()) {
177179
return true;
180+
}
178181
}
179182
return false;
180183
}
181184

182185
public String getLabel() {
183186
String label= getTargetPath().toString();
184-
if (this.fDiffProblem)
187+
if (this.fDiffProblem) {
185188
return NLS.bind(Messages.FileDiffResult_2, new String[] {label, this.fErrorMessage});
189+
}
186190
return label;
187191
}
188192

@@ -206,8 +210,9 @@ public List<String> getLines() {
206210
* @return the fuzz factor or <code>-1</code> if no hunks could be matched
207211
*/
208212
public int calculateFuzz(List<String> lines, IProgressMonitor monitor) {
209-
if (monitor == null)
213+
if (monitor == null) {
210214
monitor = new NullProgressMonitor();
215+
}
211216
this.fBeforeLines = new ArrayList<>(lines);
212217
// TODO: What about deletions?
213218
if (this.fDiff.getDiffType(getConfiguration().isReversed()) == FilePatch2.ADDITION) {
@@ -226,8 +231,9 @@ public int calculateFuzz(List<String> lines, IProgressMonitor monitor) {
226231
result.setShift(shift);
227232
int fuzz = result.calculateFuzz(lines, monitor);
228233
shift = result.getShift();
229-
if (fuzz > highestFuzz)
234+
if (fuzz > highestFuzz) {
230235
highestFuzz = fuzz;
236+
}
231237
monitor.worked(1);
232238
}
233239
this.fAfterLines = lines;
@@ -252,8 +258,9 @@ public List<Hunk> getFailedHunks() {
252258
IHunk[] hunks = this.fDiff.getHunks();
253259
for (IHunk hunk : hunks) {
254260
HunkResult result = this.fHunkResults.get(hunk);
255-
if (result != null && !result.isOK())
261+
if (result != null && !result.isOK()) {
256262
failedHunks.add(result.getHunk());
263+
}
257264
}
258265
return failedHunks;
259266
}

team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FilePatch2.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ public DiffProject getProject() {
8080
* @param diffProject the parent project
8181
*/
8282
void setProject(DiffProject diffProject) {
83-
if (this.fProject == diffProject)
83+
if (this.fProject == diffProject) {
8484
return;
85-
if (this.fProject != null)
85+
}
86+
if (this.fProject != null) {
8687
this.fProject.remove(this);
88+
}
8789
this.fProject= diffProject;
8890
}
8991

@@ -95,14 +97,17 @@ void setProject(DiffProject diffProject) {
9597
*/
9698
public IPath getPath(boolean reverse) {
9799
if (getDiffType(reverse) == ADDITION) {
98-
if (reverse)
100+
if (reverse) {
99101
return this.fOldPath;
102+
}
100103
return this.fNewPath;
101104
}
102-
if (reverse && this.fNewPath != null)
105+
if (reverse && this.fNewPath != null) {
103106
return this.fNewPath;
104-
if (this.fOldPath != null)
107+
}
108+
if (this.fOldPath != null) {
105109
return this.fOldPath;
110+
}
106111
return this.fNewPath;
107112
}
108113

@@ -178,8 +183,9 @@ public int getDiffType(boolean reverse) {
178183
*/
179184
public IPath getStrippedPath(int strip, boolean reverse) {
180185
IPath path= getPath(reverse);
181-
if (strip > 0 && strip < path.segmentCount())
186+
if (strip > 0 && strip < path.segmentCount()) {
182187
path= path.removeFirstSegments(strip);
188+
}
183189
return path;
184190
}
185191

@@ -191,10 +197,12 @@ public int segmentCount() {
191197
//Update prefix count - go through all of the diffs and find the smallest
192198
//path segment contained in all diffs.
193199
int length= 99;
194-
if (this.fOldPath != null)
200+
if (this.fOldPath != null) {
195201
length= Math.min(length, this.fOldPath.segmentCount());
196-
if (this.fNewPath != null)
202+
}
203+
if (this.fNewPath != null) {
197204
length= Math.min(length, this.fNewPath.segmentCount());
205+
}
198206
return length;
199207
}
200208

@@ -212,8 +220,9 @@ public IPath getTargetPath(PatchConfiguration configuration) {
212220
}
213221

214222
public FilePatch2 asRelativeDiff() {
215-
if (this.fProject == null)
223+
if (this.fProject == null) {
216224
return this;
225+
}
217226
IPath adjustedOldPath = null;
218227
if (this.fOldPath != null) {
219228
adjustedOldPath = new Path(null, this.fProject.getName()).append(this.fOldPath);

0 commit comments

Comments
 (0)