Example #1
0
        private static IEnumerable <StatementCommentNode> AddCommentNodes(IEnumerable <StatementBase> statements, IEnumerable <OracleToken> comments)
        {
            var commentEnumerator  = comments.GetEnumerator();
            var statemenEnumerator = statements.GetEnumerator();

            var tokenYielded = false;

            while (commentEnumerator.MoveNext())
            {
                while (tokenYielded || statemenEnumerator.MoveNext())
                {
                    tokenYielded = false;

                    if (commentEnumerator.Current.Index > statemenEnumerator.Current.SourcePosition.IndexEnd)
                    {
                        continue;
                    }

                    var targetNode = FindCommentTargetNode(statemenEnumerator.Current.RootNode, commentEnumerator.Current.Index);

                    var commentNode = new StatementCommentNode(targetNode, commentEnumerator.Current);
                    targetNode?.Comments.Add(commentNode);

                    tokenYielded = true;

                    yield return(commentNode);

                    break;
                }

                if (tokenYielded)
                {
                    continue;
                }

                yield return(new StatementCommentNode(null, commentEnumerator.Current));
            }
        }
Example #2
0
		private static IEnumerable<StatementCommentNode> AddCommentNodes(IEnumerable<StatementBase> statements, IEnumerable<OracleToken> comments)
		{
			var commentEnumerator = comments.GetEnumerator();
			var statemenEnumerator = statements.GetEnumerator();

			var tokenYielded = false;
			while (commentEnumerator.MoveNext())
			{
				while (tokenYielded || statemenEnumerator.MoveNext())
				{
					tokenYielded = false;

					if (commentEnumerator.Current.Index > statemenEnumerator.Current.SourcePosition.IndexEnd)
					{
						continue;
					}

					var targetNode = FindCommentTargetNode(statemenEnumerator.Current.RootNode, commentEnumerator.Current.Index);
				
					var commentNode = new StatementCommentNode(targetNode, commentEnumerator.Current);
					targetNode?.Comments.Add(commentNode);

					tokenYielded = true;

					yield return commentNode;

					break;
				}

				if (tokenYielded)
				{
					continue;
				}

				yield return new StatementCommentNode(null, commentEnumerator.Current);
			}
		}