@@ -339,7 +339,7 @@ private static InitializationBlock createInitializationBlock(InitializerDeclarat
339339 return throwStmt .asThrowStmt ().getExpression ().toString ();
340340 }
341341 }).collect (Collectors .toList ()));
342- initializationBlock .setCode (LexicalPreservingPrinter .setup (initializerDeclaration .getBody ()). toString ( ));
342+ initializationBlock .setCode (LexicalPreservingPrinter .print (initializerDeclaration .getBody ()));
343343 initializationBlock .setStartLine (
344344 initializerDeclaration .getRange ().isPresent () ? initializerDeclaration .getRange ().get ().begin .line
345345 : -1 );
@@ -563,7 +563,7 @@ private static Pair<String, Callable> processCallableDeclaration(CallableDeclara
563563 callableNode .setStartLine (callableDecl .getRange ().isPresent () ? callableDecl .getRange ().get ().begin .line : -1 );
564564 callableNode .setEndLine (callableDecl .getRange ().isPresent () ? callableDecl .getRange ().get ().end .line : -1 );
565565 callableNode .setReferencedTypes (getReferencedTypes (body ));
566- callableNode .setCode (body .isPresent () ? LexicalPreservingPrinter .setup (body .get ()). toString ( ) : "" );
566+ callableNode .setCode (body .isPresent () ? LexicalPreservingPrinter .print (body .get ()) : "" );
567567 callableNode .setCodeStartLine (body .isPresent ()? body .get ().getBegin ().get ().line : -1 );
568568
569569 callableNode .setAccessedFields (getAccessedFields (body , classFields , typeName ));
@@ -1090,7 +1090,7 @@ public static Pair<Map<String, JavaCompilationUnit>, Map<String, List<Problem>>>
10901090 for (SourceRoot sourceRoot : projectRoot .getSourceRoots ()) {
10911091 for (ParseResult <CompilationUnit > parseResult : sourceRoot .tryToParse ()) {
10921092 if (parseResult .isSuccessful ()) {
1093- CompilationUnit compilationUnit = parseResult .getResult ().get ();
1093+ CompilationUnit compilationUnit = LexicalPreservingPrinter . setup ( parseResult .getResult ().get () );
10941094 symbolTable .put (compilationUnit .getStorage ().get ().getPath ().toString (),
10951095 processCompilationUnit (compilationUnit ));
10961096 } else {
@@ -1116,7 +1116,7 @@ public static Pair<Map<String, JavaCompilationUnit>, Map<String, List<Problem>>>
11161116 JavaParser javaParser = new JavaParser (parserConfiguration );
11171117 ParseResult <CompilationUnit > parseResult = javaParser .parse (code );
11181118 if (parseResult .isSuccessful ()) {
1119- CompilationUnit compilationUnit = parseResult .getResult ().get ();
1119+ CompilationUnit compilationUnit = LexicalPreservingPrinter . setup ( parseResult .getResult ().get () );
11201120 Log .debug ("Successfully parsed code. Now processing compilation unit" );
11211121 symbolTable .put ("<pseudo-path>" , processCompilationUnit (compilationUnit ));
11221122 } else {
@@ -1158,7 +1158,7 @@ public static Pair<Map<String, JavaCompilationUnit>, Map<String, List<Problem>>>
11581158 for (Path javaFilePath : javaFilePaths ) {
11591159 ParseResult <CompilationUnit > parseResult = javaParser .parse (javaFilePath );
11601160 if (parseResult .isSuccessful ()) {
1161- CompilationUnit compilationUnit = parseResult .getResult ().get ();
1161+ CompilationUnit compilationUnit = LexicalPreservingPrinter . setup ( parseResult .getResult ().get () );
11621162 System .out .println ("Successfully parsed file: " + javaFilePath .toString ());
11631163 symbolTable .put (compilationUnit .getStorage ().get ().getPath ().toString (),
11641164 processCompilationUnit (compilationUnit ));
0 commit comments