Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dubious package detection for empty standalone files #750

Closed
pluckhuang opened this issue Dec 19, 2018 · 9 comments
Closed

Dubious package detection for empty standalone files #750

pluckhuang opened this issue Dec 19, 2018 · 9 comments

Comments

@pluckhuang
Copy link

Issue Type: Bug

a.java empty file in package A, i write "package A", then notice me "The declared package "A" does not match the expected package ""Java(536871240)", however, i move this a.java to B directory, then move back to A directory, this notice disappear! why is it..

VS Code version: Code 1.30.0 (c6e592b, 2018-12-11T22:22:15.793Z)
OS version: Darwin x64 18.2.0

@pluckhuang pluckhuang changed the title a a package err Dec 19, 2018
@pluckhuang pluckhuang changed the title a package err a package notice err Dec 19, 2018
@yaohaizh
Copy link
Collaborator

@hjb912 What the type of your project? Could you provide a gif for reproducing this issue.
Thanks.

@danjmillier
Copy link

I'm also getting this same error myself:

image

@fbricon
Copy link
Collaborator

fbricon commented Jan 23, 2019

@danjmillier can you reload vscode?

@danjmillier
Copy link

@fbricon I've tried reloading and even restarting my laptop, still no dice. Oddly enough, if I make a "main2" folder and change "package main" to "package main2" it works and I'm not sure why..

@fbricon
Copy link
Collaborator

fbricon commented Feb 7, 2019

So this is caused by jdt.ls's invisible project mechanism, that initializes it's source directory as "_/whatever/package", because the opened Java file was empty, so the initial package could not be inferred.

@the1derer
Copy link

I am also facing the same issue.

@yaohaizh
Copy link
Collaborator

@testforstephen Could you help investigate this issue?

@testforstephen
Copy link
Collaborator

When the language server is activated by an empty standalone java file, a new idea is trying to search a non empty java file from the same directory. If found, use the non empty java file to resolve package name, otherwise, take the workspaceRoot as source root and then the relative path to workspaceRoot should be the package name.

@fbricon any thoughts?

@fbricon
Copy link
Collaborator

fbricon commented Mar 5, 2019

yeah you can try that

@fbricon fbricon added this to the Mid March 2019 milestone Mar 14, 2019
@fbricon fbricon changed the title a package notice err Dubious package detection for empty standalone files Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants