Skip to content

Commit

Permalink
fix: use adjusted position
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Dec 15, 2024
1 parent c862f08 commit 12148fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (wa *wslAnalyzer) run(pass *analysis.Pass) (interface{}, error) {
continue
}

filename := pass.Fset.PositionFor(file.Pos(), false).Filename
filename := pass.Fset.Position(file.Pos()).Filename
if !strings.HasSuffix(filename, ".go") {
continue
}
Expand Down
12 changes: 6 additions & 6 deletions wsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1113,8 +1113,8 @@ func (p *processor) findLeadingAndTrailingWhitespaces(ident *ast.Ident, stmt, ne
return
}

blockStartLine = p.fileSet.PositionFor(blockStartPos, false).Line
blockEndLine = p.fileSet.PositionFor(blockEndPos, false).Line
blockStartLine = p.fileSet.Position(blockStartPos).Line
blockEndLine = p.fileSet.Position(blockEndPos).Line

// No whitespace possible if LBrace and RBrace is on the same line.
if blockStartLine == blockEndLine {
Expand Down Expand Up @@ -1362,14 +1362,14 @@ func isExampleFunc(ident *ast.Ident) bool {
}

func (p *processor) nodeStart(node ast.Node) int {
return p.fileSet.PositionFor(node.Pos(), false).Line
return p.fileSet.Position(node.Pos()).Line
}

func (p *processor) nodeEnd(node ast.Node) int {
line := p.fileSet.PositionFor(node.End(), false).Line
line := p.fileSet.Position(node.End()).Line

if isEmptyLabeledStmt(node) {
return p.fileSet.PositionFor(node.Pos(), false).Line
return p.fileSet.Position(node.Pos()).Line
}

return line
Expand Down Expand Up @@ -1408,7 +1408,7 @@ func (p *processor) addErrorRange(reportAt, start, end token.Pos, reason string)
}

func (p *processor) addWarning(w string, pos token.Pos, t interface{}) {
position := p.fileSet.PositionFor(pos, false)
position := p.fileSet.Position(pos)

p.warnings = append(p.warnings,
fmt.Sprintf("%s:%d: %s (%T)", position.Filename, position.Line, w, t),
Expand Down

0 comments on commit 12148fa

Please sign in to comment.