Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • #61
    Interesting edge case. These are marked writable because they can be updated, via APIs on TabSet such as tabSet.setTabTitle(), and the generic setTabProperties(). But rather than marking them "W" we should leave off the W and just link to the setter on TabSet via the docs. We'll correct this, so your script shouldn't need any special logic here.

    Comment


    • #62
      Ok, I will ignore the W on objects for now, effectively making them read-only. Will the same logic for other objects as well such as SectionStackSection, Hilite, EditNode, HeaderSpan etc.? And does it make sense for my validation process to check for any Objects with an attribute marked with the W flag?

      Comment


      • #63
        The height attribute on Canvas is specified as Number or String, which makes sense. The setHeight(height: Number) method, however, specifies only number. I will add another validation to make sure that type in the setter method matches the type on the attribute.

        Comment


        • #64
          SectionStack has an attribute called sections which is an Array of SectionStackSection Properties. It also has a getSections() method but the method returns a list of names. So, according to the docs, if an attribute has a getter, then you must use the getter. However in this case, the getter does not return the sections, it returns the names of the sections. So, should getSections() be renamed to getSectionNames()? Or should getSections() return an array of SectionStackSections? Or am I missing something else?

          I discovered this because the generator no longer generates properties for attributes that have a getter, the idea being to force use of the getter when it is available.

          Comment


          • #65
            There's a attribute on ListGrid called dateTimeFormatter, however in the docs, the name is datetimeFormatter. This requires a special rule in the generator to fix the T in time. There's a similar attibute on DetailViewer but in that case, the name really is datetimeFormatter.

            Comment


            • #66
              New version (from 5/6/17 snapshot). I've added more validations and formatted for easy viewing. The details can be found in the repository Errors.txt file. Not everything is necessarily an error but might need looking at.

              Metrics for build SNAPSHOT_v11.1d_2017-05-06
              Types: 229
              Classes: 309
              Objects: 67
              Methods: 3555
              Methods with bad flags: 3
              Classes without inherits from: 202
              string values with quotes: 216
              string values without quotes: 657
              string values with period: 130
              array of: 1
              Array of: 225
              Array[] of: 10
              array[] of: 0
              Just array or Array: 10
              String types without baseType: 83
              Method params with missing name: 15
              Method params with bad name: 1
              Method params missing type: 7
              Methods with required parameters after optional parameters: 7
              Setter Methods with paramter type that does not match the attribute type: 88
              Non-optional params with the word 'Optional' in the description: 19
              Getter Methods with return type that does not match the attribute type: 42

              Comment


              • #67
                Latest from SNAPSHOT_v11.1d_2017-05-09 is committed. I don't think much has changed. In order to improve communications about issues found in the referenceDocs.xml file, I am now generating a progress report which can be found here: Progress.md. Note that I've implemented a lot of 'rules' that I have inferred from the docs, the forum and some common sense. If my understanding is flawed, please let me know and I'll adjust the rules accordingly.

                Comment


                • #68
                  We'll review the Object properties that claim "W". For now, yes, just ignore this flag.

                  SectionStack.getSections(): we'll add a new API getSectionNames() and deprecate getSections(), so you should be able to have your script ignore the wrong-typed getter since it will be deprecated.

                  We don't see an attribute in the code or in referencesDocs.xml for listGrid.dateTimeFormatter with a capital "T", neither for DetailViewer. Possibly still running against an older version?

                  Comment


                  • #69
                    A couple of items from Errors.txt:

                    Setter Methods with paramter type that does not match the attribute type: 88
                    1. method:AdaptiveMenu.setItems, attrType='Array of MenuItem', setter Type = 'Array of MenuItem | MenuItem'
                    Where the setter offers a superset of the types of the attribute, this is not an error. It's just a setter than provides extra flexibility.

                    Methods with non-optional params with the word 'optional' in the description: 19. Parameters listed here (may be more than one parameter per method)
                    None of these are errors. Optional here just means you can omit a value for the parameter (pass null or undefined). We've never seen anyone confused by this use of "optional", so don't plan to change it.

                    Getter Methods with return type that does not match the attribute type: 42
                    Some of these are not errors:
                    1. It's not an error for the getter to be a subset of the attribute type (getters cannot return multiple types after all)
                    2. It's not an error for an attribute of type "Something Properties" to have a getter than returns a "Something"
                    3. It's not an error for an attribute of type "AutoChild Something" to have a getter that returns a "Something" (same with "MultiAutoChild Something")

                    Many of the rest actually represent errors and are being assigned, but again it'll take a while to clear these errors out since we're on the verge of putting out a new release.

                    Comment


                    • #70
                      There are 3 cases where your script is flagging a mismatch between a getter and an attribute, where the detected "getter" actually has params, so should not be detected as a getter:

                      1. method:Calendar.getWorkdayEnd, attrType='Time', return Type = 'String'
                      ​2. method:Calendar.getWorkdayStart, attrType='Time', return Type = 'String'
                      31. method:ListGrid.getSelection, attrType='Selection', return Type = 'Array of ListGridRecord'

                      Other than these and the other cases we explained above where the type isn't really a mismatch, we can correct everything else you found.

                      Comment


                      • #71
                        Hello kylemwhite, I'm not a TypeScript expert, but I've just tried to use your work in Intellij IDEA, and it seems to work properly.
                        Kudos for your work!

                        Comment


                        • #72
                          Hi kylemwhite,

                          Originally posted by claudiobosticco View Post
                          Hello kylemwhite, I'm not a TypeScript expert, but I've just tried to use your work in Intellij IDEA, and it seems to work properly.
                          Kudos for your work!
                          a big thank you from me as well. Even though I'm not using SmartClient but SmartGWT, I think removing that the small irregularities you find will make the framework as whole better.
                          Besides of this all SmartClient users will be able to program faster and with less errors with your "TypeScript-Intellisense".

                          Best regards
                          Blama

                          Comment


                          • #73
                            Re: dateTimeFormatter
                            Sure enough, it doesn't exist. I don't know why I thought it did. I'm guessing I had some bad JavaScript that set that property (improperly) but actually created it. Fortunately TS is helping me fix all my bad habits.

                            ​Re: Getter Methods
                            The old rule identified a getter method of someProperty as a method that is the combination of get and SomeProperty (i.e. getSomeProperty). I've changed it so the rule now looks for a method with that name AND has no parameters. I've also implemented the 3 rules for getter methods so this number has gone down from 42 to 15, and many of those are just different spellings (int/Integer) and different versions of string types (HTML/HTMLString).

                            Re: Setter Methods
                            I've implemented the rule that allows the setter type to be a superset of the attribute type. The count has gone down from 88 to 83. Again, many are just different spellings of the same thing or different version of string.

                            Re: non-optional parameters with 'optional' in the description
                            Optional here just means you can omit a value for the parameter (pass null or undefined)
                            If you can omit the value completely, isn't that what optional='true' means? If you're supposed to pass null or undefined, then can we change the type to include " | null"?

                            Let's look at Date.toNormalDate() for example. I believe this is valid (I've tested and it works):

                            Code:
                            strDate = myDate.toNormalDate();   // no parameter specified, the default "toLocaleString" will be used (unless it was changed with setNormalDisplayFormat())
                            But if the parameter is not marked optional='true', Then this will be invalid in TypeScript as it will expect a parameter.

                            Comment


                            • #74
                              Parameters marked optional can be completely omitted, like a different method signature in Java. For example, if the last parameter of a 3-argument method is optional, you can call it with two arguments.

                              Parameters where the word optional happens to appear in the description can generally be null. We don't plan on adding a formal notion of this lesser kind of optionality to the docs. Note that it definitely would not be correct to enforce that parameters must be non-null if the word "optional" doesn't occur in the description; lots of parameters may be passed as null and something reasonable happens, but the word "optional" isn't used to describe the behavior that results.

                              Comment


                              • #75
                                I wasn't planning on having the generator create any code based on anything in any description, that would be silly. I'm just using the description to try to determine if a parameter was supposed to be marked optional='true' but got missed.

                                Parameters marked optional can be completely omitted, like a different method signature in Java. For example, if the last parameter of a 3-argument method is optional, you can call it with two arguments.
                                I think you're saying the same thing as me. For example, the Messaging.subscribe classMethod has 4 parameters. The last one is optional (according to the description), which means it can be omitted. However, that parameter is not marked with optional='true' in the docs.

                                Code:
                                <docItem ref="classMethod:Messaging.subscribe" type="classMethod" definingClass="class:Messaging" description=" Subscribes the client to the messaging channel identified by channel.&amp;#010 &lt;p&gt;&amp;#010 When the server or another connected browser sends a message on this channel, the callback &amp;#010 will be invoked with a single 'data' parameter containing the data that was just sent to the&amp;#010 channel.&amp;#010 &lt;p&gt;&amp;#010 Calling subscribe() again for a channel you are already subscribed to will result in the new&amp;#010 callback replacing the old, and will cause the server connection to be re-established.&amp;#010&amp;#010" flags="" name="subscribe">
                                    <groups>messaging</groups>
                                <params optional="false" type="String" name="channel">
                                </params>
                                <params optional="false" type="MessagingCallback" description="callback fired whenever data is sent to this channel" name="callback">
                                </params>
                                <params optional="false" type="Callback" description="callback fired when the subscription is established" name="subscribeCallback">
                                </params>
                                <params optional="false" type="String" description="JMS selector used with Queues to filter the messages
                                that arrive  to the channel (optional)." name="selector">
                                </params>
                                If marking the parameter as optional='true' does not indicate that it can be omitted, then what DOES it mean?

                                Comment

                                Working...
                                X