Ejemplo n.º 1
0
        /// <inheritdoc/>
        public override SyntaxNode VisitEventTrigger(UvssEventTriggerSyntax node)
        {
            var unchanged = true;

            var newTriggerKeyword = (SyntaxToken)Visit(node.TriggerKeyword);

            if (newTriggerKeyword != node.TriggerKeyword)
            {
                unchanged = false;
            }

            var newEventKeyword = (SyntaxToken)Visit(node.EventKeyword);

            if (newEventKeyword != node.EventKeyword)
            {
                unchanged = false;
            }

            var newEventName = (UvssEventNameSyntax)Visit(node.EventName);

            if (newEventName != node.EventName)
            {
                unchanged = false;
            }

            var newArgumentList = (UvssEventTriggerArgumentList)Visit(node.ArgumentList);

            if (newArgumentList != node.ArgumentList)
            {
                unchanged = false;
            }

            var newQualifierToken = (SyntaxToken)Visit(node.QualifierToken);

            if (newQualifierToken != node.QualifierToken)
            {
                unchanged = false;
            }

            var newBody = (UvssBlockSyntax)Visit(node.Body);

            if (newBody != node.Body)
            {
                unchanged = false;
            }

            return(unchanged ? node : new UvssEventTriggerSyntax(
                       newTriggerKeyword,
                       newEventKeyword,
                       newEventName,
                       newArgumentList,
                       newQualifierToken,
                       newBody));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Compiles a <see cref="UvssEventTrigger"/> from the specified syntax node.
        /// </summary>
        private static UvssEventTrigger CompileEventTrigger(UvssEventTriggerSyntax node, CultureInfo culture)
        {
            var eventName = GetEventName(node.EventName);
            var arguments = node.ArgumentList == null?Enumerable.Empty <String>() :
                                node.ArgumentList.ArgumentTokens.Select(x => x.Text).ToList();

            var handled     = arguments.Contains("handled");
            var setHandled  = arguments.Contains("set-handled");
            var isImportant = node.QualifierToken?.Kind == SyntaxKind.ImportantKeyword;

            var trigger = new UvssEventTrigger(eventName, handled, setHandled, isImportant);

            foreach (var action in node.Actions)
            {
                trigger.Actions.Add(CompileTriggerAction(action, culture));
            }

            return(trigger);
        }
 /// <summary>
 /// Visits the specified event trigger node.
 /// </summary>
 /// <param name="node">The node to visit.</param>
 /// <returns>A node which should replace the visited node, or a reference to the visited node
 /// itself if no changes were made.</returns>
 public virtual SyntaxNode VisitEventTrigger(UvssEventTriggerSyntax node)
 {
     return(VisitSyntaxNode(node));
 }