angelozerr / tern-qooxdoo

tern-qooxdoo
MIT License
6 stars 1 forks source link

"this" in Document #1

Open dabretin opened 10 years ago

dabretin commented 10 years ago

First af all thx for your work !!! Next...not really an issue, but a wish ;) Qooxdoo class definition is "special". All methods are defined in the "members" section rather than classical "prototype" JS Class. Soo, autocompletion is lost when trying to get the class members with "this.".

Is it possible to modify the function scope in the AST to fix it ?

PS: sorry for my bad English...

angelozerr commented 10 years ago

@dabretin to be honnest with you, I don't know qooxdoo.

I have developped quickly this tern plugin by generating from qooxdoo source the tern JSON Type definition. But it must be improved a lot.

It will help you a lot if you give me an example where there is the problem. Thank's

dabretin commented 10 years ago

I have just seen that you're french...as I am...But English is international soo if you can understant me, I will continue writing in this language ;)

Wow!!! Fast response ;) Soo...

Qooxdoo class definition is non-classic. Example:

qx.Class.define("problem.HelloWorld",
{
  extend: problem.base, //inherit
  include : [ problem.MString ], //Mixin...sort of multiple inheritance...in fact, the framework will merge the "members" section

  statics : //Consts
  {
    CONSTANTE_1: "Your message: "
  },

  construct : function(strMessage) //Constructor
  {
    this.base(arguments); //super constructor call
    this.__strMessage = strMessage;
  },

  members: //prototype
  {
    //Vars
    __strMessage : null,

    printMessage: function()
    {
      console.log(this.constructor.CONSTANTE_1 + this.__strMessage);
    }
  }
});

As this syntax does not correspond with classical javascript class definition, tern.js is lost when I try to autocomplete "this" in a members function:

    printMessage: function()
    {
      this. //correct aucotomplete let me see '__strMessage' and 'printMessage', but it only show me ante-defined this properties
      console.log(this.constructor.CONSTANTE_1 + this.__strMessage);
    }

I think that the "findExpressionAround" of infer save the scope of function in AST. It should be the "members" node, but (I think) it's the global scope node saved...

angelozerr commented 10 years ago

I have just seen that you're french...as I am...But English is international soo if you can understant me, I will continue writing in this language ;)

Yes I prefer speaking english in order to a lot of people can follow our discussion (My english is bad too).

To manage your issue, we need write a tern function inside the qooxdoo tern plugin which manages scope, injection, etc inside qx.Class.define

I'm very busy for the moment with tern integration inside Eclipse IDE (see https://github.com/angelozerr/tern.java), so I hav eno time to do that.

I have started this qooxdoo tern plugin to have a start point and I hope people (you?) will help me to improve it.

If you wish to do that, I suggest you that you study official tern plugins https://github.com/marijnh/tern/tree/master/plugin

dabretin commented 10 years ago

I will study tern sources because I have actually no idea of doing that ;) I will feedback later (now...it's holidays !) :D Once again, thc for your work :+1: