PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { Supplier<JsonFile> jsonFileSupplier = holder.getFile().getUserData(JsonPathEvaluateManager.JSON_PATH_EVALUATE_SOURCE_KEY); JsonFile sourceFile = jsonFileSupplier != null ? jsonFileSupplier.get() : null; if (sourceFile == null) return PsiElementVisitor.EMPTY_VISITOR; NotNullLazyValue<Set<String>> allKeys = NotNullLazyValue.lazy(() -> collectAllKeysFromFile(sourceFile)); return new JsonPathVisitor() { @Override public void visitIdSegment(@NotNull JsonPathIdSegment segment) { super.visitIdSegment(segment); JsonPathId identifier = segment.getId(); String idString = identifier.getText(); if (StringUtil.isNotEmpty(idString) && !allKeys.getValue().contains(idString)) { holder.registerProblem(identifier, null, JsonPathBundle.message("inspection.message.jsonpath.unknown.key", idString)); } } }; }