0

enter image description here

As shown above, when I type a variable name, if the prompted variable name is in a class, the variable will be prompted as a local variable, is there any way to remove such a prompt, that is, the variable in the class will not be prompted in any way locally?

Johnny Willemsen
  • 2,942
  • 1
  • 14
  • 16
ChenLee
  • 1,371
  • 3
  • 15
  • 33

1 Answers1

0

That's not a "local variable", but an "identifier local to this file" (as supposed to a built-in or a keyword).

You can write your own auto-completers to be more context-aware. Here's a small sample - you're given a code location and return an array of completions.

YellowAfterlife
  • 2,967
  • 1
  • 16
  • 24
  • I know how to write a simple completer, but how does this function work, and how do I go about classifying the variables and local variables in the category? Do I need to involve traversal of the abstract syntax tree here? – ChenLee Jun 05 '23 at 09:13
  • You would need _some_ sort of structure representation - it can be a complete AST (there are a few libraries and even Python implementations in JS) or a simpler algorithm making a few assumptions about code structure (like class fields and methods being inside the class rather than assigned in some function that the constructor calls). – YellowAfterlife Jun 06 '23 at 00:10