This file provides guidance to WARP (warp.dev) when working with code in this repository.
c-xrefactory is a free Emacs refactoring tool and code browser for C & Yacc. It provides advanced code navigation, symbol browsing, and automated refactoring capabilities through a client-server architecture where the c-xref server (written in C) communicates with Emacs via a custom protocol.
make prod # Build optimized c-xref for production usemake # Build with coverage and run unit tests
make all # Same as above - build and run unit tests
make unit # Build and run unit tests with coverage
make devel # Build, run quick tests, produce coverage
make ci # Full CI build - unit tests + system tests + coveragemake test # Run all tests (from top level)
make -C tests quick # Run only fast tests
make -C tests slow # Run only slow tests
make -C tests all # Run both fast and slow tests
make -C tests verbose # Run tests with detailed outputmake coverage # Generate .gcov files for Emacs cov-mode
make clean-coverage # Clean coverage data
make coverage-report # Generate HTML coverage reportTo run a single test (useful for debugging):
./tests/run_test tests/test_<testname>make clean # Clean build artifacts
make -C src clean # Clean source directory
make -C byacc-1.9 clean # Clean bundled yacc- Client-Server Model: Emacs client communicates with c-xref server via custom protocol
- Parser Pipeline: Uses bundled yacc-1.9 to generate C and Yacc parsers
- Integrated Preprocessor: Custom C preprocessor implementation that preserves macro information for navigation and refactoring (does not use system cpp)
- Memory Management: Custom memory allocation with stack-based memory for performance
- Symbol Database: Maintains cross-reference database for navigation and refactoring
src/: Core C implementation (~389 files)main.c: Entry point for c-xref serverserver.c: Server communication handling*_parser.y: Yacc grammar files for C and Yacc parsinglexer.c,yylex.c: Lexical analysissemact.c: Semantic actions during parsingrefactory.c: Core refactoring logiccomplete.c: Code completion enginecxref.c: Cross-reference generation- Memory subsystem:
memory.c,stackmemory.c - Symbol management:
symbol.c,symboltable.c,reference.c
tests/: Comprehensive test suite with 140+ test directories- Each test directory contains:
- Input C/Yacc files
- Expected output files
- Test-specific configuration
tests/run_test: Test execution script with coverage collection- Test categories: unit tests (fast), system tests (slow), integration tests
editors/emacs/: Emacs Lisp integrationc-xrefactory.el: Main Emacs interfacec-xref.el: Core functionality bindingc-xrefprotocol.el: Protocol communication
This is a hobby/OSS project with variable contributor availability. Do not use calendar time estimates in planning documents or proposals.
Instead, emphasize:
- Value - What becomes possible after this work?
- Scope - What exactly is included/excluded?
- Dependencies - What must be done first?
- Risk - What could go wrong?
- Relative effort - If discussing effort at all, use only: "smaller", "larger", "foundational"
Acceptable phrasing:
- "Smaller effort, can be tested independently"
- "Larger refactoring, requires careful test coverage"
- "Foundational work that enables X and Y"
- "Depends on completion of clean persistence store"
- "Can be deferred without blocking other work"
Avoid:
- "2-3 weeks", "1 month", "2 days" (calendar time)
- Story points (still conflates effort with time)
- Pressure language: "urgent", "critical path", "must be done ASAP"
- False precision: "14 hours", "3 weeks exactly"
When requesting architecture plans or refactoring strategies:
- No time estimates - focus on scope and success metrics
- Include risk analysis and mitigations
- Document assumptions and open questions
- Make each phase independently valuable
- Clarify dependencies between phases
Example structure:
## Phase 1: [What it does]
**Dependencies**: None (or what must be done first)
**Risk**: [What could go wrong]
**Scope**: Clearly define what's in/out
**Success criteria**: How to know it worked
**Value**: What becomes possible after this
## Phase 2: [What it does]
**Dependencies**: Phase 1 completion
...
IMPORTANT: This project uses file watches that automatically rebuild and run tests when code changes are detected. Do NOT run make or test commands unless explicitly requested by the user. Simply make code changes and wait for the user to report test results from the watches.
Commit messages should follow this format:
[topic]: Brief summary (50 chars or less)
Optional detailed explanation of the change, why it was needed,
and what it fixes or improves.
Common topic prefixes:
[fix]- Bug fixes[feat]- New features[refactor]- Code restructuring without behavior changes[test]- Test additions or modifications[docs]- Documentation changes[build]- Build system or dependency changes[perf]- Performance improvements
When modifying grammar files:
# Yacc files automatically regenerate .tab.c files via Makefile rules
make -C src clean # Force regeneration of parsers- Create directory:
tests/test_<feature_name>/ - Add test files and expected outputs
- Create
.slowfile if test is slow - Tests auto-discovered by Makefile
The build system supports debugging flags:
make EXTRA_CFLAGS=-DYYDEBUG build # Enable parser debuggingThe project uses gcov/lcov for coverage:
- Unit tests: ~80% coverage achieved
- Coverage files:
.gcov(for Emacs cov-mode),.info(for lcov) - HTML reports generated in
coverage/directory
- C compiler (gcc/clang)
- yacc (bundled yacc-1.9 included)
- libz, libcjson
- On macOS: Homebrew libraries auto-detected
- Emacs (for client interface)
- Standard Unix tools: make, bash
- Auto-detects Homebrew paths for ARM64 vs x86_64
- Can use gcc-14 if available
- Uses compatible gcov tool based on compiler
- Uses custom yacc-1.9 (not modern bison)
- Grammars not adapted to modern yacc/bison
- Java support removed (grammar was Java 1.4 era)
- Custom memory management for performance
- Stack-based allocation for temporary data during parsing
- Extensive use of generated hash tables and lists
Basic LSP server functionality exists but is experimental:
lsp_*.cfiles contain LSP protocol handlers- Communication works but features not yet accessible
- Future development direction for IDE integration
The tool supports sophisticated refactoring operations:
- Symbol renaming (variables, functions, types, macros)
- Function/macro parameter manipulation (add, delete, reorder)
- Code extraction (functions, macros, variables)
- Include file renaming
- Dead code detection and removal
- Yacc grammar symbol navigation
When discussing documentation, in particularly when adding text or descriptions, the term 'docs' refers to the Structurizr-based Asciidoc documentation located in the doc/docs directory.