-
Notifications
You must be signed in to change notification settings - Fork 320
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
Xbase/Xtend refactoring #2890
Merged
LorenzoBettini
merged 10 commits into
eclipse-xtext:main
from
LorenzoBettini:lb_xbase_cleanup-1
Jan 8, 2024
Merged
Xbase/Xtend refactoring #2890
LorenzoBettini
merged 10 commits into
eclipse-xtext:main
from
LorenzoBettini:lb_xbase_cleanup-1
Jan 8, 2024
Conversation
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 was referenced Jan 3, 2024
szarnekow
reviewed
Jan 8, 2024
org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java
Outdated
Show resolved
Hide resolved
szarnekow
reviewed
Jan 8, 2024
org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java
Outdated
Show resolved
Hide resolved
szarnekow
approved these changes
Jan 8, 2024
org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/compiler/XbaseCompiler.java
Show resolved
Hide resolved
use getNamedType instead of manually retrieving the last element of supertypes
instead of redefining _toJavaStatement we redefine constructorCallToJavaExpression and we call it also in other parts
when redefining them it's useless to make them public; when used internally, make them private
LorenzoBettini
force-pushed
the
lb_xbase_cleanup-1
branch
from
January 8, 2024 18:02
15b244d
to
7ac3f49
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This provides some general refactoring for Xbase and Xtend and as a preparation for #2886, for which I'll also provide a PR soon.
The main focus is on the treatment of anonymous classes, which was originally split into Xbase and Xtend. In this PR, anonymous classes are handled by the XbaseCompiler completely, which now provides a new method https://github.com/eclipse/xtext/compare/main...LorenzoBettini:xtext:lb_xbase_cleanup-1?expand=1#diff-3c98e6c5688a98e8fc686a884a0462f80d32c824ea233925c42b813a15345743R1148
canCompileToJavaAnonymousClasses
. This relies on theJvmGenericType.isAnonymous
. This was done before byXbaseCompiler
, though with some duplicated code. Now,XbaseCompiler
consistently calls this method to treat other situations that in the past were customized inXtendCompiler
.For example,
isVariableDeclarationRequired
is now properly handled in theXbaseCompiler
also for constructor calls, which possibly refer to an anonymous class and does not need to be customized byXtendCompiler
.Similarly,
_toJavaStatement(final XConstructorCall expr...
does not need to be redefined by theXtendCompiler
, which only needs to redefineconstructorCallToJavaExpression
to handle the generation of its anonymous classes.I also took the chance to restrict the visibility of a few methods in
XtendCompiler
, which are used only internally.The build is green.