MCPcopy Index your code
hub / github.com/benfry/processing4 / fixFloatsRegex

Method fixFloatsRegex

java/src/processing/mode/java/SourceUtil.java:188–206  ·  view source on GitHub ↗
(CharSequence source)

Source from the content-addressed store, hash-verified

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 /*

Callers 1

preparePredictionsMethod · 0.95

Calls 6

insertMethod · 0.95
findMethod · 0.80
endMethod · 0.65
startMethod · 0.45
containsMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected