]> O.S.I.I.S - jp/crowedit.git/commitdiff
syntax analysis revamping wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 8 Mar 2025 16:03:49 +0000 (17:03 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 8 Mar 2025 16:03:49 +0000 (17:03 +0100)
16 files changed:
CrowEditBase/src/Compiler/SyntaxAnalyser.cs
CrowEditBase/src/Compiler/SyntaxNode.cs
CrowEditBase/src/Compiler/SyntaxRootNode.cs
CrowEditBase/src/Compiler/TokenType.cs
CrowEditBase/src/SourceEditor.cs
CrowEditBase/src/TextDocument.cs
plugins/CECrowPlugin/src/Parsing/IML/ImlSyntaxNodes.cs
plugins/CECrowPlugin/src/Parsing/Styling/StyleSyntaxAnalyser.cs
plugins/CECrowPlugin/src/Parsing/Styling/SyntaxNodes.cs
plugins/CEEbnfPlugin/src/Parsing/EbnfSyntaxAnalyser.cs
plugins/CEEbnfPlugin/src/Parsing/EbnfSyntaxNodes.cs
plugins/CERoslynPlugin/src/CSSyntaxAnalyser.cs
plugins/CEXmlPlugin/src/Parsing/XmlDocument.cs
plugins/CEXmlPlugin/src/Parsing/XmlSyntaxAnalyser.cs
plugins/CEXmlPlugin/src/Parsing/XmlSyntaxNodes.cs
plugins/CEXmlPlugin/src/Parsing/XmlTokenType.cs

index 409787413da841b6d6ee799720693ba6360c48bc..449fc0a0b9b0d081edd9f5a6c4879f0e571c3083 100644 (file)
@@ -11,12 +11,10 @@ namespace CrowEditBase
 {
        public abstract class SyntaxAnalyser {
                protected SourceDocument document;
-               protected LineCollection lines;
                protected SyntaxRootNode Root;
-               public IEnumerable<SyntaxException> Exceptions => Root?.GetAllExceptions();
+               public IEnumerable<SyntaxException> Exceptions => null;// Root?.GetAllExceptions();
                public SyntaxAnalyser (SourceDocument document) {
                        this.document = document;
-                       this.lines = document.Lines;
                }
                public abstract Task<SyntaxRootNode> Process ();
                
@@ -81,7 +79,7 @@ namespace CrowEditBase
                /// </summary>
                /// <param name="endToken">The final token of this node</param>
                /// <param name="endLine">the endline number of this node</param>
-               protected void finishCurrentNode (int endTokenOffsetFromCurrentTokIdx = 0) {
+               /*protected void finishCurrentNode (int endTokenOffsetFromCurrentTokIdx = 0) {
                        int lastTokOffset = tokIdx - currentNode.TokenIndexBase + endTokenOffsetFromCurrentTokIdx;
                        currentNode.lastTokenOfset = lastTokOffset < 0 ? null : lastTokOffset;
                        if (endTokenOffsetFromCurrentTokIdx < 0) {
@@ -96,7 +94,7 @@ namespace CrowEditBase
                        currentNode = currentNode.Parent;
                }
                protected void setCurrentNodeEndLine (int endLine)
-                       => currentNode.EndLine = endLine;
+                       => currentNode.EndLine = endLine;*/
                protected bool skipTrivia(bool skipLineBreaks = true) {
                        while (tryPeekFlag(out Token tok, TokenType.Trivia)) {
                                if (tok.Type == TokenType.LineBreak) {
@@ -109,8 +107,8 @@ namespace CrowEditBase
                        return !EOF;
                }
                protected void addException(string message) {
-                       CharLocation loc = lines.GetLocation(curTok.Start);
-                       currentNode.AddException(new SyntaxException(message, loc, curTok));
+                       /*CharLocation loc = lines.GetLocation(curTok.Start);
+                       currentNode.AddException(new SyntaxException(message, loc, curTok));*/
                }
 
 
index e88631321e77a5718ab9a2e627c62507da1e3e37..d720aaeb37b48ad5f66ec2f3cc61948900ff3606 100644 (file)
@@ -9,41 +9,36 @@ using Crow;
 
 namespace CrowEditBase
 {
-       /*public class SingleTokenSyntax {
+       public class SingleTokenSyntax : SyntaxNode {
                Token token;
-
-       }*/
-       public class SyntaxNode : CrowEditComponent {
-               #region CTOR
-               internal SyntaxNode () {}
-               public SyntaxNode (int startLine, int tokenBase, int? lastTokenIdx = null) {
-                       StartLine = startLine;
-                       TokenIndexBase = tokenBase;
-                       if (lastTokenIdx.HasValue)
-                               lastTokenOfset = lastTokenIdx - tokenBase;
-               }
-               #endregion
-
+        public override TokenType Type => token.Type;
+        public override int SpanStart => token.Start;
+               public override int SpanEnd => token.End;
+               public SingleTokenSyntax(Token tok) {
+                       token = tok;
+               }
+       }
+       public class MultiNodeSyntax : SyntaxNode {
                internal List<SyntaxNode> children = new List<SyntaxNode> ();
+               public IEnumerable<SyntaxNode> Children => children;
+               public SyntaxNode AddChild (SyntaxNode child) {
+                       children.Add (child);
+                       child.Parent = this;
+                       return child;
+               }
+               public void RemoveChild (SyntaxNode child) {
+                       children.Remove (child);
+                       child.Parent = null;
+               }
+               public IEnumerable<T> GetChilds<T> () => children.OfType<T>();
 
+               
+               public override bool HasChilds => children.Count > 0;
+        public override int SpanStart => HasChilds ? children[0].SpanStart : 0;
+               public override int SpanEnd => HasChilds ? children[children.Count - 1].SpanEnd : 0;
 
-               internal int? lastTokenOfset;
-               internal int lineCount;
-
-               #region  Folding and ?expand?
-               bool _isExpanded;
                internal bool isFolded;
-
-               public bool isExpanded {
-                       get => _isExpanded;
-                       set {
-                               if  (_isExpanded == value)
-                                       return;
-                               _isExpanded = value;
-                               NotifyValueChanged (_isExpanded);
-                       }
-               }
-               public virtual bool IsFoldable => IsComplete && !(Parent != Root && Parent.StartLine == StartLine) && lineCount > 1;
+               public virtual bool IsFoldable => IsComplete && !(Parent != Root && Parent.StartLocation.Line == StartLocation.Line) && LineCount > 1;
                public void ExpandToTheTop () {
                        isExpanded = true;
                        Parent?.ExpandToTheTop ();
@@ -52,14 +47,14 @@ namespace CrowEditBase
                        isFolded = false;
                        Parent.UnfoldToTheTop ();
                }
-               public IEnumerable<SyntaxNode> VisibleFoldableNodes {
+               public IEnumerable<MultiNodeSyntax> VisibleFoldableNodes {
                        get {
                                if (IsFoldable) {
                                        yield return this;
                                }
                                if (!isFolded) {
-                                       foreach (SyntaxNode n in Children) {
-                                               foreach (SyntaxNode folds in n.VisibleFoldableNodes)
+                                       foreach (MultiNodeSyntax n in Children.OfType<MultiNodeSyntax>()) {
+                                               foreach (MultiNodeSyntax folds in n.VisibleFoldableNodes)
                                                        yield return folds;
                                        }
                                }
@@ -68,32 +63,63 @@ namespace CrowEditBase
                public virtual int FoldedLineCount {
                        get {
                                if (isFolded)
-                                       return lineCount;
+                                       return LineCount;
                                int tmp = 0;
                                if (HasChilds) {
-                                       foreach (SyntaxNode n in children.Where (c => c.IsFoldable))
+                                       foreach (MultiNodeSyntax n in children.OfType<MultiNodeSyntax>().Where (c => c.IsFoldable))
                                                tmp += n.FoldedLineCount;
                                }
                                return tmp;
                        }
                }
+               public override SyntaxNode FindNodeIncludingSpan (TextSpan span) {
+                       foreach (SyntaxNode node in children) {
+                               if (node.Contains (span))
+                                       return node.FindNodeIncludingSpan (span);
+                       }
+                       return this;
+               }
+               public override SyntaxNode FindNodeIncludingPosition (int pos) {
+                       foreach (SyntaxNode node in children) {
+                               if (node.Contains (pos))
+                                       return node.FindNodeIncludingPosition (pos);
+                       }
+                       return this;
+               }               
+    }
+       public abstract class SyntaxNode : CrowEditComponent {
+
+
+               #region  Folding and ?expand?
+               bool _isExpanded;
+               public bool isExpanded {
+                       get => _isExpanded;
+                       set {
+                               if  (_isExpanded == value)
+                                       return;
+                               _isExpanded = value;
+                               NotifyValueChanged (_isExpanded);
+                       }
+               }
                #endregion
 
+               public MultiNodeSyntax Parent { get; internal set; }
+               public virtual SyntaxRootNode Root => Parent.Root;
+               public virtual TokenType Type => TokenType.Unknown;
+               public virtual int SpanStart => 0;
+               public virtual int SpanEnd => 0;
 
                
-               public IEnumerable<SyntaxNode> Children => children;
-               public bool HasChilds => children.Count > 0;
-               public SyntaxNode Parent { get; private set; }
-               public virtual bool IsComplete => lastTokenOfset.HasValue;
+               public virtual bool HasChilds => false;
+               public virtual bool IsComplete => false;
 
-               public virtual SyntaxRootNode Root => Parent.Root;
 
 
-               public int StartLine { get; private set; }
-               public virtual int LineCount => lineCount;
+               /*public int StartLine { get; private set; }
+               public virtual int LineCount => lineCount;*/
 
 
-               List<SyntaxException> exceptions = new List<SyntaxException>();
+               /*List<SyntaxException> exceptions = new List<SyntaxException>();
                public IEnumerable<SyntaxException> Exceptions => exceptions;
                public void AddException(SyntaxException e) => exceptions.Add(e);
                public void ResetExceptions(SyntaxException e) => exceptions.Clear();
@@ -104,7 +130,7 @@ namespace CrowEditBase
                                        foreach (SyntaxException ce in n.GetAllExceptions())
                                                yield return ce;
                                }
-               }
+               }*/
 
 
                protected Token getTokenByIndex (int idx) => Root.GetTokenByIndex(idx);
@@ -134,7 +160,7 @@ namespace CrowEditBase
                public virtual SyntaxNode NextSiblingOrParentsNextSibling
                        => NextSibling ?? Parent.NextSiblingOrParentsNextSibling;
 
-               public virtual int TokenIndexBase { get; private set; }
+               /*public virtual int TokenIndexBase { get; private set; }
                public virtual int TokenCount => lastTokenOfset.HasValue ? lastTokenOfset.Value + 1 : 0;
                public int? LastTokenIndex =>  lastTokenOfset.HasValue ? TokenIndexBase + lastTokenOfset.Value : null;
 
@@ -143,26 +169,12 @@ namespace CrowEditBase
                                lineCount = value - StartLine + 1;
                        }
                        get => StartLine + lineCount - 1;
-               }
-               public TextSpan Span {
-                       get {
-                               Token startTok = getTokenByIndex(TokenIndexBase);
-                               Token endTok = LastTokenIndex.HasValue ? getTokenByIndex (LastTokenIndex.Value) : startTok;
-                               return new TextSpan (startTok.Start, endTok.End);
-                       }
-               }
-               public int SpanStart;
+               }*/
+               public TextSpan Span => new TextSpan (SpanStart, SpanEnd);
+               public CharLocation StartLocation => Root.GetLocation(SpanStart);
+               public CharLocation EndLocation => Root.GetLocation(SpanEnd);
+               public int LineCount => EndLocation.Line - StartLocation.Line + 1;
 
-               public SyntaxNode AddChild (SyntaxNode child) {
-                       children.Add (child);
-                       child.Parent = this;
-                       return child;
-               }
-               public void RemoveChild (SyntaxNode child) {
-                       children.Remove (child);
-                       child.Parent = null;
-               }
-               public IEnumerable<T> GetChilds<T> () => children.OfType<T>();
                /*
                public void Replace (SyntaxNode newNode) {
                        Parent.replaceChild (this, newNode);
@@ -188,20 +200,14 @@ namespace CrowEditBase
                                curNode = curNode.Parent;
                        }
                }*/
-               void offset (int tokenOffset, int lineOffset) {
+               /*void offset (int tokenOffset, int lineOffset) {
                        TokenIndexBase += tokenOffset;
                        StartLine += lineOffset;
                        foreach (SyntaxNode child in children) {
                                child.offset (tokenOffset, lineOffset);
                        }
-               }
-               public SyntaxNode FindNodeIncludingPosition (int pos) {
-                       foreach (SyntaxNode node in children) {
-                               if (node.Contains (pos))
-                                       return node.FindNodeIncludingPosition (pos);
-                       }
-                       return this;
-               }
+               }*/
+/*             
                public T FindNodeIncludingPosition<T> (int pos) {
                        foreach (SyntaxNode node in children) {
                                if (node.Contains (pos))
@@ -209,21 +215,17 @@ namespace CrowEditBase
                        }
 
                        return this is T tt ? tt : default;
-               }
-               public SyntaxNode FindNodeIncludingSpan (TextSpan span) {
-                       foreach (SyntaxNode node in children) {
-                               if (node.Contains (span))
-                                       return node.FindNodeIncludingSpan (span);
-                       }
-                       return this;
-               }
+               }*/
+               public virtual SyntaxNode FindNodeIncludingPosition (int pos) => this;
+               public virtual SyntaxNode FindNodeIncludingSpan (TextSpan span) => this;
+               
                public bool Contains (int pos) => Span.Contains (pos);
                public bool Contains (TextSpan span) => Span.Contains (span);
-               public void Dump (int level = 0) {
+               /*public void Dump (int level = 0) {
                        Console.WriteLine ($"{new string('\t', level)}{this}");
                        foreach (SyntaxNode node in children)
                                node.Dump (level + 1);
-               }
+               }*/
                //public override string ToString() => $"l:({StartLine,3},{LineCount,3}) tks:{TokenIndexBase},{TokenCount} {this.GetType().Name}";
                public override string ToString() => $"{this.GetType().Name}";
                public string AsText() {
@@ -234,7 +236,7 @@ namespace CrowEditBase
 
         public class CompareOnStartLine : IComparer<SyntaxNode>
         {
-            public int Compare(SyntaxNode x, SyntaxNode y) => x.StartLine - y.StartLine;
+            public int Compare(SyntaxNode x, SyntaxNode y) => x.StartLocation.Line - y.StartLocation.Line;
         }
     }
 }
\ No newline at end of file
index 20f683cfbfac9c153f87a6736abbb5d4d5faa67f..44f7492f578a364b474206c9bcc3f2e8f23d4ec7 100644 (file)
@@ -6,21 +6,23 @@ using Crow.Text;
 
 namespace CrowEditBase
 {
-       public abstract class SyntaxRootNode : SyntaxNode {
-               public SyntaxRootNode (ReadOnlyMemory<char> source, Token[] tokens) {
-                       this.source = source;
+       public abstract class SyntaxRootNode : MultiNodeSyntax {
+               public SyntaxRootNode (ReadOnlyTextBuffer buffer, Token[] tokens) {
+                       this.buffer = buffer;
                        this.tokens = tokens;
                }
-               protected readonly ReadOnlyMemory<char> source;
+               protected readonly ReadOnlyTextBuffer buffer;
                protected Token[] tokens;
-               public override int TokenIndexBase => 0;
-               public override int TokenCount => tokens == null ? 0 : Math.Max (0, tokens.Length - 1);
                public override SyntaxRootNode Root => this;
+
+
                public override bool IsFoldable => false;
-               public override SyntaxNode NextSiblingOrParentsNextSibling => null;
                public override void UnfoldToTheTop() {}
+               public override SyntaxNode NextSiblingOrParentsNextSibling => null;
 
                public ReadOnlySpan<Token> Tokens => tokens;
+
+
                public string GetTokenStringByIndex (int idx) => tokens != null ?
                        idx >= 0 && idx < tokens.Length ? GetText(tokens[idx].Span).ToString() : null : null;
                public Token GetTokenByIndex (int idx) => tokens != null ?
@@ -32,7 +34,9 @@ namespace CrowEditBase
                        return idx == 0 ? 0 : idx < 0 ? ~idx - 1 : idx;
                }
                public ReadOnlySpan<char> GetText(TextSpan span) =>
-                       source.Span.Slice(span.Start, span.Length);
+                       buffer.Source.Span.Slice(span.Start, span.Length);
+               public CharLocation GetLocation(int pos) => buffer.Lines.GetLocation(pos);
+                       
                public string GetTokenString(Token tok) =>
                        GetText(tok.Span).ToString();
        }
index e35993c3f015f7a8afb463fda3cf2be31d8e8af8..d34c355f52e45ed5c5ac72e2061bd811397d2200 100644 (file)
@@ -19,7 +19,17 @@ namespace CrowEditBase
                BlockCommentEnd                 = 0x0106,
                Name                                    = 0x0200,
                Punctuation                             = 0x0400,
+               OpenParen                               = 0x0401,
+               CloseParen                              = 0x0402,
+               OpenBracket                             = 0x0403,
+               CloseBracket                    = 0x0404,
+               OpenBrace                               = 0x0405,
+               CloseBrace                              = 0x0406,
+               DoubleQuote                             = 0x0407,
+               SingleQuote                             = 0x0408,               
+
                Operator                                = 0x0800,
                Keyword                                 = 0x1000,
+               Syntax                                  = 0x8000
        }
 }
\ No newline at end of file
index ce40fb62e262c3056a9fc4f03cfd51db8aa72760..9a1ba9178a53565059ba90814006b33e6bf7af80 100644 (file)
@@ -170,8 +170,8 @@ namespace CrowEditBase
                                        return;
                                currentLoc = value;
                                if (currentLoc.HasValue) {
-                                       SyntaxNode fold = getFoldContainingLine (currentLoc.Value.Line);
-                                       while (fold != null && fold.StartLine == currentLoc.Value.Line)
+                                       MultiNodeSyntax fold = getFoldContainingLine (currentLoc.Value.Line);
+                                       while (fold != null && fold.StartLocation.Line == currentLoc.Value.Line)
                                                fold = fold.Parent;
                                        fold?.UnfoldToTheTop();
                                        updateCurrentTokAndNode();
@@ -208,7 +208,7 @@ namespace CrowEditBase
                        hideOverlay ();
                        if (mouseIsInMargin) {
                                if (e.Button == MouseButton.Left && mouseIsInFoldRect) {
-                                       SyntaxNode curNode = getFoldStartingAt (hoverLoc.Value.Line);
+                                       MultiNodeSyntax curNode = getFoldStartingAt (hoverLoc.Value.Line);
                                        if (curNode != null) {
                                                curNode.isFolded = !curNode.isFolded;
                                                textMeasureIsUpToDate = false;
@@ -346,9 +346,9 @@ namespace CrowEditBase
                                }
                                if (Document is SourceDocument doc) {
                                        switch (e.Key) {
-                                               case Key.F3:
+                                               /*case Key.F3:
                                                        doc.Root?.Dump();
-                                                       break;
+                                                       break;*/
                                                case Key.Enter:
                                                case Key.KeypadEnter:
                                                        //doc.updateCurrentTokAndNode (Selection.Start);
@@ -385,23 +385,23 @@ namespace CrowEditBase
                }
                #endregion
 
-               SyntaxNode getFoldStartingAt (int line) {
+               MultiNodeSyntax getFoldStartingAt (int line) {
                        if (!(Document is SourceDocument doc))
                                return null;
-                       IEnumerable<SyntaxNode> folds = doc.Root.VisibleFoldableNodes;
+                       IEnumerable<MultiNodeSyntax> folds = doc.Root.VisibleFoldableNodes;
                        if (folds == null)
                                return null;
-                       return folds.FirstOrDefault (n => n.StartLine == line);
+                       return folds.FirstOrDefault (n => n.StartLocation.Line == line);
                }
-               SyntaxNode getFoldContainingLine (int line) {
+               MultiNodeSyntax getFoldContainingLine (int line) {
                        if (!(Document is SourceDocument doc))
                                return null;
                        doc.EnterReadLock();
                        try {
-                               IEnumerable<SyntaxNode> folds = doc.Root.VisibleFoldableNodes;
+                               IEnumerable<MultiNodeSyntax> folds = doc.Root.VisibleFoldableNodes;
                                if (folds == null)
                                        return null;
-                               return folds.LastOrDefault (n => n.StartLine <= line && n.EndLine >= line);
+                               return folds.LastOrDefault (n => n.StartLocation.Line <= line && n.EndLocation.Line >= line);
                        } finally {
                                doc.ExitReadLock ();
                        }
@@ -415,16 +415,16 @@ namespace CrowEditBase
                                int foldedLines = 0;
                                if (!doc.IsParsed)
                                        return 0;
-                               IEnumerator<SyntaxNode> foldsEnum = doc.Root.VisibleFoldableNodes.GetEnumerator();
+                               IEnumerator<MultiNodeSyntax> foldsEnum = doc.Root.VisibleFoldableNodes.GetEnumerator();
                                bool notEndOfFolds = foldsEnum.MoveNext();
-                               while (notEndOfFolds && foldsEnum.Current.StartLine < absoluteLine) {
+                               while (notEndOfFolds && foldsEnum.Current.StartLocation.Line < absoluteLine) {
                                        if (foldsEnum.Current.isFolded) {
                                                foldedLines += foldsEnum.Current.LineCount - 1;
                                                SyntaxNode nextNode = foldsEnum.Current.NextSiblingOrParentsNextSibling;
                                                if (nextNode == null)
                                                        break;
                                                notEndOfFolds = foldsEnum.MoveNext();
-                                               while (notEndOfFolds && foldsEnum.Current.StartLine < nextNode.StartLine)
+                                               while (notEndOfFolds && foldsEnum.Current.StartLocation.Line < nextNode.StartLocation.Line)
                                                        notEndOfFolds = foldsEnum.MoveNext();
                                        } else
                                                notEndOfFolds = foldsEnum.MoveNext();
@@ -442,20 +442,20 @@ namespace CrowEditBase
                                int foldedLines = 0;
                                if (!doc.IsParsed)
                                        return 0;
-                               IEnumerator<SyntaxNode> nodeEnum = doc.Root.VisibleFoldableNodes.GetEnumerator ();
+                               IEnumerator<MultiNodeSyntax> nodeEnum = doc.Root.VisibleFoldableNodes.GetEnumerator ();
                                if (!nodeEnum.MoveNext())
                                        return 0;
 
                                int l = 0;
                                while (l < visualLine + foldedLines) {
-                                       if (nodeEnum.Current.StartLine == l) {
+                                       if (nodeEnum.Current.StartLocation.Line == l) {
                                                if (nodeEnum.Current.isFolded) {
-                                                       foldedLines += nodeEnum.Current.lineCount - 1;
+                                                       foldedLines += nodeEnum.Current.LineCount - 1;
                                                        SyntaxNode nextNode = nodeEnum.Current.NextSiblingOrParentsNextSibling;
                                                        if (nextNode == null || !nodeEnum.MoveNext())
                                                                return foldedLines;
 
-                                                       while (nodeEnum.Current.StartLine < nextNode.StartLine) {
+                                                       while (nodeEnum.Current.StartLocation.Line < nextNode.StartLocation.Line) {
                                                                if (!nodeEnum.MoveNext())
                                                                        return foldedLines;
                                                        }
@@ -651,10 +651,10 @@ namespace CrowEditBase
                                int linesToSkip = (int)Math.Floor(ScrollY / lineHeight);
 
                                
-                               IEnumerator<SyntaxNode> foldsEnum = doc.Root.VisibleFoldableNodes.GetEnumerator ();
+                               IEnumerator<MultiNodeSyntax> foldsEnum = doc.Root.VisibleFoldableNodes.GetEnumerator ();
                                bool notEndOfFolds = foldsEnum.MoveNext();
 
-                               while (notEndOfFolds && foldsEnum.Current.StartLine < linesToSkip) {
+                               while (notEndOfFolds && foldsEnum.Current.StartLocation.Line < linesToSkip) {
                                        if (foldsEnum.Current.isFolded)
                                                linesToSkip += foldsEnum.Current.LineCount-1;
                                        notEndOfFolds = foldsEnum.MoveNext();
@@ -663,14 +663,14 @@ namespace CrowEditBase
                                int curLine = linesToSkip;
                                pixY = -(ScrollY % lineHeight);
 
-                               IEnumerator<int> exceptionLines = doc.Root.GetAllExceptions()?.Select(e=>e.Location.Line).Order().GetEnumerator();
-                               bool hasExceptions = exceptionLines.MoveNext();
+                               /*IEnumerator<int> exceptionLines = doc.Root.GetAllExceptions()?.Select(e=>e.Location.Line).Order().GetEnumerator();
+                               bool hasExceptions = exceptionLines.MoveNext();*/
 
                                while (curLine < doc.LinesCount && printedLines < Math.Min(visibleLines, doc.LinesCount)) {
 
-                                       while (hasExceptions && exceptionLines.Current < curLine) {
+                                       /*while (hasExceptions && exceptionLines.Current < curLine) {
                                                hasExceptions = exceptionLines.MoveNext();
-                                       }
+                                       }*/
                                                                                
                                        int encodedChar = 0;
                                        TextLine curTxtLine = doc.GetLine (curLine);
@@ -734,13 +734,13 @@ namespace CrowEditBase
 #endif
                                        if (selectionNotEmpty && curLine >= selStart.Line && curLine <= selEnd.Line)
                                                fillHighlight (gr, curLine, selStart, selEnd, lineRect, SelectionBackground);
-                                       if (hasExceptions && exceptionLines.Current == curLine) {
+                                       /*if (hasExceptions && exceptionLines.Current == curLine) {
                                                gr.Operator = Operator.DestOver;
                                                gr.SetSource (new Color(1.0,0,0.0,0.3));
                                                gr.Rectangle (lineRect);
                                                gr.Fill ();
                                                gr.Operator = Operator.Over;                                            
-                                       }
+                                       }*/
                                        
                                        //Draw line numbering
                                        if (printLineNumbers){
@@ -751,7 +751,7 @@ namespace CrowEditBase
                                                if (tokPtr + 1 == doc.Tokens.Length && curLine < doc.LinesCount-1)
                                                        drawLineNumber (gr, curLine+1, marginRect.X + leftMarginGap + lineNumWidth, marginRect.Y + lineHeight + fe.Ascent);
                                        }
-                                       bool curFoldStart = notEndOfFolds && foldsEnum.Current.StartLine == curLine; 
+                                       bool curFoldStart = notEndOfFolds && foldsEnum.Current.StartLocation.Line == curLine; 
                                        //draw fold
                                        if (curFoldStart) {
                                                Rectangle rFld = new Rectangle ((int)marginRect.Right - leftMarginGap - foldSize,
@@ -783,13 +783,13 @@ namespace CrowEditBase
                                        pixY += lineHeight;
                                        printedLines++;
 
-                                       if (curFoldStart && curLine == foldsEnum.Current.StartLine){
+                                       if (curFoldStart && curLine == foldsEnum.Current.StartLocation.Line){
                                                if (foldsEnum.Current.isFolded)
                                                        curLine += foldsEnum.Current.LineCount;
                                                else
                                                        curLine++;
                                                notEndOfFolds = foldsEnum.MoveNext();
-                                               while (notEndOfFolds && foldsEnum.Current.StartLine < curLine) {
+                                               while (notEndOfFolds && foldsEnum.Current.StartLocation.Line < curLine) {
                                                        /*if (foldsEnum.Current.isFolded && curLine <= foldsEnum.Current.EndLine)
                                                                curLine += foldsEnum.Current.LineCount;*/
                                                        notEndOfFolds = foldsEnum.MoveNext();
index 695f724cff7e220953f4484575f308b4aacdf8c1..fec865ef850c6326978cdfc6ce18ff311f699ac1 100644 (file)
@@ -12,6 +12,14 @@ using static CrowEditBase.CrowEditBase;
 
 namespace CrowEditBase
 {
+       public class ReadOnlyTextBuffer {
+               public readonly ReadOnlyMemory<char> Source;
+               public readonly LineCollection Lines;
+               public ReadOnlyTextBuffer(ReadOnlyMemory<char> source, LineCollection lines) {
+                       Source = source;
+                       Lines = lines;
+               }
+       }
        public class TextDocument : Document {
                public TextDocument (string fullPath, string editorPath = "default")
                        : base (fullPath, editorPath) {
@@ -20,8 +28,8 @@ namespace CrowEditBase
 
                protected TextBuffer buffer;
                public ReadOnlySpan<char> source => buffer.ReadOnlySpan;
-               public ReadOnlyMemory<char> ImmutableBufferCopy => buffer.ReadOnlyCopy;
-               internal LineCollection Lines => buffer.GetLineListCopy();
+
+               public ReadOnlyTextBuffer ImmutableBufferCopy => new ReadOnlyTextBuffer(buffer.ReadOnlyCopy, buffer.GetLineListCopy());
                System.Text.Encoding encoding = System.Text.Encoding.UTF8;
                public event EventHandler<TextChangeEventArgs> TextChanged;
 
index 7885d986ad231fc4ea12fcb4b9e9d7baede51b9e..406fc0154c6cc5f8d52fe4e64d1db1cbada33a2e 100644 (file)
@@ -11,12 +11,12 @@ namespace CECrowPlugin
 
 
        public class AttributeSyntax : SyntaxNode {
-               internal int? name, equal, valueOpen, valueClose, valueTok;
+               /*internal int? name, equal, valueOpen, valueClose, valueTok;
                public string Name => name.HasValue ? Root.GetTokenStringByIndex (TokenIndexBase + name.Value) : null;
                public string Value => valueTok.HasValue ? Root.GetTokenStringByIndex (TokenIndexBase + valueTok.Value) : null;
                public Token? ValueToken => valueTok.HasValue ? Root.GetTokenByIndex (TokenIndexBase + valueTok.Value) : null;
                public AttributeSyntax (int startLine, int tokenBase)
                        : base (startLine, tokenBase) {}
-               public override bool IsComplete => base.IsComplete & name.HasValue & equal.HasValue & valueTok.HasValue & valueOpen.HasValue & valueClose.HasValue;
+               public override bool IsComplete => base.IsComplete & name.HasValue & equal.HasValue & valueTok.HasValue & valueOpen.HasValue & valueClose.HasValue;*/
        }
 }
\ No newline at end of file
index e7a670eb2d0b865b887245dead62bc7f444dbdc5..948c71bcb3667b084759979dbaa0bf56d8f71a5b 100644 (file)
@@ -22,13 +22,13 @@ namespace CECrowPlugin.Style
 
                public override async Task<SyntaxRootNode> Process () {
                        Tokenizer tokenizer = new StyleTokenizer();
-                       ReadOnlyMemory<char> source = document.ImmutableBufferCopy;
-                       Token[] tokens = tokenizer.Tokenize(source.Span);
-                       currentNode = Root = new StyleRootSyntax (source, tokens);
+                       ReadOnlyTextBuffer buff = document.ImmutableBufferCopy;
+                       Token[] tokens = tokenizer.Tokenize(buff.Source.Span);
+                       currentNode = Root = new StyleRootSyntax (buff, tokens);
 
                        currentLine = 0;
                        tokIdx = 0;
-
+                       /*
                        while (tokIdx < tokens.Length) {
                                if (!skipTrivia(true))
                                        break;
@@ -64,7 +64,7 @@ namespace CECrowPlugin.Style
                                else
                                        currentNode = currentNode.Parent;
                        }
-                       setCurrentNodeEndLine (currentLine);
+                       setCurrentNodeEndLine (currentLine);*/
 
                        return Root;
                }
index a615950b7defe96a42d7a429de204f639bb929e2..3e1d8d839b3ec13fd037f9bc3794ae41f5a998dd 100644 (file)
@@ -11,41 +11,15 @@ namespace CECrowPlugin.Style
 {
 
        public class StyleRootSyntax : SyntaxRootNode {
-               public StyleRootSyntax (ReadOnlyMemory<char> source, Token[] tokens) : base (source, tokens) { }
+               public StyleRootSyntax (ReadOnlyTextBuffer source, Token[] tokens) : base (source, tokens) { }
        }
        public class ConstantDefinitionSyntax : SyntaxNode {
-               internal int? equal;
-               public readonly StyleIdentifierSyntax Identifier;
-               public readonly ImlValueSyntax Value;
-               public override bool IsComplete => base.IsComplete & Identifier != null & equal.HasValue;
-               public ConstantDefinitionSyntax (StyleIdentifierSyntax id)
-                       : base (id.StartLine, id.TokenIndexBase) {
-                       Identifier = id;
-               }
        }
        public class StyleIdentifierSyntax : SyntaxNode {
-               public StyleIdentifierSyntax (int startLine, int tokenBase)
-                       : base (startLine, tokenBase, tokenBase) {
-                       EndLine = startLine;
-               }
        }
        public class ImlValueSyntax : SyntaxNode {
-               internal int? valueOpen, value, valueClose;
-               public override bool IsComplete => base.IsComplete & value.HasValue &
-                       valueOpen.HasValue & valueClose.HasValue;
-               public ImlValueSyntax (int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {
-               }
 
        }
        public class AttributeSyntax : SyntaxNode {
-               public Token? NameToken { get; internal set; }
-               public Token? EqualToken { get; internal set; }
-               public Token? ValueOpenToken { get; internal set; }
-               public Token? ValueCloseToken { get; internal set; }
-               public Token? ValueToken { get; internal set; }
-               public AttributeSyntax (int startLine, int startTok) : base  (startLine, startTok) {}
-               public override bool IsComplete => base.IsComplete & NameToken.HasValue & EqualToken.HasValue &
-                       ValueToken.HasValue & ValueOpenToken.HasValue & ValueCloseToken.HasValue;
        }
 }
\ No newline at end of file
index bfa4a9b4cfb13645d71667bf5a3a9885ec232d16..86759e60803c718cf9fbe4aad2d1a125ac4b3c0f 100644 (file)
@@ -25,9 +25,9 @@ namespace CrowEdit.Ebnf
         public override async Task<SyntaxRootNode> Process()
         {
                        Tokenizer tokenizer = new EbnfTokenizer();
-                       ReadOnlyMemory<char> source = document.ImmutableBufferCopy;
-                       Token[] tokens = tokenizer.Tokenize(source.Span);
-                       currentNode = Root = new EbnfRootSyntax (source, tokens);
+                       ReadOnlyTextBuffer buff = document.ImmutableBufferCopy;
+                       Token[] tokens = tokenizer.Tokenize(buff.Source.Span);
+                       currentNode = Root = new EbnfRootSyntax (buff, tokens);
 
                        currentLine = 0;
                        tokIdx = 0;
@@ -78,10 +78,8 @@ namespace CrowEdit.Ebnf
                                }
                                
                                tokIdx++;
-                       }*/
-                               
-
-                       setCurrentNodeEndLine (currentLine);
+                       }
+                       setCurrentNodeEndLine (currentLine);*/
                        return Root;
         }
                
index b709ffde6204388e1be7cd89bfbf12720b016256..b5ac699faab39bcec177deb283feccb90b6e6fa7 100644 (file)
@@ -11,82 +11,39 @@ namespace CrowEdit.Ebnf
 {
 
        public class EbnfRootSyntax : SyntaxRootNode {
-               public EbnfRootSyntax (ReadOnlyMemory<char> source, Token[] tokens) : base (source, tokens) { }
+               public EbnfRootSyntax (ReadOnlyTextBuffer source, Token[] tokens) : base (source, tokens) { }
     }
        public class EbnfSyntaxNode : SyntaxNode {
-               public EbnfSyntaxNode(int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {
-                       }
        }
 
        public class ProductionSyntax : SyntaxNode {
-               public int? ncname, equal;
-               public ExpressionSyntax expression;
-               public ProductionSyntax(int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {
-                       }
-               public ProductionSyntax(int name, int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {
-                               ncname = name;
-                       }
-        public override bool IsComplete => base.IsComplete;
     }  
        public class ExpressionSyntax : SyntaxNode {
-               public ExpressionSyntax(int startLine, int tokenBase)
-                       : base (startLine, tokenBase) { }
        }
        public class LinkSyntax : ExpressionSyntax {
-               public int? openBracket, closingBracket;
-               public LinkSyntax(int openBracket, int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {
-                               this.openBracket = openBracket;
-                       }
        }
        public class ChoiceSyntax : ExpressionSyntax {
-               public ChoiceSyntax(int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {
-                       }
        }
        // (Item ( '-' Item | Item* ))?
        public class SequenceOrDifferenceSyntax : SyntaxNode {
-               public SequenceOrDifferenceSyntax(int startLine, int tokenBase)
-                       : base (startLine, tokenBase) { }
        }
        // Item ::=  Primary ( '?' | '*' | '+' )?   */
        public class ItemSyntax : SyntaxNode {
-               public ItemSyntax(int startLine, int tokenBase)
-                       : base (startLine, tokenBase) { }
        }
        /* NCName | StringLiteral | CharCode | CharClass | '(' Choice ')'    */
        public class PrimarySyntax : SyntaxNode {
-               public PrimarySyntax(int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {
-                       }
        }
        // StringLiteral ::= '"' [^"]* '"' | "'" [^']* "'"      
        public class StringLiteralSyntax : SyntaxNode {
-               public StringLiteralSyntax(int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {
-                               
-                       }
        }
        // CharCode ::= '#x' [0-9a-fA-F]+
        public class CharCodeSyntax : SyntaxNode {
-               public CharCodeSyntax(int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {
-                       }
        }
        // CharClass ::= '[' '^'? ( Char | CharCode | CharRange | CharCodeRange )+ ']'
        public class CharClassSyntax : SyntaxNode {
-               public int? closingBracket;
-               public CharClassSyntax(int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {}
        }
        // Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]       any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
        public class CharSyntax : SyntaxNode {
-               public CharSyntax(int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {
-                       }
        }
 
 
index a2e1fd553e21531c9afbacd04d41977a509083bb..dfb7f37d36eff7895cb42429bf2337382895699b 100644 (file)
@@ -13,13 +13,9 @@ using Microsoft.CodeAnalysis.Text;
 namespace CERoslynPlugin
 {
        public class CSRootSyntax : SyntaxRootNode {
-               public CSRootSyntax (ReadOnlyMemory<char> source, Token[] tokens) : base (source, tokens) {     }
+               public CSRootSyntax (ReadOnlyTextBuffer source, Token[] tokens) : base (source, tokens) {       }
        }
-       public class CSSyntaxNode : CrowEditBase.SyntaxNode {
-
-               public CSSyntaxNode (int startLine, int tokenBase, int? lastTokenIdx = null)
-                       : base (startLine, tokenBase, lastTokenIdx) {
-               }
+       public class CSSyntaxNode : MultiNodeSyntax {
     }
        
        public class CSSyntaxAnalyser : SyntaxAnalyser {
@@ -34,9 +30,9 @@ namespace CERoslynPlugin
 
                public override async Task<SyntaxRootNode> Process () {
                        CSTokenizer tokenizer = new CSTokenizer(csdoc.tree);
-                       ReadOnlyMemory<char> source = document.ImmutableBufferCopy;
+                       ReadOnlyTextBuffer buff = document.ImmutableBufferCopy;
                        Token[] tokens = tokenizer.Tokenize();
-                       CsharpSyntaxWalkerBridge bridge = new CsharpSyntaxWalkerBridge(new CSRootSyntax (source, tokens));
+                       CsharpSyntaxWalkerBridge bridge = new CsharpSyntaxWalkerBridge(new CSRootSyntax (buff, tokens));
                        
                        bridge.Visit(await tokenizer.syntaxTree.GetRootAsync());
 
@@ -47,7 +43,7 @@ namespace CERoslynPlugin
        class CsharpSyntaxWalkerBridge : Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker
        {
                public CSRootSyntax Root;
-               CrowEditBase.SyntaxNode currentNode;
+               MultiNodeSyntax currentNode;
                public CsharpSyntaxWalkerBridge (CSRootSyntax root) : base (SyntaxWalkerDepth.StructuredTrivia)
                {
                        currentNode = Root = root;
@@ -60,11 +56,19 @@ namespace CERoslynPlugin
 
                        int indexBase = Root.FindTokenIndexIncludingPosition(node.Span.Start);
                        int lastTokIndex = Root.FindTokenIndexIncludingPosition(node.Span.End - 1);
-                       currentNode = currentNode.AddChild(new CSSyntaxNode(loc.GetLineSpan().StartLinePosition.Line, indexBase, lastTokIndex));
+                       currentNode = currentNode.AddChild(new CSSyntaxNode()) as MultiNodeSyntax;
                        
                        base.Visit (node);
-                       currentNode.EndLine = end.Line;
+
                        currentNode = currentNode.Parent;
                }
+
+        public override void VisitToken(SyntaxToken token)
+        {
+                       TextSpan fs = token.FullSpan;
+                       Token tok = new Token(fs.Start,fs.Length,(TokenType)token.RawKind);
+                       currentNode.AddChild(new SingleTokenSyntax(tok));
+            base.VisitToken(token);
+        }
     }
 }
\ No newline at end of file
index bfe5d689317c06f8530c0578fe2b2e563c123e30..4fdc81ff5b030f6285f1844db0b15f0b19109d5c 100644 (file)
@@ -32,7 +32,7 @@ namespace CrowEdit.Xml
                protected virtual IEnumerable<Suggestion> getAttributeNameSuggestions(string eltName, string attribName, TextChange change) => null;
                protected virtual IEnumerable<Suggestion> getAttributeValueSuggestions(string eltName, string attribName, string attribValue, TextChange change) => null;
                public override IList GetSuggestions (int absoluteTextPos, int currentTokenIndex, SyntaxNode CurrentNode, CharLocation loc) {
-                       Token tok = GetTokenByIndex(currentTokenIndex); 
+                       /*Token tok = GetTokenByIndex(currentTokenIndex);       
                        if (tok.Start != absoluteTextPos //middle of edited tok
                                && currentTokenIndex >= CurrentNode?.Root.TokenCount - 1) //occurs when curTok is last tok of text
                        {
@@ -119,7 +119,7 @@ namespace CrowEdit.Xml
                                        
                                }
 
-                               /*if (tokType == XmlTokenType.AttributeName) {
+                               *if (tokType == XmlTokenType.AttributeName) {
                                        if (attrib.ValueToken.HasValue) {
                                                change = new TextChange (tok.Start, tok.Length, selectedSugg);
                                                newSelection = new TextSpan(
@@ -141,8 +141,8 @@ namespace CrowEdit.Xml
                                        else if (tokType == XmlTokenType.AttributeValue)
                                                change = new TextChange (tok.Start, tok.Length, selectedSugg);
                                        newSelection = TextSpan.FromStartAndLength (change.End2 + offset);
-                               }*/
-                       }
+                               }*
+                       }*/
 
                        return null;
                }
index cf47c950334c1eb16fa04d2b9bf11e55519bd9a8..3c9da55b344e22853cd28bbe593f009836fcff38 100644 (file)
@@ -13,18 +13,18 @@ namespace CrowEdit.Xml
        public class XmlSyntaxAnalyser : SyntaxAnalyser {
         public XmlSyntaxAnalyser (XmlDocument document) : base (document) {}
                public virtual void ProcessAttributeValueSyntax(AttributeSyntax attrib) {
-                       attrib.valueTok = tokIdx - attrib.TokenIndexBase;
+                       //attrib.valueTok = tokIdx - attrib.TokenIndexBase;
                }
                public override async Task<SyntaxRootNode> Process () {
                        Tokenizer tokenizer = new XmlTokenizer();
-                       ReadOnlyMemory<char> source = document.ImmutableBufferCopy;
-                       Token[] tokens = tokenizer.Tokenize(source.Span);
-                       currentNode = Root = new XMLRootSyntax (source, tokens);
+                       ReadOnlyTextBuffer buff = document.ImmutableBufferCopy;
+                       Token[] tokens = tokenizer.Tokenize(buff.Source.Span);
+                       currentNode = Root = new XMLRootSyntax (buff, tokens);
 
                        currentLine = 0;
                        tokIdx = 0;
 
-                       while (tokIdx < tokens.Length) {
+                       /*while (tokIdx < tokens.Length) {
                                if (curTok.Type == TokenType.LineBreak)
                                        currentLine++;
                                else if (!curTok.Type.HasFlag (TokenType.Trivia)) {
@@ -89,24 +89,6 @@ namespace CrowEdit.Xml
                                                                addException ("Open/Close element name mismatch");
                                                        }
                                                        finishCurrentNode ();
-                                                       /*else {
-                                                               addException ("Open/Close element name mismatch");
-                                                               finishCurrentNode ();//finish eltEndTag->curNode is parent elt
-                                                               currentNode.RemoveChild(eltEndTag);
-                                                               finishCurrentNode (-eltEndTag.TokenCount); //dont credit parent element with those tokens from the non matching end tag
-                                                                                                                                                  //curNode should be parent element of previous element
-                                                               while(currentNode is ElementSyntax esp) {
-                                                                       //eltEndTag is out of tree, so Name get threw exception
-                                                                       if (string.Equals(esp.StartTag.Name, eltEndTagName, StringComparison.Ordinal)) {
-                                                                               esp.EndTag = eltEndTag;
-                                                                               esp.AddChild (eltEndTag);
-                                                                               finishCurrentNode ();
-                                                                               break;
-                                                                       } else {
-                                                                               finishCurrentNode (-eltEndTag.TokenCount);
-                                                                       }
-                                                               }
-                                                       }*/
                                                } else {
                                                        addException ("Unexpected Token");
                                                        finishCurrentNode (-1);
@@ -151,7 +133,7 @@ namespace CrowEdit.Xml
                                        currentNode = currentNode.Parent;
                        }
                        //check why this is required..
-                       setCurrentNodeEndLine (currentLine);
+                       setCurrentNodeEndLine (currentLine);*/
                        return Root;
                }
        }
index dca4c1dd7dcc86dd49d9f529398ab2c43842319e..7ae0b16f638364eee2f48e542e75d93d414befde 100644 (file)
@@ -10,65 +10,41 @@ namespace CrowEdit.Xml
 {
 
        public class XMLRootSyntax : SyntaxRootNode {
-               public XMLRootSyntax (ReadOnlyMemory<char> source, Token[] tokens) : base (source, tokens) { }
+               public XMLRootSyntax (ReadOnlyTextBuffer buff, Token[] tokens) : base (buff, tokens) { }
        }
-       public class ProcessingInstructionSyntax : SyntaxNode {
-               public int? PIClose, name;
-               public override bool IsComplete => base.IsComplete & name.HasValue & PIClose.HasValue;
-               public ProcessingInstructionSyntax (int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {
-               }
+       public class ProcessingInstructionSyntax : MultiNodeSyntax {
+//             public override bool IsComplete => base.IsComplete & name.HasValue & PIClose.HasValue;
+               public ProcessingInstructionSyntax (){}
        }
 
        public abstract class ElementTagSyntax : SyntaxNode {
-               public int? name, close;
-               public override bool IsComplete => base.IsComplete & name.HasValue & close.HasValue;
-               public string Name => name.HasValue ?
-                               Root.GetTokenStringByIndex (TokenIndexBase + name.Value) : null;
-               protected ElementTagSyntax (int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {
-               }
+//             public override bool IsComplete => base.IsComplete & name.HasValue & close.HasValue;
+               protected ElementTagSyntax () { }
        }
        public class ElementStartTagSyntax : ElementTagSyntax {
-               public ElementStartTagSyntax (int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {
-               }
+               public ElementStartTagSyntax () {}
        }
        public class ElementEndTagSyntax : ElementTagSyntax {
-               public ElementEndTagSyntax (int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {
-               }
+               public ElementEndTagSyntax () { }
        }
 
-       public class EmptyElementSyntax : SyntaxNode {
-               public readonly ElementStartTagSyntax StartTag;
-               public EmptyElementSyntax (ElementStartTagSyntax startNode) : base (startNode.StartLine, startNode.TokenIndexBase, startNode.LastTokenIndex) {
-                       StartTag = startNode;
-                       AddChild (StartTag);
+       public class EmptyElementSyntax : MultiNodeSyntax {
+               public EmptyElementSyntax (ElementStartTagSyntax startNode) {
+                       AddChild (startNode);
                }
-        public override bool IsComplete => base.IsComplete && StartTag != null;
+        //public override bool IsComplete => base.IsComplete && StartTag != null;
     }
 
-       public class ElementSyntax : SyntaxNode {
-               public readonly ElementStartTagSyntax StartTag;
-               public ElementEndTagSyntax EndTag { get; set; }
+       public class ElementSyntax : MultiNodeSyntax {
 
-               public override bool IsComplete => base.IsComplete & StartTag.IsComplete & (EndTag != null && EndTag.IsComplete);
+               //public override bool IsComplete => base.IsComplete & StartTag.IsComplete & (EndTag != null && EndTag.IsComplete);
 
-               public ElementSyntax (ElementStartTagSyntax startTag)
-                       : base (startTag.StartLine, startTag.TokenIndexBase) {
-                       StartTag = startTag;
-                       AddChild (StartTag);
+               public ElementSyntax (ElementStartTagSyntax startTag) {
+                       AddChild (startTag);
                }
        }
 
-       public class AttributeSyntax : SyntaxNode {
-               public int? name, equal, valueOpen, valueClose, valueTok;
-               public string Name => name.HasValue ? Root.GetTokenStringByIndex (TokenIndexBase + name.Value) : null;
-               public string Value => valueTok.HasValue ? Root.GetTokenStringByIndex (TokenIndexBase + valueTok.Value) : null;
-               public Token? ValueToken => valueTok.HasValue ? Root.GetTokenByIndex (TokenIndexBase + valueTok.Value) : null;
-               public AttributeSyntax (int startLine, int tokenBase)
-                       : base (startLine, tokenBase) {}
-               public override bool IsComplete => base.IsComplete & name.HasValue & equal.HasValue & valueTok.HasValue & valueOpen.HasValue & valueClose.HasValue;
+       public class AttributeSyntax : MultiNodeSyntax {                        
+               //public override bool IsComplete => base.IsComplete & name.HasValue & equal.HasValue & valueTok.HasValue & valueOpen.HasValue & valueClose.HasValue;
        }
 }
\ No newline at end of file
index afd76431f8dcc807173f75ae5e5eb8d228a735f8..18d4c4945afc5c8649a7b9dbaf027b282eb4887b 100644 (file)
@@ -18,23 +18,26 @@ namespace CrowEdit.Xml
                BlockComment                    = 0x0105,
                BlockCommentEnd                 = 0x0106,
                Name                                    = 0x0200,
-               ElementName                             = 0x0201,
-               AttributeName                   = 0x0202,
-               PI_Target                               = 0x0203,
+               ElementName                             = 0x8201,
+               AttributeName                   = 0x8202,
+               PI_Target                               = 0x8203,
                Punctuation                             = 0x0400,
-               PI_Start                                = 0x0401,// '<?'
-               PI_End                                  = 0x0402,// '?>'
-               ElementOpen                     = 0x0403,// '<'
-               EndElementOpen                  = 0x0404,// '</'
-               EmptyElementClosing             = 0x0405,// '/>'
-               ClosingSign                             = 0x0406,// '>'
-               DTDObjectOpen                   = 0x04A0,// '<!'
+
+               PI_Start                                = 0x8401,// '<?'
+               PI_End                                  = 0x8402,// '?>'
+               ElementOpen                     = 0x8403,// '<'
+               EndElementOpen                  = 0x8404,// '</'
+               EmptyElementClosing             = 0x8405,// '/>'
+               ClosingSign                             = 0x8406,// '>'
+               DTDObjectOpen                   = 0x84A0,// '<!'
                Operator                                = 0x0800,
                EqualSign                               = 0x0801,
                Keyword                                 = 0x1000,
-               AttributeValue                  = 0x2000,
-               AttributeValueOpen              = 0x2001,
-               AttributeValueClose             = 0x2002,
+               AttributeValue                  = 0x8000,
+               AttributeValueOpen              = 0x8401,
+               AttributeValueClose             = 0x8402,
+
+
                Content,
        }
 }
\ No newline at end of file