public static string GetGameObjectName(IBuffer buffer) { var start = ourGameObjectNameSearcher.Find(buffer, 0, buffer.Length); if (start < 0) { return(null); } var eol = ourEndLineSearcher.Find(buffer, start, buffer.Length); if (eol < 0) { eol = ourEndLine2Searcher.Find(buffer, start, buffer.Length); } if (eol < 0) { return(null); } var nameBuffer = ProjectedBuffer.Create(buffer, new TextRange(start, eol + 1)); var lexer = new YamlLexer(nameBuffer, false, false); var parser = new YamlParser(lexer.ToCachingLexer()); var document = parser.ParseDocument(); return((document.Body.BlockNode as IBlockMappingNode)?.Entries.FirstOrDefault()?.Content.Value .GetPlainScalarText()); }
public static IHierarchyReference GetReferenceBySearcher(IPsiSourceFile assetSourceFile, IBuffer assetDocumentBuffer, StringSearcher searcher) { var start = searcher.Find(assetDocumentBuffer, 0, assetDocumentBuffer.Length); if (start < 0) { return(null); } var end = ourBracketSearcher.Find(assetDocumentBuffer, start, assetDocumentBuffer.Length); if (end < 0) { return(null); } var buffer = ProjectedBuffer.Create(assetDocumentBuffer, new TextRange(start, end + 1)); var lexer = new YamlLexer(buffer, false, false); var parser = new YamlParser(lexer.ToCachingLexer()); var document = parser.ParseDocument(); return((document.Body.BlockNode as IBlockMappingNode)?.Entries.FirstOrDefault()?.Content.Value.ToHierarchyReference(assetSourceFile)); }