Пример #1
0
        public Task <CodeLensDetailsDescriptor> GetDetailsAsync(CodeLensDescriptorContext descriptorContext, CancellationToken token)
        {
            var args = new CodeLensCopyLinkResult
            {
                ApplicableSpan = descriptorContext.ApplicableSpan.GetValueOrDefault()
            };

            var response = new CodeLensDetailsDescriptor
            {
                Headers = new List <CodeLensDetailHeaderDescriptor>(),
                Entries = new List <CodeLensDetailEntryDescriptor>(),
                PaneNavigationCommands = new List <CodeLensDetailPaneCommand>(),
                CustomData             = new List <CodeLensCopyLinkResult> {
                    args
                }
            };

            return(Task.FromResult(response));
        }
Пример #2
0
        public async Task <CodeLensDetailsDescriptor> GetDetailsAsync(CodeLensDescriptorContext context, CancellationToken token)
        {
            try
            {
                // When opening the details pane, the data point is re-created leaving `data` uninitialized. VS will
                // then call `GetDataAsync()` and `GetDetailsAsync()` concurrently.
                if (!_dataHasLoaded.Wait(timeout: TimeSpan.FromSeconds(.5), token))
                {
                    _bindings = await GetReferenceSetAsync(context, token);
                }

                var result = new CodeLensDetailsDescriptor()
                {
                    Headers    = CreateHeaders(),
                    Entries    = CreateEntries(),
                    CustomData =
                        _bindings != null
                            ? new List <object>()
                    {
                        _bindings
                    }
                            : new List <object>(),
                    PaneNavigationCommands = new List <CodeLensDetailPaneCommand>()
                    {
                        //new CodeLensDetailPaneCommand
                        //{
                        //    CommandDisplayName = "Add binding...",
                        //    CommandId = _addBindingCommandId,
                        //    CommandArgs = new object[] { /*(object)id*/ }
                        //}
                    },
                };

                return(result);
            }
            catch (Exception ex)
            {
                LogCL(ex);
                throw;
            }
        }
            public Task <CodeLensDetailsDescriptor> GetDetailsAsync(CodeLensDescriptorContext context, CancellationToken token)
            {
                // get the most recent 5 commits
                var commits = GitUtil.GetCommits(this.gitRepo, this.descriptor.FilePath, 5).AsEnumerable();

                if (commits == null || commits.Count() == 0)
                {
                    return(Task.FromResult <CodeLensDetailsDescriptor>(null));
                }

                var firstCommit = commits.First();
                var result      = new CodeLensDetailsDescriptor()
                {
                    Headers    = CreateHeaders(),
                    Entries    = CreateEntries(commits),
                    CustomData = new List <GitCommitCustomDetailsData>()
                    {
                        new GitCommitCustomDetailsData()
                        {
                            CommitDescription = firstCommit.Message,
                            CommitAuthor      = firstCommit.Author.Name,
                            CommitSha         = firstCommit.Sha
                        }
                    },
                    PaneNavigationCommands = new List <CodeLensDetailPaneCommand>()
                    {
                        new CodeLensDetailPaneCommand()
                        {
                            CommandId = new CodeLensDetailEntryCommand()
                            {
                                CommandSet  = new Guid("57735D06-C920-4415-A2E0-7D6E6FBDFA99"),
                                CommandId   = 0x1005,
                                CommandName = "Git.ShowHistory",
                            },
                            CommandDisplayName = "Show History"
                        }
                    },
                };

                return(Task.FromResult(result));
            }
Пример #4
0
            public Task <CodeLensDetailsDescriptor> GetDetailsAsync(CodeLensDescriptorContext context, CancellationToken token)
            {
                // get the most recent 5 commits
                var commits = GitUtil.GetCommits(this.gitRepo, this.descriptor.FilePath, 5).AsEnumerable();

                if (commits == null || commits.Count() == 0)
                {
                    return(Task.FromResult <CodeLensDetailsDescriptor>(null));
                }

                var headers = new List <CodeLensDetailHeaderDescriptor>()
                {
                    new CodeLensDetailHeaderDescriptor()
                    {
                        UniqueName = "CommitType",
                        Width      = 22,
                    },
                    new CodeLensDetailHeaderDescriptor()
                    {
                        UniqueName  = "CommitId",
                        DisplayName = "Commit Id",
                        Width       = 100, // fixed width
                    },
                    new CodeLensDetailHeaderDescriptor()
                    {
                        UniqueName  = "CommitDescription",
                        DisplayName = "Description",
                        Width       = 0.66666, // use 2/3 of the remaining width
                    },
                    new CodeLensDetailHeaderDescriptor()
                    {
                        UniqueName  = "CommitAuthor",
                        DisplayName = "Author",
                        Width       = 0.33333, // use 1/3 of the remaining width
                    },
                    new CodeLensDetailHeaderDescriptor()
                    {
                        UniqueName  = "CommitDate",
                        DisplayName = "Date",
                        Width       = 85, // fixed width
                    }
                };

                var entries = commits.Select(
                    commit => new CodeLensDetailEntryDescriptor()
                {
                    Fields = new List <CodeLensDetailEntryField>()
                    {
                        new CodeLensDetailEntryField()
                        {
                            ImageId = GetCommitTypeIcon(commit),
                        },
                        new CodeLensDetailEntryField()
                        {
                            Text = commit.Id.Sha.Substring(0, 8),
                        },
                        new CodeLensDetailEntryField()
                        {
                            Text = commit.MessageShort,
                        },
                        new CodeLensDetailEntryField()
                        {
                            Text = commit.Author.Name,
                        },
                        new CodeLensDetailEntryField()
                        {
                            Text = commit.Author.When.ToString(@"MM\/dd\/yyyy", CultureInfo.CurrentCulture),
                        },
                    },
                    Tooltip           = commit.Message,
                    NavigationCommand = new CodeLensDetailEntryCommand()
                    {
                        CommandSet  = new Guid("f3cb9f10-281b-444f-a14e-de5de36177cd"),
                        CommandId   = 0x0100,
                        CommandName = "Git.NavigateToCommit",
                    },
                    NavigationCommandArgs = new List <object>()
                    {
                        commit.Id.Sha
                    },
                });

                var result = new CodeLensDetailsDescriptor()
                {
                    Headers = headers,
                    Entries = entries,
                    PaneNavigationCommands = new List <CodeLensDetailPaneCommand>()
                    {
                        new CodeLensDetailPaneCommand()
                        {
                            CommandId = new CodeLensDetailEntryCommand()
                            {
                                CommandSet  = new Guid("57735D06-C920-4415-A2E0-7D6E6FBDFA99"),
                                CommandId   = 0x1005,
                                CommandName = "Git.ShowHistory",
                            },
                            CommandDisplayName = "Show History"
                        }
                    },
                };

                return(Task.FromResult(result));
            }
Пример #5
0
            public Task <CodeLensDetailsDescriptor> GetDetailsAsync(CodeLensDescriptorContext context, CancellationToken token)
            {
                // get the most recent 5 commits
                var commits = HelixUtility.GetCommits(this.rep, this.descriptor.FilePath, 5).AsEnumerable();

                if (commits == null || commits.Count() == 0)
                {
                    return(Task.FromResult <CodeLensDetailsDescriptor>(null));
                }

                var headers = new List <CodeLensDetailHeaderDescriptor>()
                {
                    new CodeLensDetailHeaderDescriptor()
                    {
                        UniqueName = "CommitType",
                        Width      = 22,
                    },
                    new CodeLensDetailHeaderDescriptor()
                    {
                        UniqueName  = "Changelist",
                        DisplayName = "Changelist",
                        Width       = 100, // fixed width
                    },
                    new CodeLensDetailHeaderDescriptor()
                    {
                        UniqueName  = "CommitDescription",
                        DisplayName = "Description",
                        Width       = 0.66666, // use 2/3 of the remaining width
                    },
                    new CodeLensDetailHeaderDescriptor()
                    {
                        UniqueName  = "CommitAuthor",
                        DisplayName = "Author",
                        Width       = 0.33333, // use 1/3 of the remaining width
                    },
                    new CodeLensDetailHeaderDescriptor()
                    {
                        UniqueName  = "CommitDate",
                        DisplayName = "Date",
                        Width       = 85, // fixed width
                    }
                };

                var entries = commits.Select(
                    commit => new CodeLensDetailEntryDescriptor()
                {
                    Fields = new List <CodeLensDetailEntryField>()
                    {
                        new CodeLensDetailEntryField()
                        {
                            ImageId = GetCommitTypeIcon(commit),
                        },
                        new CodeLensDetailEntryField()
                        {
                            Text = commit.Id.ToString(),    //commit.Id.Sha.Substring(0, 8),
                        },
                        new CodeLensDetailEntryField()
                        {
                            Text = commit.Description.Length > 50 ?
                                   commit.Description.Replace(System.Environment.NewLine, " ").Substring(0, 50) + "..." :
                                   commit.Description.Replace(System.Environment.NewLine, " "),//commit.MessageShort,
                        },
                        new CodeLensDetailEntryField()
                        {
                            Text = commit.OwnerName,    //commit.Author.Name,
                        },
                        new CodeLensDetailEntryField()
                        {
                            Text = commit.ModifiedDate.ToString(@"MM\/dd\/yyyy", CultureInfo.CurrentCulture),    //commit.Author.When.ToString(@"MM\/dd\/yyyy", CultureInfo.CurrentCulture),
                        },
                    },
                    Tooltip           = commit.Description,//commit.Message,
                    NavigationCommand = new CodeLensDetailEntryCommand()
                    {
                        CommandSet  = new Guid("f3cb9f10-281b-444f-a14e-de5de36177cd"),
                        CommandId   = 0x0100,
                        CommandName = "Helix.NavigateToChangelist",
                    },
                    //NavigationCommandArgs = new List<object>() { commit.Id.Sha },
                    NavigationCommandArgs = new List <object>()
                    {
                        commit.Id.ToString()
                    },
                });

                var result = new CodeLensDetailsDescriptor();

                result.Headers = headers;
                result.Entries = entries;
                List <CodeLensDetailPaneCommand> PaneNavigationCommands = new List <CodeLensDetailPaneCommand>();

                CodeLensDetailPaneCommand historyCmd = new CodeLensDetailPaneCommand();

                historyCmd.CommandId             = new CodeLensDetailEntryCommand();
                historyCmd.CommandId.CommandSet  = new Guid("f3cb9f10-281b-444f-a14e-de5de36177cd");
                historyCmd.CommandId.CommandId   = 0x1005;
                historyCmd.CommandId.CommandName = "Helix.ShowHistory";
                historyCmd.CommandDisplayName    = "Show History";
                PaneNavigationCommands.Add(historyCmd);
                if (timelapseExists())
                {
                    CodeLensDetailPaneCommand timeLapseViewCmd = new CodeLensDetailPaneCommand();
                    timeLapseViewCmd.CommandId             = new CodeLensDetailEntryCommand();
                    timeLapseViewCmd.CommandId.CommandSet  = new Guid("f3cb9f10-281b-444f-a14e-de5de36177cd");
                    timeLapseViewCmd.CommandId.CommandId   = 0x1010;
                    timeLapseViewCmd.CommandId.CommandName = "Helix.TimeLapseView";
                    timeLapseViewCmd.CommandDisplayName    = "Time-lapse View";
                    timeLapseViewCmd.CommandArgs           = new List <object>()
                    {
                        this.descriptor.FilePath
                    };
                    PaneNavigationCommands.Add(timeLapseViewCmd);
                }

                result.PaneNavigationCommands = PaneNavigationCommands;
                return(Task.FromResult(result));
            }