File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
src/main/java/org/variantsync/diffdetective/util Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,28 @@ static String fullExplanation(Source source) {
205205 return result .toString ();
206206 }
207207
208+ /**
209+ * The same as {@link #fullExplanation(Source)} but with a different formatting.
210+ * Where fullExplanation renders this tree of sources as using newlines and indentation,
211+ * functionExplanation renders this tree as one large, nested function call of the form:
212+ * {@link #getSourceExplanation()}({@link #getSourceArguments() args}..., {@link #getSources() nested sources}...).
213+ */
214+ default String functionExplanation () {
215+ String result = getSourceExplanation () + "(" ;
216+
217+ final List <String > args = new ArrayList <>();
218+ for (Object arg : getSourceArguments ()) {
219+ args .add (arg .toString ());
220+ }
221+ for (Source child : getSources ()) {
222+ args .add (child .functionExplanation ());
223+ }
224+
225+ result += args .stream ().collect (Collectors .joining (", " ));
226+
227+ return result + ")" ;
228+ }
229+
208230 /**
209231 * Uses a depth first traversal of the {@link Source} {@link getSources hierarchy} to find and
210232 * return all instances of {@code clazz}.
You can’t perform that action at this time.
0 commit comments