From 9d4415742e17fa3bb2e51450291acc6ecb9912b3 Mon Sep 17 00:00:00 2001 From: Alexander Pann Date: Fri, 12 Jul 2024 21:07:25 +0200 Subject: [PATCH] Add information on how to access the project from a tool window --- src/doc/docs/platform_essentials/accessing_the_project.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/doc/docs/platform_essentials/accessing_the_project.md b/src/doc/docs/platform_essentials/accessing_the_project.md index b203edc4..e0a860f0 100644 --- a/src/doc/docs/platform_essentials/accessing_the_project.md +++ b/src/doc/docs/platform_essentials/accessing_the_project.md @@ -46,6 +46,12 @@ Intentions always have the `editorContext` available and can access the project The project expression is available in tests, although you should only need it when invoking the generator or resolving nodes through the global repository. +### Tool Window + +val dataContext = DataManager.getInstance().getDataContext(toolWindow.component) +val project = MPSDataKeys.PROJECT.getData(dataContext) +val mpsProject = MPSDataKeys.MPS_PROJECT.getData(dataContext) + ### Plugin Solution/Plugin Aspect If you need access to the project object, you can use a project plugin with an MPSProject instance in the init and dispose block. You can pass the instance to other classes as well. To get the IntelliJ project use `#!java ProjectHelper.toIdeaProject(project)`.