No task waits on a Codex review; the redesign tasks are confirmed on the product owner's Z Fold7; TASK-016's leftovers are on hold; no biometric reauthentication. Agent: main (opus) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
76 lines
3.8 KiB
Markdown
76 lines
3.8 KiB
Markdown
# TASK-049: C/C++ syntax highlighting and multi-line comment coloring
|
|
|
|
Status: implemented; required checks pass; confirmed by the human product owner on their Z Fold7 (2026-09-29)
|
|
Owner: Claude
|
|
Reviewer: human product owner
|
|
|
|
## Outcome
|
|
|
|
The human product owner's team mainly reads C# and C++ in this app. C/C++ files currently fall
|
|
back to plain, uncolored text, and a block comment that spans several lines is only colored on its
|
|
first and last line (TASK-048's recorded known limitation). After this task C/C++ sources are
|
|
highlighted, and a multi-line comment keeps its comment color on every line it covers, in every
|
|
language that has block comments.
|
|
|
|
## Scope
|
|
|
|
- Included: a `CPP` language (`.c .h .cc .cpp .cxx .hpp .hh .hxx .inl .ipp`) with its keyword set;
|
|
preprocessor directives (`#include`, `#pragma`, `#define`, C#'s `#region` ...) in their own color,
|
|
with an `#include <...>` target colored as a string; cross-line block-comment state (`/* */` and
|
|
`<!-- -->`) carried from one line to the next; numbers with digit separators (`30_000`,
|
|
`1'000'000`) and hex literals; unit tests for all of the above.
|
|
- Excluded: a real parser. Multi-line *strings* (C++ raw strings, C# verbatim/raw strings, Python
|
|
triple quotes) still only color on the line where they start. Type/method coloring, the Visual
|
|
Studio palette, the header/source pairing view and the standalone full-screen viewer belong to
|
|
the redesign tasks that follow.
|
|
|
|
## Writable paths
|
|
|
|
- `app/src/main/java/com/ubisam/ubgitea/feature/codebrowser/content/SyntaxHighlighter.kt`
|
|
- `app/src/main/java/com/ubisam/ubgitea/feature/codebrowser/CodeBrowserScreen.kt` (`CodeBlock` only)
|
|
- `app/src/test/java/com/ubisam/ubgitea/feature/codebrowser/content/SyntaxHighlighterTest.kt`
|
|
- `tasks/049-cpp-highlighting-and-multiline-comments.md`, `docs/development-log.md`
|
|
|
|
## Acceptance criteria
|
|
|
|
- [x] `.c .h .cc .cpp .cxx .hpp .hh .hxx .inl .ipp` files resolve to the C/C++ language.
|
|
- [x] C/C++ keywords, strings, numbers, line comments and block comments are colored.
|
|
- [x] `#include <chrono>` colors the directive as preprocessor and `<chrono>` as a string.
|
|
- [x] Every line inside a multi-line `/* ... */` or `<!-- ... -->` comment is colored as a comment,
|
|
and code after the closing delimiter on the same line is highlighted normally.
|
|
- [x] A `/*` inside a string literal or after `//` does not open a comment.
|
|
- [x] Highlighting is computed once per file, not on every recomposition.
|
|
- [x] Unit tests cover the criteria above.
|
|
- [ ] Confirmed on the human product owner's device against real C++ sources.
|
|
|
|
## Security and privacy
|
|
|
|
No additional concerns. No network, storage or logging is touched.
|
|
|
|
## Required checks
|
|
|
|
```text
|
|
./gradlew compileDebugKotlin compileDebugUnitTestKotlin testDebugUnitTest assembleDebug lintDebug
|
|
```
|
|
|
|
## Evidence
|
|
|
|
Recorded on 2026-09-28 in the worktree `awesome-pascal-3f2ada`, on top of `39be1b7` plus the
|
|
still-uncommitted TASK-045..048 changes copied from the main checkout, using Android Studio's
|
|
bundled JDK (`D:\AndroidStudio\jbr`, OpenJDK 21):
|
|
|
|
- `./gradlew compileDebugKotlin compileDebugUnitTestKotlin testDebugUnitTest` -- passed; 289 tests,
|
|
0 failures, 0 errors, 0 skipped. New `SyntaxHighlighterTest`: 21 tests, all passing.
|
|
- `./gradlew assembleDebug lintDebug` -- passed; lint 0 errors, 40 warnings.
|
|
- `SyntaxHighlighter.kt`: new `CPP` language and extension mapping; `tokenizeLines` (Compose-free,
|
|
carries open block-comment state across lines); `highlightLines`; preprocessor role and color;
|
|
number pattern extended to hex and digit separators. `highlightLine` kept as a single-line
|
|
wrapper.
|
|
- `CodeBrowserScreen.kt`: `CodeBlock` highlights the whole file once inside `remember` and renders
|
|
the cached lines in both the wrap and no-wrap branches.
|
|
- Not done: installing on a device. No device was connected to this session.
|
|
|
|
## Review findings
|
|
|
|
None yet.
|