-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
linter: refactored report functions (#1053)
Now at the heart of all the functions for creating reports is a function that creates a report at a given location. Report and ReportPHPDoc are now wrappers that convert node and PHPDocLocation to Location for ReportLocation. ReportByLine has been removed as it is no longer used and can be replaced with ReportLocation. Fixed error, if the warning was given on the last line in the file, then the context line was empty. A new ir.Location structure has been added. ir.Location stores the shifts relative to the current line. A new structure is needed since position.Position stores line shifts relative to the beginning of the file, and not relative to the current line, which is very inconvenient for using ReportLocation.
- Loading branch information
Showing
7 changed files
with
252 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package ir | ||
|
||
// Location stores the position of some element, where StartChar and EndChar | ||
// are offsets relative to the current line, as opposed to position.Position, | ||
// where the offset is relative to the beginning of the file. | ||
type Location struct { | ||
StartLine int | ||
EndLine int | ||
StartChar int | ||
EndChar int | ||
} | ||
|
||
func NewLocation(startLine int, endLine int, startChar int, endChar int) *Location { | ||
return &Location{ | ||
StartLine: startLine, | ||
EndLine: endLine, | ||
StartChar: startChar, | ||
EndChar: endChar, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.