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

NPE prevents Import > Install Tern Modules wizard initialization #321

Closed
demonfiddler opened this issue Sep 15, 2015 · 4 comments
Closed
Milestone

Comments

@demonfiddler
Copy link
Contributor

For me, the import wizard never actually gets displayed. The error log shows the following exception:

java.lang.NullPointerException
at tern.eclipse.ide.tools.internal.ui.wizards.repository.InstallTernModulesSelectionWizardPage.validate(InstallTernModulesSelectionWizardPage.java:286)
at tern.eclipse.ide.tools.internal.ui.wizards.TernWizardPage.dialogChanged(TernWizardPage.java:80)
at tern.eclipse.ide.tools.internal.ui.wizards.TernWizardPage.createControl(TernWizardPage.java:71)
at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:175)
at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:705)
at org.eclipse.jface.wizard.WizardDialog.setWizard(WizardDialog.java:1153)
at org.eclipse.jface.wizard.WizardDialog.updateForPage(WizardDialog.java:1211)

It would appear that the preceding call at line 285 to InstallTernModulesSelectionWizardPage.modulesBlock.getCheckedModules() returns null as a consequence of having been called prematurely; that is to say, before any call to TernModulesBlock.setCheckedModules(Collection) has been made.

@angelozerr
Copy link
Owner

@demonfiddler this module import is was just a POC. I will fix this bug, but if you wish to have this feature, we need to finalize ternjs/tern#424

@demonfiddler
Copy link
Contributor Author

Thanks for the (very) quick response @angelozerr. I'd seen the #195 thread, which is how I learnt of the wizard's existence. Then I found it in my installed tern-feature.feature.group_1.0.0.201508302102 and tried to use it.

Actually, I'm writing an Eclipse plug-in to add support for a large (2.5 MB) custom library that is generated from XSDs. I found JSDT's content assist somewhat flakey and incomplete and wondered whether Tern Eclipse IDE could do a better job. So I was really looking for an Eclipse extension point by which my Eclipse plug-in could contribute a simple Tern plug-in that loads a JSON module definition (created by condense) - both would be packaged within my Eclipse plug-in. This would avoid requiring the user to configure their IDE manually by downloading the module using your wizard.

[incidental] Anyhow, this all turns out to be largely academic since condense does not emit JSDoc-derived metadata for type members, which from an end-user's perspective is exactly the same limitation as suffered by native JSDT content assist (although for different reasons). See #321 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=333712 respectively.

@angelozerr
Copy link
Owner

So I was really looking for an Eclipse extension point by which my Eclipse plug-in could contribute a simple Tern plug-in that loads a JSON module definition (created by condense) - both would be packaged within my Eclipse plug-in.

Today it doesn't exists this extension point. I would like to do that, please create an issue for that.

This would avoid requiring the user to configure their IDE manually by downloading the module using your wizard.

I understand. If you wish to test your JSON Type Definition inside tern.java, you have 2 choices :

  • copy/paste your JSON Type Definition in your root project and go at JavaScript / Tern / Developement and check "Loading local plugin?". Apply your project preferences and reopen it. You should see your JSON Type Definition in the Tern / Modules. Seelct it adn you should use it.
  • otherwise, go at ternjs folder (in your ECLIPSE_HOME/plugins/ternjs_**) create you a folder tern-myfwk, (like https://github.com/angelozerr/tern.java/tree/master/core/ternjs/node_modules) which must contains myfwk.json, packages.json which define in the main fields your myfwk.json. You can too create a metadata file which brings some informations like icon, description, dependencies, etc. The extension point will update this folder when it will exists.

[incidental] Anyhow, this all turns out to be largely academic since condense does not emit JSDoc-derived metadata for type members, which from an end-user's perspective is exactly the same limitation as suffered by native JSDT content assist (although for different reasons).

I'm writing a JSDoc -> Tern generator that I'm using to generate Phaser. If you wish I could commit my work and explain you how it works, but it's not very clean for the moment. My future idea is to provide this generator inside tern.java.

@demonfiddler
Copy link
Contributor Author

Thanks for your responses and kind offer to commit your generator. I won't trouble you to do this for now, as I need to consult with my management as to whether we'll be taking our efforts any further at this juncture - it's been quite time-consuming and we haven't achieved the results we'd hoped for.

One further thought: the default tern repository currently enumerates Tern modules as children of the node_modules/tern folder within the ternjs Eclipse plug-in. A binary plug-in's installed image should be treated as a read-only location. Eclipse plug-ins have a writable 'state location' (see Plugin.getStateLocation() : IPath), which would be an appropriate place for maintaining user-downloaded modules. So it might be better to aim for a 'composed repository' that presents the contents of several repositories as if they were a single repository. That way, you could still read the built-in modules from the ternjs binary plug-in image, read downloaded custom modules from the plug-in state location, and read additional repositories contributed by 3rd party Eclipse plug-ins via the proposed extension point from within their contributing plug-ins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants