-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
review fix: Object[]::new references resolution #1945
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4038aed
up
monperrus 9b6c7b3
Merge remote-tracking branch 'inria/master' into fix-new-reference
surli 98d9d55
Start working on #1883
surli 183f94c
Merge remote-tracking branch 'inria/master' into fix-new-reference
surli 92e1db7
Approach a solution
surli a7ae7b2
Add an exception in SpoonArchitectureEnforcerTest
surli 58f00e8
Update ExecutableReferenceTest.java
monperrus ab5d769
Add more assertion and change a bit the class
surli d058c7d
Add exclusions where needed
surli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
27 changes: 27 additions & 0 deletions
27
src/main/java/spoon/support/reflect/declaration/InvisibleArrayConstructor.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,27 @@ | ||
/** | ||
* Copyright (C) 2006-2017 INRIA and contributors | ||
* Spoon - http://spoon.gforge.inria.fr/ | ||
* | ||
* This software is governed by the CeCILL-C License under French law and | ||
* abiding by the rules of distribution of free software. You can use, modify | ||
* and/or redistribute the software under the terms of the CeCILL-C license as | ||
* circulated by CEA, CNRS and INRIA at http://www.cecill.info. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details. | ||
* | ||
* The fact that you are presently reading this means that you have had | ||
* knowledge of the CeCILL-C license and that you accept its terms. | ||
*/ | ||
package spoon.support.reflect.declaration; | ||
|
||
/** | ||
* This class is used to represent the constructor of an array when calling with an expression like | ||
* <pre> | ||
* String[]::new | ||
* </pre> | ||
*/ | ||
public class InvisibleArrayConstructor<T> extends CtConstructorImpl<T> { | ||
|
||
} |
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
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 |
---|---|---|
|
@@ -8,13 +8,15 @@ | |
import spoon.reflect.declaration.CtInterface; | ||
import spoon.reflect.declaration.CtMethod; | ||
import spoon.reflect.reference.CtExecutableReference; | ||
import spoon.reflect.visitor.CtScanner; | ||
import spoon.reflect.visitor.Query; | ||
import spoon.reflect.visitor.filter.ReferenceTypeFilter; | ||
import spoon.reflect.visitor.filter.TypeFilter; | ||
import spoon.test.reference.testclasses.Bar; | ||
import spoon.test.reference.testclasses.Burritos; | ||
import spoon.test.reference.testclasses.EnumValue; | ||
import spoon.test.reference.testclasses.Kuu; | ||
import spoon.test.reference.testclasses.Stream; | ||
import spoon.test.reference.testclasses.SuperFoo; | ||
|
||
import java.util.List; | ||
|
@@ -24,6 +26,7 @@ | |
import static org.junit.Assert.assertNotEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
public class ExecutableReferenceTest { | ||
|
@@ -204,4 +207,23 @@ public void testHashcodeWorksWithReference() { | |
|
||
assertNotEquals(hashCode1, hashCode2); | ||
} | ||
|
||
@Test | ||
public void testPbWithStream() { | ||
// contract: array constructor references are well represented | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add assert on type of element (instanceof InvisibleArrayConstructorImpl)? |
||
|
||
final Launcher launcher = new Launcher(); | ||
launcher.addInputResource("./src/test/java/spoon/test/reference/testclasses/Stream.java"); | ||
launcher.buildModel(); | ||
|
||
CtClass klass = launcher.getFactory().Class().get(Stream.class); | ||
List<CtExecutableReference> executableReferenceList = klass.getElements(new TypeFilter<>(CtExecutableReference.class)); | ||
|
||
for (CtExecutableReference execRef : executableReferenceList) { | ||
String refString = execRef.toString(); | ||
CtExecutable executable = execRef.getExecutableDeclaration(); | ||
assertNotNull(refString, executable); | ||
} | ||
} | ||
|
||
} |
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,9 @@ | ||
package spoon.test.reference.testclasses; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class Stream { | ||
public Stream() { | ||
new ArrayList().stream().toArray(Bar[]::new); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By convention, should end by Impl:
InvisibleArrayConstructorImpl
, and should be inspoon.support.reflect.declaration
(all implementation classes are in spoon.support)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is in spoon.support. I will rename it.