jpsim / jpsim/SourceKitten

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

Open
#516 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
2.4k
Forks
237
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the shown sourcekitten doc --objc command against EarlGrey/Core/GREYInteraction.h and inspect the emitted declaration data. Determine whether argument and return types can be exposed for this Objective-C input; done means the output includes that type information or clearly documents the limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, objective-c, swift
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.