private StringBuilder CommentOut_InvocationExpressionVB(VNCCA.RewriteFileCommandConfiguration commandConfiguration, out bool performedReplacement) { performedReplacement = false; var rewriter = new VNC.CodeAnalysis.SyntaxRewriters.VB.CommentOutSingleLineInvocationExpression(commandConfiguration.TargetPattern, teComment.Text); rewriter.Messages = commandConfiguration.Results; rewriter._configurationOptions = commandConfiguration.CodeAnalysisOptions; SyntaxNode newNode = rewriter.Visit(commandConfiguration.SyntaxTree.GetRoot()); performedReplacement = VNCSR.Helpers.SaveFileChanges(commandConfiguration, newNode); return(commandConfiguration.Results); }
private StringBuilder Remove_ExpressionStatementVB(VNCCA.RewriteFileCommandConfiguration commandConfiguration, out bool performedReplacement) { performedReplacement = false; var rewriter = new VNC.CodeAnalysis.SyntaxRewriters.VB.RemoveExpressionStatement( commandConfiguration.TargetPattern, (Boolean)ceCommentOut_FieldDeclaration.IsChecked, teComment.Text); rewriter.Messages = commandConfiguration.Results; rewriter._configurationOptions = commandConfiguration.CodeAnalysisOptions; SyntaxNode newNode = rewriter.Visit(commandConfiguration.SyntaxTree.GetRoot()); performedReplacement = VNCSR.Helpers.SaveFileChanges(commandConfiguration, newNode); return(commandConfiguration.Results); }
private StringBuilder WrapSQLExecuteXCallsInDALHelperVB(VNCCA.RewriteFileCommandConfiguration commandConfiguration, out bool performedReplacement) { performedReplacement = false; var rewriter = new VNC.CodeAnalysis.SyntaxRewriters.VB.WrapSQLExecuteXCallsInDALHelper( commandConfiguration.TargetPattern); rewriter._configurationOptions = commandConfiguration.CodeAnalysisOptions; rewriter.Messages = commandConfiguration.Results; rewriter.Replacements = commandConfiguration.Replacements; SyntaxNode newNode = rewriter.Visit(commandConfiguration.SyntaxTree.GetRoot()); string fileSuffix = CodeExplorer.configurationOptions.ceAddFileSuffix.IsChecked.Value ? CodeExplorer.configurationOptions.teFileSuffix.Text : ""; performedReplacement = VNCSR.Helpers.SaveFileChanges(commandConfiguration, newNode); return(commandConfiguration.Results); }
private StringBuilder Remove_FieldDeclarationVB(VNCCA.RewriteFileCommandConfiguration commandConfiguration, out bool performedReplacement) { performedReplacement = false; 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; } var rewriter = new VNC.CodeAnalysis.SyntaxRewriters.VB.RemoveFieldDeclaration( commandConfiguration.TargetPattern, fieldDeclarationLocation, (Boolean)ceCommentOut_FieldDeclaration.IsChecked, teComment.Text); rewriter.Messages = commandConfiguration.Results; rewriter._configurationOptions = commandConfiguration.CodeAnalysisOptions; SyntaxNode newNode = rewriter.Visit(commandConfiguration.SyntaxTree.GetRoot()); performedReplacement = VNCSR.Helpers.SaveFileChanges(commandConfiguration, newNode); return(commandConfiguration.Results); }
void ProcessOperation(VNCCA.Types.RewriteFileCommand command, wucConfigurationOptions configurationOptions) { StringBuilder sb = new StringBuilder(); CodeExplorer.teSourceCode.Clear(); CodeExplorer.teSourceCode.InvalidateVisual(); string projectFullPath = CodeExplorerContext.teProjectFile.Text; var filesToProcess = CodeExplorerContext.GetFilesToProcess(); Dictionary <string, Int32> replacements = new Dictionary <string, int>(); if (filesToProcess.Count > 0) { if ((Boolean)configurationOptions.ceListImpactedFilesOnly.IsChecked) { sb.AppendLine("Would Process these files ...."); } foreach (string filePath in filesToProcess) { try { 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(); } Boolean performedReplacement = false; // // This is where the action happens // SyntaxTree tree = VisualBasicSyntaxTree.ParseText(sourceCode); VNCCA.RewriteFileCommandConfiguration rewriteFileCommandConfiguration = new VNCCA.RewriteFileCommandConfiguration(); rewriteFileCommandConfiguration.Results = sbFileResults; rewriteFileCommandConfiguration.SyntaxTree = tree; rewriteFileCommandConfiguration.FilePath = filePath; rewriteFileCommandConfiguration.Replacements = replacements; rewriteFileCommandConfiguration.WalkerPattern.UseRegEx = (bool)ceReplacementTargetUseRegEx.IsChecked; rewriteFileCommandConfiguration.TargetPattern = teTargetExpression.Text; rewriteFileCommandConfiguration.ReplacementPattern = teReplacementInvocationExpression.Text; rewriteFileCommandConfiguration.CodeAnalysisOptions = CodeExplorer.configurationOptions.GetConfigurationInfo(); sbFileResults = command(rewriteFileCommandConfiguration, out performedReplacement); //sbFileResults = command(sbFileResults, tree, filePath, targetInvocationExpression, newInvocationExpression, replacements, out performedReplacement); if ((bool)configurationOptions.ceAlwaysDisplayFileName.IsChecked || (sbFileResults.Length > 0)) { sb.AppendLine("Searching " + filePath); } if (performedReplacement) { sb.AppendLine("Rewrote " + filePath); } sb.Append(sbFileResults.ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } else { sb.AppendLine("No files selected to process"); } CodeExplorer.teSourceCode.Text = sb.ToString(); }