discord-jadx/app/src/main/java/lombok/delombok/DelombokResult.java

61 lines
2.5 KiB
Java

package lombok.delombok;
import com.sun.tools.javac.tree.JCTree;
import java.io.IOException;
import java.io.Writer;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.tools.JavaFileObject;
import lombok.javac.CommentInfo;
/* loaded from: com.discord-118107.apk:lombok/delombok/DelombokResult.SCL.lombok */
public class DelombokResult {
private final List<CommentInfo> comments;
private final List<Integer> textBlockStarts;
private final JCTree.JCCompilationUnit compilationUnit;
private final boolean changed;
private final FormatPreferences formatPreferences;
public DelombokResult(List<CommentInfo> list, List<Integer> list2, JCTree.JCCompilationUnit jCCompilationUnit, boolean z2, FormatPreferences formatPreferences) {
this.comments = list;
this.textBlockStarts = list2;
this.compilationUnit = jCCompilationUnit;
this.changed = z2;
this.formatPreferences = formatPreferences;
}
public void print(Writer writer) throws IOException {
CharSequence content;
if (this.changed || (content = getContent()) == null) {
if (this.formatPreferences.generateDelombokComment()) {
writer.write("// Generated by delombok at ");
writer.write(String.valueOf(new Date()));
writer.write(System.getProperty("line.separator"));
}
com.sun.tools.javac.util.List from = this.comments instanceof com.sun.tools.javac.util.List ? (com.sun.tools.javac.util.List) this.comments : com.sun.tools.javac.util.List.from((CommentInfo[]) this.comments.toArray(new CommentInfo[0]));
int[] iArr = new int[this.textBlockStarts.size()];
int i = 0;
Iterator<Integer> it = this.textBlockStarts.iterator();
while (it.hasNext()) {
i++;
iArr[i] = it.next().intValue();
}
this.compilationUnit.accept(new PrettyPrinter(writer, this.compilationUnit, from, iArr, new FormatPreferenceScanner().scan(this.formatPreferences, getContent())));
return;
}
writer.write(content.toString());
}
private CharSequence getContent() throws IOException {
JavaFileObject sourceFile = this.compilationUnit.getSourceFile();
if (sourceFile == null) {
return null;
}
return sourceFile.getCharContent(true);
}
public boolean isChanged() {
return this.changed;
}
}