Skip to content

Commit

Permalink
OpenAPI,refactor: make the logic of handleKey reusable
Browse files Browse the repository at this point in the history
This change is derrived from universal-ctags#3258.
The original commit is so large.
@masatake splited the commit smaller per-topic ones.
@masatake wrote this commit log.
  • Loading branch information
segoon authored and masatake committed Jan 9, 2022
1 parent 19c0baf commit 230b6be
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions parsers/openapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,12 @@ const struct tagSource tagSources[] = {
},
};

static void handleKey(struct sOpenAPISubparser *openapi,
yaml_token_t *token)
static void handleToken(struct sOpenAPISubparser *openapi, yaml_token_t *token,
const struct tagSource *tss, size_t ts_count)
{
for (int i = 0; i < ARRAY_SIZE(tagSources); i++)
for (int i = 0; i < ts_count; i++)
{
const struct tagSource* ts = &tagSources[i];
const struct tagSource* ts = &tss[i];

if (stateStackMatch(openapi->type_stack,
ts->keys, ts->countKeys))
Expand All @@ -254,6 +254,12 @@ static void handleKey(struct sOpenAPISubparser *openapi,
}
}

static void handleKey(struct sOpenAPISubparser *openapi,
yaml_token_t *token)
{
handleToken (openapi, token, tagSources, ARRAY_SIZE (tagSources));
}

static void openapiPlayStateMachine (struct sOpenAPISubparser *openapi,
yaml_token_t *token)
{
Expand Down

0 comments on commit 230b6be

Please sign in to comment.