forked from projectlombok/lombok
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fixes projectlombok#3783] Return generated node for side effect check
- Loading branch information
Showing
9 changed files
with
150 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
test/eclipse/resource/extractvariable/multiple/after/A.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package pkg; | ||
|
||
import java.util.Arrays; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class A { | ||
private String string; | ||
|
||
public List<String> test() { | ||
String temp = getString(); | ||
return Arrays.asList(temp, temp, temp); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
test/eclipse/resource/extractvariable/multiple/before/A.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package pkg; | ||
|
||
import java.util.Arrays; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class A { | ||
private String string; | ||
|
||
public List<String> test() { | ||
return Arrays.asList(getString(), getString(), getString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package pkg; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class A { | ||
private String string; | ||
|
||
public String test() { | ||
String temp = getString(); | ||
return temp; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
test/eclipse/resource/extractvariable/single/before/A.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package pkg; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class A { | ||
private String string; | ||
|
||
public String test() { | ||
return getString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
test/eclipse/src/lombok/eclipse/refactoring/ExtractVariableTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (C) 2024 The Project Lombok Authors. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package lombok.eclipse.refactoring; | ||
|
||
import static lombok.eclipse.RefactoringUtils.performRefactoring; | ||
|
||
import org.eclipse.jdt.core.ICompilationUnit; | ||
import org.eclipse.jdt.core.dom.CompilationUnit; | ||
import org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring; | ||
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringASTParser; | ||
import org.eclipse.jdt.internal.ui.javaeditor.ASTProvider; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import lombok.eclipse.EclipseRunner; | ||
import lombok.eclipse.SetupBeforeAfterTest; | ||
|
||
@RunWith(EclipseRunner.class) | ||
public class ExtractVariableTest { | ||
|
||
@Rule | ||
public SetupBeforeAfterTest setup = new SetupBeforeAfterTest(); | ||
|
||
@Test | ||
public void single() throws Exception { | ||
ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("A.java"); | ||
|
||
CompilationUnit compilationUnit = new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(cu, true); | ||
|
||
ExtractTempRefactoring extractTempRefactoring = new ExtractTempRefactoring(compilationUnit, 121, 11); | ||
extractTempRefactoring.setTempName("temp"); | ||
performRefactoring(extractTempRefactoring); | ||
} | ||
|
||
@Test | ||
public void multiple() throws Exception { | ||
ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("A.java"); | ||
|
||
CompilationUnit compilationUnit = new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(cu, true); | ||
|
||
ExtractTempRefactoring extractTempRefactoring = new ExtractTempRefactoring(compilationUnit, 167, 11); | ||
extractTempRefactoring.setTempName("temp"); | ||
performRefactoring(extractTempRefactoring); | ||
} | ||
} |