public CodeStructureRootElement Build(IPsiSourceFile sourceFile, CodeStructureOptions options) { if (!(sourceFile.GetTheOnlyPsiFile(T4Language.Instance) is IT4File t4File)) { return(null); } var cSharpFile = sourceFile.GetTheOnlyPsiFile(CSharpLanguage.Instance) as ICSharpFile; var secondaryRangeTranslator = (cSharpFile as IFileImpl)?.SecondaryRangeTranslator; if (secondaryRangeTranslator == null) { return(null); } var state = new CSharpCodeStructureProcessingState(CodeStructureOptions.Default); var rootElement = new T4CodeStructureRootElement(t4File); foreach (ITreeNode treeNode in t4File.Children()) { ProcessT4Node(treeNode, rootElement, cSharpFile, secondaryRangeTranslator, state); } return(rootElement); }
public CodeStructureRootElement Build(IPsiSourceFile sourceFile, CodeStructureOptions options) { var t4File = sourceFile.GetTheOnlyPsiFile(T4Language.Instance) as IT4File; if (t4File == null) return null; // TODO: handle VB var cSharpFile = sourceFile.GetTheOnlyPsiFile(CSharpLanguage.Instance) as ICSharpFile; var cSharpFileImpl = cSharpFile as IFileImpl; if (cSharpFileImpl == null || cSharpFileImpl.SecondaryRangeTranslator == null) return null; var state = new CSharpCodeStructureProcessingState(CodeStructureOptions.Default); var rootElement = new T4CodeStructureRootElement(t4File); foreach (ITreeNode treeNode in t4File.Children()) ProcessT4Node(treeNode, rootElement, cSharpFile, cSharpFileImpl.SecondaryRangeTranslator, state); return rootElement; }