示例#1
0
 public void AddChildSymbol(ALSymbolInformation symbolInfo)
 {
     if (symbolInfo == null)
     {
         return;
     }
     if (this.childSymbols == null)
     {
         this.childSymbols = new List <ALSymbolInformation>();
     }
     this.childSymbols.Add(symbolInfo);
 }
        protected void ProcessSourceCode()
        {
            ALSymbolInformation parent;
            Dictionary <ALSymbolKind, ALSymbolInformation> groupSymbolsCollection = new Dictionary <ALSymbolKind, ALSymbolInformation>();

            if (this.IncludeDependencies)
            {
                parent = new ALSymbolInformation(ALSymbolKind.Package, this.FullName);
                this.Root.AddChildSymbol(parent);
            }
            else
            {
                parent = this.Root;
            }

            //process source files
            ALSymbolInfoSyntaxTreeReader syntaxTreeReader = new ALSymbolInfoSyntaxTreeReader(false);

            string[] files = System.IO.Directory.GetFiles(this.Path, "*.al", SearchOption.AllDirectories);
            for (int i = 0; i < files.Length; i++)
            {
                ALSymbolInformation documentSymbols = syntaxTreeReader.ProcessSourceFile(files[i]);
                if (documentSymbols.childSymbols != null)
                {
                    for (int symbolIndex = 0; symbolIndex < documentSymbols.childSymbols.Count; symbolIndex++)
                    {
                        ALSymbolInformation symbol          = documentSymbols.childSymbols[symbolIndex];
                        ALSymbolKind        groupSymbolKind = symbol.kind.ToGroupSymbolKind();
                        ALSymbolInformation groupSymbol     = null;
                        if (groupSymbolsCollection.ContainsKey(groupSymbolKind))
                        {
                            groupSymbol = groupSymbolsCollection[groupSymbolKind];
                        }
                        else
                        {
                            groupSymbol = new ALSymbolInformation(groupSymbolKind, groupSymbolKind.ToName());
                            groupSymbolsCollection.Add(groupSymbolKind, groupSymbol);
                        }
                        groupSymbol.AddChildSymbol(symbol);
                    }
                }
            }

            //add group symbols to parent element
            if (groupSymbolsCollection.Values.Count > 0)
            {
                List <ALSymbolInformation> groups = groupSymbolsCollection.Values.OrderBy(p => p.kind).ToList();
                for (int i = 0; i < groups.Count; i++)
                {
                    parent.AddChildSymbol(groups[i]);
                }
            }
        }
示例#3
0
        public ALSymbolInformation GetObjectsTree()
        {
            ALSymbolInformation symbol = this.CreateCopy(false);

            if ((!this.kind.IsObjectDefinition()) && (this.childSymbols != null))
            {
                for (int i = 0; i < this.childSymbols.Count; i++)
                {
                    symbol.AddChildSymbol(this.childSymbols[i].GetObjectsTree());
                }
            }
            return(symbol);
        }
示例#4
0
        public List <ALSymbolInformation> GetSymbolsListByPath(int[][] paths, ALSymbolKind kind)
        {
            List <ALSymbolInformation> symbolsList = new List <ALSymbolInformation>();

            for (int i = 0; i < paths.Length; i++)
            {
                ALSymbolInformation symbol = this.GetSymbolByPath(paths[i]);
                if ((symbol != null) && (
                        (kind == ALSymbolKind.Undefined) ||
                        (symbol.kind == kind) ||
                        ((kind == ALSymbolKind.AnyALObject) && (symbol.kind.IsObjectDefinition()))))
                {
                    symbolsList.Add(symbol);
                }
            }
            return(symbolsList);
        }
示例#5
0
        public ALSymbolInformation CreateCopy(bool withChildSymbols)
        {
            ALSymbolInformation symbol = new ALSymbolInformation();

            symbol.id             = this.id;
            symbol.name           = this.name;
            symbol.subtype        = this.subtype;
            symbol.fullName       = this.fullName;
            symbol.kind           = this.kind;
            symbol.range          = this.range;
            symbol.selectionRange = this.selectionRange;

            if ((withChildSymbols) && (this.childSymbols != null))
            {
                for (int i = 0; i < this.childSymbols.Count; i++)
                {
                    symbol.AddChildSymbol(this.childSymbols[i].CreateCopy(withChildSymbols));
                }
            }

            return(symbol);
        }
示例#6
0
 public ALSymbolInformation GetSymbolByPath(int[] path)
 {
     if ((this.Root != null) && (path != null) && (path.Length > 0))
     {
         ALSymbolInformation symbol = this.Root;
         for (int i = path.Length - 1; i >= 0; i--)
         {
             if ((symbol.childSymbols == null) || (path[i] >= symbol.childSymbols.Count))
             {
                 return(null);
             }
             if (path[i] == -1)
             {
                 symbol = this.Root;
             }
             else
             {
                 symbol = symbol.childSymbols[path[i]];
             }
         }
         return(symbol);
     }
     return(null);
 }
示例#7
0
 public ALSymbolsLibrary(ALSymbolInformation rootSymbol)
 {
     this.Root = rootSymbol;
 }
        protected void ProcessDependencies(ALProjectFile projectFile, bool forceReload)
        {
            //load list of packages
            ALAppPackageFileInfosCollection packageFiles = new ALAppPackageFileInfosCollection();

            packageFiles.LoadFromFolder(this.PackagesPath);

            //collect list of projects from other folders
            WorkspaceProjectsCollection workspaceProjects = null;

            if ((this.WorkspaceFolders != null) && (this.WorkspaceFolders.Length > 1))
            {
                workspaceProjects = new WorkspaceProjectsCollection(this.WorkspaceFolders);
                workspaceProjects.Load();
            }

            bool baseAppLoaded   = false;
            bool systemAppLoaded = false;

            //collect packages
            if (projectFile.dependencies != null)
            {
                for (int i = 0; i < projectFile.dependencies.Length; i++)
                {
                    bool workspaceProjectFound = false;
                    if (workspaceProjects != null)
                    {
                        WorkspaceProject depProject = workspaceProjects.FindByReference(projectFile.dependencies[i].appId,
                                                                                        projectFile.dependencies[i].publisher, projectFile.dependencies[i].name, projectFile.dependencies[i].version);
                        if (depProject != null)
                        {
                            workspaceProjectFound = true;
                            this.AddDepProject(depProject);
                        }
                    }

                    if (!workspaceProjectFound)
                    {
                        this.AddPackage(packageFiles, projectFile.dependencies[i].publisher,
                                        projectFile.dependencies[i].name, projectFile.dependencies[i].version, forceReload);
                    }

                    if ((!String.IsNullOrWhiteSpace(projectFile.dependencies[i].publisher)) &&
                        (!String.IsNullOrWhiteSpace(projectFile.dependencies[i].name)) &&
                        (projectFile.dependencies[i].publisher.ToLower().Trim().Equals("microsoft")))
                    {
                        string appName = projectFile.dependencies[i].name.ToLower().Trim();
                        if (appName.Equals("system application"))
                        {
                            systemAppLoaded = true;
                        }
                        else if (appName.Equals("base application"))
                        {
                            baseAppLoaded = true;
                        }
                    }
                }
            }

            //collect system packages
            if (!String.IsNullOrWhiteSpace(projectFile.application))
            {
                this.AddPackage(packageFiles, "Microsoft", "Application", projectFile.application, forceReload);

                if (!baseAppLoaded)
                {
                    this.AddPackage(packageFiles, "Microsoft", "Base Application", projectFile.application, forceReload);
                }
                if (!systemAppLoaded)
                {
                    this.AddPackage(packageFiles, "Microsoft", "System Application", projectFile.application, forceReload);
                }
            }

            if (!String.IsNullOrWhiteSpace(projectFile.platform))
            {
                this.AddPackage(packageFiles, "Microsoft", "System", projectFile.platform, forceReload);
            }

            if (!String.IsNullOrWhiteSpace(projectFile.test))
            {
                this.AddPackage(packageFiles, "Microsoft", "Test", projectFile.test, forceReload);
            }

            //collect dependencies

            if (this.Dependencies.Count > 0)
            {
                ALSymbolInformation dependenciesList = new ALSymbolInformation(ALSymbolKind.Dependencies, "Dependencies");
                for (int i = 0; i < this.Dependencies.Count; i++)
                {
                    dependenciesList.AddChildSymbol(this.Dependencies[i].Root);
                }
                this.Root.AddChildSymbol(dependenciesList);
            }
        }