Example #1
0
        public Ast_Location(O2MappedAstData astData, IMethod iMethod)
        {
            File = astData.file(iMethod);

            var methodDeclaration = astData.methodDeclaration(iMethod);
            if (methodDeclaration.notNull())
            {
                Line = methodDeclaration.StartLocation.Line;
                Column = methodDeclaration.StartLocation.Column;
                Line_End = methodDeclaration.EndLocation.Line;
                Column_End = methodDeclaration.EndLocation.Column;
            }
        }
        public Ast_Location(O2MappedAstData astData, IMethod iMethod)
        {
            File = astData.file(iMethod);

            var methodDeclaration = astData.methodDeclaration(iMethod);

            if (methodDeclaration.notNull())
            {
                Line       = methodDeclaration.StartLocation.Line;
                Column     = methodDeclaration.StartLocation.Column;
                Line_End   = methodDeclaration.EndLocation.Line;
                Column_End = methodDeclaration.EndLocation.Column;
            }
        }
 public static TreeView afterSelect_ShowMethodSignatureInSourceCode(this TreeView treeView, O2MappedAstData astData, ascx_SourceCodeViewer codeViewer)
 {
     treeView.afterSelect(
         (treeNode) =>
     {
         var text = WinForms_ExtensionMethods_TreeView.get_Text(treeNode);
         var methodDeclaration = astData.methodDeclaration_withSignature(treeNode.get_Text());
         if (methodDeclaration != null)
         {
             treeNode.color(Color.DarkGreen);
             var file = astData.file(methodDeclaration);
             codeViewer.open(file);
             codeViewer.editor().clearBookmarksAndMarkers();
             codeViewer.editor().setSelectionText(methodDeclaration.StartLocation, methodDeclaration.EndLocation);
         }
         else
         {
             treeNode.color(Color.Red);
         }
     });
     return(treeView);
 }
        public static MethodStream_Item methodStreamItem(this Saved_MethodStream savedMethodStream, O2MappedAstData astData, IMethod iMethod, MethodStream_ItemType itemType)
        {
            var methodStreamItem = new MethodStream_Item();

            methodStreamItem.ItemType = itemType;

            if (iMethod.Parameters.Count > 0)
            {
                methodStreamItem.Parameters = new NameValueItems();
                foreach (var parameter in iMethod.Parameters)
                {
                    methodStreamItem.Parameters.add(parameter.Name.str(), parameter.ReturnType.FullyQualifiedName);
                }
            }
            if (iMethod.Attributes.Count > 0)
            {
                methodStreamItem.Attributes = new NameValueItems();
                foreach (var attribute in iMethod.Attributes)
                {
                    methodStreamItem.Attributes.add(attribute.AttributeTarget.str(), attribute.AttributeType.FullyQualifiedName);
                }
            }

            methodStreamItem.Name  = iMethod.name();
            methodStreamItem.Class = iMethod.DeclaringType.Name;
            if (astData.file(iMethod).notNull())
            {
                methodStreamItem.Location = new Ast_Location(astData, iMethod);
            }
            methodStreamItem.Namespace  = iMethod.DeclaringType.Namespace;
            methodStreamItem.Signature  = iMethod.fullName();
            methodStreamItem.ReturnType = iMethod.ReturnType.FullyQualifiedName;
            methodStreamItem.DotNetName = iMethod.DotNetName;

            return(methodStreamItem);
        }
Example #5
0
 public static MethodMapping methodMapping(this O2MappedAstData astData, string signature, string key, string parentMethod, string parentClass, INode iNode)
 {
     return(new MethodMapping(signature, key, astData.file(iNode), parentMethod, parentClass, iNode));
 }
Example #6
0
        public static MethodStream_Item methodStreamItem(this Saved_MethodStream savedMethodStream,  O2MappedAstData astData, IMethod iMethod, MethodStream_ItemType itemType)
        {
            var methodStreamItem = new MethodStream_Item();

            methodStreamItem.ItemType = itemType;

            if (iMethod.Parameters.Count > 0)
            {
                methodStreamItem.Parameters = new NameValueItems();
                foreach(var parameter in iMethod.Parameters)
                    methodStreamItem.Parameters.add(parameter.Name.str(), parameter.ReturnType.FullyQualifiedName);
            }
            if (iMethod.Attributes.Count > 0)
            {
                methodStreamItem.Attributes = new NameValueItems();
                foreach(var attribute in iMethod.Attributes)
                    methodStreamItem.Attributes.add(attribute.AttributeTarget.str(), attribute.AttributeType.FullyQualifiedName);
            }

            methodStreamItem.Name = iMethod.name();
            methodStreamItem.Class = iMethod.DeclaringType.Name;
            if (astData.file(iMethod).notNull())
                methodStreamItem.Location = new Ast_Location(astData, iMethod);
            methodStreamItem.Namespace = iMethod.DeclaringType.Namespace;
            methodStreamItem.Signature = iMethod.fullName();
            methodStreamItem.ReturnType = iMethod.ReturnType.FullyQualifiedName;
            methodStreamItem.DotNetName = iMethod.DotNetName;

            return methodStreamItem;
        }
        public static TreeView afterSelect_ShowInSourceCodeEditor(this O2MappedAstData o2MappedAstData, TreeView treeView, SourceCodeEditor codeEditor)
        {
            return((TreeView)codeEditor.invokeOnThread(() =>
            {
                treeView.afterSelect <AstTreeView.ElementNode>((node) =>
                {
                    var element = (INode)node.field("element");
                    var file = o2MappedAstData.file(element);
                    if (file != null)
                    {
                        codeEditor.open(file);
                        codeEditor.setSelectionText(element.StartLocation, element.EndLocation);
                    }
                });

                // if it is a list select the first one
                treeView.afterSelect <List <INode> >((nodes) =>
                {
                    if (nodes.size() > 0)
                    {
                        var node = nodes[0];
                        var file = o2MappedAstData.file(node);
                        if (file != null)
                        {
                            codeEditor.open(file);
                            codeEditor.setSelectionText(node.StartLocation, node.EndLocation);
                        }
                    }
                });

                treeView.afterSelect <INode>((node) =>
                {
                    var file = o2MappedAstData.file(node);
                    if (file != null)
                    {
                        codeEditor.open(file);
                        codeEditor.setSelectionText(node.StartLocation, node.EndLocation);
                    }
                });

                treeView.afterSelect <ISpecial>((iSpecial) =>
                {
                    var file = o2MappedAstData.file(iSpecial);
                    if (file != null)
                    {
                        codeEditor.open(file);
                        codeEditor.setSelectionText(iSpecial.StartPosition, iSpecial.EndPosition);
                    }
                });

                // if it is a list select the first one
                treeView.afterSelect <List <ISpecial> >((iSpecials) =>
                {
                    if (iSpecials.size() > 0)
                    {
                        var iSpecial = iSpecials[0];
                        var file = o2MappedAstData.file(iSpecial);
                        if (file != null)
                        {
                            codeEditor.open(file);
                            codeEditor.setSelectionText(iSpecial.StartPosition, iSpecial.EndPosition);
                        }
                    }
                });

                treeView.afterSelect <CodeTypeDeclaration>((codeTypeDeclaration) =>
                {
                    if (o2MappedAstData.MapAstToDom.TypesDomToAst.hasKey(codeTypeDeclaration))
                    {
                        var typeDeclaration = o2MappedAstData.MapAstToDom.TypesDomToAst[codeTypeDeclaration];
                        var file = o2MappedAstData.file(typeDeclaration);
                        if (file != null)
                        {
                            codeEditor.open(file);
                            codeEditor.setSelectionText(typeDeclaration.StartLocation, typeDeclaration.EndLocation);
                        }
                    }
                    else
                    {
                        "in afterSelect<CodeTypeDeclaration>, key was node found for :{0}".format(codeTypeDeclaration.str());
                    }
                });

                treeView.afterSelect <CodeMemberMethod>((codeMemberMethod) =>
                {
                    if (o2MappedAstData.MapAstToDom.MethodsDomToAst.hasKey(codeMemberMethod))
                    {
                        var methodDeclaration = o2MappedAstData.MapAstToDom.MethodsDomToAst[codeMemberMethod];
                        var file = o2MappedAstData.file(methodDeclaration);
                        if (file != null)
                        {
                            codeEditor.open(file);
                            codeEditor.setSelectionText(methodDeclaration.StartLocation, methodDeclaration.EndLocation);
                        }
                    }
                    else
                    {
                        "in afterSelect<CodeMemberMethod> no key for {0}".format(codeMemberMethod.str()).error();
                    }
                });

                treeView.afterSelect <IMethod>((method) =>
                {
                    var file = o2MappedAstData.file(method);
                    if (file != null)
                    {
                        codeEditor.open(file);
                        if (o2MappedAstData.MapAstToNRefactory.IMethodToMethodDeclaration.hasKey(method))
                        {
                            var methodDeclaration = o2MappedAstData.MapAstToNRefactory.IMethodToMethodDeclaration[method];
                            codeEditor.setSelectionText(methodDeclaration.StartLocation, methodDeclaration.EndLocation);
                        }
                        else
                        if (o2MappedAstData.MapAstToNRefactory.IMethodToConstructorDeclaration.hasKey(method))
                        {
                            var constructorDeclaration = o2MappedAstData.MapAstToNRefactory.IMethodToConstructorDeclaration[method];
                            codeEditor.setSelectionText(constructorDeclaration.StartLocation, constructorDeclaration.EndLocation);
                        }
                        "in afterSelect<CodeMemberMethod> no key for {0}".format(method.str()).error();
                    }
                    ;
                });
                return treeView;
            }));
        }