Example #1
0
				public override void VisitLabelStatement (LabelStatement labelStatement)
				{
					base.VisitLabelStatement (labelStatement);

					var t = labelStatement.GetParent <TryCatchStatement> ();
					if (t == null)
						return;

					if (t.TryBlock.Statements.First () == labelStatement) {
						labelStatement.Remove ();
						t.Parent.InsertChildBefore (t, labelStatement, (Role<Statement>)t.Role);
					}
				}
Example #2
0
				public override void VisitLabelStatement (LabelStatement labelStatement)
				{
					base.VisitLabelStatement (labelStatement);


					if (HasGoto (labelStatement) || HasBreakto (labelStatement)) {
						return;
					}

					labelStatement.Remove ();

				}
Example #3
0
			public override void VisitLabelStatement (LabelStatement labelStatement)
			{
				base.VisitLabelStatement (labelStatement);

				var ifs = labelStatement.NextSibling as IfElseStatement;
				if (ifs == null || !ifs.FalseStatement.IsNull)
					return;

				var b = ifs.TrueStatement as BlockStatement;
				if (b == null || b.Statements.Count == 0)
					return;

				var gt = b.Statements.Last () as GotoStatement;
				if (gt == null || gt.Label != labelStatement.Label)
					return;

				if (labelStatement.GetParent<MethodDeclaration> ().Descendants.OfType<GotoStatement> ().Count () != 1)
					return;

				gt.Remove ();
				b.Remove ();
				var wh = new WhileStatement {
					Condition = ifs.Condition.Clone (),
					EmbeddedStatement = b,
				};

				ifs.ReplaceWith (wh);

				labelStatement.Remove ();

			}