static string NewValue(this LineOrientedFormatter.Item2 item, SourcePart part) { var subResult = ""; if(item.Part.Position >= part.Position) subResult += item.NewHeader; subResult += part.Intersect(item.Part).Id; return subResult; }
public Result<Declarator> WithName(Definable target, SourcePart position) { var result = new Declarator(Tags, target, Position + position); if (Target == null) return result; return result.Issues(IssueId.InvalidDeclarationTag.Create(Position)); }
internal static string Filter (this IEnumerable<LineOrientedFormatter.Line> rawLines, SourcePart part) { var result = ""; var lines = rawLines .Select(line => line.Data.Where(item => item.Contains(part))) .SelectMany(items => items.Where(item => item.IsRelevant)); foreach(var item in lines) result += item.NewValue(part); return result; }
public override string ToString() { string ret = ""; ret += isSeries > 0 ? "Series of " : ""; ret += SourceSide.Trim().Length > 0 ? SourceSide.ToLower() + " " : ""; ret += ActionType.Trim().Length > 0 ? ActionType.ToLower() + " " : ""; ret += SourcePart.Trim().Length > 0 ? SourcePart.ToLower() + " " : ""; ret += TransitionText.Trim().Length > 0 ? TransitionText.ToLower() + " " : ""; ret += DestSide.Trim().Length > 0 ? DestSide.ToLower() + " " : ""; ret += DestPart.Trim().Length > 0 ? DestPart.ToLower() + " " : ""; ret += SpecialText.Trim().Length > 0 ? SpecialText.ToLower() + " " : ""; return(ret); }
public override int GetHashCode() { // ReSharper disable NonReadonlyFieldInGetHashCode if (hashCode != 0) { return(hashCode); } hashCode = Source.GetHashCode() ^ ((SourcePart == null) ? 0 : SourcePart.GetHashCode()) ^ Message.Name.GetHashCode() ^ Arguments.Length; foreach (object arg in IdentArguments) { hashCode ^= (arg == null ? 0 : arg.GetHashCode()); } return(hashCode); // ReSharper restore NonReadonlyFieldInGetHashCode }
string IFormatter.Reformat(Syntax target, SourcePart part) { var rawLines = target .Chain(item => item.Parent) .Last() .Items .OrderBy(item => item.Token.SourcePart().Position) .SelectMany(GetItems) .NullableToArray() .Select(CreateLine) ; while(rawLines.Any(IsTooLongLine)) rawLines = rawLines.SelectMany(LineBreaker); var result = rawLines.Filter(part); if(rawLines.Any(IsTooLongLine)) NotImplementedMethod(result, part); return result; }
internal DefinableToken(Definable tokenClass, SourcePart tokenData) { _data = tokenData; _tokenClass = tokenClass; }
internal SourceIssue(Issue issue, SourcePart sourcePart) { Issue = issue; SourcePart = sourcePart; StopByObjectIds(35); }
internal string ExtractText(SourcePart token) { var headLength = token.Start.Match(_varbatimTextHead); if(headLength != null) return (token.Start + headLength.Value).Span(token.End + -headLength.Value).Id; var result = ""; for(var i = 1; i < token.Length - 1; i++) { result += (token.Start + i).Current; if((token.Start + i).Current == token.Start.Current) i++; } return result; }
public Token[] AsTokens() { return(SourcePart.AsTokens()); }
public override string Reformat(SourcePart targetPart) => SourcePart.Intersect(targetPart)?.Id ?? "";
string IFormatter.Reformat(Syntax target, SourcePart targetPart) => Frame.Create(target, this).ItemsForResult.Format(targetPart);
Syntax CheckedLocate(SourcePart part) => SourcePart.Contains(part) ? Locate(part) : null;
public Trimmed TrimLine(SourcePart span) => new Trimmed(this, span);
internal Trimmed(Token token, SourcePart sourcePart) { Token = token; SourcePart = sourcePart.Intersect(Token.SourcePart) ?? Token.SourcePart.Start.Span(0); }
public abstract string Reformat(SourcePart targetPart);
internal static IEnumerable<EditPiece> GetEditPieces (this Syntax syntax, SourcePart sourcePart, IFormatter formatter = null) => (formatter ?? new Configuration().Create()) .GetEditPieces(syntax, sourcePart);
internal Declarator(IDeclarationTag[] tags, Definable target, SourcePart position) { Position = position; Tags = tags; Target = target; }
IEnumerable<EditPiece> IFormatter.GetEditPieces(Syntax target, SourcePart targetPart) { NotImplementedMethod(target, targetPart); return null; }
public override string Reformat(SourcePart targetPart) => new Formatting.Configuration().Create().Reformat(Syntax, targetPart);
public Item2(SourcePart part, string newHeader, bool isRelevant) { Part = part; NewHeader = newHeader; IsRelevant = isRelevant; }
public static string Reformat (this Syntax syntax, SourcePart sourcePart, IFormatter formatter = null) => (formatter ?? new Configuration().Create()).Reformat (syntax, sourcePart);
internal Syntax Locate(SourcePart part) => Left?.CheckedLocate(part) ?? Right?.CheckedLocate(part) ?? this;
internal Issue Create(SourcePart position) => new Issue(this, position);
IEnumerable<EditPiece> IFormatter.GetEditPieces(Syntax target, SourcePart targetPart) => Frame.Create(target, this).ItemsForResult.GetEditPieces(targetPart);
internal static bool Contains(this LineOrientedFormatter.Item2 item, SourcePart part) => item.Part.Position < part.EndPosition && item.Part.EndPosition > part.Position;
public Item(SourcePart sourcePart, IScannerTokenType type) { SourcePart = sourcePart; Type = type; }
internal void SelectSource(SourcePart source) { if (source == null) return; TextBox.SetSelection(source.Position, source.EndPosition); }