Thin the app's comments
The same pass the server had, on the Kotlin side: comments restating what the code says are gone, and the ones recording a measurement, a constraint or an incident are kept but cut to a few lines each. 6540 comment lines to 5674, and 920 lines off the app. Two doc comments had drifted onto the item above the one they describe -- `contextAfter`'s onto `sessionWorking` in Events.kt, and `UsageMonitor`'s equivalent on the server was fixed in the previous commit. Each is back on its own item, which is the only non-comment line this diff moves. The comments are reflowed to the column limit at their own indentation: several were written wide, and ktfmt re-wrapped them into lines holding a single orphan word. `/tmp` script, not kept -- ktfmt is idempotent over the result, which is the check. Left alone deliberately: this codebase's remaining comment density is high because the comments carry things the code cannot say -- what a null means, what a number was measured against, which bug a guard exists for. Of the 238 one-line doc comments in the app, five were pure restatement of the name and were removed; the rest each say something the signature does not. ktfmtFormat, compileDebugKotlin, lintDebug and testDebugUnitTest pass; cargo test (127), clippy --all-targets and fmt still clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
79682f03a7
commit
edc39c7371
68 files changed
+2077
-2997
No files matched your search
@@ -49,10 +49,9 @@ data class Rules(
|
||||
/** Tokens that open a comment running to the end of the line. */
|
||||
val lineComments: List<String> = emptyList(),
|
||||
/**
|
||||
* Whether [lineComments] count only at the start of a word.
|
||||
*
|
||||
* The shells need it: `$#`, `${#x}` and `a#b` are not comments, and greying the rest of those
|
||||
* lines is one of the mistakes this scanner exists to stop.
|
||||
* Whether [lineComments] count only at the start of a word. The shells need it: `$#`, `${#x}`
|
||||
* and `a#b` are not comments, and greying the rest of those lines is one of the mistakes this
|
||||
* scanner exists to stop.
|
||||
*/
|
||||
val lineCommentsAtWordStart: Boolean = false,
|
||||
val blockComment: BlockComment? = null,
|
||||
@@ -63,8 +62,8 @@ data class Rules(
|
||||
val rawStrings: Boolean = false,
|
||||
/**
|
||||
* Rust: `'` opens a character literal only when a backslash or one character and a `'` follow.
|
||||
* Otherwise it is a lifetime or a label and no string starts -- without this, `'a` opens a
|
||||
* string that runs to the next apostrophe in the block.
|
||||
* Otherwise it is a lifetime or a label -- without this, `'a` opens a string that runs to the
|
||||
* next apostrophe in the block.
|
||||
*/
|
||||
val lifetimes: Boolean = false,
|
||||
)
|
||||
@@ -91,11 +90,10 @@ enum class Attributes {
|
||||
* The spans [language] colours in [code] -- the one way to ask, whatever the language turns out to
|
||||
* be made of.
|
||||
*
|
||||
* Nearly every language here is tokens: keywords, strings and comments, which is a row of [RULES]
|
||||
* and the one shared scanner in [scan]. Markdown has none of those, and what a character means
|
||||
* there depends on where on the line it sits, so it brings a scanner of its own ([scanMarkdown]).
|
||||
* That is the whole extension point -- a new language is a row of rules or an entry in [SCANNERS],
|
||||
* and no caller learns which one it got.
|
||||
* Nearly every language here is tokens, which is a row of [RULES] and the one shared scanner.
|
||||
* Markdown has none of those, and what a character means there depends on where on the line it
|
||||
* sits, so it brings a scanner of its own. That is the whole extension point -- a new language is a
|
||||
* row of rules or an entry in [SCANNERS], and no caller learns which one it got.
|
||||
*/
|
||||
fun spansOf(code: String, language: Language): List<Span> = SCANNERS.getValue(language)(code)
|
||||
|
||||
@@ -140,8 +138,8 @@ private val RULES: Map<Language, Rules> by lazy {
|
||||
blockComment = C_STYLE,
|
||||
quotes = listOf(DOUBLE, SINGLE),
|
||||
),
|
||||
// `###` opens and closes a block comment and `#` opens a line one, which is why the
|
||||
// scanner tries the block opener first.
|
||||
// `###` opens and closes a block comment and `#` opens a line one, which is why the scanner
|
||||
// tries the block opener first.
|
||||
Language.COFFEESCRIPT to
|
||||
Rules(
|
||||
keywords = KEYWORDS_COFFEESCRIPT,
|
||||
@@ -162,8 +160,8 @@ private val RULES: Map<Language, Rules> by lazy {
|
||||
keywords = KEYWORDS_FISH,
|
||||
lineComments = listOf("#"),
|
||||
lineCommentsAtWordStart = true,
|
||||
// fish's single quotes escape only `\'` and `\\`, which is what "skip the
|
||||
// character after a backslash" already does.
|
||||
// fish's single quotes escape only `\'` and `\\`, which is what "skip the character
|
||||
// after a backslash" already does.
|
||||
quotes = listOf(DOUBLE, SINGLE),
|
||||
),
|
||||
Language.GO to
|
||||
@@ -288,10 +286,9 @@ private val RULES: Map<Language, Rules> by lazy {
|
||||
* The keyword sets.
|
||||
*
|
||||
* Every list below other than RON, TOML, fish and JSON came from dev.snipme:highlights 1.1.0
|
||||
* (`SyntaxTokens.kt`, Apache-2.0), the library this scanner replaced, so that no fence which is
|
||||
* coloured today turns plain. Entries that are not plain words were dropped -- Kotlin's `as?`,
|
||||
* `!in` and `!is`, Swift's `#if` family, Ruby's `defined?`, CoffeeScript's `=` and `->` -- because
|
||||
* the word scanner cannot reach them and the library only matched them by luck.
|
||||
* (Apache-2.0), the library this scanner replaced, so that no fence which is coloured today turns
|
||||
* plain. Entries that are not plain words were dropped -- Kotlin's `as?`, Swift's `#if` family,
|
||||
* Ruby's `defined?` -- because the word scanner cannot reach them.
|
||||
*/
|
||||
private fun words(list: String): Set<String> =
|
||||
list.split(Regex("\\s+")).filterNot(String::isEmpty).toSet()
|
||||
|
||||
Reference in new issue
Block a user