CoffeeChaton / vscode-autohotkey-NekoHelp-Old

my style
Other
9 stars 0 forks source link

Feature request: detect variables and functions with the same name. #16

Closed marius-sucan closed 1 year ago

marius-sucan commented 1 year ago

Hello!

I would like to be able to detect if I have a variable name that is also a function. Is it possible? This would be very helpful for me.

Thank you .

murataygunn commented 1 year ago

Just use built-in search tool's regex function.

marius-sucan commented 1 year ago

Just use built-in search tool's regex function.

That is not how this works.

murataygunn commented 1 year ago

Search for variableName and put () at the end.

marius-sucan commented 1 year ago

Search for variableName and put () at the end.

Uuuuuu, I am shocked. Sarcasm. Ya must be a l33t pro! uuuu... nais.

What if we have many functions and many variables, we do it one by one, right? what if we have variables that are not defined as varName := value , but in other ways ? what if the var is designating an object ? what if a variable name is a part of a larger/longer variable name?

The code I am working on has around 2000 functions and I do not know how many variables.

@CoffeeChaton is definitely going to understand why I requested this feature.

murataygunn commented 1 year ago

It doesn't make sense. I still recommend using it with the regex feature of the integrated search system, because this extension doesn't do anything different. And you want this nice coder to do your legwork for you. That's a very selfish and uncommon request.

marius-sucan commented 1 year ago

I don't understand why you even post here... do you even use this extension? Any extension is meant to help users do repetitive tasks. For example , this extension allows users to easily identify unused declared variables. Now, what you are saying, is that people like me are selfish, because we want to a tool to easily identify these. You could select each variable name and check if it's used, using the search tool. Why have an extension that does the legwork for me? By your logic, the work done by this awesome guy is somehow pointless.

You are outlandish. I'll no longer reply to your messages.

Best regards, Marius.

CoffeeChaton commented 1 year ago

1674694166214

CoffeeChaton commented 1 year ago

Let me explain why I provide this diagnostic function, because when i want to use Higher-order function in ahk-v1, i always forget to need use func("funcName") to set functionObject.

js

function fnName(){
    return "A"
}

let fn = fnName; // 
let fnResult = fn(); // call fn && fnResult === "A"

console.log(fnResult); // look like call MsgBox % "A"

ahk v2

fnName() {
    return "A"
}

fn := fnName
fnResult := fn() ; // call func && fnResult === "A";
MsgBox(fnResult)

ahk v1

fnName() {
    return "A"
}

fn := func("fnName") ; fn is funcObject
;     ^ I always forget to use the `func()`
fnResult := fn() ; call function && fnResult === "A";
MsgBox % fnResult
CoffeeChaton commented 1 year ago

I love ahk v2 and js, but when I switch back to ahk v1 from those languages, I always forget that I need to use func("fnName"). I've forgotten what running without func() wrapping fn-name would do, but I once wasted a weekend just trying to find a bug in 1500 lines of code

I always stumble on some common mistakes, such as the classic:

ahk v1

i := 5
loop, i {
    ; ^ forget to use `% i` or `%i%`
    ;   === Loop 0 
    ; ahk v2 fix this 
    MsgBox % A_Index
}
CoffeeChaton commented 1 year ago

any idea of exp code? or Better diag msg/ settings ?

marius-sucan commented 1 year ago

I love ahk v2 and js, but when I switch back to ahk v1 from those languages, I always forget that I need to use func("fnName"). I've forgotten what running without func() wrapping fn-name would do, but I once wasted a weekend just trying to find a bug in 1500 lines of code

I always stumble on some common mistakes, such as the classic:

ahk v1

i := 5
loop, i {
    ; ^ forget to use `% i` or `%i%`
    ;   === Loop 0 
    ; ahk v2 fix this 
    MsgBox % A_Index
}

You should ignore such cases. People don't use proper syntax. At least that's what I would do.

marius-sucan commented 1 year ago
  • settings.json

    {
    "AhkNekoHelp.Diag.code511": 10, // default 0 max 999
    "AhkNekoHelp.Diag.code512": 10, // default 0 max 999
    "AhkNekoHelp.Diag.code513": 10, // default 0 max 999
    }
  • diag msg look like:

    1. var/param "fnA" is the same func-name "fnA()"
    2. global-val "fnA" is the same func-name "fnA()"
    3. label "fnA:" is the same func-name "fnA()"
  • exp code

    1. code 511
    2. code 512
    3. code 513

any idea of exp code? or Better diag msg/ settings ?

I think it's perfect. Thank you for the work you are doing !

I don't have any better ideas...

Best regards, Marius.

murataygunn commented 1 year ago

Sorry @marius-sucan, I completely misunderstood the subject. Later, when I saw the examples, I understood better. I didn't even know that we can assign a function to a variable in AutoHotkey. I apologize for creating pollution on this subject.

CoffeeChaton commented 1 year ago

You should ignore such cases. People don't use proper syntax. At least that's what I would do.

I just want to say that I often make mistakes in some classic problems, so I hope the IDE can provide the diagnosis immediately when I write the code to save the debug time.

CoffeeChaton commented 1 year ago
  • settings.json
{
    "AhkNekoHelp.Diag.code511": 10, // default 0 max 999
    "AhkNekoHelp.Diag.code512": 10, // default 0 max 999
    "AhkNekoHelp.Diag.code513": 10, // default 0 max 999
}
  • exp code
  1. code 511
  2. code 512
  3. code 513

close with v0.0.20