- Overview
- Getting Started
- Project Goals
- theia FAQ
- Using the theia IDE
- Getting Started
- Installing VS Code Extensions
- Using AI Features
- theia Coder (AI assistant)
- Using the dynamic Toolbar
- Data Usage & Telemetry
- Download
- Adopting the theia Platform
- Build your own IDE/Tool
- Extending the theia IDE
- Extensions and Plugins
- Authoring theia Extensions
- Authoring VS Code Extensions
- Consuming theia fixes without upgrading
- Platform Concepts & APIs
- Services and Contributions
- Architecture Overview
- Commands/Menus/Keybindings
- Widgets
- Preferences
- theia AI
- Label Provider
- Message Service
- Property View
- Tree Widget
- Events
- Frontend Application Contributions
- Backend Application Contributions
- Communication via JSON-RPC
- Tasks
- Internationalization
- Language Support
- Dynamic Toolbar
- Breadcrumbs
- Enhanced Tab Bar Preview
- Contribution Filter
- Advanced Tips
Advanced Tips
In this section we'll outline some advanced hints and tips to get the most out of developing tools based on Eclipse theia.
Providing custom API to VS Code extensions in Eclipse theia​
theia allows running VS Code extension by providing a compatible API (see this overview for details). It is possible to extend this API to allow VS Code extensions running in theia to access additional functionality compared to when they run within VS Code. This allows you to provide a feature as a VS Code extension targeting VS Code and theia. However, when running in theia, the feature can be enhanced by using custom API only available in theia.
The following code example shows the usage custom API which is invoked only when running in a theia-based application. This is determined via the application name. The API is imported asynchronously to avoid runtime errors in VS Code.
if (vscode.env.appName === MY_THEIA_APP_NAME) {
// Implement theia API
const api = await import('@mytheiaextension/mycustomapi');
// After importing the custom API, it can be used as any other API. The following lines are using an example API.
api.host.getMessageHandler(() => getMessage());
api.host.onRequestMessage((actor: string) => {
const message = getMessage(actor);
api.host.showMessage(message);
});
}
An alternative to providing a custom API is to define custom commands. Again, these commands would only be available if the VS Code extension is running in theia (see following code example).
if (vscode.env.appName === MY_THEIA_APP_NAME) {
// Execute theia custom command
const commands = await vscode.commands.getCommands();
if (commands.indexOf(MY_THEIA_CUSTOM_COMMAND) > -1) {
vscode.commands.executeCommand(MY_THEIA_CUSTOM_COMMAND);
}
}
An example of this technique can be seen here: