package lombok.delombok; import java.io.CharArrayReader; import java.io.IOException; import java.io.Reader; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.Map; /* loaded from: com.discord-120015.apk:lombok/delombok/FormatPreferenceScanner.SCL.lombok */ public class FormatPreferenceScanner { /* renamed from: lombok.delombok.FormatPreferenceScanner$1 reason: invalid class name */ /* loaded from: com.discord-120015.apk:lombok/delombok/FormatPreferenceScanner$1.SCL.lombok */ class AnonymousClass1 extends Reader { int pos = 0; int max; private final /* synthetic */ CharSequence val$source; AnonymousClass1(CharSequence charSequence) { this.val$source = charSequence; this.max = charSequence.length(); } @Override // java.io.Reader, java.io.Closeable, java.lang.AutoCloseable public void close() throws IOException { } @Override // java.io.Reader public int read(char[] cArr, int i, int i2) throws IOException { int i3 = 0; if (this.pos >= this.max) { return -1; } for (int i4 = i; i4 < i + i2; i4++) { CharSequence charSequence = this.val$source; int i5 = this.pos; this.pos = i5 + 1; cArr[i4] = charSequence.charAt(i5); i3++; if (this.pos == this.max) { return i3; } } return i2; } } private FormatPreferences tryEasy(FormatPreferences formatPreferences, boolean z2) { int i = 0; Iterator> it = formatPreferences.rawMap.entrySet().iterator(); while (it.hasNext()) { if (!"scan".equalsIgnoreCase(it.next().getValue())) { i++; } } if (z2 || i >= FormatPreferences.KEYS.size()) { return formatPreferences; } return null; } public FormatPreferences scan(FormatPreferences formatPreferences, CharSequence charSequence) { FormatPreferences tryEasy = tryEasy(formatPreferences, charSequence == null); if (tryEasy != null) { return tryEasy; } try { return scan_(formatPreferences, new AnonymousClass1(charSequence)); } catch (IOException e) { throw new RuntimeException(e); } } public FormatPreferences scan(FormatPreferences formatPreferences, char[] cArr) { FormatPreferences tryEasy = tryEasy(formatPreferences, cArr == null); if (tryEasy != null) { return tryEasy; } try { return scan_(formatPreferences, new CharArrayReader(cArr)); } catch (IOException e) { throw new RuntimeException(e); } } public FormatPreferences scan(FormatPreferences formatPreferences, Reader reader) throws IOException { FormatPreferences tryEasy = tryEasy(formatPreferences, reader == null); return tryEasy != null ? tryEasy : scan_(formatPreferences, reader); } private static FormatPreferences scan_(FormatPreferences formatPreferences, Reader reader) throws IOException { int i = 0; ArrayList arrayList = new ArrayList(); char[] cArr = new char[32700]; int i2 = 1; int i3 = 0; StringBuilder sb = new StringBuilder(); boolean z2 = true; boolean z3 = false; char c = ' '; while (true) { if (i2 >= i3) { int read = reader.read(cArr); if (read == -1) { break; } i2 = 0; i3 = read; } else { i2++; char c2 = cArr[i2]; if (z3) { if (c == '*' && c2 == '/') { z3 = false; } c = c2; } else if (c == '/' && c2 == '*') { z3 = true; c = ' '; sb.setLength(0); z2 = false; } else if (z2) { boolean isWhitespace = Character.isWhitespace(c2); if (c2 == '\n') { if (sb.length() > 0 && sb.charAt(sb.length() - 1) == '\r') { sb.setLength(sb.length() - 1); } if (sb.length() > 0) { i++; } arrayList.add(sb.toString()); sb.setLength(0); c = c2; } else if (isWhitespace) { sb.append(c2); c = c2; } else { if (sb.length() > 0) { arrayList.add(sb.toString()); sb.setLength(0); } c = c2; z2 = false; } } else { c = c2; if (c2 == '\n') { z2 = true; sb.setLength(0); } } } } String str = null; int i4 = Integer.MAX_VALUE; Iterator it = arrayList.iterator(); while (true) { if (!it.hasNext()) { break; } String str2 = (String) it.next(); if (str2.indexOf(9) > -1) { str = "\t"; break; } else if (str2.length() >= 2 && str2.length() <= 8 && str2.length() < i4) { i4 = str2.length(); } } if (i4 == Integer.MAX_VALUE) { str = "\t"; } if (str == null) { char[] cArr2 = new char[i4]; Arrays.fill(cArr2, ' '); str = new String(cArr2); } return new FormatPreferences(formatPreferences.rawMap, str, Boolean.valueOf(i > 0)); } }