コード例 #1
0
        protected override async Task <DocumentSymbolsResponse> HandleMessage(DocumentSymbolsRequest parameters, RequestContext <DocumentSymbolsResponse> context)
        {
            DocumentSymbolsResponse response = new DocumentSymbolsResponse();

            try
            {
                ALSymbolInfoSyntaxTreeReader symbolTreeBuilder = new ALSymbolInfoSyntaxTreeReader(
                    this.Server.ALExtensionProxy);
                if (String.IsNullOrWhiteSpace(parameters.source))
                {
                    response.root = symbolTreeBuilder.ProcessSourceFile(parameters.path);
                }
                else
                {
                    response.root = symbolTreeBuilder.ProcessSourceCode(parameters.source);
                }
            }
            catch (Exception e)
            {
                response.root          = new ALSymbolInformation();
                response.root.fullName = e.Message;
            }

            return(response);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            //string extensionPath = "C:\\Users\\azwie\\.vscode\\extensions\\ms-dynamics-smb.al-5.0.329509";
            //string extensionPath = "C:\\Users\\azwie\\Downloads\\VSCode-win32-x64-1.45.1\\data\\extensions\\microsoft.al-0.13.82793";
            string extensionPath = "C:\\Projects\\MicrosoftALVersions\\LatestBC";

            ALDevToolsServerHost host = new ALDevToolsServerHost(extensionPath);

            host.Initialize();

            ALDevToolsServer alDevToolsServer = new ALDevToolsServer(extensionPath);

            //string filePath = "C:\\Projects\\Sandboxes\\al-test-projects\\small\\Pag50000.MySmallTableList.al";
            string filePath = "C:\\Projects\\Sandboxes\\al-test-projects\\SmallBC16\\MyPage.al";
            ALSymbolInfoSyntaxTreeReader syntaxTreeReader = new ALSymbolInfoSyntaxTreeReader(true);
            ALSymbolInformation          symbols          = syntaxTreeReader.ProcessSourceFile(filePath);

            ALFullSyntaxTree syntaxTree = new ALFullSyntaxTree();

            syntaxTree.Load("", filePath);

            CodeAnalyzersLibrariesCollection caLibCol = new CodeAnalyzersLibrariesCollection(alDevToolsServer);
            CodeAnalyzersLibrary             caLib    = caLibCol.GetCodeAnalyzersLibrary("${CodeCop}");

            filePath = "C:\\Projects\\Sandboxes\\al-test-projects\\SmallBC16\\AnZwDev_Small but great AZ AL Extension_1.0.0.0.app";
            ALSymbolInfoPackageReader packageReader = new ALSymbolInfoPackageReader();

            packageReader.ReadAppPackage(filePath);

            Console.WriteLine("Done");
        }
コード例 #3
0
        static void Main(string[] args)
        {
            // The code provided will print ‘Hello World’ to the console.
            // Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app.

            ALDevToolsServer server = new ALDevToolsServer("C:\\Users\\azwie\\.vscode\\extensions\\ms-dynamics-smb.al-4.0.209944");

            ALExtensionProxy alExtensionProxy = server.ALExtensionProxy;
            //alExtensionProxy.Load();

            CodeAnalyzersLibrary library = server.CodeAnalyzersLibraries.GetCodeAnalyzersLibrary("${AppSourceCop}");


            //ALPackageSymbolsLibrary lib = new ALPackageSymbolsLibrary(alExtensionProxy,
            //    "C:\\Projects\\Sandboxes\\samplealprojects\\big\\.alpackages\\Microsoft_Application_11.0.20901.0.app");
            //lib.Load(false);

            ALSymbolInfoSyntaxTreeReader s = new ALSymbolInfoSyntaxTreeReader(alExtensionProxy);
            //ALSymbolInformation m = s.ProcessSourceFile("C:\\Projects\\Sandboxes\\ALProject5\\New Page.al");
            //ALSymbolInformation m = s.ProcessSourceFile(
            //    "C:\\Projects\\Sandboxes\\samplealprojects\\big\\ftest\\CardPageTest02.al");

            ALSymbolInformation m = s.ProcessSourceFile(
                "C:\\Projects\\Sandboxes\\samplealprojects\\small\\tt1.al");



            /*
             * DateTime t1 = DateTime.Now;
             * ALSymbolInfoPackageReader appPackageReader = new ALSymbolInfoPackageReader(alExtensionProxy);
             * ALAppPackage package = appPackageReader.ReadAppPackage("C:\\Projects\\Sandboxes\\samplealprojects\\big\\.alpackages\\Microsoft_Application_14.0.29581.0.app");
             * DateTime t2 = DateTime.Now;
             * TimeSpan t = t2 - t1;
             * Console.WriteLine(t.TotalMilliseconds.ToString() + "ms");
             * Console.WriteLine("Package " + package.Name);
             * if (package.Tables != null)
             *  Console.WriteLine("Tables: " + package.Tables.Count.ToString());
             *
             * ALSymbolInformation symbol = package.ToALSymbol();
             */

            ALPackageSymbolsCache   packagesCache  = new ALPackageSymbolsCache(alExtensionProxy);
            ALProjectSymbolsLibrary projectSymbols = new ALProjectSymbolsLibrary(packagesCache,
                                                                                 alExtensionProxy,
                                                                                 false,
                                                                                 "C:\\Projects\\Sandboxes\\samplealprojects\\big",
                                                                                 ".alpackages");

            projectSymbols.Load(false);



            Console.WriteLine("Hello World!");
            Console.ReadKey();

            // Go to http://aka.ms/dotnet-get-started-console to continue learning how to build a console app!
        }
コード例 #4
0
        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(this.ALExtensionProxy);

            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]);
                }
            }
        }