Skip to content

Commit

Permalink
bug fix #178 iterator support
Browse files Browse the repository at this point in the history
  • Loading branch information
tangzx committed Aug 17, 2018
1 parent e322db1 commit 7768fb7
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/main/java/com/tang/intellij/lua/ty/Declarations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,9 @@ private fun resolveParamType(paramNameDef: LuaParamNameDef, context: SearchConte
if (paramOwner is LuaForBStat) {
val exprList = paramOwner.exprList
val callExpr = PsiTreeUtil.findChildOfType(exprList, LuaCallExpr::class.java)
val paramIndex = paramOwner.getIndexFor(paramNameDef)
val expr = callExpr?.expr
if (expr is LuaNameExpr) {
val paramIndex = paramOwner.getIndexFor(paramNameDef)

// ipairs && TyArray
if (expr.name == Constants.WORD_IPAIRS) {
if (paramIndex == 0)
Expand All @@ -288,16 +287,16 @@ private fun resolveParamType(paramNameDef: LuaParamNameDef, context: SearchConte
}
}
}
}

// iterator support
val type = callExpr.guessType(context)
if (type is ITyFunction) {
val returnTy = type.mainSignature.returnTy
if (returnTy is TyTuple) {
return returnTy.list.getOrElse(paramIndex) { Ty.UNKNOWN }
} else if (paramIndex == 0) {
return returnTy
}
// iterator support
val type = callExpr?.guessType(context)
if (type is ITyFunction) {
val returnTy = type.mainSignature.returnTy
if (returnTy is TyTuple) {
return returnTy.list.getOrElse(paramIndex) { Ty.UNKNOWN }
} else if (paramIndex == 0) {
return returnTy
}
}
}
Expand Down

0 comments on commit 7768fb7

Please sign in to comment.