2929import java .io .IOException ;
3030import java .net .URL ;
3131
32- import javax .annotation .CheckForNull ;
33-
3432// TODO: Auto-generated Javadoc
3533/**
3634 * Review comment to the pull request.
4038 * @see GHPullRequest#createReviewComment(String, String, String, int) GHPullRequest#createReviewComment(String, String,
4139 * String, int)
4240 */
43- public class GHPullRequestReviewComment extends GHObject implements Reactable {
41+ public class GHPullRequestReviewComment extends GHIssueComment implements Refreshable {
4442
4543 /**
46- * The side of the diff to which the comment applies
44+ * The side of the diff to which the comment applies.
45+ *
46+ * @see <a href="https://docs.github.com/en/rest/pulls/comments">Pull Request Review Comments API</a>
4747 */
4848 public static enum Side {
4949 /** Left side */
@@ -66,31 +66,23 @@ public static Side from(String value) {
6666
6767 }
6868
69- private GHCommentAuthorAssociation authorAssociation ;
70-
71- private String body ;
72- private String bodyHtml ;
73- private String bodyText ;
69+ // PR review comment specific fields (not in GHIssueComment)
7470 private String commitId ;
7571 private String diffHunk ;
76- private String htmlUrl ;
7772 private long inReplyToId = -1L ;
7873 private int line = -1 ;
7974 private String originalCommitId ;
8075 private int originalLine = -1 ;
8176 private int originalPosition = -1 ;
82- private Integer originalStartLine = - 1 ;
77+ private Integer originalStartLine ;
8378 private String path ;
8479 private int position = -1 ;
85- private Long pullRequestReviewId = - 1L ;
80+ private Long pullRequestReviewId ;
8681 private String pullRequestUrl ;
8782 private GHPullRequestReviewCommentReactions reactions ;
8883 private String side ;
89- private Integer startLine = - 1 ;
84+ private Integer startLine ;
9085 private String startSide ;
91- private GHUser user ;
92- /** The owner. */
93- GHPullRequest owner ;
9486
9587 /**
9688 * Create default GHPullRequestReviewComment instance
@@ -107,6 +99,7 @@ public GHPullRequestReviewComment() {
10799 * @throws IOException
108100 * Signals that an I/O exception has occurred.
109101 */
102+ @ Override
110103 public GHReaction createReaction (ReactionContent content ) throws IOException {
111104 return owner .root ()
112105 .createRequest ()
@@ -122,6 +115,7 @@ public GHReaction createReaction(ReactionContent content) throws IOException {
122115 * @throws IOException
123116 * the io exception
124117 */
118+ @ Override
125119 public void delete () throws IOException {
126120 owner .root ().createRequest ().method ("DELETE" ).withUrlPath (getApiRoute ()).send ();
127121 }
@@ -134,6 +128,7 @@ public void delete() throws IOException {
134128 * @throws IOException
135129 * Signals that an I/O exception has occurred.
136130 */
131+ @ Override
137132 public void deleteReaction (GHReaction reaction ) throws IOException {
138133 owner .root ()
139134 .createRequest ()
@@ -142,42 +137,6 @@ public void deleteReaction(GHReaction reaction) throws IOException {
142137 .send ();
143138 }
144139
145- /**
146- * Gets the author association to the project.
147- *
148- * @return the author association to the project
149- */
150- public GHCommentAuthorAssociation getAuthorAssociation () {
151- return authorAssociation ;
152- }
153-
154- /**
155- * The comment itself.
156- *
157- * @return the body
158- */
159- public String getBody () {
160- return body ;
161- }
162-
163- /**
164- * Gets The body in html format.
165- *
166- * @return {@link String} the body in html format
167- */
168- public String getBodyHtml () {
169- return bodyHtml ;
170- }
171-
172- /**
173- * Gets The body text.
174- *
175- * @return {@link String} the body text
176- */
177- public String getBodyText () {
178- return bodyText ;
179- }
180-
181140 /**
182141 * Gets commit id.
183142 *
@@ -196,21 +155,11 @@ public String getDiffHunk() {
196155 return diffHunk ;
197156 }
198157
199- /**
200- * Gets the html url.
201- *
202- * @return the html url
203- */
204- public URL getHtmlUrl () {
205- return GitHubClient .parseURL (htmlUrl );
206- }
207-
208158 /**
209159 * Gets in reply to id.
210160 *
211- * @return the in reply to id
161+ * @return the in reply to id, or -1 if not a reply
212162 */
213- @ CheckForNull
214163 public long getInReplyToId () {
215164 return inReplyToId ;
216165 }
@@ -281,11 +230,12 @@ public int getOriginalStartLine() {
281230 /**
282231 * Gets the pull request to which this review comment is associated.
283232 *
284- * @return the parent
233+ * @return the parent pull request
285234 */
235+ @ Override
286236 @ SuppressFBWarnings (value = { "EI_EXPOSE_REP" }, justification = "Expected behavior" )
287237 public GHPullRequest getParent () {
288- return owner ;
238+ return ( GHPullRequest ) owner ;
289239 }
290240
291241 /**
@@ -300,9 +250,8 @@ public String getPath() {
300250 /**
301251 * Gets position.
302252 *
303- * @return the position
253+ * @return the position, or -1 if not available
304254 */
305- @ CheckForNull
306255 public int getPosition () {
307256 return position ;
308257 }
@@ -387,6 +336,7 @@ public Side getStartSide() {
387336 * @throws IOException
388337 * the io exception
389338 */
339+ @ Override
390340 public GHUser getUser () throws IOException {
391341 return owner .root ().intern (user );
392342 }
@@ -396,13 +346,31 @@ public GHUser getUser() throws IOException {
396346 *
397347 * @return the paged iterable
398348 */
349+ @ Override
399350 public PagedIterable <GHReaction > listReactions () {
400351 return owner .root ()
401352 .createRequest ()
402353 .withUrlPath (getApiRoute () + "/reactions" )
403354 .toIterable (GHReaction [].class , item -> owner .root ());
404355 }
405356
357+ /**
358+ * Refreshes this comment by fetching the full data from the API.
359+ *
360+ * <p>
361+ * This is useful when the comment was obtained via {@link GHPullRequestReview#listReviewComments()}, which uses a
362+ * GitHub API endpoint that does not return all fields. After calling this method, fields like {@link #getLine()},
363+ * {@link #getOriginalLine()}, {@link #getSide()}, etc. will return their actual values.
364+ *
365+ * @throws IOException
366+ * if an I/O error occurs
367+ * @see GHPullRequest#listReviewComments()
368+ */
369+ @ Override
370+ public void refresh () throws IOException {
371+ owner .root ().createRequest ().withUrlPath (getApiRoute ()).fetchInto (this ).wrapUp (getParent ());
372+ }
373+
406374 /**
407375 * Create a new comment that replies to this comment.
408376 *
@@ -419,7 +387,7 @@ public GHPullRequestReviewComment reply(String body) throws IOException {
419387 .with ("body" , body )
420388 .withUrlPath (getApiRoute (true ) + "/replies" )
421389 .fetch (GHPullRequestReviewComment .class )
422- .wrapUp (owner );
390+ .wrapUp (getParent () );
423391 }
424392
425393 /**
@@ -430,6 +398,7 @@ public GHPullRequestReviewComment reply(String body) throws IOException {
430398 * @throws IOException
431399 * the io exception
432400 */
401+ @ Override
433402 public void update (String body ) throws IOException {
434403 owner .root ().createRequest ().method ("PATCH" ).with ("body" , body ).withUrlPath (getApiRoute ()).fetchInto (this );
435404 this .body = body ;
@@ -460,12 +429,12 @@ protected String getApiRoute(boolean includePullNumber) {
460429 /**
461430 * Wrap up.
462431 *
463- * @param owner
464- * the owner
432+ * @param pullRequest
433+ * the pull request owner
465434 * @return the GH pull request review comment
466435 */
467- GHPullRequestReviewComment wrapUp (GHPullRequest owner ) {
468- this .owner = owner ;
436+ GHPullRequestReviewComment wrapUp (GHPullRequest pullRequest ) {
437+ this .owner = pullRequest ;
469438 return this ;
470439 }
471440}
0 commit comments