Git Product home page Git Product logo

vscode-inline-parameters's People

Contributors

cyberbeni avatar hot-1 avatar iamnikola avatar imliam avatar jack0york avatar l1997i avatar richardluo0 avatar robertostermann avatar ryangjchandler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vscode-inline-parameters's Issues

Python inline parameters won't work for Python<3.6

Thanks so much for the awesome extension.

I found a bug for Python inline parameters.

In src/python/pythonHelper.ts#L12, f-strings are used to format strings.

const command = `python ${context.extensionPath}/out/src/python/helpers/main.py ${fsPath}`; // Production

However, this feature was introduced in Python 3.6. If the default Python configured in the environment is Python2 or <3.6, the Python features of this extension will not work properly. Specifically, it will have the following error,

[2022-04-11 20:41:00.818] [exthost] [error] Error: Command failed: python /home/luis/.vscode-server/extensions/robertostermann.inline-parameters-extended-1.1.1/out/src/python/helpers/main.py /home/luis/test/test.py
  File "/home/luis/.vscode-server/extensions/robertostermann.inline-parameters-extended-1.1.1/out/src/python/helpers/main.py", line 17
    expression_line = f"expression line: {node.func.lineno}"

As a solution for this, I think you should choose the appropriate Python version in the program (because most computers have both Python3 and Python2 installed).

One of the simplest solutions is to specify the use of Python3 directly in src/python/pythonHelper.ts#L12, but this still cannot ensure that Python>=3.6.

const command = `python ${context.extensionPath}/out/src/python/helpers/main.py ${fsPath}`; // Before
const command = `python3 ${context.extensionPath}/out/src/python/helpers/main.py ${fsPath}`; // After

PHP: wrong inlay hints

Description:
php_inlay_hints

Method Definition:
image

Extension settings (default overriden):
"inline-parameters.php.suppressWhenArgumentMatchesName": false

Inlay settings:
"editor.inlayHints.enabled": "offUnlessPressed"

If there is some additional info, feel free to ask.

Golang: missing parameter hint on variable function call.

Screenshot_20220527_180647

GO version: 1.18
Parser output for line 19:

expression call: walkValue | expression line: 19 | expression character: 13 | argument start line: 19 | argument start character: 14 | argument end line: 19 | argument end character: 26
NEW EXPRESSION
expression call: &{val Field} | expression line: 19 | expression character: 23 | argument start line: 19 | argument start character: 24 | argument end line: 19 | argument end character: 25
NEW EXPRESSION

Java: parameter hints duplication

When builtin inlay hints for java enabled the hints appears twice even when inline-parameters.java.enabled set to false.

OS: Windows 10
vscode version: 1.67.2
extension version: 1.2.1
settings:
{ "inline-parameters.java.enabled": false, "java.inlayHints.parameterNames.enabled": "all" }

Screenshot 2022-05-27 040336

[Feature Request] Configuration for function names to ignore inline hinting

Hi again! :)

I find this extension extremely helpful for new code and packages that I'm using, but it still has room for improvement. At least on the Python side, since that's what I'm using it for.

Describe the Feature Request

Many Python's built-in functions' parameters are unnecessary to inlay hint and introduce unnecessary clutter most of the time. Also, use of keyword arguments in many Python's built-in functions calls just doesn't work because many built-in functions are C functions bound to Python.

Because of that, I propose having a configuration argument that would ignore built-ins, if that is even feasible.
If not that, the second best thing would be to allow configuring an ignore list of function names that will never be inlay hinted.

I find this feature to be neat and it would also expand on the customizability of the extension.

Describe Preferred Solution

If built-in ignoring is possible the user would need to set e.g. "inline-parameters.python.ignoreBuiltIns": true in VS Code's settings.json.

Describe Alternatives

Seeing that the above is probably far-fetched, I propose giving users an option to configure a list of functions they don't want to inlay hint instead.
The user would have to define e.g. "inline-parameters.python.functionsToIgnore": ["print", "len", "sort", ...] in settings.json.

Related Code

I haven't developed any extension so I don't have any experience in the process of building and testing the changes of a VS Code extension.

I have no clue how the main proposal would be implemented, but I have an idea of what changes need to be made to implement the alternative.

The following suggestions are for Python, but it probably applies to all of them, implementation-wise.

The new configuration option with an empty list as the default value should be added here:

"inline-parameters.python.suppressWhenArgumentMatchesName": {
"type": "boolean",
"markdownDescription": "Suppress parameter name hints on arguments whose text is identical to the parameter name.",
"default": true
}
}

And here as well:

static suppressWhenArgumentMatchesName(): boolean {
return this.pythonConfiguration.get("suppressWhenArgumentMatchesName");
}
}

Finally we just need to modify the condition to also check the ignore list:

if (parameters[index] === undefined || parameters[index].name === undefined) continue;

The modified condition would be something along the lines of:

if (
    parameters[index] === undefined || 
    parameters[index].name === undefined || 
    PythonConfiguration.functionsToIgnore().includes(parameters[index].name)
) {
    continue;
}

Thanks for reading this long write-up :) . I will be very grateful if this can be implemented in any way, shape or form.
I'll gladly help/assist if I can be of any use :D

JS/TS support

my fellow,
when is js/ts support available?

it'll be a great experience to use this extension for both fe/be development.

Inline parameters don't show when there is a space in the file path

I'm running Python 3.10.4 and tested this on a simple program:

def test_func(msg: str, addon: str):
    print(msg + " " + addon)

test_func("Hello", "World")

However, no inline parameters are shown.
This is the output:

expression line: 2 | expression character: 4 | argument start line: 2 | argument start character: 10 | argument end line: 2 | argument end character: 27
NEW EXPRESSION
expression line: 4 | expression character: 0 | argument start line: 4 | argument start character: 10 | argument end line: 4 | argument end character: 17
expression line: 4 | expression character: 0 | argument start line: 4 | argument start character: 19 | argument end line: 4 | argument end character: 26
NEW EXPRESSION

So clearly it is running, but nothing is showing. Any ideas?

Go parameters start with struct name for methods

Thanks for adding Go support! By chance I found the extension a day after you added support for it.

It works great if you call functions that are not methods. But if it's a method then the parameters start with the struct name, which it should not do.

Here's a repro:

package main

type A struct {
	s string
}

func (a A) addSuffix(suffix string) string {
	return a.s + suffix
}

func abc(a string) string {
	return a
}

func main() {
	abc("test") // Works as expected.

	a := A{}
	a.addSuffix("test") // Inlines "A:" (the struct name) when it should be "suffix:".
}

vscodium support

Hi! First of all thank you for this useful extension.

I use vscodium which is a clone of vscode, we can't use your extension right now because you have to published it to open-vsx too.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.