From 6de3d0e1f992a88c69a72f705fb7ba21dd62d76e Mon Sep 17 00:00:00 2001 From: nimakarimipour Date: Fri, 4 Oct 2024 15:16:41 -0500 Subject: [PATCH] update javadoc --- .../cs/riple/core/registries/index/Fix.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Fix.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Fix.java index 31da2ac8..4fbaf9fe 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Fix.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Fix.java @@ -24,6 +24,7 @@ package edu.ucr.cs.riple.core.registries.index; +import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import edu.ucr.cs.riple.injector.Helper; import edu.ucr.cs.riple.injector.changes.ASTChange; @@ -67,7 +68,7 @@ public Set toLocations() { } /** - * Checks if fix is targeting a method. + * Checks if fix contains only one change and the change is on a method. * * @return true, if fix is targeting a method. */ @@ -76,11 +77,14 @@ public boolean isOnMethod() { } /** - * Returns the targeted method information. + * Returns the targeted method location if this fix contains only one change and that change is on + * method. * * @return Target method information. */ public OnMethod toMethod() { + Preconditions.checkArgument( + isOnMethod(), "This fix contains more than one change or the change is not on method."); return changes.iterator().next().getLocation().toMethod(); } @@ -96,7 +100,7 @@ public void ifOnMethod(Consumer consumer) { } /** - * Checks if fix is targeting a parameter. + * Checks if fix contains only one change and the change is on a parameter. * * @return true, if fix is targeting a parameter. */ @@ -105,11 +109,15 @@ public boolean isOnParameter() { } /** - * Returns the targeted parameter information. + * Returns the targeted parameter location if this fix contains only one change and that change is + * on a parameter. * * @return Target method parameter. */ public OnParameter toParameter() { + Preconditions.checkArgument( + isOnParameter(), + "This fix contains more than one change or the change is not on parameter."); return changes.iterator().next().getLocation().toParameter(); } @@ -125,7 +133,7 @@ public void ifOnParameter(Consumer consumer) { } /** - * Checks if fix is targeting a field. + * Checks if fix contains only one change and the change is on a field. * * @return true, if fix is targeting a field. */ @@ -134,11 +142,14 @@ public boolean isOnField() { } /** - * Returns the targeted field information. + * Returns the targeted field location if this fix contains only one change and that change is on + * a field. * * @return Target field information. */ public OnField toField() { + Preconditions.checkArgument( + isOnField(), "This fix contains more than one change or the change is not on field."); return changes.iterator().next().getLocation().toField(); } @@ -180,7 +191,7 @@ public JSONObject getJson() { } /** - * Checks if fix is modifying constructor (parameter or method). + * Checks if fix is a single change and is modifying constructor (parameter or method). * * @return true, if fix is modifying constructor. */