public virtual void Visit(ISyntaxEntity entity)
 {
     if (entity != null)
     {
         entity.AcceptVisitor(this);
     }
 }
 public override void Visit(ISyntaxEntity entity)
 {
     if (entity != null && entity.AssociatedComment != null)
     {
         m_commentsInFile.Add(entity.AssociatedComment);
     }
 }
        internal static string GetImageSourceFromKind(ISyntaxEntity node)
        {
            if (null == node)
            {
                return(string.Empty);
            }

            if (UIConstants.UIImageFileDictionary.Keys.Contains(node.Kind))
            {
                if (node.Kind == SyntaxEntityKind.CodeFile)
                {
                    var currentLang = node.CurrentCodeFile.Language;
                    if (currentLang.GetType().Name.Contains("CSharp"))
                    {
                        return("../res/csharp.png");
                    }
                    else if (currentLang.GetType().Name.Contains("Python"))
                    {
                        return("../res/python.png");
                    }
                    return("../res/default.png");
                }
                else
                {
                    return(UIConstants.UIImageFileDictionary[node.Kind]);
                }
            }
            else
            {
                return("../res/default.png");
            }
        }
 /// <summary>
 /// <summary>
 /// Constructor for Function type.
 /// </summary>
 /// <param name="name">The name of the function</param>
 /// <param name="location">The FileSpan location of the function</param>
 /// <param name="parent">the parent of the current CodeFile</param>
 /// <param name="currentCodeFile">The current CodeFile</param>
 public FunctionDefinition(string name, FileSpan location, ISyntaxEntity parent, CodeFile currentCodeFile)
     : base(name, location, parent, currentCodeFile)
 {
     Parameters = new List <FormalParameter>();
     IsOverride = false;
     ReturnType = String.Empty;
 }
        public void SetTreeView(ISyntaxEntity node, string label)
        {
            //Cleaning UI
            listView.Visibility = Visibility.Collapsed;
            treeView.Visibility = Visibility.Visible;
            TreeItems.Clear();

            treeRootViewModel = null;

            //Modifed by prvai
            //buildTree(node, null);
            BuildTreeViewModel(node, null);

            //modified by prvai
            TreeItems.Add(treeRootViewModel);

            treeView.Focus();

            if (treeView.HasItems)
            {
                var selectedItem = treeView.Items[0] as MenuItemViewModel;
                selectedItem.IsSelected = true;
                //TreeViewItem item = treeView.ItemContainerGenerator.Items[0] as TreeViewItem;
                //item.IsSelected = true;
            }

            isTreeViewActive = true;

            ResizeControl();
        }
 public override void PostWalk(IronPython.Compiler.Ast.ClassDefinition node)
 {
     Trace.TraceInformation("in method postWalk(ClassDefinition node)");
     m_currentParent = m_savedParents.Pop();
     Trace.TraceInformation("restored m_current parent to " + m_currentParent.Name);
     base.PostWalk(node);
 }
Exemple #7
0
 internal static CatchBlock CreateCatchBlock(CatchClauseSyntax node, ISyntaxEntity parent, CodeFile codeFile, SyntaxTree tree)
 {
     return(new CatchBlock("", new FileSpan(tree.GetLineSpan(node.Span)), parent, codeFile)
     {
         CatchType = node.Declaration.Type.ToString(),
         CatchFilterClause = (null == node.Filter) ? string.Empty : node.Filter.FilterExpression.ToString()
     });
 }
Exemple #8
0
 public virtual void AddChild(ISyntaxEntity child)
 {
     m_children.Add(child);
     m_children.Sort(delegate(ISyntaxEntity c1, ISyntaxEntity c2)
     {
         return(c1.Location.StartLineNumber.CompareTo(c2.Location.StartLineNumber));
     });
 }
Exemple #9
0
        internal static FunctionDefinition CreateMethod(LambdaExpressionSyntax node, ISyntaxEntity parent, CodeFile currentCodeFile, SyntaxTree tree)
        {
            FunctionDefinition func = createFunctionObject("", tree.GetLineSpan(node.Span), new SyntaxTokenList(), parent, currentCodeFile);

            func.TypeOfFunction    = FunctionTypes.AnonymousFunction;
            func.AssociatedComment = GetComment(func, node, tree, currentCodeFile);

            return(func);
        }
Exemple #10
0
        public override void VisitDestructorDeclaration(DestructorDeclarationSyntax node)
        {
            var methodObj = CSharpEntityCreationHelper.CreateMethod(node, m_currentParent, m_currentCodeFile, m_currentTree);

            ISyntaxEntity oldParent = setCurrentParent(methodObj);

            base.VisitDestructorDeclaration(node);
            m_currentParent = oldParent;
        }
Exemple #11
0
        public override void VisitTryStatement(TryStatementSyntax node)
        {
            var tryObj = CSharpEntityCreationHelper.CreateTryBlock(node, m_currentParent, m_currentCodeFile, m_currentTree);

            ISyntaxEntity oldParent = setCurrentParent(tryObj);

            base.VisitTryStatement(node);
            m_currentParent = oldParent;
        }
Exemple #12
0
        public override void VisitPropertyDeclaration(PropertyDeclarationSyntax node)
        {
            var propertyObj = CSharpEntityCreationHelper.CreateProperty(node, m_currentParent, m_currentCodeFile, m_currentTree);

            ISyntaxEntity oldParent = setCurrentParent(propertyObj);

            base.VisitPropertyDeclaration(node);
            m_currentParent = oldParent;
        }
 public GenerateFunctionDetails(List <InvocationDetails> functionActivationRecords, SortedDictionary <int, List <long> > timestamps, TimeSeriesAdapter timeSeriesAdapter, ISyntaxEntity function)
 {
     this.functionActivationRecords = functionActivationRecords;
     this.timestamps        = timestamps;
     this.function          = function;
     this.timeSeriesAdapter = timeSeriesAdapter;
     AverageInvocationRecords();
     GetFunctionLevelStatistics();
 }
Exemple #14
0
        public override void VisitInterfaceDeclaration(InterfaceDeclarationSyntax node)
        {
            var intfObj = CSharpEntityCreationHelper.CreateInterface(node, m_currentParent, m_currentCodeFile, m_currentTree);

            ISyntaxEntity oldParent = setCurrentParent(intfObj);

            base.VisitInterfaceDeclaration(node);
            m_currentParent = oldParent;
        }
Exemple #15
0
        public override void VisitEnumDeclaration(EnumDeclarationSyntax node)
        {
            var enumObj = CSharpEntityCreationHelper.CreateEnum(node, m_currentParent, m_currentCodeFile, m_currentTree);

            ISyntaxEntity oldParent = setCurrentParent(enumObj);

            base.VisitEnumDeclaration(node);
            m_currentParent = oldParent;
        }
Exemple #16
0
        public override void VisitForEachStatement(ForEachStatementSyntax node)
        {
            var foreachObj = CSharpEntityCreationHelper.CreateForEachBlock(node, m_currentParent, m_currentCodeFile, m_currentTree);

            ISyntaxEntity oldParent = setCurrentParent(foreachObj);

            base.VisitForEachStatement(node);
            m_currentParent = oldParent;
        }
Exemple #17
0
        public override void VisitStructDeclaration(StructDeclarationSyntax node)
        {
            var classObj = CSharpEntityCreationHelper.CreateStruct(node, m_currentParent, m_currentCodeFile, m_currentTree);

            ISyntaxEntity oldParent = setCurrentParent(classObj);

            base.VisitStructDeclaration(node);
            m_currentParent = oldParent;
        }
Exemple #18
0
        public override void VisitWhileStatement(WhileStatementSyntax node)
        {
            var whileObj = CSharpEntityCreationHelper.CreateWhileBlock(node, m_currentParent, m_currentCodeFile, m_currentTree);

            ISyntaxEntity oldParent = setCurrentParent(whileObj);

            base.VisitWhileStatement(node);
            m_currentParent = oldParent;
        }
Exemple #19
0
        public override void VisitCatchClause(CatchClauseSyntax node)
        {
            var catchObj = CSharpEntityCreationHelper.CreateCatchBlock(node, m_currentParent, m_currentCodeFile, m_currentTree);

            ISyntaxEntity oldParent = setCurrentParent(catchObj);

            base.VisitCatchClause(node);
            m_currentParent = oldParent;
        }
Exemple #20
0
        public override void VisitElseClause(ElseClauseSyntax node)
        {
            var elseObj = CSharpEntityCreationHelper.CreateElseBlock(node, m_currentParent, m_currentCodeFile, m_currentTree);

            ISyntaxEntity oldParent = setCurrentParent(elseObj);

            base.VisitElseClause(node);
            m_currentParent = oldParent;
        }
Exemple #21
0
        internal static UserDefinedType CreateEnum(BaseTypeDeclarationSyntax node, ISyntaxEntity parent, CodeFile currentCodeFile, SyntaxTree tree)
        {
            UserDefinedType typeObj = new Entities.UDT.EnumDefinition(node.Identifier.Text, new FileSpan(tree.GetLineSpan(node.Span)), parent, currentCodeFile);

            processModifiers(typeObj, node.Modifiers);
            typeObj.AccessSpecifiers  = typeObj.AccessSpecifiers == AccessSpecifiers.None ? AccessSpecifiers.Internal : typeObj.AccessSpecifiers;
            typeObj.AssociatedComment = GetComment(typeObj, node, tree, currentCodeFile);

            return(typeObj);
        }
 protected void VisitChildren(ISyntaxEntity entity)
 {
     if (entity != null && entity.Children != null)
     {
         foreach (ISyntaxEntity child in entity.Children)
         {
             child.AcceptVisitor(this);
         }
     }
 }
Exemple #23
0
        internal static MemberProperty CreateProperty(IndexerDeclarationSyntax node, ISyntaxEntity parent, CodeFile codeFile, SyntaxTree tree)
        {
            MemberProperty p = new MemberProperty("", new FileSpan(tree.GetLineSpan(node.Span)), parent, codeFile);

            p.PropertyType      = node.Type.ToString();
            p.IsIndexer         = true;
            p.AssociatedComment = GetComment(p, node, tree, codeFile);

            return(p);
        }
        public override bool Walk(PythonAst ast)
        {
            if (ast == null)
            {
                return(false);
            }

            m_currentCodeFile = new CodeFile("Python", new FileSpan(ast.Start.Line, ast.Start.Column, ast.End.Line, ast.End.Column), new Python());
            m_currentParent   = m_currentCodeFile;
            return(true);
        }
Exemple #25
0
        public override void VisitConversionOperatorDeclaration(ConversionOperatorDeclarationSyntax node)
        {
            var methodObj = CSharpEntityCreationHelper.CreateMethod(node, m_currentParent, m_currentCodeFile, m_currentTree);

            Debug.Assert(methodObj.TypeOfFunction == FunctionTypes.ConversionOperator);

            ISyntaxEntity oldParent = setCurrentParent(methodObj);

            base.VisitConversionOperatorDeclaration(node);
            m_currentParent = oldParent;
        }
        /// <summary>
        /// This function overrides the behavior when the current node being walked is a ClassDefinition
        /// </summary>
        /// <param name="node"> the ClassDefinition node</param>
        /// <returns> boolean value. not important for this implementation. it is handeled by a call to the base Walk() method.</returns>
        public override bool Walk(IronPython.Compiler.Ast.ClassDefinition node)
        {
            UserDefinedType udt = PythonEntityCreationHelper.createClassUDT(node, m_currentCodeFile, m_currentParent);

            m_currentParent.AddChild(udt);
            udt.Parent = m_currentParent;
            m_savedParents.Push(m_currentParent);
            m_currentParent = udt;

            return(true);
        }
 public override void PostWalk(IronPython.Compiler.Ast.FunctionDefinition node)
 {
     if (node == null)
     {
         return;
     }
     Trace.TraceInformation("in postWalk(FunctionDefinition node) for node " + node.Name);
     m_currentParent = m_savedParents.Pop();
     Trace.TraceInformation("restored m_currentParent to " + m_currentParent.Name);
     base.PostWalk(node);
 }
Exemple #28
0
        public override void VisitIndexerDeclaration(IndexerDeclarationSyntax node)
        {
            var prop = CSharpEntityCreationHelper.CreateProperty(node, m_currentParent, m_currentCodeFile, m_currentTree);

            Debug.Assert(prop.IsIndexer);

            ISyntaxEntity oldParent = setCurrentParent(prop);

            base.VisitIndexerDeclaration(node);
            m_currentParent = oldParent;
        }
Exemple #29
0
        private ISyntaxEntity setCurrentParent(ISyntaxEntity obj)
        {
            m_currentParent.AddChild(obj);
            (obj as AbstractSyntaxEntity).Parent = m_currentParent;

            ISyntaxEntity savedParent = m_currentParent;

            m_currentParent = obj;

            return(savedParent);
        }
Exemple #30
0
        public override void VisitAnonymousMethodExpression(AnonymousMethodExpressionSyntax node)
        {
            var methodObj = CSharpEntityCreationHelper.CreateMethod(node, m_currentParent, m_currentCodeFile, m_currentTree);

            Debug.Assert(methodObj.TypeOfFunction == FunctionTypes.AnonymousDelegate);

            ISyntaxEntity oldParent = setCurrentParent(methodObj);

            base.VisitAnonymousMethodExpression(node);
            m_currentParent = oldParent;
        }