Theia: Execute some codes on save or save all

Created on 13 Jun 2019  路  4Comments  路  Source: eclipse-theia/theia

Maybe it's not a issue, more need some guides.
I'm new to Theia ide and want to get the whole or just changed document content while user click save or save all. Someone can give some hints about how to implement, thank you.

BTW: Theia version is 0.7.1.

question

Most helpful comment

  1. I have some confusion between 'open...' and 'open workspace...' items in 'File' menu, what's the difference? In frontend ui, both trigger open folders dialog, I don't know whether the backend implementation differs, could you explain a little bit.

The Open Workspace menu item in the File top-level menu is mainly used for multiple-root workspaces. It is used to select a *.theia-workspace or *.code-workspace file. When multi-root is
not enabled (preference "workspace.supportMultiRootWorkspace"), the two items behave similarly.

  1. If I wanna retrieve all file contents in a workspace, do you have some suggestions , I have found a "WorkspaceService" interface, there including workspace attribute or roots method pointing to the folder and files, don't know if it's the appropriate way.

The WorkspaceService can definitely be used to retrieve the workspace's root(s).
From there you can most likely use the filesystem functionality to gather all it's contents.

All 4 comments

Do you write Theia or VS Code extension?

@akosyakov Thanks for your help, using onWillSaveTextDocument works! 2 more questions:

  1. I have some confusion between 'open...' and 'open workspace...' items in 'File' menu, what's the difference? In frontend ui, both trigger open folders dialog, I don't know whether the backend implementation differs, could you explain a little bit.
  2. If I wanna retrieve all file contents in a workspace, do you have some suggestions , I have found a "WorkspaceService" interface, there including workspace attribute or roots method pointing to the folder and files, don't know if it's the appropriate way.
  1. I have some confusion between 'open...' and 'open workspace...' items in 'File' menu, what's the difference? In frontend ui, both trigger open folders dialog, I don't know whether the backend implementation differs, could you explain a little bit.

The Open Workspace menu item in the File top-level menu is mainly used for multiple-root workspaces. It is used to select a *.theia-workspace or *.code-workspace file. When multi-root is
not enabled (preference "workspace.supportMultiRootWorkspace"), the two items behave similarly.

  1. If I wanna retrieve all file contents in a workspace, do you have some suggestions , I have found a "WorkspaceService" interface, there including workspace attribute or roots method pointing to the folder and files, don't know if it's the appropriate way.

The WorkspaceService can definitely be used to retrieve the workspace's root(s).
From there you can most likely use the filesystem functionality to gather all it's contents.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tetchel picture tetchel  路  3Comments

tetchel picture tetchel  路  3Comments

akosyakov picture akosyakov  路  3Comments

cekvenich picture cekvenich  路  3Comments

jeanlucburot picture jeanlucburot  路  3Comments