intersystems / language-server

Repository for the VS Code Language Server
https://marketplace.visualstudio.com/items?itemName=intersystems.language-server
Other
16 stars 6 forks source link

Go To Definition confuses properties and methods with the same name #289

Closed mcmundt closed 1 year ago

mcmundt commented 1 year ago

Type: Bug

Create an ObjectScript class (Test.ClassOne) with a property named "TestMe" and a classmethod also named "TestMe".

Create an ObjectScript class (Test.ClassTwo) with a classmethod MyMethod. In MyMethod, add the line "do ##class(Test.ClassOne).TestMe()"

Compile both classes

In the code editor for Test.ClassTwo, right-click on TestMe() under MyMethod, and choose "Go To Definition" from the context menu. VS Code will switch to the editor for Test.ClassOne, but will place the cursor on the TestMe property rather than the TestMe method.

Note that there is a real-world example of this in EnsLib.Workflow.Operation. In TaskHandler(), right-click on ..DeferResponse() and choose "Go To Definition".

Extension version: 2.3.6 VS Code version: Code 1.82.2 (abd2f3db4bdb28f9e95536dfa84d8479f1eb312d, 2023-09-14T05:51:20.981Z) OS version: Linux x64 5.15.0-83-generic snap Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz (2 x 2904)| |GPU Status|2d_canvas: unavailable_software
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: disabled_software
multiple_raster_threads: disabled_off
opengl: disabled_off
rasterization: disabled_software
raw_draw: disabled_off_ok
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
webgpu: disabled_off| |Load (avg)|0, 0, 0| |Memory (System)|7.72GB (2.02GB free)| |Process Argv|--no-sandbox --force-user-env --unity-launch --crash-reporter-id 90828d65-5c08-411c-878d-8fea9dcf241b| |Screen Reader|no| |VM|100%| |DESKTOP_SESSION|ubuntu| |XDG_CURRENT_DESKTOP|Unity| |XDG_SESSION_DESKTOP|ubuntu| |XDG_SESSION_TYPE|x11|
isc-bsaviano commented 1 year ago

@mcmundt

InterSystems strongly recommends that you do not give two members the same name. This can have unexpected results.

Source: https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=RCOS_appx_identifiers#RCOS_appx_identifiers_class_members

I can look into how much effort would be required to address this, but it's not high priority for me due to the recommendation against it.

mcmundt commented 1 year ago

I did a quick query against %Dictionary and found hundreds of cases in ISC product classes where methods/parameters/properties in the same class had the same name.

Still maybe not urgent, but it seems like people don't read the docs, so it would be nice to have the IDE behave correctly.