Example #1
0
        private IBaseNode FindDocumentationNode(LinkedListNode <IBaseToken> searchNode, int maxLineDelta)
        {
            IBaseToken searchToken        = searchNode.Value;
            int        start              = searchToken.Index;
            int        startLine          = searchToken.Position.Line;
            int        minEndLine         = startLine - maxLineDelta;
            LinkedListNode <IBaseToken> n = searchNode;

            while (n != null)
            {
                IBaseToken baseToke = n.Value;
                if (baseToke.Position.Line >= minEndLine)
                {
                    DoxygenToken doxyToken = baseToke as DoxygenToken;
                    if (doxyToken != null)
                    {
                        if (doxyToken.Kind == DoxygenTokenKind.DoxyBlockStartSingle || doxyToken.Kind == DoxygenTokenKind.DoxyBlockEnd)
                        {
                            var foundNode = GetDocumentationNode?.Invoke(baseToke);
                            return(foundNode);
                        }
                    }
                }
                else
                {
                    break;
                }
                n = n.Previous;
            }
            return(null);
        }
Example #2
0
            public void AddToken(IBaseToken token)
            {
                Stopwatch w = Stopwatch.StartNew();

                _tokens.Add(token);
                w.Stop();
                Stats.InsertDuration += w.Elapsed;
            }
        public override bool ParseToken(LinkedListStream <IBaseToken> stream)
        {
            IBaseToken token = stream.Peek();

            if (typeof(DoxygenToken).Equals(token.GetType()))
            {
                DoxygenToken doxyToken = (DoxygenToken)token;
                switch (doxyToken.Kind)
                {
                case DoxygenTokenKind.DoxyBlockStartSingle:
                    return(ParseSingleBlock(stream));

                case DoxygenTokenKind.DoxyBlockStartMulti:
                {
                    DoxygenEntity blockEntity = new DoxygenEntity(DoxygenEntityKind.BlockMulti, doxyToken);
                    PushEntity(blockEntity);
                    stream.Next();
                    return(true);
                }

                case DoxygenTokenKind.DoxyBlockEnd:
                {
                    CloseEverythingUntil(DoxygenEntityKind.BlockMulti);
                    Debug.Assert(Top != null);
                    DoxygenEntity rootEntity = (DoxygenEntity)Top.Entity;
                    Debug.Assert(rootEntity.Kind == DoxygenEntityKind.BlockMulti);
                    Pop();
                    rootEntity.EndRange = doxyToken.Range;
                    stream.Next();
                    return(true);
                }

                default:
                {
                    ParseBlockContent(stream, Top);
                    return(true);
                }
                }
            }
            else
            {
                return(false);
            }
        }
        private bool ParseSingleBlock(LinkedListStream <IBaseToken> stream)
        {
            // @NOTE(final) Single block = auto-brief

            IBaseToken    blockToken  = stream.Peek();
            DoxygenEntity blockEntity = new DoxygenEntity(DoxygenEntityKind.BlockSingle, blockToken);

            PushEntity(blockEntity);
            stream.Next();

            IBaseToken endToken   = null;
            IBaseToken briefToken = DoxygenTokenPool.Make(DoxygenTokenKind.Command, blockToken.Range, true);

            DoxygenEntity briefEntity = new DoxygenEntity(DoxygenEntityKind.Brief, briefToken);
            DoxygenNode   briefNode   = PushEntity(briefEntity);

            while (!stream.IsEOF)
            {
                IBaseToken   token     = stream.Peek();
                DoxygenToken doxyToken = token as DoxygenToken;
                if (doxyToken != null && doxyToken.Kind == DoxygenTokenKind.DoxyBlockEnd)
                {
                    endToken = token;
                    stream.Next();
                    break;
                }
                if (!ParseBlockContent(stream, briefNode))
                {
                    break;
                }
                Debug.Assert(stream.CurrentValue != token);
            }

            Pop(); // Pop brief

            Pop(); // Pop block

            if (endToken != null)
            {
                blockEntity.EndRange = endToken.Range;
            }

            return(true);
        }
Example #5
0
        public void ParseTokens(IEnumerable <IBaseToken> tokens)
        {
            LinkedListStream <IBaseToken> tokenStream = new LinkedListStream <IBaseToken>(tokens);

            while (!tokenStream.IsEOF)
            {
                IBaseToken old = tokenStream.CurrentValue;
                if (!typeof(TToken).Equals(old.GetType()))
                {
                    tokenStream.Next();
                    continue;
                }
                if (!ParseToken(tokenStream))
                {
                    tokenStream.Next();
                }
                Debug.Assert(old != tokenStream.CurrentValue);
            }
        }
        private bool ParseBlockContent(LinkedListStream <IBaseToken> stream, IBaseNode contentRoot)
        {
            IBaseToken token = stream.Peek();

            if (typeof(DoxygenToken).Equals(token.GetType()))
            {
                DoxygenToken doxyToken = (DoxygenToken)token;
                switch (doxyToken.Kind)
                {
                case DoxygenTokenKind.EmptyLine:
                    CloseParagraphOrSection(contentRoot);
                    return(true);

                case DoxygenTokenKind.Command:
                    return(ParseCommand(stream, contentRoot));

                case DoxygenTokenKind.InvalidCommand:
                    string commandName = doxyToken.Value.Substring(1);
                    AddError(doxyToken.Position, $"Unknown doxygen command '{commandName}'", "Command", commandName);
                    stream.Next();
                    return(true);

                case DoxygenTokenKind.TextStart:
                    ParseText(stream, contentRoot);
                    return(true);

                default:
                    stream.Next();
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
Example #7
0
 public StyleEntry(IBaseToken token, int style) : this(token.Index, token.Length, style)
 {
 }
Example #8
0
 public CppEntity(CppEntityKind kind, IBaseToken token, string ident) : base(token.Range)
 {
     Kind = kind;
     Id   = ident;
 }
 public DoxygenEntity(DoxygenEntityKind kind, IBaseToken token) : this(kind, token.Range)
 {
 }