Dont use pointer for commment prefs (avoid nil)

This commit is contained in:
Mike Farah 2021-01-13 16:56:24 +11:00
parent 91c72d2d9e
commit 0484d0232b
2 changed files with 6 additions and 6 deletions

View File

@ -125,7 +125,7 @@ func assignAllCommentsOp(updateAssign bool) lex.Action {
Value: assignCommentOpType.Type,
StringValue: value,
UpdateAssign: updateAssign,
Preferences: &commentOpPreferences{LineComment: true, HeadComment: true, FootComment: true},
Preferences: commentOpPreferences{LineComment: true, HeadComment: true, FootComment: true},
}
return &token{TokenType: operationToken, Operation: op}, nil
}
@ -252,11 +252,11 @@ func initLexer() (*lex.Lexer, error) {
lexer.Add([]byte(`fi`), opToken(getFileIndexOpType))
lexer.Add([]byte(`path`), opToken(getPathOpType))
lexer.Add([]byte(`lineComment`), opTokenWithPrefs(getCommentOpType, assignCommentOpType, &commentOpPreferences{LineComment: true}))
lexer.Add([]byte(`lineComment`), opTokenWithPrefs(getCommentOpType, assignCommentOpType, commentOpPreferences{LineComment: true}))
lexer.Add([]byte(`headComment`), opTokenWithPrefs(getCommentOpType, assignCommentOpType, &commentOpPreferences{HeadComment: true}))
lexer.Add([]byte(`headComment`), opTokenWithPrefs(getCommentOpType, assignCommentOpType, commentOpPreferences{HeadComment: true}))
lexer.Add([]byte(`footComment`), opTokenWithPrefs(getCommentOpType, assignCommentOpType, &commentOpPreferences{FootComment: true}))
lexer.Add([]byte(`footComment`), opTokenWithPrefs(getCommentOpType, assignCommentOpType, commentOpPreferences{FootComment: true}))
lexer.Add([]byte(`comments\s*=`), assignAllCommentsOp(false))
lexer.Add([]byte(`comments\s*\|=`), assignAllCommentsOp(true))

View File

@ -23,7 +23,7 @@ func assignCommentsOperator(d *dataTreeNavigator, matchingNodes *list.List, expr
return nil, err
}
preferences := expressionNode.Operation.Preferences.(*commentOpPreferences)
preferences := expressionNode.Operation.Preferences.(commentOpPreferences)
comment := ""
if !expressionNode.Operation.UpdateAssign {
@ -67,7 +67,7 @@ func assignCommentsOperator(d *dataTreeNavigator, matchingNodes *list.List, expr
}
func getCommentsOperator(d *dataTreeNavigator, matchingNodes *list.List, expressionNode *ExpressionNode) (*list.List, error) {
preferences := expressionNode.Operation.Preferences.(*commentOpPreferences)
preferences := expressionNode.Operation.Preferences.(commentOpPreferences)
log.Debugf("GetComments operator!")
var results = list.New()