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