Procedure parsed item
상속: ParsedScopeItem
예제 #1
0
        /// <summary>
        /// Procedures
        /// </summary>
        public void Visit(ParsedProcedure pars)
        {
            // check lenght of block
            pars.TooLongForAppbuilder = HasTooMuchChar(pars.Line, pars.EndBlockLine);

            // fill dictionnary containing the name of all procedures defined
            if (!_definedProcedures.Contains(pars.Name))
            {
                _definedProcedures.Add(pars.Name);
            }

            // to code explorer
            _parsedExplorerItemsList.Add(new CodeExplorerItem {
                DisplayText   = pars.Name,
                Branch        = CodeExplorerBranch.Procedure,
                Flag          = AddExternalFlag((pars.IsPrivate ? CodeExplorerFlag.Private : 0) | (pars.TooLongForAppbuilder ? CodeExplorerFlag.IsTooLong : 0)),
                DocumentOwner = pars.FilePath,
                GoToLine      = pars.Line,
                GoToColumn    = pars.Column,
                SubString     = SetExternalInclude(pars.TooLongForAppbuilder ? BlockTooLongString + " (+" + NbExtraCharBetweenLines(pars.Line, pars.EndBlockLine) + ")" : null)
            });

            // to completion data
            _parsedCompletionItemsList.Add(new CompletionItem {
                DisplayText = pars.Name,
                Type        = CompletionType.Procedure,
                SubString   = !_isBaseFile ? _currentParsedFileName : string.Empty,
                Flag        = AddExternalFlag((pars.IsExternal ? ParseFlag.ExternalProc : 0) | (pars.IsPrivate ? ParseFlag.Private : 0)),
                Ranking     = AutoComplete.FindRankingOfParsedItem(pars.Name),
                ParsedItem  = pars,
                FromParser  = true
            });
        }
예제 #2
0
        /// <summary>
        /// Procedures
        /// </summary>
        public void Visit(ParsedProcedure pars)
        {
            // to code explorer
            var parentNode = pars.Flags.HasFlag(ParseFlag.External) ? GetExplorerListNode("External procedures", CodeExplorerIconType.ExternalProcedure) : GetExplorerListNode("Procedures", CodeExplorerIconType.Procedure);
            var newNode    = CodeItem.Factory.New(pars.Flags.HasFlag(ParseFlag.External) ? CodeExplorerIconType.ExternalProcedure : CodeExplorerIconType.Procedure);

            newNode.DisplayText   = pars.Name;
            newNode.Flags         = pars.Flags;
            newNode.SubText       = pars.Flags.HasFlag(ParseFlag.External) ? pars.ExternalDllName : null;
            newNode.DocumentOwner = pars.FilePath;
            newNode.GoToLine      = pars.Line;
            newNode.GoToColumn    = pars.Column;
            PushToCodeExplorer(parentNode, newNode);

            // to completion data
            var proc = CompletionItem.Factory.New(pars.Flags.HasFlag(ParseFlag.External) ? CompletionType.ExternalProcedure : CompletionType.Procedure);

            proc.DisplayText    = pars.Name;
            proc.ParsedBaseItem = pars;
            proc.FromParser     = true;
            proc.SubText        = pars.Flags.HasFlag(ParseFlag.External) ? pars.ExternalDllName : null;
            proc.Ranking        = AutoCompletion.FindRankingOfParsedItem(pars.Name);
            proc.Flags          = pars.Flags;
            PushToAutoCompletion(proc, pars);
        }
예제 #3
0
파일: Parser.cs 프로젝트: jcaillon/3P
        /// <summary>
        /// Matches a procedure definition
        /// </summary>
        /// <param name="procToken"></param>
        private bool CreateParsedProcedure(Token procToken)
        {
            // info we will extract from the current statement :
            string name = "";
            bool isExternal = false;
            bool isPrivate = false;
            _lastTokenWasSpace = true;
            StringBuilder leftStr = new StringBuilder();

            Token token;
            int state = 0;
            do {
                token = PeekAt(1); // next token
                if (token is TokenEos) break;
                if (token is TokenComment) continue;
                switch (state) {
                    case 0:
                        // matching name
                        if (!(token is TokenWord)) continue;
                        name = token.Value;
                        state++;
                        continue;
                    case 1:
                        // matching external
                        if (!(token is TokenWord)) continue;
                        if (token.Value.EqualsCi("external")) isExternal = true;
                        if (token.Value.EqualsCi("private")) isPrivate = true;
                        break;
                }
                AddTokenToStringBuilder(leftStr, token);
            } while (MoveNext());

            if (state < 1) return false;
            var newProc = new ParsedProcedure(name, procToken, leftStr.ToString(), isExternal, isPrivate) {
                // = end position of the EOS of the statement
                EndPosition = token.EndPosition
            };
            AddParsedItem(newProc);
            _context.Scope = newProc;
            return true;
        }