Beispiel #1
0
 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;
 }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        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;
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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;
        }
Beispiel #7
0
 internal DefinableToken(Definable tokenClass, SourcePart tokenData)
 {
     _data = tokenData;
     _tokenClass = tokenClass;
 }
Beispiel #8
0
 internal SourceIssue(Issue issue, SourcePart sourcePart)
 {
     Issue = issue;
     SourcePart = sourcePart;
     StopByObjectIds(35);
 }
Beispiel #9
0
        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;
        }
Beispiel #10
0
 public Token[] AsTokens()
 {
     return(SourcePart.AsTokens());
 }
Beispiel #11
0
 public override string Reformat(SourcePart targetPart)
     => SourcePart.Intersect(targetPart)?.Id ?? "";
Beispiel #12
0
 string IFormatter.Reformat(Syntax target, SourcePart targetPart)
     => Frame.Create(target, this).ItemsForResult.Format(targetPart);
Beispiel #13
0
 Syntax CheckedLocate(SourcePart part)
     => SourcePart.Contains(part) ? Locate(part) : null;
Beispiel #14
0
 public Trimmed TrimLine(SourcePart span) => new Trimmed(this, span);
Beispiel #15
0
 internal Trimmed(Token token, SourcePart sourcePart)
 {
     Token = token;
     SourcePart = sourcePart.Intersect(Token.SourcePart)
         ?? Token.SourcePart.Start.Span(0);
 }
Beispiel #16
0
 public abstract string Reformat(SourcePart targetPart);
Beispiel #17
0
 internal static IEnumerable<EditPiece> GetEditPieces
     (this Syntax syntax, SourcePart sourcePart, IFormatter formatter = null)
     => (formatter ?? new Configuration().Create())
         .GetEditPieces(syntax, sourcePart);
Beispiel #18
0
 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;
 }
Beispiel #20
0
 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;
 }
Beispiel #22
0
 public static string Reformat
     (this Syntax syntax, SourcePart sourcePart, IFormatter formatter = null)
     =>
         (formatter ?? new Configuration().Create()).Reformat
             (syntax, sourcePart);
Beispiel #23
0
 internal Syntax Locate(SourcePart part)
     => Left?.CheckedLocate(part) ??
     Right?.CheckedLocate(part) ??
     this;
Beispiel #24
0
 internal Issue Create(SourcePart position) => new Issue(this, position);
Beispiel #25
0
 IEnumerable<EditPiece> IFormatter.GetEditPieces(Syntax target, SourcePart targetPart)
     => Frame.Create(target, this).ItemsForResult.GetEditPieces(targetPart);
Beispiel #26
0
 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;
 }
Beispiel #28
0
 internal void SelectSource(SourcePart source)
 {
     if (source == null)
         return;
     TextBox.SetSelection(source.Position, source.EndPosition);
 }