Skip to content

Commit

Permalink
Slight reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
navijation committed Nov 22, 2023
1 parent f09e1e0 commit 3bddbac
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,26 @@ func (a *analyzer) shouldProcessLit(
return a.isTypeProcessingNeeded(info)
}

//revive:disable-next-line:unused-receiver
func (a *analyzer) litSkippedFields(
lit *ast.CompositeLit,
typ *types.Struct,
onlyExported bool,
) fields.StructFields {
a.fieldsCacheMu.RLock()
f, ok := a.fieldsCache[typ]
a.fieldsCacheMu.RUnlock()

if !ok {
a.fieldsCacheMu.Lock()
f = fields.NewStructFields(typ)
a.fieldsCache[typ] = f
a.fieldsCacheMu.Unlock()
}

return f.SkippedFields(lit, onlyExported)
}

func (a *analyzer) decideEnforcementDirective(
pass *analysis.Pass, lit *ast.CompositeLit, stack []ast.Node,
) EnforcementDirective {
Expand All @@ -264,26 +284,6 @@ func (a *analyzer) decideEnforcementDirective(
return parseEnforcement(commentMap[parent])
}

//revive:disable-next-line:unused-receiver
func (a *analyzer) litSkippedFields(
lit *ast.CompositeLit,
typ *types.Struct,
onlyExported bool,
) fields.StructFields {
a.fieldsCacheMu.RLock()
f, ok := a.fieldsCache[typ]
a.fieldsCacheMu.RUnlock()

if !ok {
a.fieldsCacheMu.Lock()
f = fields.NewStructFields(typ)
a.fieldsCache[typ] = f
a.fieldsCacheMu.Unlock()
}

return f.SkippedFields(lit, onlyExported)
}

func (a *analyzer) getFileCommentMap(fileSet *token.FileSet, file *ast.File) ast.CommentMap {
a.commentMapCacheMu.RLock()
commentMap, exists := a.commentMapCache[file]
Expand Down

0 comments on commit 3bddbac

Please sign in to comment.