Skip to content

Commit 41d9bee

Browse files
Perform clean code of bundles/org.eclipse.jface.text
1 parent 2b23a8f commit 41d9bee

File tree

133 files changed

+4385
-2714
lines changed

Some content is hidden

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

133 files changed

+4385
-2714
lines changed

bundles/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/AnnotationBag.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public AnnotationBag(String type) {
4747
* @param annotation the annotation to add
4848
*/
4949
public void add(Annotation annotation) {
50-
if (fAnnotations == null)
50+
if (fAnnotations == null) {
5151
fAnnotations= new HashSet<>(2);
52+
}
5253
fAnnotations.add(annotation);
5354
}
5455

@@ -60,8 +61,9 @@ public void add(Annotation annotation) {
6061
public void remove(Annotation annotation) {
6162
if (fAnnotations != null) {
6263
fAnnotations.remove(annotation);
63-
if (fAnnotations.isEmpty())
64+
if (fAnnotations.isEmpty()) {
6465
fAnnotations= null;
66+
}
6567
}
6668
}
6769

@@ -82,8 +84,9 @@ public boolean isEmpty() {
8284
* @since 3.1
8385
*/
8486
public Iterator<Annotation> iterator() {
85-
if (!isEmpty())
87+
if (!isEmpty()) {
8688
return fAnnotations.iterator();
89+
}
8790
return null;
8891
}
8992
}

bundles/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationHover.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ private boolean isCaptionLine(Position position, IDocument document, int line) {
7676
if (position.getOffset() > -1 && position.getLength() > -1) {
7777
try {
7878
int captionOffset;
79-
if (position instanceof IProjectionPosition)
79+
if (position instanceof IProjectionPosition) {
8080
captionOffset= ((IProjectionPosition) position).computeCaptionOffset(document);
81-
else
81+
} else {
8282
captionOffset= 0;
83+
}
8384
int startLine= document.getLineOfOffset(position.getOffset() + captionOffset);
8485
return line == startLine;
8586
} catch (BadLocationException x) {
@@ -91,11 +92,9 @@ private boolean isCaptionLine(Position position, IDocument document, int line) {
9192
private String getProjectionTextAtLine(ISourceViewer viewer, int line, int numberOfLines) {
9293

9394
IAnnotationModel model= null;
94-
if (viewer instanceof ISourceViewerExtension2) {
95-
ISourceViewerExtension2 viewerExtension= (ISourceViewerExtension2) viewer;
95+
if (viewer instanceof ISourceViewerExtension2 viewerExtension) {
9696
IAnnotationModel visual= viewerExtension.getVisualAnnotationModel();
97-
if (visual instanceof IAnnotationModelExtension) {
98-
IAnnotationModelExtension modelExtension= (IAnnotationModelExtension) visual;
97+
if (visual instanceof IAnnotationModelExtension modelExtension) {
9998
model= modelExtension.getAnnotationModel(ProjectionSupport.PROJECTION);
10099
}
101100
}
@@ -106,15 +105,18 @@ private String getProjectionTextAtLine(ISourceViewer viewer, int line, int numbe
106105
Iterator<Annotation> e= model.getAnnotationIterator();
107106
while (e.hasNext()) {
108107
ProjectionAnnotation annotation= (ProjectionAnnotation) e.next();
109-
if (!annotation.isCollapsed())
108+
if (!annotation.isCollapsed()) {
110109
continue;
110+
}
111111

112112
Position position= model.getPosition(annotation);
113-
if (position == null)
113+
if (position == null) {
114114
continue;
115+
}
115116

116-
if (isCaptionLine(position, document, line))
117+
if (isCaptionLine(position, document, line)) {
117118
return getText(document, position.getOffset(), position.getLength(), numberOfLines);
119+
}
118120

119121
}
120122
} catch (BadLocationException x) {

bundles/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ public ProjectionAnnotationModel() {
4848
* @param annotation the annotation
4949
*/
5050
public void collapse(Annotation annotation) {
51-
if (annotation instanceof ProjectionAnnotation) {
52-
ProjectionAnnotation projection= (ProjectionAnnotation) annotation;
51+
if (annotation instanceof ProjectionAnnotation projection) {
5352
if (!projection.isCollapsed()) {
5453
projection.markCollapsed();
5554
modifyAnnotation(projection, true);
@@ -64,8 +63,7 @@ public void collapse(Annotation annotation) {
6463
* @param annotation the annotation
6564
*/
6665
public void expand(Annotation annotation) {
67-
if (annotation instanceof ProjectionAnnotation) {
68-
ProjectionAnnotation projection= (ProjectionAnnotation) annotation;
66+
if (annotation instanceof ProjectionAnnotation projection) {
6967
if (projection.isCollapsed()) {
7068
projection.markExpanded();
7169
modifyAnnotation(projection, true);
@@ -80,13 +78,12 @@ public void expand(Annotation annotation) {
8078
* @param annotation the annotation
8179
*/
8280
public void toggleExpansionState(Annotation annotation) {
83-
if (annotation instanceof ProjectionAnnotation) {
84-
ProjectionAnnotation projection= (ProjectionAnnotation) annotation;
85-
86-
if (projection.isCollapsed())
81+
if (annotation instanceof ProjectionAnnotation projection) {
82+
if (projection.isCollapsed()) {
8783
projection.markExpanded();
88-
else
84+
} else {
8985
projection.markCollapsed();
86+
}
9087

9188
modifyAnnotation(projection, true);
9289
}
@@ -129,8 +126,9 @@ public boolean collapseAll(int offset, int length) {
129126
}
130127
}
131128

132-
if (collapsing)
129+
if (collapsing) {
133130
fireModelChanged();
131+
}
134132

135133
return collapsing;
136134
}
@@ -166,8 +164,9 @@ protected boolean expandAll(int offset, int length, boolean fireModelChanged) {
166164
}
167165
}
168166

169-
if (expanding && fireModelChanged)
167+
if (expanding && fireModelChanged) {
170168
fireModelChanged();
169+
}
171170

172171
return expanding;
173172
}

bundles/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionRulerColumn.java

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ public ProjectionRulerColumn(int width, IAnnotationAccess annotationAccess) {
7272
@Override
7373
protected void mouseClicked(int line) {
7474
clearCurrentAnnotation();
75-
if (fMouseDownLine != line)
75+
if (fMouseDownLine != line) {
7676
return;
77+
}
7778
ProjectionAnnotation annotation= findAnnotation(line, true);
7879
if (annotation != null) {
7980
ProjectionAnnotationModel model= (ProjectionAnnotationModel) getModel();
@@ -88,8 +89,9 @@ protected void mouseDown(int rulerLine) {
8889

8990
@Override
9091
protected void mouseDoubleClicked(int rulerLine) {
91-
if (findAnnotation(rulerLine, true) != null)
92+
if (findAnnotation(rulerLine, true) != null) {
9293
return;
94+
}
9395

9496
ProjectionAnnotation annotation= findAnnotation(rulerLine, false);
9597
if (annotation != null) {
@@ -119,15 +121,16 @@ private ProjectionAnnotation findAnnotation(int line, boolean exact) {
119121
Iterator<Annotation> e= model.getAnnotationIterator();
120122
while (e.hasNext()) {
121123
Object next= e.next();
122-
if (next instanceof ProjectionAnnotation) {
123-
ProjectionAnnotation annotation= (ProjectionAnnotation) next;
124+
if (next instanceof ProjectionAnnotation annotation) {
124125
Position p= model.getPosition(annotation);
125-
if (p == null)
126+
if (p == null) {
126127
continue;
128+
}
127129

128130
int distance= getDistance(annotation, p, document, line);
129-
if (distance == -1)
131+
if (distance == -1) {
130132
continue;
133+
}
131134

132135
if (!exact) {
133136
if (distance < previousDistance) {
@@ -168,14 +171,16 @@ private int getDistance(ProjectionAnnotation annotation, Position position, IDoc
168171
if (line < endLine) {
169172
if (annotation.isCollapsed()) {
170173
int captionOffset;
171-
if (position instanceof IProjectionPosition)
174+
if (position instanceof IProjectionPosition) {
172175
captionOffset= ((IProjectionPosition) position).computeCaptionOffset(document);
173-
else
176+
} else {
174177
captionOffset= 0;
178+
}
175179

176180
int captionLine= document.getLineOfOffset(position.getOffset() + captionOffset);
177-
if (startLine <= captionLine && captionLine < endLine)
181+
if (startLine <= captionLine && captionLine < endLine) {
178182
return Math.abs(line - captionLine);
183+
}
179184
}
180185
return line - startLine;
181186
}
@@ -207,8 +212,9 @@ public Control createControl(CompositeRuler parentRuler, Composite parentControl
207212
control.addMouseTrackListener(new MouseTrackAdapter() {
208213
@Override
209214
public void mouseExit(MouseEvent e) {
210-
if (clearCurrentAnnotation())
215+
if (clearCurrentAnnotation()) {
211216
redraw();
217+
}
212218
}
213219
});
214220

@@ -227,16 +233,16 @@ public void mouseExit(MouseEvent e) {
227233
redraw= true;
228234
}
229235
}
230-
if (redraw)
236+
if (redraw) {
231237
redraw();
238+
}
232239
});
233240
return control;
234241
}
235242

236243
@Override
237244
public void setModel(IAnnotationModel model) {
238-
if (model instanceof IAnnotationModelExtension) {
239-
IAnnotationModelExtension extension= (IAnnotationModelExtension) model;
245+
if (model instanceof IAnnotationModelExtension extension) {
240246
model= extension.getAnnotationModel(ProjectionSupport.PROJECTION);
241247
}
242248
super.setModel(model);

0 commit comments

Comments
 (0)