No modules found in angularjs_require example project
Angelo,
could you, please, investigate why no modules could be detected on the following example project:
https://github.com/tastejs/todomvc/tree/master/examples/angularjs_require
Error annotations like 'Cannot find controller with name TodoController.' could be seen on
As I can see, no JS Files are added to the Tern Server in case of project itself is used as JS Path. Could it be a reason of lost modules? Before the re-organozation of the 'file management API' I was able to create a fix that allowed to convert collect JS Files and Folders in ProjectScriptPath.getScriptResources() to let all the JSs to be loaded into the server. But it didn't helped me to see any modules in Angular Explorer for this example project. After the re-organization, I cannot use the code from org.eclipse.* to make all the JS Files and Folders to be loaded to the Server to test if it helps (I didn't tried other ways at the moment).
Also, requirejs API is used to define controller in the project. Could it be a reason of the problem? What do you think on can AngularJS work correctly for this project?
@vrubezhny as you have said, the problem is about using RequireJS & AngularJS.
There is 2 problems with "TodoController" used inside index.html :
- retrieve the "todomvc" module intialialized with RequireJS In app.js :
define(['angular'], function (angular) {
return angular.module('todomvc', []);
});
- link the "todomvc" module with index.html which defines not the ng-app inside the HTML.
<section id="todoapp" ng-controller="TodoController">
....
It's possible to manage this case, but it needs some several configuration :
- add folder script path to js folder.
- select angular + requirejs tern modules
- create in the project root folder the angular-mock.js like this :
define(function() {
return angular;
});
This file will be used only for tern (perhaps we should add virtual file feature for tern.java to avoid doing that in the file system).
Add this file to the script path :

Configure requirejs options like this :

- baseURL : set the base url of requirejs to the js eclipse folder.
- path : add 'angular' path linked to the ../angular-mock to use the angular mock which returns an instance of angular. It overrides :
require.config({
paths: {
angular: '../bower_components/angular/angular'
},
After that, you should see the todomvc in the Angular Explorer and you can "Link to Controller" with index.html to retrieve "TodoController" inside index.html :

I know it's a little complex as configuration. Any feedback (like virtual file) are welcome to simpify this configuration.
@vrubezhny can I close this issue?
@angelozerr, sorry for non answering for a long time.
I have another example when Angular Explorer doesn't work at all and I cannot understand why. It's jboss-kitchensink-angularjs example (unfortunately I cannot attach it here, so, I'll send you a zipped archive with the project so you could import it).
The project is adopter to be 'tern & angular' project by JBossTools, so you'll have to convert it into Tern and Angular project (due to create required natures to use it without JBT).
It looks like the project completely has no sources: tern.eclipse.ide.internal.core.resources.IDETernProject.getScriptPaths() is always returns empty list. Looks like the scriptPaths is never initialized on it.
Also, the same error message appears: Description Resource Path Location Type Cannot find module with name kitchensink. index.html /jboss-kitchensink-angularjs/src/main/webapp line 17 HTML Problem
Is this a bug or Angular Explorer is not supposed to work with this kind of projects? (See the copy of this message and attached zipped project in e-mail message).
The project is adopter to be 'tern & angular' project by JBossTools, so you'll have to convert it into Tern and Angular project (due to create required natures to use it without JBT).
No need to do that today, because Eclipse tern and angular nature doesn't exists more today.
To know if the project is a tern project,I check if there are a .tern-project. To check that it's an angular project, I check that angular plugin is declared in the .tern-project.
Is this a bug or Angular Explorer is not supposed to work with this kind of projects? (See the copy of this message and attached zipped project in e-mail message).
Your problem is that Angular Explorer works only when project have tern script path (add tern script path to your js folder and it should work).
Tern script path can be computed from JSDT Include path, but our .jsdtdcope contains :
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/bower_components/*/|**/node_modules/*/|**/*.min.js/" kind="src" path="src/main/webapp/js"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>
and if I remember I support only src kind. In other words to fix your problem, Tern scripat path <-> JSDT Install Path must be improved (like support of exclude folder, files).
@vrubezhny forget my last comment. I have commited https://github.com/angelozerr/tern.java/commit/db1314d2e10f677b82abd60940c9aeb6d58cf777
Please tell me if it works for you.
@angelozerr, yeah, the first classpathentry in that list was of kind="src"...
Now (after commit for issue #118 is applied) Angular Explorer can show the modules. So, this part is OK now.
But I still couldn't see any proposals on page/jboss-kitchensink-angularjs/src/main/webapp/partials/home.html (inside {{..}} brackets) after I've linked to kitchensink->MembersCtrl controller... Did we dropped to the initial case of this issue (like with angularjs_require example project in the first comments)?
The jboss-kitchensink-angularjs example still has an error marker on '' ng-app tag attribute that says: "Cannot find module with name kitchensink.". But it can be hiperlinked correctly to app.js script where it's defined though. Another difference is that the module isn't defined with 'define()' function... angular.module('kitchensink',...) is used to do that... Is that also a problem? (If so, why hyperlink knows how to open app.js from ng-app="kitchensink" tag attribute value on index,html page?)
Also, please see issue #153 I've opened (it appeared after I've changed the SRC entry in Include path to point to "src/main/webapp" instead of "src/main/webapp/js" directory and refreshed Angular Explorer). But I'm sure it wasn't the reason of non-appearing proposals on home.html page.
But I still couldn't see any proposals on page/jboss-kitchensink-angularjs/src/main/webapp/partials/home.html (inside {{..}} brackets) after I've linked to kitchensink->MembersCtrl controller...
@vrubezhny I will study this problem when I will find time. Retrieve Angular controller is a very hard task ,because you can defien controller with several mean.
@angelozerr, Angular Explorer now shows modules. and issue #153 appears to be fixed.
But the problem with Content Assist for this certain example (jboss-kitchensink-angularjs project) still stays the same (no content assist appears inside {{..}} brackets.
Could you give me a sample please.