Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse global enums #1387

Merged
merged 8 commits into from
Nov 20, 2022
Merged

parse global enums #1387

merged 8 commits into from
Nov 20, 2022

Conversation

sdghchj
Copy link
Member

@sdghchj sdghchj commented Nov 19, 2022

Describe the PR
if a global custom type is defined based on an underlying integer or string type, it will be considered as an enum type.

an enum type exists with two extensions:
x-enum-varnames: record their names
x-enum-comments: record their comments associated to their names.

Relation issue
#1367

@codecov
Copy link

codecov bot commented Nov 19, 2022

Codecov Report

Base: 95.71% // Head: 95.55% // Decreases project coverage by -0.16% ⚠️

Coverage data is based on head (3ddcf66) compared to base (829fbe1).
Patch coverage: 91.14% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1387      +/-   ##
==========================================
- Coverage   95.71%   95.55%   -0.17%     
==========================================
  Files          14       16       +2     
  Lines        2826     2994     +168     
==========================================
+ Hits         2705     2861     +156     
- Misses         66       74       +8     
- Partials       55       59       +4     
Impacted Files Coverage Δ
types.go 100.00% <ø> (ø)
packages.go 92.06% <86.30%> (-0.37%) ⬇️
const.go 91.35% <91.35%> (ø)
field_parser.go 98.57% <100.00%> (ø)
package.go 100.00% <100.00%> (ø)
parser.go 93.78% <100.00%> (+0.10%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sdghchj
Copy link
Member Author

sdghchj commented Nov 19, 2022

@ubogdan

Copy link
Contributor

@ubogdan ubogdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation was written in a hurry, The review was done in the same manner. Hope the results won't get worst.

return value
}
return cv.Value
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior of this function is quite unusual. it value is an ast.Expresion , it populates the ConstVariable type and value , otherwise, it returns a value that may be ni ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cv.Value is initialized in the func collectConstVariables with a ast.Expr, and then will be reassigned with the evaluated non-nil value of integer or string type,so it would never be nil.

@sdghchj sdghchj merged commit bdfec2b into master Nov 20, 2022
@sdghchj sdghchj deleted the enums branch November 20, 2022 10:26
sdghchj added a commit that referenced this pull request Nov 22, 2022
* enhancement: evaluate const across packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants