Repository navigation
Conversation
9324d80 to
276b0d1
Compare
276b0d1 to
85cb5f9
Compare
85cb5f9 to
352faee
Compare
352faee to
8104259
Compare
8104259 to
3701c29
Compare
3701c29 to
2ba4d26
Compare
2ba4d26 to
402a1ea
Compare
402a1ea to
50f8e2c
Compare
50f8e2c to
fecc6b9
Compare
fecc6b9 to
7c80bb5
Compare
7c80bb5 to
62b1b80
Compare
0c19a7f to
630ce22
Compare
630ce22 to
7c234f8
Compare
| */ | ||
| final class SessionTypes { | ||
|
|
||
| private static final String[] SUPERTYPE_KEYS = {"super", "interfaces"}; |
There was a problem hiding this comment.
What SessionTypes is for
The server sends each type declaration only once per session, but every file is translated against its own semantic model. So a second file that needs p.Child gets nothing from the server, yet still needs p.Child and all its parents. SessionTypes keeps what the server already sent and hands it out again.
sequenceDiagram
participant T as Translator (file B)
participant C as SessionTypes
participant X as Server (get-types)
T->>C: get({p.Child})
alt name never asked
C->>X: get-types({p.Child})
X-->>C: Child, Parent, Marker, Object (sent once)
else already asked, or known undeclared
Note over C: no server call
end
C->>C: walk "super" and "interfaces" in the cache
C-->>T: Child + all its supertypes
SUPERTYPE_KEYS are the two fields of a declaration that point to parents:
"p.Child": { "super": "p.Parent`1", "interfaces": ["p.Marker"] }
"p.Parent": { "super": "java.lang.Object", "interfaces": null }super is one name (or null), interfaces is an array (or null). The loop over both keys walks up the hierarchy so the returned object holds the full closure:
flowchart LR
Child -->|super| Parent
Child -->|interfaces| Marker
Parent -->|super| Object["java.lang.Object"]
Also: a name the server does not declare goes into undeclared so it is never asked twice, and erase strips the generic arity suffix (p.Map`2 becomes p.Map).
7c234f8 to
dfeb0d2
Compare
dfeb0d2 to
a3aa127
Compare
|
Code Review ✅ Approved 🟡 Medium risk 6 closed / 6 findingsThe new, currently unused SemSitter parser adds server-backed parsing and session loading; future activation could alter parse results or fail analysis on startup. Adds ✅ 6 closed✅ Edge Case: Files on different roots crash parse instead of falling back to ECJ
✅ Quality: FILE_BY_FILE cancellation reports the progress as completed
Closed: Cross-PR: #6553's translator stops compiling against the 4-arg DocumentTranslator
Closed: Quality: Per-file fallback runs a full JParser.parse, logging and set-up per file
Closed: Quality: BATCH mode ignores AnalysisProgress, reporting progress per batch
...and 1 more closed from earlier reviews Verification Rules 3/3 met Repos 3 inspected · PRs 3 inspectedFunctional validation No results Rules 3 passed 2 not applicable
Broader impact Repos 3 inspected PRs 3 inspectedCross-repo 3 repositories inspected 0 open impacts
Auto-approval Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
david-schroeter
left a comment
There was a problem hiding this comment.
This PR looks good!
I only left a few questions and a few nit comments that can be addressed if you agree with them.
| } | ||
| Path root = ProjectRoot.commonAncestor(files.stream().map(InputFile::path).toList()) | ||
| .orElseThrow(() -> new IllegalStateException("The files share no directory to start the SemSitter server on.")); | ||
| files.sort(Comparator.comparing(file -> ProjectRoot.relative(root, file.path()))); |
There was a problem hiding this comment.
Does SemSitter expect files in a specific order, or can we preserve the caller’s order here?
| cancelled = true; | ||
| break; |
There was a problem hiding this comment.
Nit: Could we return here instead of breaking? That would allow us to drop the cancelled flag. The finally block run anyway.
| private int done; | ||
| private long lastLog; | ||
|
|
||
| Batch(AnalysisProgress analysisProgress, int files, long periodMillis) { |
There was a problem hiding this comment.
Could we pass the reporting interval through a package-private ParseProgress.start(...) overload? Production can keep the 10-second default, and the test can pass 0 to verify the progress log without sleeping or exposing Batch.
| * the preview flag are only given when the project sets them. | ||
| */ | ||
| static Map<String, List<String>> of(JavaVersion javaVersion, List<File> classpath, Path javaHome) { | ||
| Map<String, List<String>> settings = new LinkedHashMap<>(); |
There was a problem hiding this comment.
Nit: Is the insertion order of the setting keys intentional? If not, could we use a HashMap here?
| return found; | ||
| } | ||
|
|
||
| private static Set<String> supertypes(JsonElement value) { |
There was a problem hiding this comment.
Is there a reason supertypes() returns a Set rather than a List? It looks like the traversal already skips types that are in found.




Part 3 of 17 of JAVA-7392. Ticket: JAVA-7395.
Intent
SemSitterParseris aJParserthat runs one SemSitter server perparsecall and hands each file's document to aDocumentTranslator. Nothing creates it yet.It never hands a file to ECJ: the two frontends stay independent, so a comparison between them means something.
flowchart TD P[parse files] --> S{server starts and accepts settings?} S -->|no| E1[IllegalStateException: analysis fails] S -->|yes| F[for each file: get-file, translate] F -->|tree| OK[result] F -->|UnsupportedConstructException| U[parse error for this file] F -->|syntax error| R[parse error at its position] F -->|IO or runtime failure| X[parse failure for this file only]A file the translator does not support yet shows up like a file ECJ cannot parse: logged, counted as a parse error, and the analysis goes on.
ParseProgress:ProgressReportfile by file; in batch mode the sharedAnalysisProgressdrives the logs, like the ECJ batch parser (start on the first batch, global percentage, done on the last)SessionTypes: every type declaration the server sends is kept once for the whole sessionDocumentTranslator.ServerLoaders: types and package lookups, answering null once the server is closedProjectRootandSemSitterSettings: server root and settings from the analysis configurationState on master
The plugin never creates a
SemSitterParser. ECJ parses exactly as today.Test plan
SemSitterParserTestwith a scripted server: start failures fail the analysis, unsupported files are parse errors, batch progress, cancellation and loader failuresSessionTypesTest,ProjectRootTest,SemSitterSettingsTest