| 186 | Pattern.compile("[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?"); |
| 187 | |
| 188 | public static List<Edit> fixFloatsRegex(CharSequence source) { |
| 189 | final List<Edit> edits = new ArrayList<>(); |
| 190 | |
| 191 | Matcher matcher = NUMBER_LITERAL_REGEX.matcher(source); |
| 192 | while (matcher.find()) { |
| 193 | int offset = matcher.start(); |
| 194 | int end = matcher.end(); |
| 195 | String group = matcher.group().toLowerCase(); |
| 196 | boolean isFloatingPoint = group.contains(".") || group.contains("e"); |
| 197 | boolean hasSuffix = end < source.length() && |
| 198 | Character.toLowerCase(source.charAt(end)) != 'f' && |
| 199 | Character.toLowerCase(source.charAt(end)) != 'd'; |
| 200 | if (isFloatingPoint && !hasSuffix) { |
| 201 | edits.add(Edit.insert(offset, "f")); |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | return edits; |
| 206 | } |
| 207 | |
| 208 | |
| 209 | /* |