private KeyValuePair <string, UstList <UstNode> > SourceFileToCodeTokens(RootUstNode sourceFile) { var allNodes = new UstList <UstNode>(); allNodes.AddRange(sourceFile.AllInvocationExpressions()); allNodes.AddRange(sourceFile.AllAnnotations()); allNodes.AddRange(sourceFile.AllDeclarationNodes()); allNodes.AddRange(sourceFile.AllStructDeclarations()); allNodes.AddRange(sourceFile.AllEnumDeclarations()); return(KeyValuePair.Create(sourceFile.FileFullPath, allNodes)); }
public static UstNode GetObject(string type) { UstNode ustNode = null; switch (type) { case IdConstants.RootIdName: ustNode = new RootUstNode(); break; case IdConstants.UsingDirectiveIdName: ustNode = new UsingDirective(); break; case IdConstants.NamespaceIdName: ustNode = new NamespaceDeclaration(); break; case IdConstants.ClassIdName: ustNode = new ClassDeclaration(); break; case IdConstants.InterfaceIdName: ustNode = new InterfaceDeclaration(); break; case IdConstants.BodyIdName: ustNode = new BlockStatement(); break; case IdConstants.ObjectCreationIdName: ustNode = new ObjectCreationExpression(); break; case IdConstants.InvocationIdName: ustNode = new InvocationExpression(); break; case IdConstants.LiteralIdName: ustNode = new LiteralExpression(); break; case IdConstants.MethodIdName: ustNode = new MethodDeclaration(); break; default: break; } return(ustNode); }
/// <summary> /// Determines if a syntax tree has any references to objects in a namespace. /// Note: This differs from a UsingDirective, i.e. an unreferenced UsingDirective /// will not be returned here. /// </summary> /// <param name="node">Syntax tree node with reference list</param> /// <param name="referenceIdentifier">Namespace used to identify a reference</param> /// <returns>Whether or not a reference is being used in the syntax tree</returns> public static bool ContainsReference(this RootUstNode node, string referenceIdentifier) => node.References.Any(r => r.Namespace == referenceIdentifier);