Forum Discussion

howie_'s avatar
howie_
Contributor
10 years ago

Intellisense on user-defined objects


Hey everyone, 



I've created an ODT class with member method. The intellisense/code completion is able to detect the class, and the method, but it doesn't show me the method's arguments/parameters. Here's an example of what I've got: 



ODT structure: 

-------------------------

     class: Math

          method: Add(a, b)





Use in script:

-------------------------

var math = ODT.Classes.Math;

math.Add(...





Current code completion information:

--------------------------------------------

      "Add(), a user-defined object"





Desired code completion information: 

--------------------------------------------------

     "Add(a, b), a user-defined object"

     

     or better:

     "Add(int a, int b), a user-defined object"

     

     or even better:

     "Add(int a, int b), Adds two integers together and returns their sum"





Is this possible? I can't seem to find any information about it anywhere.



Thanks for your help, 

Howie


5 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    As far as I am aware, you cannot add that kind of intellisense to ODT classes.  



    If, however, you create your class, not as an ODT object, but as an item within a Script extension, you can add whatever "intellisense" information you want.  Check out the articles here.



    http://support.smartbear.com/viewarticle/55349/
  • Philip_Baird's avatar
    Philip_Baird
    Community Expert

    Hi Howie, I am assuming from your post that you have created a Script Extension "Person".


     


    Script Extensions do not create instantiable Classes, you are correct in your observation that they create a singleton Object, much the same as, say, the built in Test Complete aqString Object.


     


    The only way to acheive want you want from a Script Extension is to have the following in the Person Script Extension


     


    var Person = function( age ) {


      this.Age = age;


    }


     


    function newPerson( age ) {


      return new Person( age );


    }


     


    which can then be called such as


     




    function testNewPerson() {


      var a = Person.newPerson( 10 );


      var b = Person.newPerson( 3 );


      


      Log.Message( a.Age +  ", " + b.Age );


    }


     


    Regards,


    Phil Baird

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    What about an Array of Car objects?  With a function to "AddNewCar" to the person?  Then you could call something like



    Person.Car[1].Make

    Person.Car[2].Make



    And so on.
  • Hey Robert, 



    First off I want to thank you for pointing me toward Script Extensions. I've been playing with them all day, and I'm really excited about what they mean not only for my work,  but for next guy who has to maintain my work (probably me, but that's neither here nor there). 



    I do have one question. I've created an object, "Person", and for our project I'm going to need about 150 of them. Is there any way that I can use the "new" keyword to create multiple instances of the "Person" object? So far all I'm getting is a static/singleton-type object. Any advice? 



    -Howie 







    For clarification, here's what I can do now: 

    --------------------------------------------------------

    var a = Person;

    var b = Person;



    a.Age= 10;

    b.Age = 3;



    Log.Message(a.Age +  ", " + b.Age);

    >> 3, 3







    What I'd like to do: 

    -----------------------------------

    var a = new Person();

    var b = new Person();



    a.Age= 10;

    b.Age = 3;



    Log.Message(a.Age +  ", " + b.Age);

    >> 10, 3

  • Thanks for your help Phil.  You don't happen to know if you can nest RuntimeObjects, do you? I'd like to be able to do this: 





    Person.Name = "Fred";

    Person.Age = "37";

    Person.Car.Make = "Honda";

    Person.Car.Model = "Civic";

    Person.Car.Year = 2010;



    I've been trying for a little while, but nothing seems to be panning out so far. 

    I'd really prefer not to have to do this: 



    Person.Name = "Fred";

    Person.CarMake="Honda";



    What if Fred buys a second car? or a third?