static void VerifyTerm(ParseTreeNode parseTreeNode, BnfTerm expectedTerm, params BnfTerm[] moreExpectedTerms) { var allExpected = new[] { expectedTerm }.Concat(moreExpectedTerms); if (!allExpected.Where(node => parseTreeNode.Term == node).Any()) { throw new InvalidOperationException("expected '{0}' to be a '{1}'".FormatString(parseTreeNode, allExpected.JoinString(", "))); } }
private static void Compile(string outDirPath) { var args = new[] { "-cp", ".;CoverageWriter.jar;junit-4.8.2.jar", "-sourcepath", "src", "-d", ".", @"test\*.java" }; var info = new ProcessStartInfo { FileName = JavacCommand, Arguments = args.JoinString(" "), CreateNoWindow = true, UseShellExecute = false, WorkingDirectory = outDirPath, }; try { using (var p = Process.Start(info)) p.WaitForExit(); } catch (Win32Exception e) { throw new InvalidOperationException("Failed to launch 'javac'.", e); } }
public void SetInReplyTo(TweetViewModel tweet) { if (tweet == null) { // clear in reply to this.CurrentInputDescription.InReplyToId = 0; } else { // スクリーン名の取得 var screen = tweet.Status.User.ScreenName; var sid = tweet.Status.Id; var ts = tweet.Status as TwitterStatus; if (!Setting.Instance.InputExperienceProperty.OfficialRetweetInReplyToRetweeter && ts != null && ts.RetweetedOriginal != null) { screen = ts.RetweetedOriginal.User.ScreenName; sid = ts.RetweetedOriginal.Id; } if (this.CurrentInputDescription.InputText.StartsWith(".@")) { // multi reply mode string remain; var screens = SplitTweet(this.CurrentInputDescription.InputText, out remain); if (screens.FirstOrDefault(s => s.Equals(screen, StringComparison.CurrentCultureIgnoreCase)) != null) { // 選択ユーザーのスクリーン名だけ抜く this.CurrentInputDescription.InputText = "." + screens.Where(s => !s.Equals(screen, StringComparison.CurrentCultureIgnoreCase)) .Select(s => "@" + s) .JoinString(" ") + " " + remain; } else { this.CurrentInputDescription.InputText = "." + screens.Select(s => "@" + s).JoinString(" ") + " " + "@" + screen + " " + remain; this.SetInputCaretIndex(this.CurrentInputDescription.InputText.Length); } this.CurrentInputDescription.InReplyToId = 0; } else if (this.CurrentInputDescription.InReplyToId != 0 && this.CurrentInputDescription.InputText.StartsWith("@")) { // single reply mode -> muliti reply mode if (this.CurrentInputDescription.InReplyToId == sid) { this.CurrentInputDescription.InputText = "." + this.CurrentInputDescription.InputText; this.CurrentInputDescription.InReplyToId = 0; } else { string remain; var screens = SplitTweet(this.CurrentInputDescription.InputText, out remain); this.CurrentInputDescription.InputText = "." + screens.Select(s => "@" + s).JoinString(" ") + " " + "@" + screen + " " + remain; this.CurrentInputDescription.InReplyToId = 0; this.SetInputCaretIndex(this.CurrentInputDescription.InputText.Length); } this.overrideTargets = null; } else { // single reply mode this.CurrentInputDescription.InReplyToId = sid; if (tweet.Status is TwitterDirectMessage) { this.OverrideTarget(new[] { AccountStorage.Get(((TwitterDirectMessage)tweet.Status).Recipient.ScreenName) }); this.CurrentInputDescription.InputText = "d @" + screen + " "; this.SetInputCaretIndex(this.CurrentInputDescription.InputText.Length); } else { var mentions = RegularExpressions.AtRegex.Matches(tweet.TweetText); var sns = new[] { "@" + screen }.Concat(mentions.Cast<Match>().Select(m => m.Value)) .Distinct().Where(s => !AccountStorage.Contains(s)).ToArray(); /* if (tweet.Status is TwitterStatus && AccountStorage.Contains(((TwitterStatus)tweet.Status).InReplyToUserScreenName)) sns = sns.Except(new[] { "@" + ((TwitterStatus)tweet.Status).InReplyToUserScreenName }).ToArray(); */ if (sns.Length > 1) { this.CurrentInputDescription.InputText = sns.JoinString(" ") + " "; this.SetInputCaretIndex(sns[0].Length + 1, sns.JoinString(" ").Length - sns[0].Length); } else { this.CurrentInputDescription.InputText = "@" + screen + " "; this.SetInputCaretIndex(this.CurrentInputDescription.InputText.Length); } if (tweet.Status is TwitterStatus && AccountStorage.Contains(((TwitterStatus)tweet.Status).InReplyToUserScreenName)) { this.OverrideTarget(new[] { AccountStorage.Get(((TwitterStatus)tweet.Status).InReplyToUserScreenName) }); } } } } }