MCPcopy Index your code
hub / github.com/processing/processing / replaceAll

Method replaceAll

app/src/processing/app/ui/FindReplace.java:459–495  ·  view source on GitHub ↗

Replace everything that matches by doing find and replace alternately until nothing more found.

()

Source from the content-addressed store, hash-verified

457 * alternately until nothing more found.
458 */
459 public void replaceAll() {
460 // move to the beginning
461 editor.setSelection(0, 0);
462
463 boolean foundAtLeastOne = false;
464 int startTab = -1;
465 int startIndex = -1;
466 int counter = 10000; // prevent infinite loop
467
468 editor.startCompoundEdit();
469 while (--counter > 0) {
470 if (find(false, false)) {
471 int caret = editor.getSelectionStart();
472 int stopIndex = startIndex + replaceField.getText().length();
473 if (editor.getSketch().getCurrentCodeIndex() == startTab &&
474 (caret >= startIndex && (caret <= stopIndex))) {
475 // we've reached where we started, so stop the replace
476 Toolkit.beep();
477 editor.statusNotice("Reached beginning of search!");
478 break;
479 }
480 if (!foundAtLeastOne) {
481 foundAtLeastOne = true;
482 startTab = editor.getSketch().getCurrentCodeIndex();
483 startIndex = editor.getSelectionStart();
484 }
485 replace(false);
486 } else {
487 break;
488 }
489 }
490 editor.stopCompoundEdit();
491 if (!foundAtLeastOne) {
492 Toolkit.beep();
493 }
494 setFound(false);
495 }
496
497
498 public void setFindText(String t) {

Callers 12

actionPerformedMethod · 0.95
readMethod · 0.45
showTraceMethod · 0.45
loadMethod · 0.45
runMethod · 0.45
sanitizeHtmlTagsMethod · 0.45
translateCategoryMethod · 0.45
removeAccentsMethod · 0.45
applyFilterMethod · 0.45
pasteMethod · 0.45
setMenuMnemonicsMethod · 0.45
handlePrintMethod · 0.45

Calls 12

findMethod · 0.95
beepMethod · 0.95
replaceMethod · 0.95
setFoundMethod · 0.95
setSelectionMethod · 0.80
startCompoundEditMethod · 0.80
getSketchMethod · 0.80
stopCompoundEditMethod · 0.80
statusNoticeMethod · 0.65
getSelectionStartMethod · 0.45
getTextMethod · 0.45
getCurrentCodeIndexMethod · 0.45

Tested by

no test coverage detected