Commit Graph

5 Commits

Author SHA1 Message Date
Lulu13022002 8294f7dca4
unflatten closure representation 2024-04-22 18:40:27 +02:00
Lulu13022002 b0d9d2d6ed
fix string and char overlapping other closures 2024-04-18 20:19:04 +02:00
Lulu13022002 278ec348b1
fix fully qualified name parsing
I just remembered what the code here: be2c97e077 (diff-d1c41ba7339650258002e194c96b640601661a9e6f21d4ea5fec6499f7718464L63)
was supposed to do. This is a reimplementation of the same things but without redundant operation. In short the cleaner
that remove multi line comment and whitespace in FQN should only run before or after a dot. Semi colon for imports
are already the terminator of the type name so there's no need for a special case for them.
And fix an issue where star ('*') in the middle of an import type name was wrongly detected.
Reserved keyword or syntax error in the type name will now throw an expection instead of just being ignored.
2024-04-14 21:54:07 +02:00
Lulu13022002 be2c97e077
cleanup and remove redundant operation for trailing single line comment on expanded type name 2024-04-12 18:59:30 +02:00
Lulu13022002 5a05ceabee
improve source parsing to be more accurate
The previous way had several flaw and was not really future proof. This
new system is based on an iterative string reader similar to how brigadier parse
arguments which simplify a lot of things tracking the cursor internally.

The comments and javadoc are now properly skipped to prevent commented line to be counted as an import.

The first scope detection to stop the parser once all imports have been processed
now detect the first '{' char uncommented. Previously it only worked for api
gen and was really restrictive since it detected the following pattern: <class type> <class name>
as a workaround.
The annotations are also skipped to prevent curly bracket that could be in
it to be counted too (this include the arguments as well).

Type name extended on multi line are also supported and checked at
runtime as defined in the JLS:
https://docs.oracle.com/javase/specs/jls/se17/html/jls-3.html#jls-3.8
For fully qualified name, each part separated by a dot are checked. Keyword
are also checked to prevent @interface to be considered as a regular annotation
when it's more a class definition. Whitespace and comments in between type name are
stripped to collect the right import in the end. Annotation between the package
name and the class name are not supported but is not needed for
import and annotation since they are forbidden by the compiler.

Multi line stuff is handled using a list of tasks to process in the right order
for the imports or annotations with two types of task: repeat and basic.

This new system is now used in the marker comment detection and in the old generated
code test.

There's also a lot of tests to make sure no regression happen in the future
that can be enabled by inluding the tag 'parser' (disabled in CI runner by default).
Additionnaly marker stub are not anymore allowed by default while parsing import,
annotation and metadata stuff but can be reenabled with the system property
'paper.generator.rewriter.searchMarkerInMetadata' for experimental/testing
purpose.

Short type name resolution (based on the collected imports) has been redone to
supports static star import and inner class type referenced either implicitly or via import.
2024-04-11 20:22:30 +02:00