コード例 #1
0
        public List <SyntaxNode> GetSyntaxNodesFromClass(ClassDeclarationSyntax node, TaggedSyntaxLibrary lib)
        {
            List <SyntaxNode> nodes       = new List <SyntaxNode>();
            INamedTypeSymbol  classSymbol = this.symbolHelper.GetSymbol(node) as INamedTypeSymbol;

            if (classSymbol != null)
            {
                List <ISymbol>   symbols  = new List <ISymbol>();
                INamedTypeSymbol baseType = classSymbol.BaseType;
                if (baseType != null)
                {
                    symbols.Add(baseType);
                }

                ImmutableArray <INamedTypeSymbol> interfaces = classSymbol.Interfaces;
                if (interfaces != null && interfaces.Count() > 0)
                {
                    foreach (INamedTypeSymbol inter in interfaces)
                    {
                        if (inter != null)
                        {
                            symbols.Add(inter);
                        }
                    }
                }

                // check for override methods
                List <IMethodSymbol> oMethods = this.getOverrideMethodSymbolsFromClass(node);
                if (oMethods != null && oMethods.Count() > 0)
                {
                    foreach (IMethodSymbol oMethod in oMethods)
                    {
                        IMethodSymbol overridden = oMethod.OverriddenMethod;
                        if (overridden != null)
                        {
                            List <SyntaxNode> oNodes = ScriptAnalyzerResourceHelper.GetSyntaxNodesFromSymbol(overridden);
                            if (oNodes != null && oNodes.Count() > 0)
                            {
                                MethodDeclarationSyntax oNode = oNodes.First() as MethodDeclarationSyntax;
                                if (oNode != null)
                                {
                                    TaggedSyntaxTree tTree = lib.GetTreeFromNode(oNode);
                                    if (tTree != null && tTree.IsTagged(oNode))
                                    {
                                        symbols.Add(oMethod);
                                    }
                                }
                            }
                        }
                    }
                }

                nodes = ScriptAnalyzerResourceHelper.GetSyntaxNodesFromSymbols(symbols);
            }

            return(nodes);
        }
コード例 #2
0
        public List <SyntaxNode> GetSyntaxNodesFromIdentifier(IdentifierNameSyntax node)
        {
            List <SyntaxNode> nodes  = new List <SyntaxNode>();
            ISymbol           symbol = this.SymbolHelper.GetSymbolInfo(node).Symbol;

            if (symbol != null)
            {
                nodes = ScriptAnalyzerResourceHelper.GetSyntaxNodesFromSymbol(symbol);
            }
            return(nodes);
        }
コード例 #3
0
        public List <SyntaxNode> GetSyntaxNodesFromObjectCreation(ObjectCreationExpressionSyntax node)
        {
            List <SyntaxNode> nodes  = new List <SyntaxNode>();
            ISymbol           symbol = this.SymbolHelper.GetSymbolInfo(node).Symbol;

            if (symbol != null)
            {
                nodes = ScriptAnalyzerResourceHelper.GetSyntaxNodesFromSymbol(symbol);
            }
            return(nodes);
        }
コード例 #4
0
        public List <SyntaxNode> GetSyntaxNodesFromConstructorInitializer(ConstructorInitializerSyntax node)
        {
            List <SyntaxNode> nodes  = new List <SyntaxNode>();
            ISymbol           symbol = this.symbolHelper.GetSymbolInfo(node).Symbol;

            if (symbol != null)
            {
                nodes = ScriptAnalyzerResourceHelper.GetSyntaxNodesFromSymbol(symbol);
            }
            return(nodes);
        }
コード例 #5
0
ファイル: ProjectAnalyzer.cs プロジェクト: susu/SEVSTools
        private ScriptAnalyzer createScriptAnalyzer(Project project)
        {
            ScriptAnalyzer     result = null;
            List <Compilation> comps  = this.getCompilations(project);

            if (comps != null && comps.Count() > 0)
            {
                ScriptAnalyzerSymbolHelper   sHelper = new ScriptAnalyzerSymbolHelper(comps.ToArray());
                ScriptAnalyzerResourceHelper rHelper = new ScriptAnalyzerResourceHelper(sHelper);
                result = new ScriptAnalyzer(rHelper);
            }

            return(result);
        }
コード例 #6
0
        public List <SyntaxNode> GetSyntaxNodesFromInvocation(InvocationExpressionSyntax node)
        {
            List <SyntaxNode> nodes   = new List <SyntaxNode>();
            List <ISymbol>    symbols = new List <ISymbol>();

            // function
            if (node.Expression != null)
            {
                ISymbol symbol = this.symbolHelper.GetSymbolInfo(node.Expression).Symbol;
                if (symbol != null)
                {
                    symbols.Add(symbol);
                }
            }

            nodes = ScriptAnalyzerResourceHelper.GetSyntaxNodesFromSymbols(symbols);
            return(nodes);
        }
コード例 #7
0
        public static List <SyntaxNode> GetSyntaxNodesFromSymbols(List <ISymbol> symbols)
        {
            List <SyntaxNode> nodes = new List <SyntaxNode>();

            if (symbols != null && symbols.Count() > 0)
            {
                // filter duplicate symbols
                symbols = ScriptAnalyzerResourceHelper.filterSymbols(symbols);
                foreach (ISymbol symbol in symbols)
                {
                    List <SyntaxNode> newNodes = ScriptAnalyzerResourceHelper.GetSyntaxNodesFromSymbol(symbol);
                    if (newNodes.Count() > 0)
                    {
                        nodes.AddRange(newNodes);
                    }
                }
            }
            return(nodes);
        }
コード例 #8
0
        public List <SyntaxNode> GetSyntaxNodesFromMethod(MethodDeclarationSyntax node, TaggedSyntaxLibrary lib)
        {
            List <SyntaxNode> nodes  = new List <SyntaxNode>();
            IMethodSymbol     symbol = this.symbolHelper.GetSymbol(node) as IMethodSymbol;

            if (symbol != null)
            {
                List <ISymbol> symbols = new List <ISymbol>();
                if (symbol.IsOverride)
                {
                    symbols.Add(symbol.OverriddenMethod);
                }
                if (symbol.IsVirtual)
                {
                    List <ISymbol> mSymbols = this.GetSymbolsFromVirtualFunction(symbol, lib).Select(s => s as ISymbol).ToList();
                    symbols.AddRange(mSymbols);
                }
                // return type
                ITypeSymbol returnType = symbol.ReturnType;
                if (returnType != null)
                {
                    symbols.Add(returnType);
                }

                // parameters
                ImmutableArray <IParameterSymbol> parameterList = symbol.Parameters;
                if (parameterList != null && parameterList.Count() > 0)
                {
                    foreach (IParameterSymbol param in parameterList)
                    {
                        if (param != null && param.Type != null)
                        {
                            symbols.Add(param.Type);
                        }
                    }
                }
                nodes = ScriptAnalyzerResourceHelper.GetSyntaxNodesFromSymbols(symbols);
            }

            return(nodes);
        }
コード例 #9
0
ファイル: ScriptAnalyzer.cs プロジェクト: susu/SEVSTools
 public ScriptAnalyzer(ScriptAnalyzerResourceHelper rHelper)
 {
     this.resourceHelper = rHelper;
 }