Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How to disable parameters being added as null?
How to disable parameters being added as null? [message #1835207] Fri, 27 November 2020 08:09 Go to next message
Kira Resari is currently offline Kira ResariFriend
Messages: 3
Registered: September 2020
Junior Member
When I modify a function so it requires an additional parameter, like this:

```
public void someFunction(AdditionalParameter additionalParameter);
```

...then naturally, all calls of `someFunction` will complain about a missing parameter. However, when I say "add missing parameters", this happens:

```
someFunction(null);
```

While this satisfies the compiler, I would prefer if it did this instead (and then complained about the `additionalParameter` variable not existing in this context):

```
someFunction(additionalParameter);
```

Is there some way to configure this?

Thanks in advance,
Kira
=^,^=
Re: How to disable parameters being added as null? [message #1835213 is a reply to message #1835207] Fri, 27 November 2020 08:27 Go to previous messageGo to next message
Eitan Rosenberg is currently offline Eitan RosenbergFriend
Messages: 147
Registered: October 2018
Senior Member
Hi,

Why not use "overloading " ?

Regards.


 	public void someFunction() {
		someFunction(null);
	}

	public void someFunction(final String input) {

		if (input == null) {
		} else {
		}

	}

Re: How to disable parameters being added as null? [message #1835217 is a reply to message #1835213] Fri, 27 November 2020 10:08 Go to previous message
Kira Resari is currently offline Kira ResariFriend
Messages: 3
Registered: September 2020
Junior Member
That was not my question.

I'll try to rephrase it.

When I use the quickFix "Add arguments to match `someFunction(AdditionalParameter additionalParameter)`, I get this:

```
someFunction(null);
```

Instead, I would like to get this:

```
someFunction(additionalParameter);
```

Is there some way to get this?
Previous Topic:Eclipse IDE: for Java EE Developers vs for Java Developers
Next Topic:Problems with the ISourceRange of the IType of an anonymous class
Goto Forum:
  


Current Time: Wed Sep 25 02:31:49 GMT 2024

Powered by FUDForum. Page generated in 0.03515 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top