Skip to content

Commit 1b0231b

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of team/bundles/org.eclipse.compare.core
1 parent 609682c commit 1b0231b

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
@@ -143,8 +143,9 @@ protected List<String> getLines(ReaderCreator content, boolean create) {
143143
}
144144

145145
protected boolean isEmpty(ReaderCreator content) {
146-
if (content == null)
146+
if (content == null) {
147147
return true;
148+
}
148149
return LineReader.load(content, false).isEmpty();
149150
}
150151

@@ -181,19 +182,22 @@ public boolean getDiffProblem() {
181182
* @return true if this Diff or any of its children Hunks have a problem, false if it doesn't
182183
*/
183184
public boolean containsProblems() {
184-
if (this.fDiffProblem)
185+
if (this.fDiffProblem) {
185186
return true;
187+
}
186188
for (HunkResult result : this.fHunkResults.values()) {
187-
if (!result.isOK())
189+
if (!result.isOK()) {
188190
return true;
191+
}
189192
}
190193
return false;
191194
}
192195

193196
public String getLabel() {
194197
String label= getTargetPath().toString();
195-
if (this.fDiffProblem)
198+
if (this.fDiffProblem) {
196199
return NLS.bind(Messages.FileDiffResult_2, label, this.fErrorMessage);
200+
}
197201
return label;
198202
}
199203

@@ -217,8 +221,9 @@ public List<String> getLines() {
217221
* @return the fuzz factor or <code>-1</code> if no hunks could be matched
218222
*/
219223
public int calculateFuzz(List<String> lines, IProgressMonitor monitor) {
220-
if (monitor == null)
224+
if (monitor == null) {
221225
monitor = new NullProgressMonitor();
226+
}
222227
this.fBeforeLines = new ArrayList<>(lines);
223228
// TODO: What about deletions?
224229
if (this.fDiff.getDiffType(getConfiguration().isReversed()) == FilePatch2.ADDITION) {
@@ -237,8 +242,9 @@ public int calculateFuzz(List<String> lines, IProgressMonitor monitor) {
237242
result.setShift(shift);
238243
int fuzz = result.calculateFuzz(lines, monitor);
239244
shift = result.getShift();
240-
if (fuzz > highestFuzz)
245+
if (fuzz > highestFuzz) {
241246
highestFuzz = fuzz;
247+
}
242248
monitor.worked(1);
243249
}
244250
this.fAfterLines = lines;
@@ -263,8 +269,9 @@ public List<Hunk> getFailedHunks() {
263269
IHunk[] hunks = this.fDiff.getHunks();
264270
for (IHunk hunk : hunks) {
265271
HunkResult result = this.fHunkResults.get(hunk);
266-
if (result != null && !result.isOK())
272+
if (result != null && !result.isOK()) {
267273
failedHunks.add(result.getHunk());
274+
}
268275
}
269276
return failedHunks;
270277
}

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)