Skip to content

Conversation

shivam71
Copy link
Contributor

@shivam71 shivam71 commented Sep 23, 2025

Issue : End position not found for implicit class scaffolding compact source file (JEP 512)

Context

  • Compact source file allow top level methods and fields.
  • Internally the fields and methods are treated as part of a implicit final class.
  • As the class in not explicitly declared in code the IDE when trying to find end position for the corresponding java element fails.
  • This change defaults to using the end position of the compilation unit tree (which is computed correctly) when for a class element source position is found but no end position is found.
  • Visible effect of this issue was missing outline view for the compact source file in the Java VSCode Extension.

Debugging output for reference

Screenshot 2025-09-22 at 5 46 25 PM

^Add meaningful description above

Click to collapse/expand PR instructions

By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -

  • are all your own work, and you have the right to contribute them.
  • are contributed solely under the terms and conditions of the Apache License 2.0 (see section 5 of the license for more information).

Please make sure (eg. git log) that all commits have a valid name and email address for you in the Author field.

If you're a first time contributor, see the Contributing guidelines for more information.

If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.

PR approval and merge checklist:

  1. Was this PR correctly labeled, did the right tests run? When did they run?
  2. Is this PR squashed?
  3. Are author name / email address correct? Are co-authors correctly listed? Do the commit messages need updates?
  4. Does the PR title and description still fit after the Nth iteration? Is the description sufficient to appear in the release notes?

If this PR targets the delivery branch: don't merge. (full wiki article)

@mbien mbien added debugger Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) labels Sep 23, 2025
@mbien mbien added this to the NB28 milestone Sep 23, 2025
@apache apache locked and limited conversation to collaborators Sep 23, 2025
@apache apache unlocked this conversation Sep 23, 2025
@mbien mbien requested review from dbalek and lahodaj September 23, 2025 12:29
Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK for now.

switch(forTree.getKind()) {
case CLASS:
if ((int) target[1] >= 0 && (int) target[2] == -1) {
// Compact Source file (JEP 512) issue implicit class end position not found in code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Compact Source file (JEP 512) issue implicit class end position not found in code
// Compact Source file (JEP 512) issue implicit class end position not found in code
// see JDK-8364015

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done !

…mpact source file compilation unit to end position of compilation unit tree.
@shivam71 shivam71 force-pushed the compact_src_file_implicit_class_end_pos_fix branch from 96bf942 to b59293f Compare October 13, 2025 08:46
@ebarboni ebarboni modified the milestones: NB28, NB29 Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) VSCode Extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants