VcsUtil.getVcsFor return null

已回答

I want to get abstractVcs when user view at  git log tab.

I can not get vcs info.

VcsUtil.getVcsFor(project, virtualFile)




if user view at editor,can get vcs info well.


I am writing a plugin which recored bookmark and annotate author.

0

`VirtualFile` that is shown in diff viewer does not belong to LocalFileSystem.
`VcsUtil.getVcsFor(project, virtualFile)` returns `null` for such files, as they are not under VCS (ex: you can't change & commit them).

What do you need this `AbstractVcs` for?

0
Avatar
Permanently deleted user

I need the right line's annotate info in the diff viewer

 

0

There are no handy API to get this info.

You can take a look at implementation of `com.intellij.openapi.vcs.actions.AnnotateDiffViewerAction`. Notably, `collectEventData` and `createTwosideAnnotationsLoader` methods.
`BookmarksListener` has no Editor in context (and single `VirtualFile`/`Document` might be shown multiple times). See `com.intellij.openapi.editor.EditorFactory#getEditors(Document)` that returns all editors for a file.
See also `com.intellij.ide.DataManager#getDataContext(Component)` to get DataContext for specific Editor.

Note, that you might want to use GitHandler directly (ex: performing a request like `git log -n 1 -L 123,123:file-path.txt`) instead of `AnnotationProvider`, as this request might be faster than loading annotations.

0
Avatar
Permanently deleted user

I will has a try to execute git shell command

0
Avatar
Permanently deleted user

How to get the right view revision number or commit number?

I decide to use git handler command to get annotate info 

 

0

Since I already wasted my time on this, I'll put my solution here:

It needs a change in IntelliJ: https://github.com/JetBrains/intellij-community/compare/192...krasa:diffRevision

Then it would probably be possible to go Bookmark->VirtualFile -> Document-> Editor-> DocumentContent-> revision (if null then it is the current one)

0
Avatar
Permanently deleted user

you should submit the pull request.

and if pr is accepted, I need wait idea release new version?

0

No, you should, after you try that it is really what you need. :)

And yes.

 

0

请先登录再写评论。