-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve inspection of component scope
- Loading branch information
1 parent
fe83700
commit 9b8a3ac
Showing
5 changed files
with
165 additions
and
37 deletions.
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
21 changes: 21 additions & 0 deletions
21
luceedebug/src/main/java/luceedebug/coreinject/ComponentScopeMarkerTraitShim.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,21 @@ | ||
package luceedebug.coreinject; | ||
|
||
/** | ||
* Intended to be an extension on lucee.runtime.ComponentImpl | ||
* We need to disambiguate between a component meaning "container of a this/variables/static scope" and "literally a this scope" | ||
* Because we want to show something like the following to the IDE: | ||
* | ||
* someObj : cfc<SomeCfcType> | ||
* - variables -> {...} | ||
* - this -> {...} | ||
* - static -> {...} | ||
* | ||
* But, `someObj` literally is `this` in the above; so we need to know when to show the nested scope listing, and when to show | ||
* the contents of the `this` scope. | ||
* | ||
* There is only a setter because we just use the setter to pin the disambiguating-wrapper object onto something with a | ||
* reasonable lifetime to prevent it from being GC'd. | ||
*/ | ||
public interface ComponentScopeMarkerTraitShim { | ||
void __luceedebug__pinComponentScopeMarkerTrait(Object obj); | ||
} |
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
45 changes: 45 additions & 0 deletions
45
luceedebug/src/main/java/luceedebug/instrumenter/ComponentImpl.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,45 @@ | ||
package luceedebug.instrumenter; | ||
|
||
import org.objectweb.asm.*; | ||
import org.objectweb.asm.commons.GeneratorAdapter; | ||
|
||
public class ComponentImpl extends ClassVisitor { | ||
public ComponentImpl(int api, ClassWriter cw) { | ||
super(api, cw); | ||
} | ||
|
||
@Override | ||
public void visit( | ||
int version, | ||
int access, | ||
String name, | ||
String signature, | ||
String superName, | ||
String[] interfaces | ||
) { | ||
final var augmentedInterfaces = new String[interfaces.length + 1]; | ||
for (int i = 0; i < interfaces.length; i++) { | ||
augmentedInterfaces[i] = interfaces[i]; | ||
} | ||
augmentedInterfaces[interfaces.length] = "luceedebug/coreinject/ComponentScopeMarkerTraitShim"; | ||
|
||
super.visit(version, access, name, signature, superName, augmentedInterfaces); | ||
} | ||
|
||
@Override | ||
public void visitEnd() { | ||
final var fieldName = "__luceedebug__pinned_componentScopeMarkerTrait"; | ||
visitField(org.objectweb.asm.Opcodes.ACC_PUBLIC, fieldName, "Ljava/lang/Object;", null, null); | ||
|
||
final var name = "__luceedebug__pinComponentScopeMarkerTrait"; | ||
final var descriptor = "(Ljava/lang/Object;)V"; | ||
final var mv = visitMethod(org.objectweb.asm.Opcodes.ACC_PUBLIC, name, descriptor, null, null); | ||
final var ga = new GeneratorAdapter(mv, org.objectweb.asm.Opcodes.ACC_PUBLIC, name, descriptor); | ||
|
||
ga.loadThis(); | ||
ga.loadArg(0); | ||
ga.putField(org.objectweb.asm.Type.getType("Llucee/runtime/ComponentImpl;"), fieldName, org.objectweb.asm.Type.getType("Ljava/lang/Object;")); | ||
ga.visitInsn(org.objectweb.asm.Opcodes.RETURN); | ||
ga.endMethod(); | ||
} | ||
} |