private static CodeSpan GetSpan(TwoDimensionalString twoDString, OffsetSpan position) { CodePosition start = twoDString.GetTwoDimensionalCordinatesFor(position.StartOffset); CodePosition end = twoDString.GetTwoDimensionalCordinatesFor(position.EndOffset); return(new CodeSpan(start, end)); }
public static Dictionary <MemberIdentifier, CodeSpan> GenerateMemberMapping(string assemblyFilePath, StringWriter writer, List <WritingInfo> writingInfos) { string theText = writer.ToString(); Dictionary <MemberIdentifier, CodeSpan> mapping = new Dictionary <MemberIdentifier, CodeSpan>(); TwoDimensionalString twoDString = new TwoDimensionalString(theText, writer.NewLine, false); foreach (WritingInfo memberInfo in writingInfos) { foreach (KeyValuePair <IMemberDefinition, OffsetSpan> item in memberInfo.MemberDeclarationToCodePostionMap) { IMemberDefinition member = item.Key; OffsetSpan position = item.Value; // Get/set keywords are printed alone in a lane. // This should trim the tabulations before them. position = twoDString.TrimStart(position); CodeSpan codeSpan = GetSpan(twoDString, position); mapping.Add(GetIdentifier(assemblyFilePath, member), codeSpan); } } return(mapping); }
public OffsetSpan TrimStart(OffsetSpan position) { int limit = position.EndOffset < TheString.Length ? position.EndOffset : TheString.Length - 1; int offset; for (offset = position.StartOffset; offset <= limit; offset++) { if (!char.IsWhiteSpace(TheString[offset])) { return(new OffsetSpan(offset, position.EndOffset)); } } throw new Exception("The span contains only whitespaces."); }
public OffsetSpan TrimStart(OffsetSpan position) { if (position.EndOffset < this.get_TheString().get_Length()) { stackVariable6 = position.EndOffset; } else { stackVariable6 = this.get_TheString().get_Length() - 1; } V_0 = stackVariable6; V_1 = position.StartOffset; while (V_1 <= V_0) { if (!Char.IsWhiteSpace(this.get_TheString().get_Chars(V_1))) { return(new OffsetSpan(V_1, position.EndOffset)); } V_1 = V_1 + 1; } throw new Exception("The span contains only whitespaces."); }
private static CodeSpan GetSpan(TwoDimensionalString twoDString, OffsetSpan position) { stackVariable3 = twoDString.GetTwoDimensionalCordinatesFor(position.StartOffset); return(new CodeSpan(stackVariable3, twoDString.GetTwoDimensionalCordinatesFor(position.EndOffset))); }