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

Improved support for large repositories #3118

Merged
merged 112 commits into from
May 30, 2023
Merged

Improved support for large repositories #3118

merged 112 commits into from
May 30, 2023

Conversation

jkschneider
Copy link
Member

@jkschneider jkschneider commented Apr 16, 2023

What's changed

  • Parser#parseInputs returns Stream.
  • Recipe#run takes LargeIterable argument.
  • Recipe#visit takes LargeIterable argument.

A lot more... blog to follow.

@timtebeek timtebeek added the enhancement New feature or request label Apr 17, 2023
@jkschneider jkschneider force-pushed the large-repositories branch 10 times, most recently from 9abdf16 to abc96dc Compare April 29, 2023 02:32
@jkschneider jkschneider force-pushed the large-repositories branch 5 times, most recently from a7082ab to 3b88694 Compare April 30, 2023 23:53
@JLLeitschuh
Copy link
Contributor

A bunch of files just have import starting merges, which bloats this changeset. Can those be backed out so that the change is smaller and slightly more reasonable to review?

Comment on lines +573 to +597
private static <J2 extends J> J2 parseAndBuild(@Language("java") String code,
Class<J2> expected,
Collection<Path> classpath) {
JavaParser.Builder<? extends JavaParser, ?> builder = JavaParser.fromJavaVersion().classpath(classpath);

J.CompilationUnit cu = builder.build()
.parse(code)
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("Could not parse as Java"));
List<J2> parts = new ArrayList<>(1);
new JavaVisitor<List<J2>>() {
@Override
public @Nullable J visit(@Nullable Tree tree, List<J2> j2s) {
if (expected.isInstance(tree)) {
//noinspection unchecked
J2 j2 = (J2) tree;
j2s.add(j2);
return j2;
}
return super.visit(tree, j2s);
}
}.visit(cu, parts);

return parts.get(0);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why not to make this a public API? This could be incredibly useful for synthesizing types.

rewrite-security already has a utility to do something very similar:

https://github.com/openrewrite/rewrite-java-security/blob/73dbecaf9354756d26a135766dd044559f6cf6f1/src/main/java/org/openrewrite/java/security/internal/TypeGenerator.java#L31-L52

@sambsnyd sambsnyd marked this pull request as ready for review May 30, 2023 21:28
@sambsnyd sambsnyd merged commit 03c4584 into main May 30, 2023
@sambsnyd sambsnyd deleted the large-repositories branch May 30, 2023 21:29
@mduerig
Copy link
Contributor

mduerig commented Jun 12, 2023

What happend to getSingleSourceApplicableTest and similar? These have been removed with this commit, what are the replacements? The documentation still refers to the old methods.

@JLLeitschuh
Copy link
Contributor

They were removed. There is a plan to bring back the functionality with an alternative mechanism. @jkschneide can better speak to this

What's the use case you are looking to support?

@mduerig
Copy link
Contributor

mduerig commented Jun 13, 2023

What's the use case you are looking to support?

I get compilation errors when upgrading the dependencies on my custom recipes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants