Optimize project structure for cases without Java files#42
Optimize project structure for cases without Java files#42runchen0919 wants to merge 2 commits intoeclipseguru:mainfrom
Conversation
|
@guw I updated the PR, and my test environment configuration is as follows: 001/.bazelversion 001/.eclipse/.bazelproject |
| * @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 { |
There was a problem hiding this comment.
Why does no java file exists? Is it generated by some other target and copied into the source tree?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 = [ | ||
| ], | ||
| ) | ||
|
|
There was a problem hiding this comment.
I think the next step is to add some assertions to
dd7b8b2 to
a75783b
Compare
a75783b to
d8790ee
Compare
|
cc: @guw The creation of temporary files has been removed, and the method now scans the file structure to infer the package name. |
Fixed: #39
@guw