public ISelectedRange GetSelectedRange(IPsiSourceFile sourceFile, DocumentRange documentRange) { Pair <IT4File, IFile> pair = GetFiles(sourceFile, documentRange); IT4File t4File = pair.First; IFile codeBehindFile = pair.Second; if (t4File == null) { return(null); } ITreeNode t4Node = t4File.FindNodeAt(documentRange); if (t4Node == null) { return(null); } // if the current selection is inside C# code, use the C# extend selection directly if (codeBehindFile != null) { ISelectEmbracingConstructProvider codeBehindProvider = PsiShared.GetComponent <PsiProjectFileTypeCoordinator>() .GetByPrimaryPsiLanguageType(codeBehindFile.Language) .SelectNotNull(fileType => Shell.Instance.GetComponent <IProjectFileTypeServices>().TryGetService <ISelectEmbracingConstructProvider>(fileType)) .FirstOrDefault(); if (codeBehindProvider != null) { ISelectedRange codeBehindRange = codeBehindProvider.GetSelectedRange(sourceFile, documentRange); if (codeBehindRange != null) { return(new T4CodeBehindWrappedSelection(t4File, codeBehindRange)); } } } return(new T4NodeSelection(t4File, t4Node)); }