Skip to content

Commit 8432188

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of bundles/org.eclipse.ltk.core.refactoring
1 parent 8e2c4c2 commit 8432188

File tree

79 files changed

+724
-432
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+724
-432
lines changed

bundles/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/CategorizedTextEditGroup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*/
3232
public class CategorizedTextEditGroup extends TextEditGroup {
3333

34-
private GroupCategorySet fGroupCategories;
34+
private final GroupCategorySet fGroupCategories;
3535

3636
/**
3737
* Creates a new text edit group with the given name and group

bundles/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/Change.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ public Change getParent() {
183183
* @param parent the parent of this change or <code>null</code>
184184
*/
185185
/* package */ void setParent(Change parent) {
186-
if (parent != null)
186+
if (parent != null) {
187187
Assert.isTrue(fParent == null);
188+
}
188189
fParent= parent;
189190
}
190191

@@ -292,10 +293,12 @@ public Object[] getAffectedObjects() {
292293
@Override
293294
public <T> T getAdapter(Class<T> adapter) {
294295
T result= Platform.getAdapterManager().getAdapter(this, adapter);
295-
if (result != null)
296+
if (result != null) {
296297
return result;
297-
if (fParent != null)
298+
}
299+
if (fParent != null) {
298300
return fParent.getAdapter(adapter);
301+
}
299302
return null;
300303
}
301304
}

bundles/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/CheckConditionsOperation.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
*/
4242
public class CheckConditionsOperation implements IWorkspaceRunnable {
4343

44-
private Refactoring fRefactoring;
45-
private int fStyle;
44+
private final Refactoring fRefactoring;
45+
private final int fStyle;
4646
private RefactoringStatus fStatus;
4747

4848
/** Flag indicating that no conditions will be checked */
@@ -74,16 +74,18 @@ public CheckConditionsOperation(Refactoring refactoring, int style) {
7474

7575
@Override
7676
public void run(IProgressMonitor pm) throws CoreException {
77-
if (pm == null)
77+
if (pm == null) {
7878
pm= new NullProgressMonitor();
79+
}
7980
try {
8081
fStatus= null;
81-
if ((fStyle & ALL_CONDITIONS) == ALL_CONDITIONS)
82+
if ((fStyle & ALL_CONDITIONS) == ALL_CONDITIONS) {
8283
fStatus= fRefactoring.checkAllConditions(pm);
83-
else if ((fStyle & INITIAL_CONDITONS) == INITIAL_CONDITONS)
84+
} else if ((fStyle & INITIAL_CONDITONS) == INITIAL_CONDITONS) {
8485
fStatus= fRefactoring.checkInitialConditions(pm);
85-
else if ((fStyle & FINAL_CONDITIONS) == FINAL_CONDITIONS)
86+
} else if ((fStyle & FINAL_CONDITIONS) == FINAL_CONDITIONS) {
8687
fStatus= fRefactoring.checkFinalConditions(pm);
88+
}
8789
} finally {
8890
pm.done();
8991
}
@@ -123,12 +125,13 @@ private boolean checkStyle(int style) {
123125
}
124126

125127
/* package */ int getTicks(RefactoringTickProvider provider) {
126-
if ((fStyle & ALL_CONDITIONS) == ALL_CONDITIONS)
128+
if ((fStyle & ALL_CONDITIONS) == ALL_CONDITIONS) {
127129
return provider.getCheckAllConditionsTicks();
128-
else if ((fStyle & INITIAL_CONDITONS) == INITIAL_CONDITONS)
130+
} else if ((fStyle & INITIAL_CONDITONS) == INITIAL_CONDITONS) {
129131
return provider.getCheckInitialConditionsTicks();
130-
else if ((fStyle & FINAL_CONDITIONS) == FINAL_CONDITIONS)
132+
} else if ((fStyle & FINAL_CONDITIONS) == FINAL_CONDITIONS) {
131133
return provider.getCheckFinalConditionsTicks();
134+
}
132135
return 0;
133136
}
134137
}

bundles/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/CompositeChange.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
*/
4545
public class CompositeChange extends Change {
4646

47-
private String fName;
48-
private List<Change> fChanges;
47+
private final String fName;
48+
private final List<Change> fChanges;
4949
private boolean fIsSynthetic;
5050
private Change fUndoUntilException;
5151

@@ -269,17 +269,19 @@ public Change perform(IProgressMonitor pm) throws CoreException {
269269
try {
270270
for (Iterator<Change> iter= fChanges.iterator(); iter.hasNext();) {
271271
change= iter.next();
272-
if (canceled && !internalProcessOnCancel(change))
272+
if (canceled && !internalProcessOnCancel(change)) {
273273
continue;
274+
}
274275

275276
if (change.isEnabled()) {
276277
Change undoChange= null;
277278
try {
278279
undoChange= change.perform(sm.split(1));
279280
} catch(OperationCanceledException e) {
280281
canceled= true;
281-
if (!internalContinueOnCancel())
282+
if (!internalContinueOnCancel()) {
282283
throw e;
284+
}
283285
undos= null;
284286
}
285287
if (undos != null) {
@@ -309,8 +311,9 @@ public void handleException(Throwable exception) {
309311
}
310312
});
311313
}
312-
if (canceled)
314+
if (canceled) {
313315
throw new OperationCanceledException();
316+
}
314317
if (undos != null) {
315318
Collections.reverse(undos);
316319
return createUndoChange(undos.toArray(new Change[undos.size()]));
@@ -460,13 +463,15 @@ protected Change createUndoChange(Change[] childUndos) {
460463

461464
@Override
462465
public Object[] getAffectedObjects() {
463-
if (fChanges.isEmpty())
466+
if (fChanges.isEmpty()) {
464467
return new Object[0];
468+
}
465469
List<Object> result= new ArrayList<>();
466470
for (Change change : fChanges) {
467471
Object[] affectedObjects= change.getAffectedObjects();
468-
if (affectedObjects == null)
472+
if (affectedObjects == null) {
469473
return null;
474+
}
470475
result.addAll(Arrays.asList(affectedObjects));
471476
}
472477
return result.toArray();
@@ -486,8 +491,9 @@ public Object getModifiedElement() {
486491
public ChangeDescriptor getDescriptor() {
487492
for (Change change : fChanges) {
488493
final ChangeDescriptor descriptor= change.getDescriptor();
489-
if (descriptor != null)
494+
if (descriptor != null) {
490495
return descriptor;
496+
}
491497
}
492498
return null;
493499
}

bundles/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/CreateChangeOperation.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
*/
5252
public class CreateChangeOperation implements IWorkspaceRunnable {
5353

54-
private Refactoring fRefactoring;
54+
private final Refactoring fRefactoring;
5555

5656
private CheckConditionsOperation fCheckConditionOperation;
5757
private int fConditionCheckingFailedSeverity;
@@ -146,8 +146,9 @@ public Change getChange() {
146146
@Override
147147
public final ChangeDescriptor getDescriptor() {
148148
String name= fChange.getName();
149-
if (name.length() == 0)
149+
if (name.length() == 0) {
150150
name= RefactoringCoreMessages.CreateChangeOperation_unknown_Refactoring;
151+
}
151152
UnknownRefactoringDescriptor unknownDescriptor= new UnknownRefactoringDescriptor(name);
152153
return new RefactoringChangeDescriptor(unknownDescriptor);
153154
}
@@ -167,8 +168,9 @@ public final ChangeDescriptor getDescriptor() {
167168
* @return the status of the condition checking
168169
*/
169170
public RefactoringStatus getConditionCheckingStatus() {
170-
if (fCheckConditionOperation != null)
171+
if (fCheckConditionOperation != null) {
171172
return fCheckConditionOperation.getStatus();
173+
}
172174
return null;
173175
}
174176

@@ -181,8 +183,9 @@ public RefactoringStatus getConditionCheckingStatus() {
181183
* @return the condition checking style
182184
*/
183185
public int getConditionCheckingStyle() {
184-
if (fCheckConditionOperation != null)
186+
if (fCheckConditionOperation != null) {
185187
return fCheckConditionOperation.getStyle();
188+
}
186189
return CheckConditionsOperation.NONE;
187190
}
188191
}

bundles/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/DocumentChange.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
*/
4949
public class DocumentChange extends TextChange {
5050

51-
private IDocument fDocument;
51+
private final IDocument fDocument;
5252
private int fLength;
5353

5454
/**

bundles/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/FileStatusContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
*/
3333
public class FileStatusContext extends RefactoringStatusContext {
3434

35-
private IFile fFile;
36-
private IRegion fSourceRegion;
35+
private final IFile fFile;
36+
private final IRegion fSourceRegion;
3737

3838
/**
3939
* Creates an status entry context for the given file and source region.

bundles/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/GroupCategory.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
*/
2929
public class GroupCategory {
3030

31-
private String fId;
32-
private String fName;
33-
private String fDescription;
31+
private final String fId;
32+
private final String fName;
33+
private final String fDescription;
3434

3535
/**
3636
* Creates a new group category with the given name and
@@ -69,10 +69,12 @@ public String getDescription() {
6969

7070
@Override
7171
public boolean equals(Object obj) {
72-
if (this == obj)
72+
if (this == obj) {
7373
return true;
74-
if (obj == null || !getClass().equals(obj.getClass()))
74+
}
75+
if (obj == null || !getClass().equals(obj.getClass())) {
7576
return false;
77+
}
7678
return fId.equals(((GroupCategory)obj).fId);
7779
}
7880

bundles/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/GroupCategorySet.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,22 @@ public static GroupCategorySet union(GroupCategorySet one, GroupCategorySet two)
6565
// for performance we are using identity here. This is
6666
// valid since group categories are value objects and
6767
// therefore best used as static final fields.
68-
if (one == two)
68+
if (one == two) {
6969
return one;
70-
if (one == NONE)
70+
}
71+
if (one == NONE) {
7172
return two;
72-
if (two == NONE)
73+
}
74+
if (two == NONE) {
7375
return one;
76+
}
7477

7578
Set<GroupCategory> combined= new HashSet<>(one.asList());
7679
combined.addAll(two.asList());
7780
return new GroupCategorySet(combined);
7881
}
7982

80-
private List<GroupCategory> fContent;
83+
private final List<GroupCategory> fContent;
8184

8285
private GroupCategorySet() {
8386
fContent= Collections.emptyList();
@@ -139,8 +142,9 @@ public boolean contains(GroupCategory category) {
139142
*/
140143
public boolean containsOneCategory(List<GroupCategory> categories) {
141144
for (GroupCategory category : categories) {
142-
if(contains(category))
145+
if(contains(category)) {
143146
return true;
147+
}
144148
}
145149
return false;
146150
}

0 commit comments

Comments
 (0)