Skip to content

Commit 230b6be

Browse files
segoonmasatake
authored andcommitted
OpenAPI,refactor: make the logic of handleKey reusable
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.
1 parent 19c0baf commit 230b6be

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

parsers/openapi.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,12 @@ const struct tagSource tagSources[] = {
233233
},
234234
};
235235

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

243243
if (stateStackMatch(openapi->type_stack,
244244
ts->keys, ts->countKeys))
@@ -254,6 +254,12 @@ static void handleKey(struct sOpenAPISubparser *openapi,
254254
}
255255
}
256256

257+
static void handleKey(struct sOpenAPISubparser *openapi,
258+
yaml_token_t *token)
259+
{
260+
handleToken (openapi, token, tagSources, ARRAY_SIZE (tagSources));
261+
}
262+
257263
static void openapiPlayStateMachine (struct sOpenAPISubparser *openapi,
258264
yaml_token_t *token)
259265
{

0 commit comments

Comments
 (0)