Scroll from Source action customization

已回答

Similar question to https://intellij-support.jetbrains.com/hc/en-us/community/posts/360002682719-Scroll-from-Source-action-customization .

Is it possible to listen to the action of "Scroll from Source" /  "Select Opened File"?

I would like to create a plugin with the following tasks:

  • listen to "Scroll from Source" or similar approache
  • resolve paths with "custom resolver" (based on the opened file path)
  • search these paths in every open project and open the file "synchronously" or
  • ask the user to create such a file with or without the same content
0

"Select Opened File" action is handled by the 

ProjectPaneSelectInTarget.select(PsiElement element, boolean requestFocus)

This class implements SelectInTarget which is used by the selectInTarget Extension Point, but in this case, it is dynamically created by the ProjectViewPane.

You may create an EP that extends that class and overrides createSelectInTarget method:

<extensions defaultExtensionNs="com.intellij">
<projectViewPane implementation="MyProjectViewPane"/>
</extensions>
class MyProjectViewPane extends ProjectViewPane {
public MyProjectViewPane(Project project) {
super(project);
}

@NotNull
@Override
public SelectInTarget createSelectInTarget() {
return new ProjectPaneSelectInTarget(myProject) {
@Override
public void select(PsiElement element, boolean requestFocus) {
super.select(element, requestFocus);
// catch selection event
}
};
}
}
0

请先登录再写评论。