Run parsed item
Inheritance: ParsedItem
コード例 #1
0
        /// <summary>
        /// Run statement,
        /// a second pass will be done after the visit is over to determine if a run is
        /// internal or external (calling internal proc or programs)
        /// </summary>
        /// <param name="pars"></param>
        public void Visit(ParsedRun pars)
        {
            // try to find the file in the propath
            if (pars.Flags.HasFlag(ParseFlag.Persistent) && !pars.Flags.HasFlag(ParseFlag.Uncertain))
            {
                string procName = pars.Name.ToLower();
                string fullFilePath;
                if (!procName.EndsWith(".p") && !procName.EndsWith(".w"))
                {
                    fullFilePath = ProEnvironment.Current.FindFirstFileInEnv(pars.Name + ".p");
                    if (String.IsNullOrEmpty(fullFilePath))
                    {
                        fullFilePath = ProEnvironment.Current.FindFirstFileInEnv(pars.Name + ".w");
                    }
                }
                else
                {
                    fullFilePath = ProEnvironment.Current.FindFirstFileInEnv(pars.Name);
                }

                if (String.IsNullOrEmpty(fullFilePath))
                {
                    pars.Flags |= ParseFlag.NotFound;
                }
                else
                {
                    // if the run is PERSISTENT, we need to load the functions/proc of the program
                    // ensure to not parse the same file twice in a parser session!
                    if (!RunPersistentFiles.Contains(fullFilePath))
                    {
                        RunPersistentFiles.Add(fullFilePath);
                        LoadProcPersistent(fullFilePath, pars.Scope);
                    }
                }
            }

            // to code explorer
            var internalRun = _parser.ParsedItemsList.Exists(item => {
                var proc = item as ParsedProcedure;
                return(proc != null && proc.Name.EqualsCi(pars.Name));
            });
            var parentNode = internalRun ? GetExplorerListNode("Run internal routine", CodeExplorerIconType.RunInternal) : GetExplorerListNode("Run external procedure", CodeExplorerIconType.RunExternal);
            var newNode    = CodeItem.Factory.New(internalRun ? CodeExplorerIconType.RunInternal : CodeExplorerIconType.RunExternal);

            newNode.DisplayText   = pars.Name;
            newNode.Flags         = pars.Flags;
            newNode.SubText       = pars.Scope.Name;
            newNode.DocumentOwner = pars.FilePath;
            newNode.GoToLine      = pars.Line;
            newNode.GoToColumn    = pars.Column;
            PushToCodeExplorer(parentNode, newNode);
        }
コード例 #2
0
ファイル: ParserVisitor.cs プロジェクト: devjerome/3P
        /// <summary>
        /// Run statement,
        /// a second pass will be done after the visit is over to determine if a run is
        /// internal or external (calling internal proc or programs)
        /// </summary>
        /// <param name="pars"></param>
        public void Visit(ParsedRun pars)
        {
            // try to find the file in the propath
            string fullFilePath = "";

            if (pars.HasPersistent && !pars.IsEvaluateValue)
            {
                string procName = pars.Name;
                if (!procName.EndsWith(".p") && !procName.EndsWith(".w"))
                {
                    fullFilePath = ProEnvironment.Current.FindFirstFileInEnv(pars.Name + ".p");
                    if (string.IsNullOrEmpty(fullFilePath))
                    {
                        fullFilePath = ProEnvironment.Current.FindFirstFileInEnv(pars.Name + ".w");
                    }
                }
                else
                {
                    fullFilePath = ProEnvironment.Current.FindFirstFileInEnv(pars.Name);
                }
            }

            // to code explorer
            _parsedExplorerItemsList.Add(new CodeExplorerItem {
                DisplayText   = pars.Name,
                Branch        = CodeExplorerBranch.Run,
                IconType      = CodeExplorerIconType.RunExternal,
                IsNotBlock    = true,
                Flag          = AddExternalFlag((pars.IsEvaluateValue ? CodeExplorerFlag.Uncertain : 0) | (pars.HasPersistent ? CodeExplorerFlag.LoadPersistent : 0) | ((pars.HasPersistent && string.IsNullOrEmpty(fullFilePath)) ? CodeExplorerFlag.NotFound : 0)),
                DocumentOwner = pars.FilePath,
                GoToLine      = pars.Line,
                GoToColumn    = pars.Column,
                SubString     = SetExternalInclude(pars.Scope.Name)
            });

            // if the run is PERSISTENT, we need to load the functions/proc of the program
            if (pars.HasPersistent && !string.IsNullOrEmpty(fullFilePath))
            {
                // ensure to not parse the same file twice in a parser session!
                if (_parsedFiles.Contains(fullFilePath))
                {
                    return;
                }
                _parsedFiles.Add(fullFilePath);

                LoadProcPersistent(fullFilePath, pars.Scope);
            }
        }