views:

544

answers:

1

I have been doing javascript development for the last couple weeks and have tried JSDT and Aptana to assist in code completion. JSDT wasn't very good at all, but I did have more luck with Aptana (used as eclipse plug-in, not the standalone product). The problem I'm encountering is that when I create javascript classes I cannot get code completion to work. For example, if I use the following then code completion doesn't work:

var foo = new function(value){
   this.myMethod= function(){
   }
}

I have also verified that the following won't work:

function foo(value){
   this.myMethod= function(){
   }
}

I have found that using a JSON style does work:

var foo = {
    myMethod: function(){

    }
}

Does anyone know why Aptana works for the last style, but not the first? Using the JSON style won't work for me because I have to have seperate instances of the class in question.

Also, I am not very successful in getting code completion to work across files. For example, if I have 3 files in the javascript directory then I usually cannot get Aptana to pick up the JSON style markup in the other two classes. This DID work at one point (for the first 2 classes I created), but since then whenever I add new classes they aren't picked up.

Thank you very much for you assistance.

Jeremy

A: 

I have identified that the following works:

/**
* The foo function
*/
function foo() { 
}

/**
* The bar function
* @param {Object} a Object a
 * @param {Object} b Object b
 */
function bar(a, b){
};

foo.prototype.b = bar;

var x = new foo();
x.b

In the above example the key is that you are registering the method using prototype. I also tried the following, but it didn't work.

/**
* The foo function
*/
var foo = new function() { 
}

/**
* The bar function
* @param {Object} a Object a
 * @param {Object} b Object b
 */
function bar(a, b){
};

foo.prototype.b = bar;

var x = new foo();
x.b

Any ideas what the difference is? Is the second a valid class in javascript?

jwmajors81
@Jwmajors, Do you have any sample Java script work which is built using the Aptana, if yes can you please share with me, thanks in advance
harigm
All the code that was written using the aptana plug-in is owned by the company I work for so i cannot post it. That is why I provided the examples provided above. Is there something specifically that you are wanting?
jwmajors81