private static IOccurence GetOccurence(FileLocationInfo location, bool bindToPsi) { var projectFile = location.ProjectFile; if (bindToPsi) { var sourceFile = projectFile.ToSourceFile(); if (sourceFile != null) { DeclaredElementEnvoy <INamespace> boundNamespace; DeclaredElementEnvoy <ITypeElement> boundTypeElement; DeclaredElementEnvoy <ITypeMember> boundTypeMember; TextControlToPsi.BindToPsi(sourceFile, new TextRange(location.CaretOffset), out boundTypeMember, out boundTypeElement, out boundNamespace); if (boundTypeMember != null || boundTypeElement != null) { var declaredElement = ((IDeclaredElementEnvoy)boundTypeMember ?? boundTypeElement).GetValidDeclaredElement(); if (declaredElement != null) { return(new CustomRangeOccurence(sourceFile, new DocumentRange(sourceFile.Document, new TextRange(location.CaretOffset)), new OccurencePresentationOptions { ContainerStyle = ContainerDisplayStyle.File })); } } } } //project file can loose its owner project (i.e. micsFilesProject) during provision tab navigation if (projectFile.GetProject() == null) { return(new DecompiledFileOccurence(location.FileSystemPath, new TextRange(location.CaretOffset), location.CachedPresentation, projectFile.GetSolution())); } if (projectFile.IsValid()) { return(new ProjectItemOccurence(projectFile, new OccurencePresentationOptions { ContainerStyle = ContainerDisplayStyle.NoContainer })); } return(null); }