Bug 265803 - Add support for multiple natures
Summary: Add support for multiple natures
Status: REOPENED
Alias: None
Product: DLTK
Classification: Technology
Component: Common (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: dltk.common-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-23 05:19 EST by Evgeny V. Chesnokov CLA
Modified: 2018-03-28 16:01 EDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Evgeny V. Chesnokov CLA 2009-02-23 05:19:13 EST
Build ID: I20090202-1535

Steps To Reproduce:
1. Install PDT.
2. Install DLTK Javascript
3. Create PDT project
4. inject Javascript nature to the .project file of the created PDT project, like this:
<natures>
  <nature>org.eclipse.php.core.PHPNature</nature>
  <nature>org.eclipse.dltk.javascript.core.nature</nature>
</natures>
5. create a couple of javascript files in the project, fill it with sample functions
6. use code completion for one of these files.

Expected result: code completion proposals contain functions defined in all the javascript files in the project.

What actually happens: only local proposals (specific to the file where code completion is called) are in the list.

More information:
I looked deeper in DLTK code and it appears that in a lot of places it assumes that one project matches one nature and one language. In the end it all comes to methods such as org.eclipse.dltk.internal.core.util.Util#isValidSourceModule(...), which validate the resource to match the project's toolkit, which is usually the first one matching the first one of script natures of a project (see PriorityDLTKExtensionManager#findScriptNature(IProject) method).


So the problem is, it appears that currently DLTK does not support more than one language per project, which is a common situation in web projects. Is there some known workaround for this problem?
Comment 1 Andrey Platov CLA 2009-02-23 06:38:24 EST
> I looked deeper in DLTK code and it appears that in a lot of places it assumes
> that one project matches one nature and one language.

... you answered the question yourself. 

DLTK support only one language per project by design, so the only one "workaround" exists is to change DLTK design.
Comment 2 Evgeny V. Chesnokov CLA 2009-02-23 09:22:20 EST
Andrey,

Okay, so this behaviour is as intended by design. But a common practice for lot of script languages out there is to use them for web development, which inevitably brings us to Javascript integrated into the other code in one way or another. Correct me if I'm wrong but this looks like a major use case to support for DLTK. I agree that this is not a bug as it does not violate the expected behaviour, but what would you say of this as an enhancement request?
Comment 3 Michael Spector CLA 2009-04-01 15:52:36 EDT
Re-opening bug. Let's discuss how DLTK should be re-designed here.
Comment 4 Gabriel Petrovay CLA 2009-04-28 08:17:30 EDT
Hi all,

Here are a couple of ideas that might suit multiple nature projects and you might consider in the decisions you make:

1. support for adding and removing script natures/facets in DLTKCore. Such functionality should also be automatically triggered by DLTK on certain events. For example, when a file is opened with an editor that belongs to a script nature plugin. This nature should be added to the file's project (of course the user must be prompted to do this)
2. providing an extension for nature specfic Script Explorers (a minor thing: let the extension provide the name of the view: PHP explorer, Query Explorer, etc). This way plugins like PHP would not have to implement their own script explorer. This can also avoid complicating things in the default Script Explorer (lik for example interpreter tree viewer nore, decorators, etc.).

As more ideas might come, I will dump them in this discussion.

Thanks!

Regards,
Gabriel
Comment 5 Eriky Raggeoto Kashivagui CLA 2015-03-13 00:10:14 EDT
I've created a thread into Eclipse`s Forum.
Comment 6 Eriky Raggeoto Kashivagui CLA 2015-03-13 00:10:51 EDT
https://www.eclipse.org/forums/index.php/m/1670021/#msg_1670021
Comment 7 Dawid Pakula CLA 2018-03-28 16:01:46 EDT
I have idea how-to fix this. Of course it introduce lot of compatibility problems (force us to use 6.0.0 version) but should be relatively simple.

1. Create ModelManager API interfaces
2. Keep ModelManager per LanguageToolkit and make it replaceable for toolkit.
3. In future move default model implementation into separate plugin and make it optional.

This solve lots of potential problems:
1. Allow ISourceModule for same IResource (for example JavaScript and PHP)
2. Prevent mixing ISourceModule in same project between LangugeToolkits
3. Allow models pluggable (for example possibility use Handly as a replacement)


What You think? I want invest my time to work on this but want to make sure you agree with that.