redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.08k stars 440 forks source link

For Java intellicode suggests a lot of poor choices #1754

Open rajinder-yadav opened 3 years ago

rajinder-yadav commented 3 years ago

Issue Type: Bug

In java, when typing code, intellicode should be smart enough to know what context I am in, like coding a class and it should only provide what the most likely keyword I am going to type next.

  1. Create a class person with two private string fields
  2. Type "p", note what is suggested (should be private, public).
  3. After private, type "S", note what is suggested, in fact typing "Str" still does not yield "String" as a top choice.

This is no where close to improving productivity like with intellij, would love to see this fixed.

I'm sure this is also a problem with other languages like TypeScript, JS, GoLang.

After pressing "p"

bug-0

After pressing "S"

bug-1

After pressing "Str"

bug-2

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 7 2700X Eight-Core Processor (16 x 3967)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: disabled_software
skia_renderer: disabled_off_ok
video_decode: unavailable_off
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled| |Load (avg)|0, 1, 1| |Memory (System)|31.29GB (9.76GB free)| |Process Argv|. --no-sandbox| |Screen Reader|no| |VM|0%|
Extensions (54) Extension|Author (truncated)|Version ---|---|--- terraform|4op|0.2.1 vscode-base64|ada|0.1.0 vscode-tomcat|ada|0.11.3 markdown-toc|Ala|1.5.6 Bookmarks|ale|11.1.0 ng-template|Ang|0.1100.2 vscode-browser-preview|auc|0.6.7 npm-intellisense|chr|1.3.1 path-intellisense|chr|2.3.0 bracket-pair-colorizer|Coe|1.0.61 vscode-markdownlint|Dav|0.38.0 vscode-eslint|dba|2.1.8 java-decompiler|dgi|0.0.2 EditorConfig|Edi|0.15.1 prettier-vscode|esb|5.5.0 markdown-preview-bitbucket|hbr|1.0.0 java-properties|ith|0.0.2 vscode-peacock|joh|3.8.0 solidity|Jua|0.0.76 sort-typescript-imports|mic|1.4.1 vscode-docker|ms-|1.1.0 python|ms-|2020.5.86806 cpptools|ms-|0.28.3 vscode-typescript-tslint-plugin|ms-|1.3.2 debugger-for-chrome|msj|4.12.8 angular2-inline|nat|0.0.17 vetur|oct|0.24.0 vscode-boot-dev-pack|Piv|0.0.8 vscode-concourse|Piv|1.24.0 vscode-manifest-yaml|Piv|1.24.0 vscode-spring-boot|Piv|1.24.0 platformio-ide|pla|1.10.0 java-ide-pack|pve|1.2.1 java|red|0.59.1 vscode-yaml|red|0.13.0 markdown-preview-enhanced|shd|0.5.15 vscode-checkstyle|she|1.3.3 java-generate-setters-getters|soh|5.3.0 sonarlint-vscode|Son|1.19.0 language-stylus|sys|1.11.0 find-then-jump|tra|2.0.4 sort-lines|Tyr|1.9.0 vscodeintellicode|Vis|1.2.10 vscode-java-debug|vsc|0.27.1 vscode-java-dependency|vsc|0.9.0 vscode-java-pack|vsc|0.12.1 vscode-java-test|vsc|0.22.3 vscode-maven|vsc|0.27.0 vscode-spring-boot-dashboard|vsc|0.1.10 vscode-spring-initializr|vsc|0.6.1 better-align|wwm|1.1.6 vscode-java-saber|You|0.1.1 markdown-pdf|yza|1.4.4 vscode-aspell|zap|0.1.4 (8 theme extensions excluded)
testforstephen commented 3 years ago

@Eskibear Could you take a look whether this can be achieved by IntelliCode extension?

Eskibear commented 3 years ago

No, it's not related to IntelliCode. The behavior is the same when IntelliCode is not installed.

testforstephen commented 3 years ago

I don't mean that this is a bug in IntelliCode, I mean whether IntelliCode could optimize the recommendation order for these completion choices.

Eskibear commented 3 years ago

Theoretically that can be done by machine learninig approaches or hardcoded rules. But no, currently IntelliCode only re-ranks methods of a certain type. Modifiers, types, keywords are not included.

0dinD commented 3 years ago

My take on the issue in the first screenshot is that it's a non-issue if you follow the widely accepted convention of using UpperCamelCase for class names. If the class were to be named Person, the access modifiers are the top results, and you have to type a capital P in order to be suggested the Person class over the access modifiers.

But I do agree that it would be nice if the IntelliCode extension could rank types based on their usage. So if anything I think you should focus on ranking types, not modifiers and keywords @Eskibear.