Predicate<FindResult> (@NotNull FindModel model, @Nullable VirtualFile file, @NotNull CharSequence text) { if (file == null) return null; FindModel.SearchContext context = model.getSearchContext(); if (context == FindModel.SearchContext.ANY || context == FindModel.SearchContext.IN_COMMENTS || context == FindModel.SearchContext.IN_STRING_LITERALS) { return null; } ThreadLocal<SoftReference<FindExceptCommentsOrLiteralsData>> data; synchronized (model) { data = model.getUserData(ourExceptCommentsOrLiteralsDataKey); assert data != null; } SoftReference<FindExceptCommentsOrLiteralsData> currentThreadDataRef = data.get(); FindExceptCommentsOrLiteralsData currentThreadData = currentThreadDataRef == null ? null : currentThreadDataRef.get(); if (currentThreadData == null || !currentThreadData.isAcceptableFor(model, file, text)) { data.set(new SoftReference<>(currentThreadData = FindExceptCommentsOrLiteralsData.create(file, model, text, this))); } return currentThreadData; }