Match patterns mix value expressions and capture targets. Skip the class * expression in `case Type(...)` and keyword labels, while invalidating every * nested capture/as/star target that may replace a module binding. */
| 4968 | * expression in `case Type(...)` and keyword labels, while invalidating every |
| 4969 | * nested capture/as/star target that may replace a module binding. */ |
| 4970 | static void py_invalidate_match_pattern(PyLSPContext *ctx, TSNode pattern, int depth) { |
| 4971 | if (!ctx || ts_node_is_null(pattern)) |
| 4972 | return; |
| 4973 | if (depth > 64) { |
| 4974 | py_disable_callable_value_proof(ctx); |
| 4975 | return; |
| 4976 | } |
| 4977 | const char *kind = ts_node_type(pattern); |
| 4978 | uint32_t count = ts_node_named_child_count(pattern); |
| 4979 | if (strcmp(kind, "class_pattern") == 0) { |
| 4980 | for (uint32_t i = 1; i < count; i++) |
| 4981 | py_invalidate_match_pattern(ctx, ts_node_named_child(pattern, i), depth + 1); |
| 4982 | return; |
| 4983 | } |
| 4984 | if (strcmp(kind, "keyword_pattern") == 0) { |
| 4985 | if (count > 0) |
| 4986 | py_invalidate_match_pattern(ctx, ts_node_named_child(pattern, count - 1), depth + 1); |
| 4987 | return; |
| 4988 | } |
| 4989 | if (strcmp(kind, "attribute") == 0) |
| 4990 | return; |
| 4991 | if (strcmp(kind, "dotted_name") == 0) { |
| 4992 | if (count == 1) |
| 4993 | py_invalidate_binding_target(ctx, ts_node_named_child(pattern, 0), depth + 1); |
| 4994 | return; |
| 4995 | } |
| 4996 | if (strcmp(kind, "identifier") == 0) { |
| 4997 | py_invalidate_binding_target(ctx, pattern, depth + 1); |
| 4998 | return; |
| 4999 | } |
| 5000 | for (uint32_t i = 0; i < count; i++) |
| 5001 | py_invalidate_match_pattern(ctx, ts_node_named_child(pattern, i), depth + 1); |
| 5002 | } |
| 5003 | |
| 5004 | static void py_invalidate_import_bindings(PyLSPContext *ctx, TSNode stmt) { |
| 5005 | if (py_import_statement_is_wildcard(stmt)) { |
no test coverage detected