Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
775 views
in Technique[技术] by (71.8m points)

code snippets - How to decapitalize an argument in a Live Template in IntelliJ

In my project, I have many serialization classes and, to make the classes more readable, I'm standardizing them, with an argument which has the same name of the $class$, that is $argName$:

@immutable
class $class$_Serialize extends Serialize<$class$> {
  final $class$ $argName$;

  $class$_Serialize(this.$argName$);

  @override
  Map<String, Object> run() => $serialize$
}

In the Live Template above, the annoyance is that I have to retype $argName$ instead of the template simply decapitalizing $class$. How would I tie $argName$ to the decapitalization of $class$ in IntelliJ?

I've already tried to mess around with editing the variables and adding the decaptialize() function in the expression column, but so far haven't had much success. It was something like this:

Attempt at using decapitalize()

question from:https://stackoverflow.com/questions/65852123/how-to-decapitalize-an-argument-in-a-live-template-in-intellij

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You are using the wrong syntax for the decapitalize function. It should look like this:

decapitalize(class)

Note that there are no $ signs around the class in the function argument.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...