Replace in path

Hello everyone,

i am trying to run "replace in path..." programmatically:

FindManager findManager = FindManager.getInstance(project);
FindModel replaceInFileModel = findManager.createReplaceInFileModel();
replaceInFileModel.setReplaceAll(true);
replaceInFileModel.setCaseSensitive(false);
replaceInFileModel.setRegularExpressions(true);
replaceInFileModel.setSearchContext(FindModel.SearchContext.ANY);
replaceInFileModel.setSearchInProjectFiles(false);
replaceInFileModel.setProjectScope(false);
replaceInFileModel.setMultipleFiles(true);
replaceInFileModel.setWithSubdirectories(true);
replaceInFileModel.setStringToFind(...);
replaceInFileModel.setStringToReplace(...);
replaceInFileModel.compileRegExp();
findManager.showFindDialog(replaceInFileModel, () -> {
replaceInFileModel.setDirectoryName(...);
replaceInFileModel.setFileFilter(...);
});

after having opened and filled the related dialog programmatically, when clicking the "replace" button, everything works correctly, but when clicking the "replace all" button instead, after confirming the popup that asks whether all found occurrences should be replaced with the replacement, no replacement is done. What am i missing?

Thanks for your input.

0

Please sign in to leave a comment.