Skip to content

Conversation

@neubig
Copy link
Contributor

@neubig neubig commented Nov 11, 2025

Summary

This PR introduces a Flask-based web application that visualizes the mapping between COBOL legacy code and modern Java implementations. The tool helps developers understand the conversion process by displaying side-by-side comparisons of COBOL and Java code with syntax highlighting.

Features

  • Tree-sitter based Java parser to extract functions and COBOL references from comments
  • Side-by-side comparison view with syntax highlighting using Pygments
  • Automatic COBOL snippet extraction based on line references in Java comments
  • Clean, responsive UI for easy navigation between files and functions
  • Support for multiple COBOL references per Java function

How It Works

The tool scans Java files for COBOL reference comments (e.g., // COBOL equivalent: CREACC.cbl 287-307) and:

  1. Parses the Java file using tree-sitter to extract function definitions
  2. Identifies COBOL reference comments within each function
  3. Extracts the corresponding COBOL source code from the specified line ranges
  4. Displays both code snippets side-by-side with syntax highlighting

Technical Stack

  • Python Flask - Web framework
  • Tree-sitter - Java AST parsing (v0.25.2)
  • Pygments - Syntax highlighting for COBOL and Java
  • Responsive HTML/CSS - Clean UI design

Usage

cd cobol-java-viewer
pip install -r requirements.txt
python app.py

Then navigate to http://localhost:12000 to view the visualization.

Screenshots

The application currently supports 42 Java files with COBOL mappings, providing a comprehensive view of the conversion process.

Files Added

  • cobol-java-viewer/app.py - Main Flask application
  • cobol-java-viewer/requirements.txt - Python dependencies
  • cobol-java-viewer/README.md - Documentation and setup instructions
  • cobol-java-viewer/templates/ - HTML templates for the web UI
  • cobol-java-viewer/.gitignore - Python-specific ignore patterns

Testing

The application has been tested with all Java files in the repository that contain COBOL reference comments. It successfully:

  • Parses all 42 Java files with COBOL mappings
  • Extracts and displays COBOL code snippets accurately
  • Renders syntax highlighting correctly for both languages
  • Provides smooth navigation between files and functions

@neubig can click here to continue refining the PR

- Convert 29 COBOL programs to modern Java/Spring Boot
- Implement 16 business logic services
- Add 4 REST API controllers (Account, Customer, Transfer, Menu)
- Create 3 JPA entities with H2 database support
- Include 14 comprehensive tests (all passing)
- Add COBOL traceability comments for maintainability

Architecture:
- Spring Boot 2.7.14 with Spring Data JPA
- REST APIs replace 3270 BMS screens
- JPA repositories replace VSAM file I/O
- Exception hierarchy replaces CICS error handling
- Database sequences replace Named Counters

Key improvements:
- 89% code reduction (25,566 → 2,751 lines)
- Type-safe with compile-time checks
- Testable with dependency injection
- Scalable stateless REST architecture
- Industry-standard frameworks

Co-authored-by: openhands <[email protected]>
Implemented critical missing business rules from COBOL programs:

1. CREACC (CreaccService.java):
   - Added account type validation (ISA, MORTGAGE, SAVING, CURRENT, LOAN only)
   - Added maximum 10 accounts per customer limit check
   - Fixed initial balance handling to use input values if provided
   - Changed transaction type from 'CRE' to 'OCA' to match COBOL
   - Enhanced transaction description format with customer number, account type, and statement dates

2. DBCRFUN (DbcrfunService.java):
   - Added restriction preventing debits from MORTGAGE/LOAN accounts
   - Added restriction preventing credits to MORTGAGE/LOAN accounts
   - These restrictions reflect business rules that mortgage/loan transactions require proper payment channels

3. AccountRepository:
   - Added countByCustomerNumber() method for account limit checking

All changes reference specific COBOL line numbers for traceability.
All 14 tests pass successfully.

Co-authored-by: openhands <[email protected]>
This commit introduces a Flask-based web application that visualizes the
mapping between COBOL legacy code and modern Java implementations.

Features:
- Tree-sitter based Java parser to extract functions and COBOL references
- Side-by-side comparison view with syntax highlighting (Pygments)
- Automatic extraction of COBOL code snippets based on line references
- Clean, responsive UI for easy navigation
- Support for multiple COBOL references per Java function

The tool scans Java files for COBOL reference comments (e.g.,
'// COBOL equivalent: CREACC.cbl 287-307') and displays the
corresponding COBOL source code alongside the Java implementation.

Technical details:
- Python Flask web framework
- Tree-sitter for Java AST parsing
- Pygments for syntax highlighting
- Supports 42 Java files with COBOL mappings

Co-authored-by: openhands <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants