@@ -45,28 +45,30 @@ var PrecisionLossError = lib.ErrorTemplate{
45
45
})
46
46
})
47
47
48
- gen .Add (fmt .Sprintf ("Use an 'f' suffix for the %s literal" , cd .Variables ["targetType" ]), func (s * lib.BugFixSuggestion ) {
49
- nearestTree := cd .InitOrGetSymbolTree (cd .MainError .DocumentPath ()).GetNearestScopedTree (variableInvolved .StartPosition ().Index )
48
+ if cd .Variables ["targetType" ] != "int" {
49
+ gen .Add (fmt .Sprintf ("Use an 'f' suffix for the %s literal" , cd .Variables ["targetType" ]), func (s * lib.BugFixSuggestion ) {
50
+ nearestTree := cd .InitOrGetSymbolTree (cd .MainError .DocumentPath ()).GetNearestScopedTree (variableInvolved .StartPosition ().Index )
50
51
51
- involvedVariable := nearestTree .GetSymbolByNode (variableInvolved )
52
- if involvedVariable == nil {
53
- // TODO: remove this check(?)
54
- return
55
- }
52
+ involvedVariable := nearestTree .GetSymbolByNode (variableInvolved )
53
+ if involvedVariable == nil {
54
+ // TODO: remove this check(?)
55
+ return
56
+ }
56
57
57
- node := cd .MainError .Document .RootNode ().
58
- NamedDescendantForPointRange (involvedVariable .Location ())
58
+ node := cd .MainError .Document .RootNode ().
59
+ NamedDescendantForPointRange (involvedVariable .Location ())
59
60
60
- involvedVariableValueNode := node .ChildByFieldName ("value" )
61
+ involvedVariableValueNode := node .ChildByFieldName ("value" )
61
62
62
- s .AddStep (
63
- "Alternatively, you can use the 'f' suffix to specify that the literal is of type %s." ,
64
- cd .Variables ["targetType" ]).AddFix (lib.FixSuggestion {
65
- NewText : involvedVariableValueNode .Text () + "f" ,
66
- StartPosition : variableInvolved .StartPosition (),
67
- EndPosition : variableInvolved .EndPosition (),
68
- Description : "This way, you directly define the float variable without the need for casting." ,
63
+ s .AddStep (
64
+ "Alternatively, you can use the 'f' suffix to specify that the literal is of type %s." ,
65
+ cd .Variables ["targetType" ]).AddFix (lib.FixSuggestion {
66
+ NewText : involvedVariableValueNode .Text () + "f" ,
67
+ StartPosition : variableInvolved .StartPosition (),
68
+ EndPosition : variableInvolved .EndPosition (),
69
+ Description : "This way, you directly define the float variable without the need for casting." ,
70
+ })
69
71
})
70
- })
72
+ }
71
73
},
72
74
}
0 commit comments