Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to debug Theia plugin folder #3251

Open
kvbhat opened this issue Oct 23, 2018 · 6 comments
Open

[Question] How to debug Theia plugin folder #3251

kvbhat opened this issue Oct 23, 2018 · 6 comments
Labels
plug-in system issues related to the plug-in system question user / developer questions vscode issues related to VSCode compatibility

Comments

@kvbhat
Copy link
Contributor

kvbhat commented Oct 23, 2018

Hi All,
I would like to contribute and work on plugin-system of theia.

But I'm unable to make the debug setup for the same.

I have followed these setups to debug the ~/theia/packages/plugin-ext/src/plugin/languages/hover.ts file-

  1. Build Theia on VSCode.
  2. From Debug "Launch Backend" Configuration.
  3. From Debug "Launch Frontend" Configuration.
  4. Create a plugin in the launched instance (hello world using the guide from https://www.theia-ide.org/doc/authoring_plugins ) and updated it to use the below code-
import * as theia from '@theia/plugin';

export function start() {
    theia.languages.registerHoverProvider({scheme: 'file'}, {
    provideHover(doc: theia.TextDocument, position: theia.Position) {
        const range = doc.getWordRangeAtPosition(position);
        const text = doc.getText(range);
        return new theia.Hover(text);
    }
    });
}

export function stop() {

}

so that hover.ts source code is called.

  1. Run command "Hosted mode: start instance"

After this step i get the below error-

yarn run v1.7.0
$ /home/kvbhat/git/IDE/theia/node_modules/.bin/theia start --port=3030
module.js:549
    throw err;
    ^
Error: Cannot find module '/home/kvbhat/git/IDE/theia/src-gen/backend/main.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
Done in 0.47s.

Could someone please guide me on how to debug the plugin-system that are being develop for theia?

Update:
If i launch backend via command line and just launch fronted i dont get the above error but then breakpoints in hover.ts are not getting hit even though the hover plugin is activated and called.

Thanks

@kvbhat kvbhat changed the title How to debug Theia plugin folder [Question] How to debug Theia plugin folder Oct 24, 2018
@elaihau
Copy link
Contributor

elaihau commented Feb 7, 2019

i tried the "hosted plugin: debug instance" command, which asks me for the path of the plugin (in my local environment it is theia/plugins/the-plugin-to-debug). And, the command populates a dialog that helps me to open another instance of theia.

however, my break points are not hit either. I tried dropping break point in both theia instances (i.e., the one running on port 3000, and the one on 3030), and neither worked. Could you @benoitf please point us to the wiki that explains how debugging

  • theia plugins, and
  • vsCode extensions as theia plugins
    should work ?

Thank you !

@benoitf
Copy link
Contributor

benoitf commented Feb 7, 2019

@elaihau you're using master branch and examples/browser or a different config ?

@elaihau
Copy link
Contributor

elaihau commented Feb 7, 2019

yes i am on the master branch, using examples/browser

@benoitf
Copy link
Contributor

benoitf commented Feb 7, 2019

@elaihau I made this quick video https://www.youtube.com/watch?v=Kjwovxq38Ms&feature=youtu.be

was trying against a Theia plug-in.

@elaihau
Copy link
Contributor

elaihau commented Feb 7, 2019

Thank you @benoitf !
Following your video I made a GIF to show how to debug a vscode extension as a theia plugin.

debug_vscode_ext

@elaihau elaihau added the question user / developer questions label Feb 7, 2019
@akosyakov
Copy link
Member

akosyakov commented Feb 28, 2019

You can create a node debug launch configuration: #4224 (comment)

In order to debug just press F5:
debug_vscode_ext

Example of debug configuration:

        {
            "name": "Launch VS Code extension",
            "type": "node",
            "request": "launch",
            "port": 9339,
            "timeout": 100000,
            "args": [
                "${workspaceFolder}/examples/browser/src-gen/backend/main.js",
                "${workspaceFolder}",
                "--port=3030",
                "--hosted-plugin-inspect=9339",
                "--plugins=local-dir:${workspaceFolder}/plugins"
            ],
            "stopOnEntry": false,
            "sourceMaps": true,
            "outFiles": [
                "${workspaceFolder}/**/*.js"
            ],
            "internalConsoleOptions": "openOnSessionStart",
            "outputCapture": "std"
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plug-in system issues related to the plug-in system question user / developer questions vscode issues related to VSCode compatibility
Projects
None yet
Development

No branches or pull requests

4 participants