Matcher (@NotNull Project project, @NotNull LanguageFileType fileType, @NotNull String constraint) { if (StringUtil.isQuotedString(constraint)) { // keep old configurations working, also useful for testing final MatchOptions matchOptions = new MatchOptions(); matchOptions.setFileType(fileType); matchOptions.fillSearchCriteria(StringUtil.unquoteString(constraint)); return new Matcher(project, matchOptions); } else { final Set<String> set = ourRecursionGuard.get(); if (!set.add(constraint)) { throw new MalformedPatternException(SSRBundle.message("error.pattern.recursively.references.itself")); } try { final Configuration configuration = ConfigurationManager.getInstance(project).findConfigurationByName(constraint); if (configuration == null) { throw new MalformedPatternException(SSRBundle.message("error.configuration.0.not.found", constraint)); } return new Matcher(project, configuration.getMatchOptions()); } finally { set.remove(constraint); if (set.isEmpty()) { // we're finished with this thread local ourRecursionGuard.remove(); } } } }