This is a screenshot of the debug mode in my custom rule development. I want to get the content in the red box.
I have made sure that the type of this identifier
class is IdentifierTree.But I still can’t get the content in “binding”.
Please tell me whether it is possible to get the contents here. I hope you could kindly give me some ideas.
List list=new ArrayList(5);
In addition, I’m also developing a rule related to collection initialization, and I also encountered a problem, that is, I can’t get the ‘5’ when creating a collection.
If there’s any way to tell me about this place, I’d be grateful.
You will never be able to access this binding. This is the internal semantic layer, and it is not exposed to the users for custom rules. However, we do expose another semantic API that should allow you to get through it.
From the IdentifierTree, call symbol().owner().
If the owner is not null, it then means that the semantic layer has been able to resolve its owner type.
You should then be able to call type()
From the type, you finally can check that it corresponds to the fully qualified name of the class you are looking for, with type.is("java.lang.StringBuffer").
Please start another thread for this. This is a completely different problem.