Skip to content

The project's package fragments are not update to date when adding a new one. #1137

Closed

Description

@jdneo

Repro steps:

  • Open a java project to let the Java Language Server start up
  • Create a new folder, the folder path is belong to one of the project's PackageFragmentRoot
  • Create a Java file in that folder
  • Then, when we get a IJavaProject instance in the Java side, and inspect the PackageFragment, there is no entry for the new created one. (You can call project.getPackageFragmentRoots() first, after find the right root, call getChildren() over it)

bug

This bug affects several scenario, like:

  • Cannot move a compilation unit to a newly created package (gif above)
  • Could not find or load main class xxx when debugging a main class in newly created package
  • Java dependency viewer cannot show the newly created package and its members in the explorer
  • Java Test explorer cannot show the newly created package and its members in the explorer

Activity

  1. jdneo commented on Oct 12, 2019

    @jdneo
    ContributorAuthor

    @snjeza @fbricon

    I found a reason which may cause this bug. In https://github.com/eclipse/eclipse.jdt.ls/blob/ff78ddaf41417aec47cfdf1aa619a96f87462f61/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/JDTUtils.java#L894

    We always refresh the parent with zero depth. After this operation, the parent of the newly created package is still not aware of the existence of its new member. Maybe we need to use DEPTH_ONE here?

  2. fbricon commented on Oct 12, 2019

    @fbricon
    Contributor

    If that's what it takes to work then ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions