未验证 提交 e913d430 编写于 作者: P Phodal Huang

fix: fix target var error

上级 e0c4ea97
......@@ -146,7 +146,6 @@ func (s *JavaCallListener) EnterLocalVariableDeclaration(ctx *parser.LocalVariab
typ := ctx.GetChild(0).(antlr.ParseTree).GetText()
if ctx.GetChild(1) != nil {
if ctx.GetChild(1).GetChild(0) != nil && ctx.GetChild(1).GetChild(0).GetChild(0) != nil {
variableName := ctx.GetChild(1).GetChild(0).GetChild(0).(antlr.ParseTree).GetText()
localVars[variableName] = typ
}
......@@ -282,14 +281,6 @@ func (s *JavaCallListener) EnterMethodCall(ctx *parser.MethodCallContext) {
stopLine := ctx.GetStop().GetLine()
stopLinePosition := startLinePosition + len(callee)
// TODO: 处理链试调用
if strings.Contains(targetType, "(") && strings.Contains(targetType, ")") && strings.Contains(targetType, ".") {
split := strings.Split(targetType, ".")
sourceTarget := split[0]
targetType = localVars[sourceTarget]
}
fullType := warpTargetFullType(targetType)
if targetType == "super" {
targetType = currentClzExtend
......@@ -333,6 +324,10 @@ func (s *JavaCallListener) EnterMethodCall(ctx *parser.MethodCallContext) {
methodMap[getMethodMapName(currentMethod)] = method
}
func isChainCall(targetType string) bool {
return strings.Contains(targetType, "(") && strings.Contains(targetType, ")") && strings.Contains(targetType, ".")
}
func buildMethodNameForBuilder(ctx *parser.MethodCallContext, targetType string) string {
// TODO: refactor
if reflect.TypeOf(ctx.GetParent()).String() == "*parser.ExpressionContext" {
......@@ -408,6 +403,11 @@ func parseTargetType(targetCtx string) string {
if strings.HasSuffix(typeOf, "MethodCallContext") {
targetType = currentClz
} else {
if isChainCall(targetVar) {
split := strings.Split(targetType, ".")
targetVar = split[0]
}
fieldType := mapFields[targetVar]
formalType := formalParameters[targetVar]
localVarType := localVars[targetVar]
......
......@@ -17,43 +17,10 @@ public class BlogRepositoryImpl implements BlogRepository {
private final BlogMapper blogMapper;
public BlogRepositoryImpl(BlogMapper blogMapper) {
this.blogMapper = blogMapper;
}
@Override
public void save(Blog blog) {
var blogPO = BlogPO.of(blog);
blogMapper.findById(blog.getId().toString()).ifPresentOrElse(
po -> blogMapper.update(blogPO),
() -> blogMapper.insert(blogPO)
);
}
@Override
public Optional<Blog> findById(UUID id) {
return blogMapper.findById(id.toString()).map(BlogPO::toDomainModel);
}
@Override
public boolean existsById(UUID id) {
return blogMapper.existsById(id.toString());
}
@Override
public void deleteById(UUID id) {
blogMapper.deleteById(id.toString());
}
@Override
public List<Blog> findAll(BlogCriteria criteria) {
return blogMapper.selectAllByCriteria(criteria).stream().map(BlogPO::toDomainModel).collect(toList());
}
@Override
public long count(BlogCriteria criteria) {
return blogMapper.countTotalByCriteria(criteria);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册