Skip to content

Commit

Permalink
fix #1446: better processing for ranges and channel types
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatov committed Mar 18, 2015
1 parent e277091 commit 34443d6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/com/goide/psi/impl/GoPsiImplUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ private static GoType processRangeClause(@NotNull GoVarDefinition o, @NotNull Go
PsiElement resolve = typeRef.getReference().resolve();
if (resolve instanceof GoTypeSpec) {
type = ((GoTypeSpec)resolve).getType();
if (type instanceof GoChannelType) {
return type.getType();
}
}
}
if (type instanceof GoArrayOrSliceType && i == 1) return type.getType();
Expand Down
20 changes: 19 additions & 1 deletion testData/highlighting/ranges.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,22 @@ func main() {
for _, <error descr="Unused variable 'd'">d</error> := range <error descr="Unresolved reference 'd'">d</error>.Packets {
}
}
func create() []*Person {return make([]*Person, 0)}
func create() []*Person {return make([]*Person, 0)}

type myStruct struct {
MyVal bool
}

type myChanType chan myStruct

func chanFn(c myChanType) {
for v := range c {
fmt.Printf("Got %v\n", v.MyVal) // v.MyVal is unresolved
}
}

func <warning>main2</warning>() {
ch := make(myChanType)
go chanFn(ch)
ch <- myStruct{true}
}

0 comments on commit 34443d6

Please sign in to comment.