-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: initial release for generics support (#42)
* feature: initial release for generics support * chores: bump go version for CI pipelines * chores: rename test file for generics * refactor: issues diagnostics improvments
- Loading branch information
Showing
11 changed files
with
237 additions
and
47 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
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ on: | |
- v* | ||
|
||
env: | ||
GO_VERSION: 1.17 | ||
GO_VERSION: 1.20 | ||
|
||
jobs: | ||
|
||
|
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
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
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 |
---|---|---|
@@ -1,7 +1,49 @@ | ||
package types | ||
|
||
import ( | ||
"fmt" | ||
"go/ast" | ||
"go/token" | ||
|
||
"golang.org/x/tools/go/analysis" | ||
) | ||
|
||
type IFace struct { | ||
Name string // Preserved for named interfaces | ||
Pos int // Position in return tuple | ||
Name string // Interface name | ||
Type IType // Type of the interface | ||
|
||
Pos token.Pos // Token Position | ||
FuncName string // | ||
} | ||
|
||
func NewIssue(name string, interfaceType IType) IFace { | ||
return IFace{ | ||
Name: name, | ||
// Pos: pos, | ||
Type: interfaceType, | ||
} | ||
} | ||
|
||
func (i *IFace) Enrich(f *ast.FuncDecl) { | ||
i.FuncName = f.Name.Name | ||
i.Pos = f.Pos() | ||
} | ||
|
||
func (i IFace) String() string { | ||
if i.Type == Generic { | ||
return fmt.Sprintf("%s returns generic interface (%s)", i.FuncName, i.Name) | ||
} | ||
|
||
return fmt.Sprintf("%s returns interface (%s)", i.FuncName, i.Name) | ||
} | ||
|
||
func (i IFace) HashString() string { | ||
return fmt.Sprintf("%v-%s", i.Pos, i.String()) | ||
} | ||
|
||
func (i IFace) ExportDiagnostic() analysis.Diagnostic { | ||
return analysis.Diagnostic{ //nolint: exhaustivestruct | ||
Pos: i.Pos, | ||
Message: i.String(), | ||
} | ||
} |
Oops, something went wrong.