ValidationInfo (@NotNull FindModel model) { ValidationInfo scopeValidationInfo = myScopeUI.validate(model, mySelectedScope); if (scopeValidationInfo != null) { return scopeValidationInfo; } if (!myHelper.canSearchThisString()) { return new ValidationInfo(FindBundle.message("find.empty.search.text.error"), mySearchComponent); } if (model.isRegularExpressions()) { String toFind = model.getStringToFind(); Pattern pattern; try { pattern = Pattern.compile(toFind, model.isCaseSensitive() ? Pattern.MULTILINE : Pattern.MULTILINE | Pattern.CASE_INSENSITIVE); if (pattern.matcher("").matches() && !toFind.endsWith("$") && !toFind.startsWith("^")) { return new ValidationInfo(FindBundle.message("find.empty.match.regular.expression.error"), mySearchComponent); } } catch (PatternSyntaxException e) { return new ValidationInfo(FindBundle.message("find.invalid.regular.expression.error", toFind, e.getDescription()), mySearchComponent); } if (model.isReplaceState()) { if (myResultsPreviewTable.getRowCount() > 0) { Object value = myResultsPreviewTable.getModel().getValueAt(0, 0); if (value instanceof FindPopupItem) { try { // Just check ReplaceInProjectManager.getInstance(myProject).replaceUsage(((FindPopupItem)value).getUsage(), model, Collections.emptySet(), true); } catch (FindManager.MalformedReplacementStringException e) { return new ValidationInfo(e.getMessage(), myReplaceComponent); } } } try { RegExReplacementBuilder.validate(pattern, getStringToReplace()); } catch (IllegalArgumentException e) { return new ValidationInfo(FindBundle.message("find.replace.invalid.replacement.string", e.getMessage()), myReplaceComponent); } } } String mask = getFileTypeMask(); if (mask != null) { if (mask.isEmpty()) { return new ValidationInfo(FindBundle.message("find.filter.empty.file.mask.error"), header.fileMaskField); } if (mask.contains(";")) { return new ValidationInfo(FindBundle.message("message.file.masks.should.be.comma.separated"), header.fileMaskField); } try { createFileMaskRegExp(mask); // verify that the regexp compiles } catch (PatternSyntaxException ex) { return new ValidationInfo(FindBundle.message("find.filter.invalid.file.mask.error", mask), header.fileMaskField); } } return null; }