func()

in src/ulsp/controller/jdk/jdk.go [103:145]


func (c *controller) ResolveBreakpoints(ctx context.Context, req *types.ResolveBreakpoints) ([]*types.BreakpointLocation, error) {
	symbols, err := c.scip.GetDocumentSymbols(ctx, req.WorkspaceRoot, req.SourceURI)
	if err != nil {
		return nil, err
	}
	res := make([]*types.BreakpointLocation, 0, len(req.Breakpoints))
	if len(symbols) == 0 {
		c.logger.Warnf("path not found in scip %q", req.SourceURI)
		return res, nil
	}
	defs := c.getClassDefinitions(ctx, symbols)
	if len(defs) == 0 {
		c.logger.Debugf("no class definitions found in file %q (found %d symbol occurrences)", req.SourceURI, len(symbols))
		return res, nil
	}
	if len(defs) == 1 {
		c.logger.Warnf("found one class definition in file %q: %+v", req.SourceURI, defs[0])
		// Only one class in the file, return the breakpoints
		for _, rbp := range req.Breakpoints {
			res = append(res, &types.BreakpointLocation{
				Line:      rbp.Line,
				Column:    rbp.Character,
				ClassName: getFullClassName(defs[0].Symbol),
			})
		}
		return res, nil
	}

	for _, rbp := range req.Breakpoints {
		// Find the enclosing class for the line
		className, err := c.findEnclosingClass(ctx, defs, rbp)
		if err != nil {
			c.logger.Warnf("failed to find enclosing class for line %d: %v", rbp.Line, err)
			continue
		}
		res = append(res, &types.BreakpointLocation{
			Line:      rbp.Line,
			Column:    rbp.Character,
			ClassName: className,
		})
	}
	return res, nil
}