SourceKitten icon indicating copy to clipboard operation
SourceKitten copied to clipboard

Question: How can I get the type of arguments / return values?

Open DanielMSchmidt opened this issue 7 years ago • 1 comments
trafficstars

I am running SourceKitten on EarlGrey (EarlGrey/Core/GREYInteraction.h) with the goal to generate Javascript on the base of it. For this I need to get the argument and return types of methods (and the other stuff SourceKitten delivers).

When I execute SourceKitten (0.20.0 installed via HomeBrew) against EarlGrey/Core/GREYInteraction.h with the command sourcekitten doc --objc EarlGrey/Core/GREYInteraction.h -- -x objective-c I only get a part of the information I would like to have:

[
  {
    "EarlGrey\/Core\/GREYInteraction.h" : {
      "key.diagnostic_stage" : "",
      "key.substructure" : [
			....
            {
              "key.always_deprecated" : false,
              "key.always_unavailable" : false,
              "key.deprecation_message" : "",
              "key.doc.column" : 17,
              "key.doc.comment" : "  In case of multiple matches, selects the element at the specified index. In case of the\n  index being over the number of matched elements, it throws an exception. Please make sure\n  that this is used after you've created the matcher. For example, in case three elements are\n  matched, and you wish to match with the second one, then @c atIndex would be used in this\n  manner:\n\n  @code\n    [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@\"Generic Matcher\")] atIndex:1];\n  @endcode\n\n  - parameter: index        The zero-indexed position of the element in the list of matched elements\n                      to be selected.\n  @throws NSException if the @c index is more than the number of matched elements.\n\n  - returns: An interaction (assertion or an action) to be performed on the element at the\n          specified index in the list of matched elements.",
              "key.doc.file" : "EarlGrey\/Core\/GREYInteraction.h",
              "key.doc.full_as_xml" : "",
              "key.doc.line" : 264,
              "key.doc.parameters" : [
                {
                  "discussion" : [
                    {
                      "kind" : "",
                      "Para" : "The zero-indexed position of the element in the list of matched elements\n              to be selected.\n  "
                    }
                  ],
                  "name" : "index"
                }
              ],
              "key.doc.result_discussion" : [
                {
                  "kind" : "",
                  "Para" : "An interaction (assertion or an action) to be performed on the element at the\n         specified index in the list of matched elements."
                }
              ],
              "key.filepath" : "EarlGrey\/Core\/GREYInteraction.h",
              "key.kind" : "sourcekitten.source.lang.objc.decl.method.instance",
              "key.name" : "-atIndex:",
              "key.parsed_declaration" : "- (nonnull instancetype)atIndex:(NSUInteger)index;",
              "key.parsed_scope.end" : 264,
              "key.parsed_scope.start" : 264,
              "key.unavailable_message" : "",
              "key.usr" : "c:objc(pl)GREYInteraction(im)atIndex:"
            }
          ],
          "key.unavailable_message" : "",
          "key.usr" : "c:objc(pl)GREYInteraction"
        }
      ]
    }
  }
]

I would like to get type information here for the arguments and return values, is this somehow possible?

DanielMSchmidt avatar Apr 24 '18 20:04 DanielMSchmidt

If you can find what the libclang function to get the return type and parameter types from a CXCursor_ObjCInstanceMethodDecl cursor, let me know and I'll add those here.

jpsim avatar Apr 25 '18 23:04 jpsim