protected override void AddChildALSymbols(ALSymbolInformation symbol)
 {
     this.Fields?.AddToALSymbol(symbol, ALSymbolKind.FieldList, "fields");
     this.Keys?.AddToALSymbol(symbol, ALSymbolKind.KeyList, "keys", ALSymbolKind.PrimaryKey);
     this.FieldGroups?.AddToALSymbol(symbol, ALSymbolKind.FieldGroupList, "fieldgroups");
     base.AddChildALSymbols(symbol);
 }
Ejemplo n.º 2
0
        public void AddToALSymbol(ALSymbolInformation symbol, ALSymbolKind collectionKind, string collectionName, ALSymbolKind firstItemSymbolKind)
        {
            if (this.Count > 0)
            {
                ALSymbolInformation collectionSymbol = symbol;
                if (!String.IsNullOrWhiteSpace(collectionName))
                {
                    collectionSymbol = new ALSymbolInformation(collectionKind, collectionName);
                    symbol.AddChildSymbol(collectionSymbol);
                }

                for (int i = 0; i < this.Count; i++)
                {
                    if ((i == 0) && (firstItemSymbolKind != ALSymbolKind.Undefined))
                    {
                        ALSymbolInformation itemSymbol = this[i].ToALSymbol();
                        itemSymbol.kind = firstItemSymbolKind;
                        collectionSymbol.AddChildSymbol(itemSymbol);
                    }
                    else
                    {
                        collectionSymbol.AddChildSymbol(this[i].ToALSymbol());
                    }
                }
            }
        }
Ejemplo n.º 3
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");
        }
Ejemplo n.º 4
0
 protected override void AddChildALSymbols(ALSymbolInformation symbol)
 {
     this.DataItems?.AddToALSymbol(symbol);
     this.Columns?.AddToALSymbol(symbol);
     this.Filters?.AddToALSymbol(symbol);
     base.AddChildALSymbols(symbol);
 }
Ejemplo n.º 5
0
        protected override ALSymbolInformation CreateMainALSymbol()
        {
            ALSymbolInformation symbol = base.CreateMainALSymbol();

            symbol.fullName = ALSyntaxHelper.EncodeName(this.Name) + ": " + ALSyntaxHelper.EncodeNamesList(this.FieldNames);
            return(symbol);
        }
Ejemplo n.º 6
0
        protected void ProcessNodeContentRangeFromChildren(SyntaxTree syntaxTree, ALSymbolInformation symbol, SyntaxNode syntax)
        {
            IEnumerable <SyntaxNode> list = syntax.ChildNodes();

            if (list != null)
            {
                Range totalRange = null;
                foreach (SyntaxNode childNode in list)
                {
                    var   lineSpan  = syntaxTree.GetLineSpan(childNode.FullSpan);
                    Range nodeRange = new Range(lineSpan.StartLinePosition.Line, lineSpan.StartLinePosition.Character,
                                                lineSpan.EndLinePosition.Line, lineSpan.EndLinePosition.Character);
                    if (totalRange == null)
                    {
                        totalRange = nodeRange;
                    }
                    else
                    {
                        if (totalRange.start.IsGreater(nodeRange.start))
                        {
                            totalRange.start.Set(nodeRange.start);
                        }
                        if (totalRange.end.IsLower(nodeRange.end))
                        {
                            totalRange.end.Set(nodeRange.end);
                        }
                    }
                }
                symbol.contentRange = totalRange;
            }
        }
Ejemplo n.º 7
0
        public virtual ALSymbolInformation ToALSymbol()
        {
            ALSymbolInformation symbol = this.CreateMainALSymbol();

            this.AddChildALSymbols(symbol);
            return(symbol);
        }
Ejemplo n.º 8
0
        protected override ALSymbolInformation CreateMainALSymbol()
        {
            ALSymbolInformation symbol = base.CreateMainALSymbol();

            symbol.extends = this.TargetObject;
            return(symbol);
        }
Ejemplo n.º 9
0
        protected override ALSymbolInformation CreateMainALSymbol()
        {
            ALSymbolInformation symbol = base.CreateMainALSymbol();

            symbol.fullName = symbol.kind.ToName() + " " + ALSyntaxHelper.EncodeName(this.Name);
            return(symbol);
        }
Ejemplo n.º 10
0
 protected void ProcessPageExtensionObjectNode(ALSymbolInformation symbol, PageExtensionSyntax syntax)
 {
     if (syntax.BaseObject != null)
     {
         symbol.extends = ALSyntaxHelper.DecodeName(syntax.BaseObject.ToString());
     }
 }
Ejemplo n.º 11
0
 protected void ProcessPageFieldNode(ALSymbolInformation symbol, PageFieldSyntax syntax)
 {
     if (syntax.Expression != null)
     {
         symbol.source = ALSyntaxHelper.DecodeName(syntax.Expression.ToString());
     }
 }
Ejemplo n.º 12
0
 protected void ProcessQueryColumnNode(ALSymbolInformation symbol, QueryColumnSyntax syntax)
 {
     if (syntax.RelatedField != null)
     {
         symbol.source = ALSyntaxHelper.DecodeName(syntax.RelatedField.ToString());
     }
 }
        protected override ALSymbolInformation CreateMainALSymbol()
        {
            ALSymbolInformation symbol = base.CreateMainALSymbol();

            //build full name
            string fullName = ALSyntaxHelper.EncodeName(this.Name) + "(";

            if (this.Parameters != null)
            {
                for (int i = 0; i < this.Parameters.Count; i++)
                {
                    if (i > 0)
                    {
                        fullName = fullName + ", ";
                    }
                    fullName = fullName + this.Parameters[i].GetSourceCode();
                }
            }
            fullName = fullName + ")";
            if ((this.ReturnTypeDefinition != null) && (!this.ReturnTypeDefinition.IsEmpty()))
            {
                fullName = fullName + ": " + this.ReturnTypeDefinition.GetSourceCode();
            }

            symbol.fullName = fullName;
            return(symbol);
        }
Ejemplo n.º 14
0
 protected void ProcessQueryDataItemNode(dynamic syntaxTree, ALSymbolInformation symbol, dynamic syntax)
 {
     if (syntax.DataItemTable != null)
     {
         symbol.source = ALSyntaxHelper.DecodeName(syntax.DataItemTable.ToString());
     }
     this.ProcessNodeContentRange(syntaxTree, symbol, syntax);
 }
Ejemplo n.º 15
0
 protected void ProcessXmlPortTableElementNode(SyntaxTree syntaxTree, ALSymbolInformation symbol, XmlPortTableElementSyntax syntax)
 {
     symbol.fullName = symbol.kind.ToName() + " " +
                       ALSyntaxHelper.EncodeName(symbol.name) +
                       ": Record " + syntax.SourceTable.ToFullString();
     symbol.source = ALSyntaxHelper.DecodeName(syntax.SourceTable.ToFullString());
     this.ProcessNodeContentRange(syntaxTree, symbol, syntax, syntax.OpenBraceToken, syntax.CloseBraceToken);
 }
Ejemplo n.º 16
0
 protected void ProcessQueryDataItemNode(SyntaxTree syntaxTree, ALSymbolInformation symbol, QueryDataItemSyntax syntax)
 {
     if (syntax.DataItemTable != null)
     {
         symbol.source = ALSyntaxHelper.DecodeName(syntax.DataItemTable.ToString());
     }
     this.ProcessNodeContentRange(syntaxTree, symbol, syntax, syntax.OpenBraceToken, syntax.CloseBraceToken);
 }
Ejemplo n.º 17
0
 protected void ProcessReportColumnNode(ALSymbolInformation symbol, ReportColumnSyntax syntax)
 {
     symbol.fullName = ALSyntaxHelper.EncodeName(symbol.name) + ": " + syntax.SourceExpression.ToFullString();
     if (syntax.SourceExpression != null)
     {
         symbol.source = ALSyntaxHelper.DecodeName(syntax.SourceExpression.ToString());
     }
 }
Ejemplo n.º 18
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!
        }
        protected override ALSymbolInformation CreateMainALSymbol()
        {
            ALSymbolInformation symbol = base.CreateMainALSymbol();

            symbol.name     = "RequestPage";
            symbol.fullName = symbol.name;
            symbol.id       = 0;
            return(symbol);
        }
Ejemplo n.º 20
0
 protected void ProcessReportDataItemNode(SyntaxTree syntaxTree, ALSymbolInformation symbol, ReportDataItemSyntax syntax)
 {
     symbol.fullName = ALSyntaxHelper.EncodeName(symbol.name) + ": Record " + syntax.DataItemTable.ToFullString();
     if (syntax.DataItemTable != null)
     {
         symbol.source = ALSyntaxHelper.DecodeName(syntax.DataItemTable.ToString());
     }
     this.ProcessNodeContentRange(syntaxTree, symbol, syntax, syntax.OpenBraceToken, syntax.CloseBraceToken);
 }
 protected override void AddChildALSymbols(ALSymbolInformation symbol)
 {
     this.DataItems?.AddToALSymbol(symbol, ALSymbolKind.ReportDataSetSection, "dataset");
     if (this.RequestPage != null)
     {
         symbol.AddChildSymbol(this.RequestPage.ToALSymbol());
     }
     base.AddChildALSymbols(symbol);
 }
Ejemplo n.º 22
0
        protected void ProcessPageChartPartNode(ALSymbolInformation symbol, PageChartPartSyntax syntax)
        {
            string name = symbol.kind.ToName() + " " + ALSyntaxHelper.EncodeName(symbol.name);

            if (syntax.ChartPartType != null)
            {
                symbol.fullName = name + ": " + syntax.ChartPartType.ToFullString();
            }
            symbol.fullName = name;
        }
Ejemplo n.º 23
0
        protected override ALSymbolInformation CreateMainALSymbol()
        {
            ALSymbolInformation symbol = base.CreateMainALSymbol();

            if (!String.IsNullOrWhiteSpace(this.RelatedTable))
            {
                symbol.fullName = ALSyntaxHelper.EncodeName(this.Name) + ": " + ALSyntaxHelper.EncodeName(this.RelatedTable);
            }
            return(symbol);
        }
Ejemplo n.º 24
0
        protected void ProcessPageGroupNode(SyntaxTree syntaxTree, ALSymbolInformation symbol, PageGroupSyntax syntax)
        {
            SyntaxToken controlKeywordToken = syntax.ControlKeyword;

            if ((controlKeywordToken != null) && (controlKeywordToken.Kind.ConvertToLocalType() == ConvertedSyntaxKind.PageRepeaterKeyword))
            {
                symbol.kind = ALSymbolKind.PageRepeater;
            }
            this.ProcessNodeContentRange(syntaxTree, symbol, syntax, syntax.OpenBraceToken, syntax.CloseBraceToken);
        }
Ejemplo n.º 25
0
        protected override ALSymbolInformation CreateMainALSymbol()
        {
            ALSymbolInformation symbol = base.CreateMainALSymbol();

            if (this.TypeDefinition != null)
            {
                symbol.fullName = ALSyntaxHelper.EncodeName(this.Name) + ": " + this.TypeDefinition.GetSourceCode();
            }
            return(symbol);
        }
        protected override ALSymbolInformation CreateMainALSymbol()
        {
            ALSymbolInformation symbol = new ALSymbolInformation(this.GetALSymbolKind(), this.TypeName);

            if (!String.IsNullOrWhiteSpace(this.AliasName))
            {
                symbol.fullName = ALSyntaxHelper.EncodeName(this.AliasName) + ": " + ALSyntaxHelper.EncodeName(this.TypeName.NotNull());
            }
            return(symbol);
        }
Ejemplo n.º 27
0
        protected bool ProcessSyntaxNodeAttribute(SyntaxTree syntaxTree, ALSymbolInformation parent, SyntaxNode node)
        {
            switch (node.Kind.ConvertToLocalType())
            {
            case ConvertedSyntaxKind.PropertyList:
                bool hasProperties = this.ProcessSyntaxNodePropertyList(syntaxTree, parent, node);
                return(!this.IncludeProperties);      // || (!hasProperties);

            case ConvertedSyntaxKind.SimpleTypeReference:
            case ConvertedSyntaxKind.RecordTypeReference:
            case ConvertedSyntaxKind.DotNetTypeReference:
                parent.subtype        = node.ToFullString();
                parent.elementsubtype = node.GetType().TryGetPropertyValueAsString(node, "DataType");
                if (String.IsNullOrWhiteSpace(parent.elementsubtype))
                {
                    parent.elementsubtype = parent.subtype;
                }
                return(true);

            case ConvertedSyntaxKind.MemberAttribute:
                string memberAttributeName = node.GetSyntaxNodeName().NotNull();
                if ((parent.kind == ALSymbolKind.MethodDeclaration) || (parent.kind == ALSymbolKind.LocalMethodDeclaration))
                {
                    ALSymbolKind newKind = ALSyntaxHelper.MemberAttributeToMethodKind(memberAttributeName);
                    if (newKind != ALSymbolKind.Undefined)
                    {
                        parent.kind = newKind;
                        return(true);
                    }
                }
                parent.subtype = memberAttributeName;
                return(true);

            case ConvertedSyntaxKind.ObjectId:
                ObjectIdSyntax objectIdSyntax = (ObjectIdSyntax)node;
                if ((objectIdSyntax.Value != null) && (objectIdSyntax.Value.Value != null))
                {
                    parent.id = (int)objectIdSyntax.Value.Value;
                }
                return(true);

            case ConvertedSyntaxKind.IdentifierName:
                var lineSpan = syntaxTree.GetLineSpan(node.Span);
                parent.selectionRange = new Range(lineSpan.StartLinePosition.Line, lineSpan.StartLinePosition.Character,
                                                  lineSpan.EndLinePosition.Line, lineSpan.EndLinePosition.Character);
                return(true);

            case ConvertedSyntaxKind.VariableListDeclaration:
                //safe call as variable list declaration nodes are not supported by Nav2018
                this.SafeProcessVariableListDeclarationNode(syntaxTree, parent, node);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 28
0
 protected void ProcessNodeContentRange(SyntaxTree syntaxTree, ALSymbolInformation symbol, SyntaxNode node,
                                        SyntaxToken contentStartToken, SyntaxToken contentEndToken)
 {
     if ((contentStartToken != null) && (contentEndToken != null))
     {
         var startSpan = syntaxTree.GetLineSpan(contentStartToken.Span);
         var endSpan   = syntaxTree.GetLineSpan(contentEndToken.Span);
         symbol.contentRange = new Range(startSpan.EndLinePosition.Line, startSpan.EndLinePosition.Character,
                                         endSpan.StartLinePosition.Line, endSpan.StartLinePosition.Character);
     }
 }
Ejemplo n.º 29
0
        protected void ProcessEventDeclarationNode(ALSymbolInformation symbol, EventDeclarationSyntax syntax)
        {
            string namePart = "(";

            if ((syntax.ParameterList != null)) // && (syntax.ParameterList.Parameters != null))
            {
                namePart = namePart + syntax.ParameterList.Parameters.ToFullString();
            }
            namePart = namePart + ")";

            symbol.fullName = ALSyntaxHelper.EncodeName(symbol.name) + namePart;
        }
Ejemplo n.º 30
0
        protected void ProcessNodeContentRange(dynamic syntaxTree, ALSymbolInformation symbol, dynamic syntax)
        {
            dynamic contentStartToken = syntax.OpenBraceToken;
            dynamic contentEndToken   = syntax.CloseBraceToken;

            if ((contentStartToken != null) && (contentEndToken != null))
            {
                dynamic startSpan = syntaxTree.GetLineSpan(contentStartToken.Span);
                dynamic endSpan   = syntaxTree.GetLineSpan(contentEndToken.Span);
                symbol.contentRange = new Range(startSpan.EndLinePosition.Line, startSpan.EndLinePosition.Character,
                                                endSpan.StartLinePosition.Line, endSpan.StartLinePosition.Character);
            }
        }