4949import vadl .pass .PassManager ;
5050import vadl .pass .PassOrder ;
5151import vadl .pass .exception .DuplicatedPassKeyException ;
52+ import vadl .utils .EditorUtils ;
5253import vadl .utils .SourceLocation ;
5354import vadl .viam .Specification ;
5455
@@ -211,6 +212,37 @@ private Specification parseToVIAM() {
211212 return spec ;
212213 }
213214
215+ protected void printDumps (String message ) {
216+ if (ArtifactTracker .getDumpPaths ().isEmpty ()) {
217+ return ;
218+ }
219+
220+ System .out .println (message );
221+ for (var path : ArtifactTracker .getDumpPaths ()) {
222+ if (EditorUtils .isIntelliJIDE ()) {
223+ var uri = path .toAbsolutePath ().toUri ();
224+ System .out .printf ("\t - %s\n " , uri );
225+ } else {
226+ System .out .printf ("\t - %s\n " , path );
227+ }
228+ }
229+ }
230+
231+ protected void printArtifacts (String message ) {
232+ if (ArtifactTracker .getArtifactPathsPaths ().isEmpty ()) {
233+ return ;
234+ }
235+ System .out .println (message );
236+ for (var path : ArtifactTracker .getArtifactPathsPaths ()) {
237+ if (EditorUtils .isIntelliJIDE ()) {
238+ var uri = path .toAbsolutePath ().toUri ();
239+ System .out .printf ("\t - %s\n " , uri );
240+ } else {
241+ System .out .printf ("\t - %s\n " , path );
242+ }
243+ }
244+ }
245+
214246 // lazy evaluated config, do NOT use this directly.
215247 // use getConfig() instead.
216248 @ Nullable
@@ -266,14 +298,7 @@ public Integer call() {
266298 https://ea.complang.tuwien.ac.at/vadl/open-vadl/issues/new
267299 """ );
268300
269- if (!ArtifactTracker .getDumpPaths ().isEmpty ()) {
270- var dumpMessage = "\n Before the crash, the following dumps were generated:" ;
271- System .out .println (dumpMessage );
272- for (var path : ArtifactTracker .getDumpPaths ()) {
273- System .out .printf ("\t - %s\n " , path );
274- }
275- System .out .println ("" );
276- }
301+ printDumps ("\n Before the crash, the following dumps were generated:" );
277302
278303 // Dirty hack to avoid stdout and stderr getting mixed in IntelliJ (flushing wasn't enough).
279304 try {
@@ -296,25 +321,13 @@ public Integer call() {
296321 }
297322 }
298323
299- if (!ArtifactTracker .getArtifactPathsPaths ().isEmpty ()) {
300- var artifactMessage = returnVal == 0
301- ? "\n The following artifacts were generated:"
302- : "\n Even though some errors occurred, the following artifacts were generated:" ;
303- System .out .println (artifactMessage );
304- for (var path : ArtifactTracker .getArtifactPathsPaths ()) {
305- System .out .printf ("\t - %s\n " , path );
306- }
307- }
324+ printArtifacts (returnVal == 0
325+ ? "\n The following artifacts were generated:"
326+ : "\n Even though some errors occurred, the following artifacts were generated:" );
308327
309- if (!ArtifactTracker .getDumpPaths ().isEmpty ()) {
310- var dumpMessage = returnVal == 0
311- ? "\n The following dumps were generated:"
312- : "\n Even though some errors occurred, the following dumps were generated:" ;
313- System .out .println (dumpMessage );
314- for (var path : ArtifactTracker .getDumpPaths ()) {
315- System .out .printf ("\t - %s\n " , path );
316- }
317- }
328+ printDumps (returnVal == 0
329+ ? "\n The following dumps were generated:"
330+ : "\n Even though some errors occurred, the following dumps were generated:" );
318331
319332 return returnVal ;
320333 }
0 commit comments