Azure / Azure/azure-sdk-tools

Add types to variables declared with call expressions

Open
#3,051 0 comments 0 reactions 0 assignees View on GitHub
APIView feature-request Go
Dominant language
C#
Stars
135
Forks
260
Avg merge
3d 1h
Merged PRs (30d)
143

Description

For example, `var TenantResourceType = NewResourceType(...)` appears just like that in a review, that is to say, without a type. It would be better to explicitly type the variable i.e., `var TenantResourceType ResourceType = ...`. (This is an easy blank for a human reader to fill in, but imagine if the call weren't to a conventional constructor.)

`apiviewgo` doesn't include a type for such declarations because the AST node for a call expression doesn't indicate that expression's type. Adding the type requires finding the definition of `NewResourceType()` and reasoning about its return in a post-processing step after traversing all a module's ASTs because we can't expect to visit the function definition before the variable declaration. I imagine doing this well in general requires the typing data described in #3049.

Contributor guide

Open the contributing guide

Research direction

Start with the apiviewgo processing flow described in the issue and read the typing data proposed in #3049. Determine how declarations and function definitions are collected across a module; done means call-expression variable declarations such as TenantResourceType include the resolved return type.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.