Handle file opening

Hi! I am creating plugin for Intellij. Looking for help with handling File and Project opening events.

To clarify my question:
Case for file opening handle in editor: I want to add my custom InlayParameterHintsProvider above each method on file opening. 
Case for project: I want to do some calculus on project opening.

Hope for a quick response, thank you!


File opened listener:

MessageBus bus = project.getMessageBus();
bus.connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {
public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
//your code

Thank you, Brian!
And how can I do something like this on Project opening event?


Create a new class that implements ProjectComponent, register it in the plugin.xml, then put the code you want to run in the constructor.


Please sign in to leave a comment.