Skip to content

Commit 4c02f59

Browse files
pvojtechovskymonperrus
authored andcommitted
refactor: never return null from CtElement#getPosition() but NoSourcePosition (#1951)
1 parent 4c2f948 commit 4c02f59

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/spoon/support/reflect/declaration/CtElementImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public SourcePosition getPosition() {
202202
if (position != null) {
203203
return position;
204204
}
205-
return null;
205+
return SourcePosition.NOPOSITION;
206206
}
207207

208208
@Override
@@ -264,6 +264,9 @@ public <E extends CtElement> E setDocComment(String docComment) {
264264
}
265265

266266
public <E extends CtElement> E setPosition(SourcePosition position) {
267+
if (position == null) {
268+
position = SourcePosition.NOPOSITION;
269+
}
267270
getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, POSITION, position, this.position);
268271
this.position = position;
269272
return (E) this;

0 commit comments

Comments
 (0)