Search in sources :

Example 1 with GoConditionalExpr

use of com.goide.psi.GoConditionalExpr in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoConvertStringToByteQuickFix method applyFix.

@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
    PsiElement element = descriptor.getPsiElement();
    if (!(element instanceof GoConditionalExpr) || !element.isValid()) {
        return;
    }
    GoConditionalExpr expr = (GoConditionalExpr) element;
    GoStringLiteral literal = ContainerUtil.findInstance(Arrays.asList(expr.getLeft(), expr.getRight()), GoStringLiteral.class);
    if (literal == null || !isSingleCharLiteral(literal)) {
        return;
    }
    literal.replace(createExpression(project, extractSingleCharFromText(literal)));
}
Also used : GoConditionalExpr(com.goide.psi.GoConditionalExpr) GoStringLiteral(com.goide.psi.GoStringLiteral) PsiElement(com.intellij.psi.PsiElement)

Aggregations

GoConditionalExpr (com.goide.psi.GoConditionalExpr)1 GoStringLiteral (com.goide.psi.GoStringLiteral)1 PsiElement (com.intellij.psi.PsiElement)1