MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / expression_needs_graph_context

Method expression_needs_graph_context

graphlite/src/exec/executor.rs:2918–3030  ·  view source on GitHub ↗

Check if an expression needs graph context

(&self, expr: &crate::ast::Expression)

Source from the content-addressed store, hash-verified

2916
2917 /// Check if an expression needs graph context
2918 fn expression_needs_graph_context(&self, expr: &crate::ast::Expression) -> bool {
2919 use crate::ast::Expression;
2920
2921 match expr {
2922 Expression::Variable(_var) => {
2923 // TODO: Check session parameters when session context is available
2924 // For now, assume variables need graph context
2925 true
2926 }
2927 Expression::PropertyAccess(_) => true, // Property access on graph elements
2928 Expression::FunctionCall(func_call) => {
2929 // Check if the function itself needs graph context
2930 if self.function_needs_graph_context(&func_call.name) {
2931 return true;
2932 }
2933 // Check if any arguments need graph context
2934 for arg in &func_call.arguments {
2935 if self.expression_needs_graph_context(arg) {
2936 return true;
2937 }
2938 }
2939 false
2940 }
2941 Expression::Binary(binary) => {
2942 self.expression_needs_graph_context(&binary.left)
2943 || self.expression_needs_graph_context(&binary.right)
2944 }
2945 Expression::Unary(unary) => self.expression_needs_graph_context(&unary.expression),
2946 Expression::Case(case_expr) => {
2947 use crate::ast::CaseType;
2948 match &case_expr.case_type {
2949 CaseType::Simple(simple_case) => {
2950 if self.expression_needs_graph_context(&simple_case.test_expression) {
2951 return true;
2952 }
2953 for branch in &simple_case.when_branches {
2954 for when_val in &branch.when_values {
2955 if self.expression_needs_graph_context(when_val) {
2956 return true;
2957 }
2958 }
2959 if self.expression_needs_graph_context(&branch.then_expression) {
2960 return true;
2961 }
2962 }
2963 if let Some(else_expr) = &simple_case.else_expression {
2964 return self.expression_needs_graph_context(else_expr);
2965 }
2966 false
2967 }
2968 CaseType::Searched(searched_case) => {
2969 for branch in &searched_case.when_branches {
2970 if self.expression_needs_graph_context(&branch.condition) {
2971 return true;
2972 }
2973 if self.expression_needs_graph_context(&branch.then_expression) {
2974 return true;
2975 }

Calls 1

Tested by

no test coverage detected