Skip to content

Jump-to-Definition in Java Sources doesn't work when module is nested in other module's source root #7917

@lihaoyi

Description

@lihaoyi

Follow up to #7913

Describe the bug

Download and unpack this zip

test.zip

This contains the following files:

build.mill
mill
Foo.java
foo/test/src/foo/FooTest.java
foo/src/foo/Foo.java
.mill-version

Open it in VSCode Metals with #7914 included and import the project (or alternately, update the version of Mill to a locally built version including this upstream fix from scip-java sourcegraph/scip-java#827)

Jump-to-definition to third-party imports in foo/src/Foo.java does not work

Image

The reason seems to be that when the top-level ./Foo.java exists, Mill reports ./ as a module/source root for the top-level Foo.java file, which then causes jump-to-definition in foo/src/Foo.java to fail.

Notably, renaming the top-level ./Foo.java to ./Foo.java2 resolves the issue, as ./Foo.java2 is not recognized as a program file and does not create a source root in the enclosing folder, which results in Jump-to-Definition working again when the project is re-imported

Image

This failure mode doesn't appear to happen to Foo.scala files for some reason, only Java files.

Jump-to-definition to external libraries works when opening this small project in IntelliJ BSP

Expected behavior

No response

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

v1.6.3

Scala version/s

Extra context or search terms

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    java supportJava support related ticketssemanticdbRelated to semanticdb usage in Metals

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions