Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support change signature refactoring #2967

Merged
merged 13 commits into from Mar 17, 2023
14 changes: 12 additions & 2 deletions .vscode/launch.json
Expand Up @@ -7,14 +7,19 @@
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"debugWebviews": true,
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
"env": {
"DEBUG_VSCODE_JAVA":"true"
},
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [ "${workspaceRoot}/dist/**/*.js" ],
"preLaunchTask": "npm: watch"
"preLaunchTask": "npm: watch",
"rendererDebugOptions": {
"urlFilter": "*redhat.java*",
"sourceMaps": true,
}
},
{
"name": "Launch Extension - Remote Server",
Expand All @@ -36,6 +41,7 @@
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"debugWebviews": true,
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
"stopOnEntry": false,
"sourceMaps": true,
Expand All @@ -44,7 +50,11 @@
"JDTLS_CLIENT_PORT": "5036",
"DEBUG_VSCODE_JAVA":"true"
},
"preLaunchTask": "npm: watch"
"preLaunchTask": "npm: watch",
"rendererDebugOptions": {
"urlFilter": "*redhat.java*",
"sourceMaps": true,
}
},
{
"name": "Launch Extension - SyntaxLS Client",
Expand Down
39 changes: 38 additions & 1 deletion document/_java.learnMoreAboutRefactorings.md
Expand Up @@ -18,7 +18,9 @@
- [Inline constant](#inline-constant)
- [Inline local variable](#inline-local-variable)
- [Inline method](#inline-method)
- [Introduce Parameter](#introduce-parameter)
- Method signature
- [Introduce Parameter](#introduce-parameter)
- [Change method signature](#change-method-signature)
- Invert boolean
- [Invert conditions](#invert-conditions)
- [Invert local variable](#invert-local-variable)
Expand Down Expand Up @@ -469,6 +471,41 @@ public void addUser(String name) {
}
```

---

## Change Method Signature
Changes the method visibility, return type, name, and updates the parameters and exceptions. The above changes can be applied through the call hierarchy of the method.

### Example
Let's change signature for the method `public void setAddress(String address)`.

#### Before

```java
public void setAddress(String address) {
this.address = address;
}

public void setAddr() {
this.setAddress("Addr");
}
```

#### Refactor configuration

![change_signature](./refactoring_change_signature.png)
#### After
```java
public void setAddress1(Object newParam, String address) {
this.address = address;
}

public void setAddr() {
this.setAddress1(null, "Addr");
}
```
---

## Invert conditions
Inverts the boolean expression in the conditions.

Expand Down
Binary file added document/refactoring_change_signature.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.