-
Notifications
You must be signed in to change notification settings - Fork 7
Fix for #103 #124
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
Merged
Merged
Fix for #103 #124
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8a8fdb4
test cases for #103
yiming-tang-cs 36e9ed1
add on more test case #103
yiming-tang-cs fa7ddbb
fix #103
yiming-tang-cs 55f2f71
#103 improve
yiming-tang-cs 3443537
delete useless import
yiming-tang-cs ab87978
change method name and format
yiming-tang-cs 05bf41a
#103 change iterator
yiming-tang-cs 87bb0bc
#103 add a test case
yiming-tang-cs 6ea3f22
add comments
yiming-tang-cs 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
20 changes: 20 additions & 0 deletions
20
...r.streamrefactoring.tests/resources/ConvertStreamToParallel/testNonInternalAPI2/in/A.java
This file contains hidden or 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,20 @@ | ||
package p; | ||
|
||
import java.util.HashSet; | ||
import java.util.stream.*; | ||
|
||
import edu.cuny.hunter.streamrefactoring.annotations.*; | ||
|
||
class A { | ||
|
||
Stream<Object> m() { | ||
Stream<Object> stream = new HashSet<>().stream().distinct(); | ||
return stream; | ||
} | ||
|
||
@EntryPoint | ||
void n() { | ||
Stream<Object> s = m(); | ||
s.count(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...r.streamrefactoring.tests/resources/ConvertStreamToParallel/testNonInternalAPI3/in/A.java
This file contains hidden or 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,20 @@ | ||
package p; | ||
|
||
import java.util.HashSet; | ||
import java.util.stream.*; | ||
|
||
import edu.cuny.hunter.streamrefactoring.annotations.*; | ||
|
||
class A { | ||
|
||
Stream<Object> m() { | ||
Stream<Object> stream = new HashSet<>().stream(); | ||
return stream; | ||
} | ||
|
||
@EntryPoint | ||
void n() { | ||
Stream<Object> s = m(); | ||
s.distinct().count(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...r.streamrefactoring.tests/resources/ConvertStreamToParallel/testNonInternalAPI4/in/A.java
This file contains hidden or 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,20 @@ | ||
package p; | ||
|
||
import java.util.HashSet; | ||
import java.util.stream.*; | ||
|
||
import edu.cuny.hunter.streamrefactoring.annotations.*; | ||
|
||
class A { | ||
|
||
Stream<Object> m() { | ||
Stream<Object> stream = new HashSet<>().stream().sorted(); | ||
return stream; | ||
} | ||
|
||
@EntryPoint | ||
void n() { | ||
Stream<Object> s = m(); | ||
s.distinct().count(); | ||
} | ||
} |
This file contains hidden or 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
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.
@saledouble This should be ordered, correct?
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.
@saledouble I'm confused as to why the the ordering is
UNORDERED
. Do you know why? I am wondering if it is the case that we determine ordering upon a terminal operation and when we think there's none, we are just using some default value. What do you think?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.
If the test case is
the ordering is 'UNORDERED' and the project throws an exception requiring terminal operations.
If the test case is
the ordering is 'ORDERED' and the project doesn't throw an exception.
Then, I found a sentence from https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html :
"When the terminal operation is initiated, the stream pipeline is executed sequentially or in parallel depending on the orientation of the stream on which it is invoked."
I think the project doesn't find the terminal operations, so the stream pipeline has never been executed.
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.
If you replace
HashSet()
withArrayList
, is it stillUNORDERED
? That would answer whether it is just accepting a default value.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.
Do you have any insight as to why it is not finding the terminal operation? Do you have ideas how to fix it? Let's discuss it prior to executing a particular strategy.
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.
If the test case is:
the ordering is 'Ordered' and the project throws an exception (require terminal operations).
According to the test result above, the answer should be yes.
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.
I came up with a question in #103 . I found the instance of stream just processes the operations in the method of enclosingMethodDeclaration.
For the example below:
Do we need to create an instance of stream for n()? Can we reuse the instance of stream for m()? Those are what I am thinking.