private bool TryGetSelectionSet( ImmutableStack <ISyntaxNode> path, out SelectionSetNode selectionSet) { SelectionSetNode root = null; ImmutableStack <ISyntaxNode> current = path; while (current.Any()) { if (current.Peek() is SelectionSetNode set) { root = set; if (IsRelevantSelectionSet(current.Pop().Peek())) { selectionSet = set; return(true); } } current = current.Pop(); } selectionSet = root; return(root != null); }
/// <summary> /// Pops the stacked input handler (and all input handlers above it). /// If <paramref name="inputHandler"/> is not found in the currently stacked input handlers, or is null, this method /// does nothing. /// </summary> /// <remarks><inheritdoc cref="ITextAreaInputHandler"/></remarks> public void PopStackedInputHandler(TextAreaStackedInputHandler inputHandler) { if (stackedInputHandlers.Any(i => i == inputHandler)) { ITextAreaInputHandler oldHandler; do { oldHandler = stackedInputHandlers.Peek(); stackedInputHandlers = stackedInputHandlers.Pop(); oldHandler.Detach(); } while (oldHandler != inputHandler); } }
public static void End(ActivityScope scope) { if (Current == null) return; if (ActivityStack.All(scopeOnTheStack => scope.Id != scopeOnTheStack.Id)) return; ActivityScope currentScope; ActivityStack = ActivityStack.Pop(out currentScope); while(ActivityStack.Any() && currentScope.Id != scope.Id) { ActivityStack = ActivityStack.Pop(out currentScope); } }
private IEnumerable <ISyntaxNode> GetCyclePath( ImmutableStack <ISyntaxNode> path) { ImmutableStack <ISyntaxNode> current = path; while (current.Any()) { current = current.Pop(out ISyntaxNode node); if (node is FragmentSpreadNode) { yield return(node); } } }
public bool CanPush(ActionQueue actionQueue, bool allowReentrantCalls) { var actionQueueInStack = _callStack.Any(_ => _ == actionQueue);// && //_callStack.Peek() != actionQueue; if (!allowReentrantCalls && actionQueueInStack) { throw new InvalidOperationException("Reentrant call detected"); } if (actionQueueInStack) { return(false); } return(true); }
public bool CanPush(ActionQueue actionQueue, bool allowReentrantCalls) { var actionQueueInStack = _callStack.Any(_ => _ == actionQueue);// && //_callStack.Peek() != actionQueue; if (!allowReentrantCalls && actionQueueInStack) { throw new InvalidOperationException($"Reentrant call detected {string.Join(">>", _callStack.Select(_ => _.ExecutingInvocationItem))}"); } if (actionQueueInStack) { return(false); } return(true); }
public static void End(ActivityScope scope) { if (Current == null) { return; } if (ActivityStack.All(scopeOnTheStack => scope.Id != scopeOnTheStack.Id)) { return; } ActivityScope currentScope; ActivityStack = ActivityStack.Pop(out currentScope); while (ActivityStack.Any() && currentScope.Id != scope.Id) { ActivityStack = ActivityStack.Pop(out currentScope); } }
private void DetectCycle( FragmentDefinitionNode fragmentDefinition, ImmutableStack <ISyntaxNode> path) { ImmutableStack <ISyntaxNode> current = path; while (current.Any()) { current = current.Pop(out ISyntaxNode node); if (node == fragmentDefinition) { _cycleDetected = true; Errors.Add(new ValidationError( "The graph of fragment spreads must not form any " + "cycles including spreading itself. Otherwise an " + "operation could infinitely spread or infinitely " + "execute on cycles in the underlying data.", GetCyclePath(path))); return; } } }
private static bool IsKnownSpell(ImmutableStack <Spell> knownSpells, Learn spellForLearn) { return(knownSpells.Any(x => x.Tiers == spellForLearn.Spell)); }