redhat-developer / redhat-developer/vscode-java

Package containing dot character not being parsed correctly

Open
#1,406 9 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug upstream
Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

Issue Type: Bug

In the src folder of a Java Gradle project, there's the package structure:

projectRoot/
└── src/
    ├── main/
    │   ├── java/
    │   │   └── javasnap.domain/
    │   │       └── cli/
    │   │           └── ClStringArgs.java
    └── test/
        ├── java/
        │   └── javasnap.domain/
        │       └── cli/
        │           └── ClStringArgsTest.java

The ClStringArgs.java and ClStringArgsTest.java file contains the package declaration:

package javasnap.domain.cli;

Which is resulting in the package delcaration being highlighted as an error by VScode in both the test and production source file:

The declared package "javasnap.domain.cli" does not match the expected package "" Java(536871240)

It's also highlighting any reference to the class ClStringArgs in both the production and test source code with the following error:

ClStringArgs cannot be resolved to a type Java(16777218)

Splitting the directory name containing the dot character into two separate directories with one nested within the other causes this error to go away.

This package naming is valid for Gradle (and Java) to be able to compile and run source code. Attempting to add a directory to the Java Source Path via VScode results in the following message:

Unsupported operation. Please use build.gradle file to manage the source directories of gradle project.

Source: Language Support for Java(TM) by Red Hat (Extension)

This source directory structure is the default structuring of Gradle builds and this package naming convention is valid and used by multiple Java libraries. Can this bug get fixed or the feature of being able to resolve package names containing the dot character correctly be added to the roadmap?

Extension version: 0.60.0
VS Code version: Code 1.44.2 (ff915844119ce9485abfe8aa9076ec76b5300ddd, 2020-04-16T17:07:18.473Z)
OS version: Darwin x64 18.7.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-3740QM CPU @ 2.70GHz (8 x 2700)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
Load (avg) 3, 3, 3
Memory (System) 16.00GB
Process Argv .
Screen Reader no
VM 0%

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the error with the shown Gradle layout, including the dotted javasnap.domain directory, ClStringArgs.java, ClStringArgsTest.java, and build.gradle. Start by tracing how the extension discovers Gradle Java source directories; done means package declarations and references resolve without errors while the project still compiles and runs.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.