KevinJin
(KevinJin)
August 2, 2022, 6:38am
1
One rule I’m writing now is:
Method, start another line above the annotated statement, and use // to comment.
In the actual development, trying use visitMethod and visitClass can’t get the internal annotation content of the method.
Do you have any feasible methods?Thank you for following this post.
KevinJin
(KevinJin)
August 3, 2022, 6:47am
2
Because the content of my previous rules is not very accurate and easy to confuse, I specially corrected it.
Rule:
The method uses single line comments internally, such as / / comments. Multi line comments or Javadoc comments are prohibited
Michael
(Michael Gumowski)
August 15, 2022, 2:09pm
4
KevinJin:
internal annotation
Hey @KevinJin ,
What do you mean by internal annotation ?
Can you share an example of code that would contain something that your rule should catch?
Cheers,
Michael
KevinJin
(KevinJin)
August 16, 2022, 3:43am
7
Hi,Michael,
I want to standardize the internal annotation writing method of the method. Only one rule of / / single line annotation can be used.
Fortunately, I have finished this rule with methodTree.modifiers().firstToken().trivias() .
Thank you for your kindly reply.
Best,
Kev
Michael
(Michael Gumowski)
August 17, 2022, 8:40am
8
Hello @KevinJin ,
Okay, so what you call “internal annotations ” are absolutely not annotations according to the Java languages. These are comments or javadoc .
In our API, you can access them through the modifiers()
of some elements from the AST (such as MethodThree
). However, the simplest way is to retrieve directly from any syntax token, using the trivias()
method. You can also decide to use a SubscriptionVisitor
, and register to the TRIVIA
kind.
Cheers,
Michael
system
(system)
Closed
August 24, 2022, 8:41am
10
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.