[ 
https://issues.apache.org/jira/browse/GROOVY-12085?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18088661#comment-18088661
 ] 

ASF GitHub Bot commented on GROOVY-12085:
-----------------------------------------

codecov-commenter commented on PR #2606:
URL: https://github.com/apache/groovy/pull/2606#issuecomment-4697021376

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2606?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 68.3177%. Comparing base 
([`f8f2f31`](https://app.codecov.io/gh/apache/groovy/commit/f8f2f31effe9e0249efd93bf73b310275fced318?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`91ba9ef`](https://app.codecov.io/gh/apache/groovy/commit/91ba9efae5d4f8c8ab445b9d8bd370167a2f8edd?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/2606/graphs/tree.svg?width=650&height=150&src=pr&token=1r45138NfQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/groovy/pull/2606?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #2606        +/-   ##
   ==================================================
   + Coverage     68.3101%   68.3177%   +0.0075%     
   - Complexity      33445      33451         +6     
   ==================================================
     Files            1518       1518                
     Lines          127028     127033         +5     
     Branches        23055      23056         +1     
   ==================================================
   + Hits            86773      86786        +13     
   + Misses          32546      32540         -6     
   + Partials         7709       7707         -2     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2606?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...ovy/parser/antlr4/util/PositionConfigureUtils.java](https://app.codecov.io/gh/apache/groovy/pull/2606?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2Futil%2FPositionConfigureUtils.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L3V0aWwvUG9zaXRpb25Db25maWd1cmVVdGlscy5qYXZh)
 | `95.9184% <100.0000%> (+0.0850%)` | :arrow_up: |
   | 
[...odehaus/groovy/runtime/powerassert/SourceText.java](https://app.codecov.io/gh/apache/groovy/pull/2606?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fruntime%2Fpowerassert%2FSourceText.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3J1bnRpbWUvcG93ZXJhc3NlcnQvU291cmNlVGV4dC5qYXZh)
 | `78.2609% <100.0000%> (+2.0704%)` | :arrow_up: |
   
   ... and [5 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/2606/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test 
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, 
report on failures, and find test suite problems.
   - :package: [JS Bundle 
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save 
yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>




> SourceText slices UTF-16 with code-point AST columns, truncating source for 
> supplementary characters
> ----------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12085
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12085
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>              Labels: breaking
>
> Power-assert renders truncated source text for any assertion containing 
> supplementary (astral-plane) characters such as emoji. Anything reusing 
> {{SourceText}} (e.g. groovy-contracts/groovy-verify source capture) is 
> affected, and the same column mismatch mis-positions syntax-error carets.
> h4. Steps to reproduce
> {code:groovy}
> assert (true ? '🥤🐝' : 'z').length() == 999
> {code}
> The rendered expression is cut short by one character per emoji preceding the 
> end (e.g. {{== 999}} renders as {{== 9}}).
> h4. Root cause
> AST column numbers are *code-point*-based ({{GroovyLangLexer}} uses 
> {{CharStreams.fromReader}} -> ANTLR {{CodePointCharStream}}; 
> {{PositionConfigureUtils}} sets {{columnNumber = getCharPositionInLine() + 
> 1}}), but {{SourceText}} slices a *UTF-16* {{String}} from 
> {{SourceUnit.getSample()}} with {{substring()}} using those columns. Each 
> astral char before the slice boundary under-counts the UTF-16 index by one, 
> cutting the slice short.
> Compounding this, {{PositionConfigureUtils}} computes {{lastColumnNumber = 
> getCharPositionInLine() + 1 + token.getText().length()}} -- a code-point 
> start plus a UTF-16 length. The UTF-16 term accidentally compensates for 
> astral chars *inside* the final token (so "emoji as last token" works) but 
> not for those *before* it, which is why the bug looks intermittent.
> h4. Suggested fix
> Make column numbers uniformly code-point-based 
> ({{token.getText().codePointCount(0, len)}} in {{PositionConfigureUtils}}), 
> then convert code-point columns to UTF-16 indices at the slice sites via 
> {{String.offsetByCodePoints}} ({{SourceText}}, and the syntax-error message 
> renderers). Note: converting the hybrid {{lastColumnNumber}} without the 
> {{codePointCount}} fix first will overshoot/throw, so both changes are needed 
> together.
> h4. Affects
> All current versions (present on master). Affects power-assert rendering and 
> any consumer of {{SourceText}}/AST column positions for supplementary 
> characters.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to