[英]Datatype of a variable using ASTParser in java
VariableDeclarationFragment node;
SimpleName name = node.getName();
If node.getName()
is of type String
, then output should be String
. 如果node.getName()
的类型为String
,则输出应为String
。 If node.getName()
is of type Integer
, then output should be Integer
. 如果node.getName()
的类型为Integer
,则输出应为Integer
。
Is there a way to do this using ASTParser
or otherwise? 有没有办法使用ASTParser
或其他方式做到这一点?
You can use the resolveBinding() operation on the VariableDeclarationFragment. 您可以在VariableDeclarationFragment上使用resolveBinding()操作。 It associates the variable with its type. 它将变量与其类型相关联。 The binding may not be available depending on the status of the AST construction. 根据AST结构的状态,绑定可能不可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.