public static MetadataFile Read(SourceFile File) { MetadataFile Result; if(!FileMap.TryGetValue(File, out Result)) { Result = new MetadataFile(File); FileMap.Add(File, Result); } return Result; }
public MetadataDirective(SourceFile InFile, int InIndex, int InEndIndex, int InDefinitionIndex, List<MetadataNode> InNodeList) { File = InFile; Index = InIndex; EndIndex = InEndIndex; DefinitionIndex = InDefinitionIndex; NodeList = InNodeList; Type = File.Tokens[Index].ToString(); Dictionary<string, int> TagsForType; if(!AllTags.TryGetValue(Type, out TagsForType)) { TagsForType = new Dictionary<string, int>(); AllTags.Add(Type, TagsForType); } foreach(MetadataNode Node in NodeList) { int Count = 0; if(TagsForType.TryGetValue(Node.TagText, out Count)) { Count++; } TagsForType[Node.TagText] = Count; } }
public static MetadataDirective TryParseDirective(SourceFile File, SourceToken[] Tokens, int Index) { string TagText = Tokens[Index].Text; if(TagText == "UCLASS" || TagText == "UPROPERTY" || TagText == "UENUM" || TagText == "USTRUCT" || TagText == "UFUNCTION") { int DirectiveIndex = Index++; List<MetadataNode> NodeList = TryParseNodeList(Tokens, ref Index); if(NodeList != null) { // Save the end of the metadata, and the start of the definition int DirectiveEndIndex = Index; // Depending on the type, parse a definition int DefinitionIndex = Index; if(TagText == "UCLASS" || TagText == "USTRUCT" || TagText == "UENUM") { for(; Index < Tokens.Length && Tokens[Index].Text != ";"; Index++) { if(Tokens[Index].Text == "{") { DefinitionIndex = Index + 1; break; } } } // Create the definition return new MetadataDirective(File, DirectiveIndex, DirectiveEndIndex, DefinitionIndex, NodeList); } } return null; }
public SourceTokenRef(SourceFile InFile, int InIndex) { File = InFile; Index = InIndex; }
public MetadataFile(SourceFile InSourceFile) { // Set the file SourceFile = InSourceFile; // Parse the directives SourceToken[] Tokens = SourceFile.Tokens; for (int Line = 0; Line + 1 < SourceFile.LineToToken.Length; Line++) { int Index = SourceFile.LineToToken[Line]; if (Index != SourceFile.LineToToken[Line + 1]) { MetadataDirective Directive = TryParseDirective(SourceFile, Tokens, Index); if(Directive != null) { Directives.Add(Directive); } } } }
public static SourceFile Read(string InPath) { string FullPath = Path.GetFullPath(InPath); SourceFile Result = null; if (!Files.TryGetValue(FullPath, out Result) && File.Exists(FullPath)) { string Text = File.ReadAllText(FullPath); Result = new SourceFile(FullPath, Text); Files.Add(FullPath, Result); } return Result; }
public SourceToken(SourceFile InFile, int InOffset, int InLength) { File = InFile; Offset = InOffset; Length = InLength; }
public static MetadataFile Read(string Path) { SourceFile File = SourceFileCache.Read(Path); return((File == null)? null : Read(File)); }