/// <summary> /// Get source code from given element that is before main body. /// </summary> /// <param name="fn">Element which precode is retrieved.</param> /// <returns>Element's precode.</returns> internal string GetPreCode(CodeFunction fn) { if (fn.FunctionKind != vsCMFunction.vsCMFunctionConstructor) { //precode is available only for ctors return(""); } var name = fn.Name; var lang = fn.Language; if (!fn.ProjectItem.IsOpen) { fn.ProjectItem.Open(); } var editPoint = fn.GetStartPoint(vsCMPart.vsCMPartHeader).CreateEditPoint(); var endPoint = fn.GetStartPoint(vsCMPart.vsCMPartBody); var preCode = editPoint.GetText(endPoint).Replace("\r", ""); var preCodeStart = preCode.IndexOf(':'); if (preCodeStart < 0) { return(""); } preCode = preCode.Substring(preCodeStart); var bodyStart = preCode.LastIndexOf('{'); preCode = preCode.Substring(0, bodyStart).Trim(); return(preCode + (char)0); }
/// <summary> /// Replaces the body. /// </summary> /// <param name="code">The code.</param> public void ReplaceBody(string code) { TextPoint sp = _codeElement.GetStartPoint(vsCMPart.vsCMPartBody); TextPoint ep = _codeElement.GetEndPoint(vsCMPart.vsCMPartBody); EditPoint startpoint = sp.CreateEditPoint(); EditPoint endpoint = ep.CreateEditPoint(); startpoint.ReplaceText(endpoint, code, (int)vsEPReplaceTextOptions.vsEPReplaceTextAutoformat); }
public static void AddCodeSite(this CodeFunction codeFunction) { if (codeFunction.HasExpressionBody()) {//展开表达式主体为程序块主体,不做逆向处理 var addReturn = !(codeFunction.Type.TypeKind == vsCMTypeRef.vsCMTypeRefVoid || codeFunction.Parent is CodeProperty codeProperty && codeFunction.EqualsOffset(codeProperty.Setter)); if (codeFunction.HasBody()) { var epFind = codeFunction.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); var epEEnd = codeFunction.GetEndPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); epFind.FindPattern("=>", (int)vsFindOptions.vsFindOptionsBackwards); epFind.Delete(2); epFind.Insert("{get{"); if (addReturn) { epFind.Insert("return "); } epEEnd.CharRight(); epEEnd.Insert("}}"); } else { var epFind = codeFunction.GetStartPoint().CreateEditPoint(); var epEEnd = codeFunction.GetEndPoint().CreateEditPoint(); epFind.FindPattern("=>"); epFind.Delete(2); epFind.Insert("{"); if (addReturn) { epFind.Insert("return "); } epEEnd.Insert("}"); } } if (codeFunction.ExistsCodeSite()) { codeFunction.DeleteCodeSite(); } EditPoint epStart = codeFunction.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); EditPoint epEnd = codeFunction.GetEndPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); if (epStart.Line == epEnd.Line) { epEnd.Insert(Environment.NewLine); } epStart.Insert(codeFunction.CSEnterText()); if (Properties.Settings.Default.IncludeCatch) { epEnd.Insert(codeFunction.CSCatchText()); } epEnd.Insert(codeFunction.CSExitText()); //格式化指定范围内的文本 codeFunction.StartPoint.CreateEditPoint().SmartFormat(codeFunction.EndPoint.CreateEditPoint()); }
public void GetStartPoint_FunctionStartsAtColumn3_ReturnsPointWithOffset3() { CreatePublicFunction("Class1.MyFunction"); SetDeclaringType("Class1"); helper.FunctionStartsAtColumn(3); TextPoint point = codeFunction.GetStartPoint(); int offset = point.LineCharOffset; Assert.AreEqual(3, offset); }
private void TreeViewItem_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (sender is TreeViewItem treeViewItem && treeViewItem.DataContext is CodeElementViewModel codeElementViewModel && codeElementViewModel.IsCodeFunction) { CodeFunction codeFunction = codeElementViewModel.CodeFunction; TextPoint textPoint; try { textPoint = codeFunction.GetStartPoint(vsCMPart.vsCMPartBody); } catch { textPoint = codeFunction.GetStartPoint(); } (codeFunction.DTE.ActiveDocument.Selection as TextSelection).MoveToPoint(textPoint); } }
public void GetStartPoint_FunctionStartsAtColumnOne_ReturnsPointWithOffsetOne() { CreateFunction( "public class Class1 {\r\n" + "public void MyFunction() {}\r\n" + "}"); global::EnvDTE.TextPoint point = codeFunction.GetStartPoint(); int offset = point.LineCharOffset; Assert.AreEqual(1, offset); }
/// <summary> /// Spreads the specified single line method onto multiple lines. /// </summary> /// <param name="method">The method to update.</param> private void SpreadSingleLineMethodOntoMultipleLines(CodeFunction method) { try { var start = method.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); var end = method.GetEndPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); // Insert a new-line before and after the opening brace. start.CharLeft(); start.Insert(Environment.NewLine); start.CharRight(); start.Insert(Environment.NewLine); // Insert a new-line before the closing brace, unless the method is empty. end.DeleteWhitespace(); if (end.DisplayColumn > 1) { end.Insert(Environment.NewLine); } // Update the formatting of the method. method.StartPoint.CreateEditPoint().SmartFormat(method.EndPoint); } catch (Exception) { // Methods may not have a body (ex: partial). } }
private void funcInfo(string className, CodeElement codeElement) { Dispatcher.VerifyAccess(); CodeFunction funcElement = codeElement as CodeFunction; TextPoint start = funcElement.GetStartPoint(vsCMPart.vsCMPartHeader); TextPoint finish = funcElement.GetEndPoint(); string fullSource = start.CreateEditPoint().GetText(finish); int openCurlyBracePos = fullSource.IndexOf('{'); if (openCurlyBracePos > -1) { string prototype = fullSource.Substring(0, openCurlyBracePos).Trim(); string pattern = @"\b(alignas|alignof|and|and_eq|asm|auto|bitand|bitor|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|false|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|noexcept|not|not_eq|nullptr|operator|or|or_eq|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|true|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while|xor|xor_eq)\b"; int linesAll = Regex.Matches(fullSource, @"[\n]").Count + 1; string uncommented = DeleteCom(fullSource, false); string uncommented_with_quot = DeleteCom(fullSource, true); int count_of_lines_wt_comments = Regex.Matches(uncommented, @"[\n]").Count + 1; /// int linesAll = Regex.Matches(uncommented_with_quot, @"[\n]").Count + 1; count_of_lines_wt_comments++; int comments_count = CommentCount(fullSource); int keywords = Regex.Matches(uncommented_with_quot, pattern).Count; string str_keyword = keywords.ToString(); string str_lines = linesAll.ToString(); string str_lines1 = (linesAll - comments_count).ToString(); table.Add(new Statistic() { FunctionName = prototype, LinesCount = str_lines, WithoutComments = str_lines1, KeywordCount = str_keyword, ClassName = className }); } }
private void ReplaceStepBindingAttribute(CodeFunction codeFunction, IStepDefinitionBinding binding, string newRegex) { if (!codeFunction.ProjectItem.IsOpen) { codeFunction.ProjectItem.Open(); } var formattedOldRegex = FormatRegexForDisplay(binding.Regex); var navigatePoint = codeFunction.GetStartPoint(vsCMPart.vsCMPartHeader); navigatePoint.TryToShow(); navigatePoint.Parent.Selection.MoveToPoint(navigatePoint); var stepBindingEditorContext = GherkinEditorContext.FromDocument(codeFunction.DTE.ActiveDocument, _gherkinLanguageServiceFactory); var attributeLinesToUpdate = stepBindingEditorContext.TextView.TextViewLines.Where(x => x.Start.GetContainingLine().GetText().Contains("\"" + formattedOldRegex + "\"")); foreach (var attributeLineToUpdate in attributeLinesToUpdate) { using (var textEdit = attributeLineToUpdate.Snapshot.TextBuffer.CreateEdit()) { var regexStart = attributeLineToUpdate.Start.GetContainingLine().GetText().IndexOf(formattedOldRegex); textEdit.Replace(attributeLineToUpdate.Start.Position + regexStart, formattedOldRegex.Length, newRegex); textEdit.Apply(); } } }
/// <summary> /// Gets the declaration of the specified code method as a string. /// </summary> /// <param name="codeFunction">The code method.</param> /// <returns>The string declaration.</returns> internal static string GetMethodDeclaration(CodeFunction codeFunction) { // Get the start point after the attributes. var startPoint = codeFunction.GetStartPoint(vsCMPart.vsCMPartHeader); return(TextDocumentHelper.GetTextToFirstMatch(startPoint, @"[\(\{;]")); }
void CreateMethodEditPoint() { var codeFunction = new CodeFunction(methodHelper.Method, documentLoader); TextPoint startPoint = codeFunction.GetStartPoint(); endPoint = codeFunction.GetEndPoint(); editPoint = startPoint.CreateEditPoint(); }
/// <summary> /// Gets the code. /// </summary> /// <param name="instance">The instance.</param> /// <returns>The code.</returns> public static string GetCode(this CodeFunction instance) { TraceService.WriteLine("CodeFunctionExtensions::GetCode codeFunction=" + instance.Name); EditPoint startPoint = instance.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); EditPoint endPoint = instance.GetEndPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); return(startPoint.GetText(endPoint)); }
public async Task GetStartPoint_WholeWithAttributes() { CodeFunction testObject = await GetCodeFunctionAsync("A", "MethodA"); TextPoint startPoint = testObject.GetStartPoint(vsCMPart.vsCMPartWholeWithAttributes); Assert.Equal(18, startPoint.Line); Assert.Equal(5, startPoint.LineCharOffset); }
public async Task GetStartPoint_NavigateWithBlankLine() { CodeFunction testObject = await GetCodeFunctionAsync("A", "MethodWithBlankLine"); TextPoint startPoint = testObject.GetStartPoint(vsCMPart.vsCMPartNavigate); Assert.Equal(48, startPoint.Line); Assert.Equal(9, startPoint.LineCharOffset); }
public async Task GetStartPoint_Body() { CodeFunction testObject = await GetCodeFunctionAsync("A", "MethodA"); TextPoint startPoint = testObject.GetStartPoint(vsCMPart.vsCMPartBody); Assert.Equal(20, startPoint.Line); Assert.Equal(1, startPoint.LineCharOffset); }
public void GetStartPoint_Navigate() { CodeFunction testObject = GetCodeFunction("A", "MethodA"); TextPoint startPoint = testObject.GetStartPoint(vsCMPart.vsCMPartNavigate); Assert.Equal(20, startPoint.Line); Assert.Equal(9, startPoint.LineCharOffset); }
public void GetStartPoint_Header() { CodeFunction testObject = GetCodeFunction("A", "MethodA"); TextPoint startPoint = testObject.GetStartPoint(vsCMPart.vsCMPartHeader); Assert.Equal(18, startPoint.Line); Assert.Equal(5, startPoint.LineCharOffset); }
public static string GetText(this CodeFunction ele, vsCMPart part = vsCMPart.vsCMPartWholeWithAttributes) { var p = ele.GetStartPoint(part); if (p == null) { return(""); } return(p.CreateEditPoint().GetText(ele.GetEndPoint(part))); }
private void EditMigrations(CodeType migration, string updateMethod) { var cc = migration as CodeClass; // get functions var members = cc.Members; // list of ints List <int> migrations = new List <int>(); // iterate through functions foreach (CodeElement member in members) { var func = member as CodeFunction; if (func == null) { continue; } // TODO: investigate use of CodeFunction var createIndex = member.Name == "Create"; if (createIndex) { migrations.Add(0); continue; } var index = member.Name.IndexOf("UpdateFrom"); if (index == -1) { continue; } migrations.Add(Int32.Parse(member.Name.Last().ToString())); } // sort numbers, just in case migrations.Sort(); // get new update number var update = migrations.Count == 0 ? 0 : migrations.Last() + 1; // create method, either update or create var methodName = update == 0 ? "Create" : "UpdateFrom" + update; CodeFunction cf = cc.AddFunction(methodName, vsCMFunction.vsCMFunctionFunction, vsCMTypeRef.vsCMTypeRefInt, -1, vsCMAccess.vsCMAccessPublic); // access new method TextPoint tp = cf.GetStartPoint(vsCMPart.vsCMPartBody); TextPoint end = cf.GetEndPoint(vsCMPart.vsCMPartBody); EditPoint ep = tp.CreateEditPoint(); // delete auto generated code ep.Delete(end); var returnVal = update + 1; ep.Insert(updateMethod + Environment.NewLine + Environment.NewLine + "return " + returnVal + ";"); tp.CreateEditPoint().SmartFormat(ep); }
/// <summary> /// Replaces the code. /// </summary> /// <param name="instance">The instance.</param> /// <param name="newCode">The new code.</param> public static void ReplaceCode( this CodeFunction instance, string newCode) { TraceService.WriteLine("CodeFunctionExtensions::ReplaceCode codeFunction=" + instance.Name); EditPoint startPoint = instance.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); EditPoint endPoint = instance.GetEndPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); startPoint.Delete(endPoint); startPoint.Insert(newCode); }
public static void NavigateToFunction(CodeFunction function) { if (!function.ProjectItem.IsOpen) { function.ProjectItem.Open(); } var startPoint = function.GetStartPoint(vsCMPart.vsCMPartHeader); startPoint.TryToShow(); startPoint.Parent.Selection.MoveToPoint(startPoint); }
public static bool HasBody(this CodeFunction codeFunction) { try { codeFunction.GetStartPoint(vsCMPart.vsCMPartBody); return(true); } catch { return(false); } }
public static bool ExistsCodeSite(this CodeFunction codeFunction) { try { codeFunction.GetStartPoint(vsCMPart.vsCMPartBody); } catch//表达式主体 { return(false); } return(codeFunction.DeleteCodeSite(false)); }
/// <summary> /// Returns true if given getter or setter is auto-generated /// </summary> public static bool IsAutoGenerated(this CodeFunction func) { if (func == null) { throw new ArgumentNullException("func"); } try { func.GetStartPoint(vsCMPart.vsCMPartBody); return(false); } catch (Exception) { return(true); } }
/// <summary> /// Get source code from given element. /// </summary> /// <param name="element">Element which source code is retrieved.</param> /// <returns>Element's source code.</returns> internal string GetSourceCode(CodeFunction element) { var name = element.Name; var lang = element.Language; if (!element.ProjectItem.IsOpen) { element.ProjectItem.Open(); } var editPoint = element.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); var body = editPoint.GetText(element.EndPoint).Replace("\r", ""); return("{" + body); }
public static bool EqualsOffset(this CodeFunction codeFunction, CodeFunction other) { if (other == null || codeFunction.HasBody() != other.HasBody()) { return(false); } if (codeFunction.HasBody()) { return(codeFunction.GetStartPoint(vsCMPart.vsCMPartBody).AbsoluteCharOffset == other.GetStartPoint(vsCMPart.vsCMPartBody).AbsoluteCharOffset); } else { return(codeFunction.StartPoint.AbsoluteCharOffset == other.StartPoint.AbsoluteCharOffset); } }
private void parseFunc(CodeFunction function, string args = "") { TextPoint beginline = function.GetStartPoint(vsCMPart.vsCMPartHeader); TextPoint endline = function.GetEndPoint(vsCMPart.vsCMPartBodyWithDelimiter); string textFunc = beginline.CreateEditPoint().GetText(endline); int firstindex = 0; int lastindex = textFunc.LastIndexOf('}'); string pattern1 = @"""([^\\""\r\n]*(\\""|\\\r\n|\\)?)*"; //кавычки. проверка строки //если мы в строке вида "stroka///// \\" с экранированными ковычками НАЧАЛО string pattern2 = @"(""|[^\\]\r\n)"; // перевод на следующую строку или закрылась двойная ковычка КОНЕЦ string pattern3 = @"\'(?:[^\\\'\r\n]*(\\\'|\\)?)*"; //манипуляции внутри строки, ограниченной одинарными ковычками НАЧАЛО string pattern4 = @"(\'|\r\n)";// // или ' или конец строки или в строке одинарная ковычка КОНЕЦ string singleComment = @"\/\/"; //работает string pattern5 = @"(?:.*\\(\r\n))+.*"; //строка и конец строки с переносом на новую строку и комменатрием на ней string pattern6 = @"(.*)(\n|\r)"; // строчка+ конец строки БЕЗ ПЕРЕНОСА string pattern7 = @"\/\*[\s\S]*?\*\/";//многострочный комментарий, должны выполняться единовременно => захват string pattern = @"(" + pattern1 + pattern2 + @"|" + pattern3 + pattern4 + @"|" + singleComment + "(" + pattern5 + @"|" + pattern6 + ")" + @"|" + pattern7 + ")"; string uncommented = Regex.Replace(textFunc, pattern, "", RegexOptions.Multiline); uncommented = Regex.Replace(uncommented, @"^(?:\s)*\n", String.Empty, RegexOptions.Multiline); string forRegex = uncommented.Substring(0, uncommented.LastIndexOf('}')); firstindex = 0; lastindex = uncommented.LastIndexOf('}'); int numOfKey = Regex.Matches(uncommented.Substring(firstindex, lastindex - firstindex), dictForFile).Count; args = (args != String.Empty) ? args : uncommented.Substring(0, uncommented.IndexOf('{')); // args = Regex.Replace(args, pattern, " ", RegexOptions.Multiline); args = Regex.Replace(args, @"^(?:\s)*\n", String.Empty, RegexOptions.Multiline); args = Regex.Replace(args, " ", String.Empty, RegexOptions.Multiline); //args = uncommented.Substring(0, textFunc.LastIndexOf(')')+1); CodeStatistic tmp = new CodeStatistic(args, numOfKey, (endline.Line - beginline.Line) + 1, Regex.Matches(uncommented, @"\n").Count); // items.Add(tmp); listView.Items.Add(tmp); // return (tmp); }
void handleFunction(CodeFunction func, CodeClass classCode) { ThreadHelper.ThrowIfNotOnUIThread(); List <CodeParameter> parameters = new List <CodeParameter>(); foreach (CodeParameter p in func.Parameters) { if (hasField(classCode, p.Name, p.Type) == false) { parameters.Insert(0, p); } } foreach (var p in parameters) { var fieldName = "_" + p.Name.Substring(0, 1).ToLower() + (p.Name.Length > 1 ? p.Name.Substring(1) : ""); //添加依赖注入 var point = func.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); point.Insert($"this.{fieldName} = {p.Name};\r\n"); point = classCode.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); var typeString = p.Type.AsString; try { while (true) { var match = Regex.Match(typeString, @"[\w|\.]+\.[\w|\.]+"); if (match.Length > 0) { typeString = typeString.Replace(match.Value, match.Value.Split('.').LastOrDefault()); } else { break; } } } catch { } point.Insert($"{typeString} {fieldName};\r\n"); } classCode.StartPoint.CreateEditPoint().SmartFormat(func.EndPoint); }
/// <summary> /// Insert code. /// </summary> /// <param name="instance">The instance.</param> /// <param name="code">The code.</param> /// <param name="atTheStart">if set to <c>true</c> [at the start].</param> public static void InsertCode( this CodeFunction instance, string code, bool atTheStart) { TraceService.WriteLine("CodeFunctionExtensions::InsertCode codeFunction=" + instance.Name); EditPoint editPoint = atTheStart ? instance.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint() : instance.GetEndPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); if (code.EndsWith(Environment.NewLine) == false) { code += Environment.NewLine; } editPoint.Insert(code); }
public static bool HasExpressionBody(this CodeFunction codeFunction) { try { if (codeFunction.HasBody())//public string 只读表达式属性 => "只读表达式属性"; { try { codeFunction.GetStartPoint(); } catch { return(true); } } else { EditPoint editPointFind = codeFunction.StartPoint.CreateEditPoint(); if (editPointFind.FindPattern("=>") && editPointFind.LessThan(codeFunction.EndPoint)) { return(true); } } } catch { } return(false); }
internal static void GenerateSerializaCode(CodeClass2 classElement, CodeFunction serializeMethod, CodeFunction deserializeMethod, Dictionary<string, CodeClass2> dic, TyrantVSPackage package/*, string serializeMethodParameterName, string deserializeMethodParameterName*/) { var memberList = new List<SerializeMember>(); foreach (CodeElement2 member in classElement.Members) { var field = member as CodeVariable2; if (field != null) { memberList.Add(new SerializeMember() { Name = field.Name, TypeRef = field.Type, Attributes = field.Attributes }); continue; } var property = member as CodeProperty2; if (property != null && property.Getter != null && property.Setter != null) memberList.Add(new SerializeMember() { Name = property.Name, TypeRef = property.Type, Attributes = property.Attributes }); } int iii = serializeMethod.Parameters.Count; string serializeMethodParameterName = serializeMethod.Parameters.Item(1).Name; string deserializeMethodParameterName = deserializeMethod.Parameters.Item(1).Name; var serializeStatementList = new List<string>(); var deserializeStatementList = new List<string>(); string deserializeMethodCode = string.Format("int num;{0}while ((num = source.ReadFieldHeader()) > 0){0}{1}{0}switch (num){0}{1}{0}", Environment.NewLine, "{"); for (int i = 0; i < memberList.Count; ++i) { var mem = memberList[i]; bool needContinue = false; foreach (CodeAttribute2 codeArrtibute in mem.Attributes) { if (codeArrtibute.FullName == "Tyrant.GameCore.DoNotSerializeAttribute") { needContinue = true; break; } } if (needContinue) continue; string serializeMethodName = ""; string deserializeMethodName = ""; if (mem.TypeRef.TypeKind == vsCMTypeRef.vsCMTypeRefArray) GetSerializeMethodAndDeserializeMethodName(mem.TypeRef.ElementType, null, ref serializeMethodName, ref deserializeMethodName, "Array", dic, package); else { if (mem.TypeRef.AsFullName.StartsWith("System.Collections.Generic.List<")) { string fullName = mem.TypeRef.AsFullName; int first = fullName.IndexOf('<'); var elementName = fullName.Substring(first + 1, fullName.Length - 2 - first); GetSerializeMethodAndDeserializeMethodName(null, elementName, ref serializeMethodName, ref deserializeMethodName, "List", dic, package); } else GetSerializeMethodAndDeserializeMethodName(mem.TypeRef, null, ref serializeMethodName, ref deserializeMethodName); } serializeStatementList.Add($"Tyrant.GameCore.CommunicatorHelper.{serializeMethodName}({i + 1}, {mem.Name}, {serializeMethodParameterName});"); deserializeStatementList.Add($"case {i + 1}:{Environment.NewLine}{mem.Name} = Tyrant.GameCore.CommunicatorHelper.{deserializeMethodName}({deserializeMethodParameterName});{Environment.NewLine}break;"); } if (serializeStatementList.Count > 0) { var point = serializeMethod.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); point.ReplaceText(serializeMethod.GetEndPoint(vsCMPart.vsCMPartBody), string.Join(Environment.NewLine, serializeStatementList), (int)vsEPReplaceTextOptions.vsEPReplaceTextAutoformat); } if (deserializeStatementList.Count > 0) { var point = deserializeMethod.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); point.ReplaceText(deserializeMethod.GetEndPoint(vsCMPart.vsCMPartBody), deserializeMethodCode + string.Join(Environment.NewLine, deserializeStatementList) + Environment.NewLine + "}" + Environment.NewLine + "}", (int)vsEPReplaceTextOptions.vsEPReplaceTextAutoformat); } }
/// <summary> /// Gets the declaration of the specified code method as a string. /// </summary> /// <param name="codeFunction">The code method.</param> /// <returns>The string declaration.</returns> internal static string GetMethodDeclaration(CodeFunction codeFunction) { // Get the start point after the attributes. var startPoint = codeFunction.GetStartPoint(vsCMPart.vsCMPartHeader); return TextDocumentHelper.GetTextToFirstMatch(startPoint, @"[\{;]"); }