예제 #1
0
        private static void Main(string[] commandLine)
        {
#if DEBUG
            commandLine = new[] { "--abbrev", "--map", "--sane", "--show-warnings" };
            Snippet snippet = SourceCode.TestCode;
#else
            var snippet = SourceCode.FromStdin();
            #endif

            Options     options = ConfigureOptions();
            List <Call> actions = options.Parse(commandLine).ToList();
            if (NoActionsSpecified(actions))
            {
                Help.Print(options);
                return;
            }
            InvokeAll(actions, snippet);
        }
예제 #2
0
 public void Sane(Snippet snippet)
 {
     _check = new SanityCheck();
     _check.CheckTree(_replacedCode, snippet);
 }
예제 #3
0
 public void Map(Snippet snippet)
 {
     "Map".Announce();
     _map.Each((key, value) => Console.WriteLine("{0}: {1}", key, value));
 }
예제 #4
0
 public void Abbrev(Snippet snippet)
 {
     ReplaceIdentifiers(snippet, new ThreeCharacters(_random).Replace);
 }
예제 #5
0
 public void Single(Snippet snippet)
 {
     ReplaceIdentifiers(snippet, new SingleCharacter(_random).Replace);
 }
예제 #6
0
 public void Normal(Snippet snippet)
 {
     ReplaceIdentifiers(snippet, new Normal().Replace);
 }
예제 #7
0
 public static void MethodName(Snippet snippet)
 {
     Console.WriteLine("Method Name: {0}", snippet.MethodName);
 }
예제 #8
0
 public static void ListTokens(Snippet snippet)
 {
     ListTokens(snippet.Tokens);
 }
예제 #9
0
 public static void CountLines(Snippet snippet)
 {
     Console.WriteLine("LOC: {0}", snippet.LinesOfCodeCount);
 }
예제 #10
0
 public static void CountIdenfifiers(Snippet snippet)
 {
     Console.WriteLine("Identifiers: {0}", snippet.Identifiers.Count());
 }
예제 #11
0
 public static void CountTokens(Snippet snippet)
 {
     Console.WriteLine("Tokens: {0}", snippet.Tokens.Count());
 }
예제 #12
0
 public static void ListIdentifiers(Snippet snippet)
 {
     ListTokens(snippet.Identifiers);
 }
예제 #13
0
        public static Snippet FromStdin()
        {
            string code = ReadCodeFromStdIn();

            return(Snippet.Parse(code));
        }