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

Make Tern.java to be able to treat a custom project nature as Tern nature #38

Merged

Conversation

vrubezhny
Copy link
Contributor

This will allow Tern.java to be seamlessly integrated to other products.

Other products may declare a custom project nature to be treated as a Tern nature by adding the following extension into some plugin.xml:

<extension 
    point="tern.eclipse.ide.core.ternNatureAdapters"
    id="com.example.product.tern.ternNatureAdapters"
    name="come.example.product.tern.ternNatureAdapters">

    <ternAdaptToNature 
        id = "com.example.product.someNature"
        name = "Some example project nature ID" />
</extension>

Signed-off-by: vrubezhny vrubezhny@exadel.com

…ture.

This will allow Tern.java to be seamlessly integrated to other products.

Signed-off-by: vrubezhny <vrubezhny@exadel.com>
@angelozerr
Copy link
Owner

Victor,it seems very cool! I tell me why you don't use your extension point for JSDT in the project tern.eclipse.ide.jsdt which is a glue between JSDT and Tern?

@vrubezhny
Copy link
Contributor Author

Not sure it's required in JSDT.
Currently we aim to include Tern.java into JBT/JBDS projects, so we want to make such adoption in JBT/JBDS (by making a separate plug-in with definition or by adding that definition to some existing plug-in's plugin.xml).

If we'll add that definition into your plug-in, it will make Tern to work for JSDT's JavaScript nature for any product that includes tern.eclipse.ide.jsdt plug-in, which is probably is not what Product owners may want to have by default. So, IMHO, it shouldn't be defined there by default.

angelozerr added a commit that referenced this pull request Apr 9, 2014
Make Tern.java to be able to treat a custom project nature as Tern nature
@angelozerr angelozerr merged commit 2de9c72 into angelozerr:master Apr 9, 2014
@angelozerr
Copy link
Owner

OK I understand. thank's for your clarification.

@maxandersen
Copy link

Will this patch also make it possible to remove the tern configure action which adds the tern nature ?

The goal here is to avoid putting unnecessary metadata into users projects and clean/remove unnecessary UI.

@vrubezhny
Copy link
Contributor Author

If user project contains that 'replacer' nature that is configured to act instead of Tern's own nature, then yes, no "Convert to Tern project" action should appear.
But this action will appear for any of user projects that have not that 'replacer' nature.

@angelozerr
Copy link
Owner

@vrubezhny I have created a wiki page for tern ide extensions. See https://github.com/angelozerr/tern.java/wiki/Tern-IDE---Extension

Don't hesitate to complete it, thank's!

@maxandersen
Copy link

Which nature will "Convert to tern project" install in this case ? the tern one i guess....since no real way to know which of the others are relevant...not optimal but I guess shuold work.

@vrubezhny
Copy link
Contributor Author

Yes, if we have a replacing nature configured by the extension point there will be no "Convert to Tern project" menu item shown. Otherwise, if we have no such a 'replacer' configured, "Convert..." action will add Tern's own nature.

We can add (or change existing) action handler in order to add that contributed replacing nature to a project, but there could be few additional problems to solve:

  1. In theory, more than one 'replacer' nature could be contributed (if more than one product is installed in Eclipse) - which nature should be added by "Convert..." action handler then?
  2. If we're aiming to modify "Convert..." action handler in order to make it to add that 'replacer' nature instead of the Tern's one, then we should show a correct display name for that 'replacer' nature somehow - we can use 'name' field from element for that purpose (it isn't used at the moment) and we should document it somehow them.

I had two choices when started to develop the extension point: 1) to inject a handler class that checks a project for required natures, or 2) to inject just a nature name and have Tern's code to make all the work. First way is more flexible and we can provide a method to add the required nature(-s) on a project, but this way requires a contributing product to have a dependency on Tern (since we have to implement some of Tern's interfaces for that purpose). The second one doesn't require to maintain any additional dependencies.

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

Successfully merging this pull request may close these issues.

3 participants