[core] Text documents escapes#4044
Merged
Merged
Conversation
Slicing Chars will be enough
This uses "fragmented docs". This is less efficient when there are a lot of escapes, but: - it doesn't require the initial buffer copy - it doesn't mutate any buffer, so Chars can be readonly all the time - it handles escapes of arbitrary inLen/outLen ratio and is thus future proof - it is much more maintainable On the downside there is - efficiency (this data structure is "pointy") - clarity of the Reader implementation (one more state to support, ie reading not from the input buffer but from an escape)
This is to profit from compact string features, and to make the use of StringBuilders more efficient.
message needs escaping
Generated by 🚫 Danger |
adangel
approved these changes
Sep 9, 2022
adangel
left a comment
Member
There was a problem hiding this comment.
Thanks!
I'm going to merge this now...
| */ | ||
|
|
||
| package net.sourceforge.pmd.lang.ast; | ||
| package net.sourceforge.pmd.lang.ast.impl.javacc; |
Member
There was a problem hiding this comment.
I wonder, whether such changes need to be mentioned in release notes or somewhere...
| @Test | ||
| public void testSeveralEscapes() throws IOException { | ||
|
|
||
| String input = "abc\\\\\\u00a0d\\uu00a0ede"; |
Member
There was a problem hiding this comment.
Is it correct, that these contiguously backslash characters are gone after translating?
I don't see, that https://docs.oracle.com/javase/specs/jls/se17/html/jls-3.html#jls-3.3 defines what happens to these backslashes, just that the last backslash of an even sequence might start a unicode escape...
Member
Author
There was a problem hiding this comment.
I think you're right, thanks for spotting this!
jshell> "\u00a0"
$1 ==> " "
jshell> "\\u00a0"
$2 ==> "\\u00a0"
jshell> "\\\u00a0"
$3 ==> "\\ "
adangel
added a commit
that referenced
this pull request
Sep 9, 2022
[core] Text documents escapes #4044
adangel
added a commit
to adangel/pmd
that referenced
this pull request
Feb 21, 2025
Not in use anymore since pmd#4044
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the PR
Related issues
Ready?
./mvnw clean verifypasses (checked automatically by github actions)