Skip to content

Conversation

@runchen0919
Copy link

Fixed: #39

@guw

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Test Results

 42 files  ±0   42 suites  ±0   1d 3h 25m 19s ⏱️ - 20m 18s
 67 tests ±0   65 ✅  - 1   1 💤 ±0  1 ❌ +1 
134 runs  ±0  121 ✅  - 2  11 💤 ±0  2 ❌ +2 

For more details on these failures, see this check.

Results for commit dd7b8b2. ± Comparison against base commit 9542833.

♻️ This comment has been updated with latest results.

@runchen0919
Copy link
Author

@guw I updated the PR, and my test environment configuration is as follows:

001/.bazelversion

7.4.1

001/.eclipse/.bazelproject

# The project view file (.bazelproject) is used to import targets into the IDE.
#
# See: https://ij.bazel.build/docs/project-views.html
#
# This files provides a default experience for developers working with the project.
# You should customize it to suite your needs.

directories:
  # .  # import everything (remove the dot if this is too much)
  module4/java/com/project/server/examples

derive_targets_from_directories: true

target_discovery_settings:
  buildfile_query=//module4/...

@runchen0919 runchen0919 marked this pull request as ready for review December 9, 2025 06:49
* @return the temporary file name if created, or null if no temporary file was needed
* @throws CoreException
*/
private String ensureJavaFileExistsInPackage(BazelTarget bazelTarget, List<String> srcs) throws CoreException {
Copy link
Member

Choose a reason for hiding this comment

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

Why does no java file exists? Is it generated by some other target and copied into the source tree?

Copy link
Author

Choose a reason for hiding this comment

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

The project structure was maintained in this way; it wasn't generated. Specifically, there are no other Java files in the same directory as BUILD in the source code.

Copy link
Member

Choose a reason for hiding this comment

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

Let's figure out a way without temp. files then. I think the logic should be fixed to handle this case, i.e. .java sources within nested directories.

Copy link
Author

Choose a reason for hiding this comment

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

This method ensures that at least one Java file in the same directory as the BUILD file can be detected in the event of multiple nested levels. If not, temporary Java files are created and then deleted after use.

Copy link
Member

Choose a reason for hiding this comment

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

Right but it does not belong here.

The logic to detect source directories is here:

It looks like it's missing to identify that particular setup.

Copy link
Author

Choose a reason for hiding this comment

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

I noticed the logic here. However, it's quite lengthy. I wanted to directly reuse the logic of detectPackagePath, so I used the temporary file creation approach. If I didn't create a temporary file, should I add more code to handle this case in the analyzeSourceDirectories method? Or do you think refactoring this method would be a reasonable thing to do?

Copy link
Member

@guw guw Dec 9, 2025

Choose a reason for hiding this comment

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

It's all the weirdness trying to map from Bazel srcs to Java source directories required by JDT.
The problem is that bazel query does not return directories but only list of files. Thus, we try to identify the directory. Depending on the provisioning strategy this could be more or less challenging.

The method is quite lengthy and increasingly challenging to maintain at this point. I have not had time to investigate a different implementation, which could also be better unit tested. I am not going to stop you from refactoring it perhaps into a separate heuristics object. I can support you with providing requirements. Although I will probably forget a few edge cases, which I need to look up from Git commit history.

deps = [
],
)

Copy link
Member

Choose a reason for hiding this comment

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

I think the next step is to add some assertions to

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project structure issues

2 participants