Fixed inner class bug.
This commit is contained in:
parent
d72cace97b
commit
dad862df09
@ -3,7 +3,7 @@ package sketching
|
|||||||
|
|
||||||
import groowt.view.web.BaseWebViewComponent
|
import groowt.view.web.BaseWebViewComponent
|
||||||
|
|
||||||
static class Greeter extends BaseWebViewComponent {
|
class Greeter extends BaseWebViewComponent {
|
||||||
String target
|
String target
|
||||||
|
|
||||||
Greeter(Map attr) {
|
Greeter(Map attr) {
|
||||||
|
@ -25,7 +25,6 @@ import org.codehaus.groovy.control.SourceUnit;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static groowt.view.web.transpile.TranspilerUtil.*;
|
import static groowt.view.web.transpile.TranspilerUtil.*;
|
||||||
@ -69,30 +68,6 @@ public class DefaultGroovyTranspiler implements GroovyTranspiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<InnerClassNode> convertPreambleClassesToInnerClasses(
|
|
||||||
ClassNode mainClassNode,
|
|
||||||
List<ClassNode> classNodes
|
|
||||||
) {
|
|
||||||
final List<InnerClassNode> result = new ArrayList<>();
|
|
||||||
for (final var classNode : classNodes) {
|
|
||||||
if (classNode instanceof InnerClassNode innerClassNode) {
|
|
||||||
result.add(innerClassNode);
|
|
||||||
} else {
|
|
||||||
final InnerClassNode icn = new InnerClassNode(
|
|
||||||
mainClassNode,
|
|
||||||
mainClassNode.getName() + "." + classNode.getNameWithoutPackage(),
|
|
||||||
classNode.getModifiers(),
|
|
||||||
classNode.getSuperClass(),
|
|
||||||
classNode.getInterfaces(),
|
|
||||||
classNode.getMixins()
|
|
||||||
);
|
|
||||||
icn.setDeclaringClass(mainClassNode);
|
|
||||||
result.add(icn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void handlePreamble(
|
protected void handlePreamble(
|
||||||
String templateClassName,
|
String templateClassName,
|
||||||
PreambleNode preambleNode,
|
PreambleNode preambleNode,
|
||||||
@ -147,12 +122,9 @@ public class DefaultGroovyTranspiler implements GroovyTranspiler {
|
|||||||
// handle classes
|
// handle classes
|
||||||
final List<ClassNode> classNodes = convertResult.classNodes();
|
final List<ClassNode> classNodes = convertResult.classNodes();
|
||||||
this.checkPreambleClasses(templateClassName, classNodes);
|
this.checkPreambleClasses(templateClassName, classNodes);
|
||||||
final List<ClassNode> toInner = classNodes.stream()
|
classNodes.stream()
|
||||||
.filter(classNode -> classNode != convertResult.scriptClass())
|
.filter(classNode -> classNode != convertResult.scriptClass())
|
||||||
.filter(classNode -> !classNode.isScript())
|
.forEach(moduleNode::addClass);
|
||||||
.toList();
|
|
||||||
final List<InnerClassNode> innerClassNodes = this.convertPreambleClassesToInnerClasses(mainClassNode, toInner);
|
|
||||||
innerClassNodes.forEach(moduleNode::addClass);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cases:
|
// Cases:
|
||||||
|
@ -18,9 +18,11 @@
|
|||||||
- [ ] Create smoke screen test cases for the compiler.
|
- [ ] Create smoke screen test cases for the compiler.
|
||||||
- [ ] Separate the api, runtime, and compiler elements. The api/runtime can depend on the compiler. If users really want
|
- [ ] Separate the api, runtime, and compiler elements. The api/runtime can depend on the compiler. If users really want
|
||||||
to meddle with the compiler for some reason, they can depend on it directly.
|
to meddle with the compiler for some reason, they can depend on it directly.
|
||||||
- [ ] Fix inner class bug.
|
|
||||||
|
|
||||||
### Done
|
### Done
|
||||||
|
- [X] Fix inner class bug.
|
||||||
|
- Update 5/20/24: Seems to be working now. N.b.: they are not truly 'inner' classes but rather classes that are added
|
||||||
|
to the same module. We should always prefer to err on the side of what the usual groovy script semantics are.
|
||||||
- [X] Get rid of sketching source set.
|
- [X] Get rid of sketching source set.
|
||||||
- Update 5/20/24: Done, but moved to `sketching/(java | groovy)/sketching` src set dirs.
|
- Update 5/20/24: Done, but moved to `sketching/(java | groovy)/sketching` src set dirs.
|
||||||
- [X] Think more about how to compile templates and components alongside each other. Perhaps we just need to bite
|
- [X] Think more about how to compile templates and components alongside each other. Perhaps we just need to bite
|
||||||
|
Loading…
Reference in New Issue
Block a user