示例#1
0
        private StringBuilder DisplayMethodStatementWalkerVB(VNCCA.SearchTreeCommandConfiguration commandConfiguration)
        {
            long startTicks = Log.Trace15("Enter", Common.LOG_APPNAME);

            VNCSW.VB.VNCVBTypedSyntaxWalkerBase walker = null;

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

            if ((bool)ceShowMethodBlock.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);
        }
示例#2
0
        private StringBuilder DisplayModuleStatementWalkerVB(VNCCA.SearchTreeCommandConfiguration commandConfiguration)
        {
            long startTicks = Log.Trace15("Enter", Common.LOG_APPNAME);

            VNCSW.VB.VNCVBTypedSyntaxWalkerBase walker = null;

            if ((bool)ceShowModuleBlock.IsChecked)
            {
                walker = new VNCSW.VB.ModuleBlock();
            }
            else
            {
                walker = new VNCSW.VB.ModuleStatement();
            }


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

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

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

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

            walker.ShowFields = (bool)ceStructureShowFields.IsChecked;

            walker.HasAttributes = (bool)CodeExplorer.configurationOptions.ceHasAttributes.IsChecked;

            walker.AllFieldTypes  = (bool)CodeExplorer.configurationOptions.ceAllTypes.IsChecked;
            walker.FieldNames     = (bool)ceStructureFieldsUseRegEx.IsChecked ? teStructureFieldsRegEx.Text : ".*";
            walker.StructureNames = (bool)ceStructuresUseRegEx.IsChecked ? teStructureRegEx.Text : ".*";

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

            // StructureBlock has special (two types) of RegEx.
            walker.InitializeRegEx();

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

            return(VNCCA.Helpers.VB.InvokeVNCSyntaxWalker(walker, commandConfiguration));
        }
示例#4
0
        StringBuilder DisplaySimpleAsClauseWalkerVB(VNCCA.SearchTreeCommandConfiguration commandConfiguration)
        {
            long startTicks = Log.Trace15("Enter", Common.LOG_APPNAME);
            var  walker     = new VNCSW.VB.SimpleAsClause();

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

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

            return(VNCCA.Helpers.VB.InvokeVNCSyntaxWalker(walker, commandConfiguration));
        }
        StringBuilder DisplayInvocationExpressionInTryCatchWalkerVB(VNCCA.SearchTreeCommandConfiguration commandConfiguration)
        {
            var walker = new VNCSW.VB.InvocationExpressionInTryCatch();

            //return VNCCA.Helpers.VB.InvokeVNCSyntaxWalker(sb,
            //    (bool)ceInvocationExpressionInTryCatchUseRegEx.IsChecked, teInvocationExpressionInTryCatchRegEx.Text,
            //    matches, crcMatchesToString, crcMatchesToFullString, tree, walker, CodeExplorer.configurationOptions.GetConfigurationInfo());

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

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

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

            walker.HasAttributes = (bool)CodeExplorer.configurationOptions.ceHasAttributes.IsChecked;

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

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

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

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

            walker.MatchLeft  = (bool)ceAssignmentStatementMatchLeft.IsChecked;
            walker.MatchRight = (bool)ceAssignmentStatementMatchRight.IsChecked;

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

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

            return(VNCCA.Helpers.VB.InvokeVNCSyntaxWalker(walker, commandConfiguration));
        }
        private StringBuilder DisplayMultipleVariableDeclaratorWalkerVB(VNCCA.SearchTreeCommandConfiguration commandConfiguration)
        {
            var walker = new VNCSW.VB.MultipleVariableDeclarator();

            walker.HasAttributes = (bool)CodeExplorer.configurationOptions.ceHasAttributes.IsChecked;

            //return VNCCA.Helpers.VB.InvokeVNCSyntaxWalker(sb,
            //    (bool)ceVariablesUseRegEx.IsChecked, teVariableRegEx.Text,
            //    matches, crcMatchesToString, crcMatchesToFullString, tree, walker, CodeExplorer.configurationOptions.GetConfigurationInfo());

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

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

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

            //return VNCCA.Helpers.VB.InvokeVNCSyntaxWalker(sb,
            //    (bool)ceNamespaceStatementUseRegEx.IsChecked, teNamespaceStatementRegEx.Text,
            //    matches, crcMatchesToString, crcMatchesToFullString, tree, walker, CodeExplorer.configurationOptions.GetConfigurationInfo());

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

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

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

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

            // TODO(crhodes)
            // Leaving this comment in to show the progression from too many arguments to commandConfiguration class.
            // Adding another argument was a pain.  Had to change too many places.  Adding another thing is now easy.

            //return VNCCA.Helpers.VB.InvokeVNCSyntaxWalker(sb,
            //    (bool)ceMemberAccessExpressionUseRegEx.IsChecked, teMemberAccessExpressionRegEx.Text,
            //    matches, crcMatchesToString, crcMatchesToFullString, tree, walker, CodeExplorer.configurationOptions.GetConfigurationInfo());

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

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

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

            VNCCA.SyntaxNode.FieldDeclarationLocation fieldDeclarationLocation = VNCCA.SyntaxNode.FieldDeclarationLocation.Class;

            // TODO(crhodes)
            // Go look at EyeOnLife and see how to do this in a cleaner way.

            switch (lbeFieldDeclarationLocation.EditValue.ToString())
            {
            case "Class":
                fieldDeclarationLocation = VNCCA.SyntaxNode.FieldDeclarationLocation.Class;
                break;

            case "Module":
                fieldDeclarationLocation = VNCCA.SyntaxNode.FieldDeclarationLocation.Module;
                break;

            case "Structure":
                fieldDeclarationLocation = VNCCA.SyntaxNode.FieldDeclarationLocation.Structure;
                break;
            }
            VNCSW.VB.VNCVBTypedSyntaxWalkerBase walker = null;

            walker = new VNCSW.VB.FieldDeclaration(fieldDeclarationLocation);

            walker.HasAttributes = (bool)CodeExplorer.configurationOptions.ceHasAttributes.IsChecked;

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

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

            return(VNCCA.Helpers.VB.InvokeVNCSyntaxWalker(walker, commandConfiguration));
        }
        public static void ProcessOperation(VNCCA.Types.SearchTreeCommand searchTreeCommand,
                                            User_Controls.wucCodeExplorer codeExplorer,
                                            User_Controls.wucCodeExplorerContext codeExplorerContext,
                                            User_Controls.wucConfigurationOptions configurationOptions)
        {
            long startTicks = Log.UTILITY("Enter", Common.LOG_APPNAME);

            StringBuilder sb = new StringBuilder();

            codeExplorer.teSourceCode.Clear();
            codeExplorer.teSourceCode.InvalidateVisual();
            //CodeExplorer.teSourceCode.Text = "";

            codeExplorer.teSyntaxNode.Clear();
            codeExplorer.teSyntaxToken.Clear();
            codeExplorer.teSyntaxTrivia.Clear();
            codeExplorer.teSyntaxStructuredTrivia.Clear();

            codeExplorer.teSummary.Clear();
            codeExplorer.teSummaryCRCToString.Clear();
            codeExplorer.teSummaryCRCToFullString.Clear();

            string projectFullPath = codeExplorerContext.teProjectFile.Text;

            var filesToProcess = codeExplorerContext.GetFilesToProcess();

            Dictionary <string, Int32> matches                = new Dictionary <string, int>();
            Dictionary <string, Int32> crcMatchesToString     = new Dictionary <string, int>();
            Dictionary <string, Int32> crcMatchesToFullString = new Dictionary <string, int>();

            if (filesToProcess.Count > 0)
            {
                if ((Boolean)configurationOptions.ceListImpactedFilesOnly.IsChecked)
                {
                    sb.AppendLine("Would Search these files ....");
                }

                foreach (string filePath in filesToProcess)
                {
                    if ((Boolean)configurationOptions.ceListImpactedFilesOnly.IsChecked)
                    {
                        sb.AppendLine(string.Format("  {0}", filePath));
                    }
                    else
                    {
                        StringBuilder sbFileResults = new StringBuilder();

                        var sourceCode = "";

                        using (var sr = new System.IO.StreamReader(filePath))
                        {
                            sourceCode = sr.ReadToEnd();
                        }

                        //
                        // This is where the action happens
                        //

                        SyntaxTree tree = VisualBasicSyntaxTree.ParseText(sourceCode);

                        VNCCA.SearchTreeCommandConfiguration searchTreeCommandConfiguration = new VNCCA.SearchTreeCommandConfiguration();

                        searchTreeCommandConfiguration.Results                = sbFileResults;
                        searchTreeCommandConfiguration.SyntaxTree             = tree;
                        searchTreeCommandConfiguration.Matches                = matches;
                        searchTreeCommandConfiguration.CRCMatchesToString     = crcMatchesToString;
                        searchTreeCommandConfiguration.CRCMatchesToFullString = crcMatchesToFullString;

                        sbFileResults = searchTreeCommand(searchTreeCommandConfiguration);

                        if ((bool)configurationOptions.ceAlwaysDisplayFileName.IsChecked || (sbFileResults.Length > 0))
                        {
                            sb.AppendLine("Searching " + filePath);
                        }

                        sb.Append(sbFileResults.ToString());
                    }
                }
            }
            else
            {
                sb.AppendLine("No files selected to process");
            }

            if (!(Boolean)configurationOptions.ceDisplayResults.IsChecked)
            {
                // If only want to see the summary ...
                sb.Clear();
            }

            codeExplorer.teSourceCode.Text = sb.ToString();

            if ((Boolean)configurationOptions.ceDisplaySummary.IsChecked)
            {
                StringBuilder summary = new StringBuilder();

                // Add information from the matches dictionary
                summary.AppendLine("\n*** Summary ***\n");

                foreach (var item in matches.OrderBy(v => v.Key).Select(k => k.Key))
                {
                    if (matches[item] >= configurationOptions.sbDisplaySummaryMinimum.Value)
                    {
                        summary.AppendLine(string.Format("Count: {0,3} {1} ", matches[item], item));
                    }
                }

                codeExplorer.teSummary.Text = summary.ToString();

                if ((Boolean)configurationOptions.ceDisplayCRC32.IsChecked)
                {
                    summary.Clear();

                    summary.AppendLine("\n*** CRC ToString Summary *** \n");

                    foreach (var item in crcMatchesToString.OrderBy(v => v.Key).Select(k => k.Key))
                    {
                        if (crcMatchesToString[item] >= configurationOptions.sbDisplaySummaryMinimum.Value)
                        {
                            summary.AppendLine(string.Format("Count: {0,3} {1} ", crcMatchesToString[item], item));
                        }
                    }

                    codeExplorer.teSummaryCRCToString.Text = summary.ToString();

                    summary.Clear();

                    summary.AppendLine("\n*** CRC ToFullString Summary ***\n");

                    foreach (var item in crcMatchesToFullString.OrderBy(v => v.Key).Select(k => k.Key))
                    {
                        if (crcMatchesToFullString[item] >= configurationOptions.sbDisplaySummaryMinimum.Value)
                        {
                            summary.AppendLine(string.Format("Count: {0,3} {1} ", crcMatchesToFullString[item], item));
                        }
                    }

                    codeExplorer.teSummaryCRCToString.Text = summary.ToString();
                }
            }

            Log.UTILITY("Exit", Common.LOG_APPNAME, startTicks);
        }