private FallbackParsingStrategy createFallbackStrategy()

in doc-architect/doc-architect-core/src/main/java/com/docarchitect/core/scanner/impl/java/JaxRsApiScanner.java [369:430]


    private FallbackParsingStrategy<ApiEndpoint> createFallbackStrategy() {
        return (file, content) -> {
            List<ApiEndpoint> endpoints = new ArrayList<>();

            // Check if file contains JAX-RS patterns
            if (!content.contains("@Path") && !content.contains("@GET") &&
                !content.contains("@POST") && !content.contains("@PUT") &&
                !content.contains("@DELETE") && !content.contains("@PATCH")) {
                return endpoints;
            }

            // Extract class name and package using shared utility
            String className = RegexPatterns.extractClassName(content, file);
            String packageName = RegexPatterns.extractPackageName(content);
            String fullyQualifiedName = RegexPatterns.buildFullyQualifiedName(packageName, className);

            // Extract base path from class-level @Path
            String basePath = "";
            Matcher pathMatcher = PATH_PATTERN.matcher(content);
            if (pathMatcher.find()) {
                basePath = pathMatcher.group(1);
            }

            // Simple heuristic: look for method annotations and extract paths
            // This is a simplified version - AST parsing gives better results
            String[] lines = content.split("\n");
            String currentPath = basePath;

            for (int i = 0; i < lines.length; i++) {
                String line = lines[i].trim();

                // Look for @Path on methods
                if (line.contains("@Path") && i + 1 < lines.length) {
                    Matcher methodPathMatcher = PATH_PATTERN.matcher(line);
                    if (methodPathMatcher.find()) {
                        currentPath = combinePaths(basePath, methodPathMatcher.group(1));
                    }
                }

                // Look for HTTP method annotations
                if (line.contains("@GET")) {
                    endpoints.add(createFallbackEndpoint(fullyQualifiedName, currentPath, "GET"));
                    currentPath = basePath; // Reset for next method
                } else if (line.contains("@POST")) {
                    endpoints.add(createFallbackEndpoint(fullyQualifiedName, currentPath, "POST"));
                    currentPath = basePath;
                } else if (line.contains("@PUT")) {
                    endpoints.add(createFallbackEndpoint(fullyQualifiedName, currentPath, "PUT"));
                    currentPath = basePath;
                } else if (line.contains("@DELETE")) {
                    endpoints.add(createFallbackEndpoint(fullyQualifiedName, currentPath, "DELETE"));
                    currentPath = basePath;
                } else if (line.contains("@PATCH")) {
                    endpoints.add(createFallbackEndpoint(fullyQualifiedName, currentPath, "PATCH"));
                    currentPath = basePath;
                }
            }

            log.debug("Fallback parsing found {} endpoints in {}", endpoints.size(), file.getFileName());
            return endpoints;
        };
    }