示例#1
0
文件: Common.cs 项目: chrhodes/VNC
        public static StringBuilder InvokeVNCSyntaxWalker(
            SyntaxWalkers.VNCSyntaxWalker walker,
            SearchTreeCommandConfiguration commandConfiguration)
        {
            Int64 startTicks = Log.DOMAINSERVICES("Enter", CodeAnalysis.Common.LOG_CATEGORY);

            StringBuilder results = new StringBuilder();

            walker.Messages = results;

            walker.TargetPattern = commandConfiguration.WalkerPattern.UseRegEx ? commandConfiguration.WalkerPattern.RegEx : ".*";

            walker._configurationOptions = commandConfiguration.CodeAnalysisOptions;

            walker.Visit(commandConfiguration.SyntaxTree.GetRoot());

            if (results.Length > 0)
            {
                commandConfiguration.Results.AppendLine(results.ToString());
            }

            Log.DOMAINSERVICES("Exit", CodeAnalysis.Common.LOG_CATEGORY, startTicks);

            return(commandConfiguration.Results);
        }
示例#2
0
        StringBuilder DisplayAsNewClauseVB(SearchTreeCommandConfiguration commandConfiguration)
        {
            long startTicks = Log.Trace15("Enter", Common.LOG_APPNAME);

            var walker = new VNCSW.VB.AsNewClause();

            commandConfiguration.WalkerPattern.UseRegEx = (bool)ceAsNewClauseUseRegEx.IsChecked;
            commandConfiguration.WalkerPattern.RegEx    = teAsNewClauseRegEx.Text;
            commandConfiguration.CodeAnalysisOptions    = CodeExplorer.configurationOptions.GetConfigurationInfo();

            return(VNCCA.Helpers.VB.InvokeVNCSyntaxWalker(walker, commandConfiguration));
        }
示例#3
0
        StringBuilder DisplaySingleLineLambdaExpressionVB(SearchTreeCommandConfiguration commandConfiguration)
        {
            long startTicks = Log.Trace15("Enter", Common.LOG_APPNAME);

            var walker = new VNCSW.VB.SingleLineLambdaExpression();

            commandConfiguration.WalkerPattern.UseRegEx = (bool)ceSingleLineLambdaExpressionUseRegEx.IsChecked;
            commandConfiguration.WalkerPattern.RegEx    = teSingleLineLambdaExpressionRegEx.Text;
            commandConfiguration.CodeAnalysisOptions    = CodeExplorer.configurationOptions.GetConfigurationInfo();

            Log.Trace15("Exit", Common.LOG_APPNAME, startTicks);

            return(VNCCA.Helpers.VB.InvokeVNCSyntaxWalker(walker, commandConfiguration));
        }
示例#4
0
        public static StringBuilder InvokeVNCSyntaxWalker(
            SyntaxWalkers.CS.VNCCSSyntaxWalkerBase walker,
            SearchTreeCommandConfiguration commandConfiguration)
        {
            Int64 startTicks = Log.DOMAINSERVICES("Enter", CodeAnalysis.Common.LOG_CATEGORY);

            StringBuilder results = new StringBuilder();

            //walker.Messages = commandConfiguration.Results;
            walker.Messages = results;

            // Setting the TargetPattern will call InitializeRegEx()
            walker.TargetPattern = commandConfiguration.WalkerPattern.UseRegEx ? commandConfiguration.WalkerPattern.RegEx : ".*";

            var foo = commandConfiguration.WalkerPattern.GetType();

            if (foo == typeof(WalkerPatternStruct))
            {
                walker.TargetPattern2 = ((WalkerPatternStruct)commandConfiguration.WalkerPattern).UseRegExFields ?
                                        ((WalkerPatternStruct)commandConfiguration.WalkerPattern).RegExFields : ".*";
            }

            walker._configurationOptions = commandConfiguration.CodeAnalysisOptions;

            walker.Matches                = commandConfiguration.Matches;
            walker.CRCMatchesToString     = commandConfiguration.CRCMatchesToString;
            walker.CRCMatchesToFullString = commandConfiguration.CRCMatchesToFullString;

            walker.Visit(commandConfiguration.SyntaxTree.GetRoot());

            if (results.Length > 0)
            {
                if (commandConfiguration.CodeAnalysisOptions.DisplayCRC32)
                {
                    results.AppendFormat("CRC32Node:            {0}\n", walker.CRC32Node);
                    results.AppendFormat("CRC32NodeKind:        {0}\n", walker.CRC32NodeKind);
                    //results.AppendFormat("CRC32Token:           {0}\n", walker.CRC32Token);
                    //results.AppendFormat("CRC32Trivia:          {0}\n", walker.CRC32Trivia);
                    //results.AppendFormat("CRC32StructuredTrivia:{0}\n", walker.CRC32StructuredTrivia);
                }

                commandConfiguration.Results.AppendLine(results.ToString());
            }

            Log.DOMAINSERVICES("Exit", CodeAnalysis.Common.LOG_CATEGORY, startTicks);

            return(commandConfiguration.Results);
        }
示例#5
0
        StringBuilder DisplayMethodBlockWalkerVB(SearchTreeCommandConfiguration commandConfiguration)
        {
            long startTicks = Log.Trace15("Enter", Common.LOG_APPNAME);

            VNCSW.VB.VNCVBTypedSyntaxWalkerBase walker = null;

            commandConfiguration.WalkerPattern.UseRegEx = (bool)ceMethodBlockUseRegEx.IsChecked;
            commandConfiguration.WalkerPattern.RegEx    = teMethodBlockRegEx.Text;
            commandConfiguration.CodeAnalysisOptions    = CodeExplorer.configurationOptions.GetConfigurationInfo();

            // TODO(crhodes)
            // Maybe figure out how to suppress showing of block.

            //if ((bool)ceShowMethodBlock2.IsChecked)
            //{
            walker = new VNCSW.VB.MethodBlock();
            //commandConfiguration.CodeAnalysisOptions.ShowAnalysisCRC = true;
            //}
            //else
            //{
            //    walker = new VNCSW.VB.MethodStatement();
            //}

            StringBuilder results = VNCCA.Helpers.VB.InvokeVNCSyntaxWalker(walker, commandConfiguration);

            // We may have done a deep dive on a method.  Go grab the results.
            // TODO(crhodes)
            // This might only be if in MethodBlock mode.  See above.

            CodeExplorer.teSyntaxNode.Text             += walker.WalkerNode.ToString();
            CodeExplorer.teSyntaxToken.Text            += walker.WalkerToken.ToString();
            CodeExplorer.teSyntaxTrivia.Text           += walker.WalkerTrivia.ToString();
            CodeExplorer.teSyntaxStructuredTrivia.Text += walker.WalkerStructuredTrivia.ToString();

            Log.Trace15("Exit", Common.LOG_APPNAME, startTicks);

            return(results);
        }