SSlinky / VBA-LanguageServer

VBA Language Server
GNU General Public License v3.0
16 stars 4 forks source link

[Feature] Quick Fix - Add from *.dll #15

Open sancarn opened 4 months ago

sancarn commented 4 months ago

Is your feature request related to a problem? Please describe.

Kinda. People often find it difficult to write Declare statements with certainty that they are correct. I have frequently accidentally written a function signature with some param which was meant to be a Integer but I accidentally wrote Long. With VBA Pro we could eventually add a quick-fix option, much like they do in other languages like python and typescript which brings auto-imports into the main import section of the module.

image

Describe the solution you'd like

Say the user writes GetWindow, we can flag the error that GetWindow is not defined. It would be great to add a Quick Fix option to import from user32. Upon choosing this option:

  1. Private Declare PtrSafe Function GetWindow Lib "user32" (ByVal hwnd As LongPtr, ByVal wCmd As apiWindowRelationship) As LongPtr will be added to the VBA7 section
  2. Private Declare Function GetWindow Lib "user32" (ByVal hwnd As LongPtr, ByVal wCmd As apiWindowRelationship) As LongPtr will be added to the < VBA6 section
  3. Enum LongPtr added if undefined to VBA6 section
  4. Enum for apiWindowRelationship added to the declare section

I anticipate this feature is pretty far off, but just wanted to add it while I thought of it.

We'll probably need some repository of Enums, DLLs etc. in some JSON format. Or perhaps more ideally generated from the win32 metadata

SSlinky commented 4 months ago

I like it, but it's definitely on the backlog. And I agree, a repository of some sort would probably be the way to manage it. I think it'll be behind adding the object model / code completion and fixes for that.