Пример #1
0
 protected void acceptExpression(
     @NonNull XExpression expression, @NonNull CharSequence indentation, boolean immediate) {
   XStringLiteral literal = (XStringLiteral) expression;
   String value = literal.getValue();
   value = value.replaceAll("\\n", "\n" + indentation);
   if (immediate) {
     if (currentLine.toString().matches("^\\s*$")) {
       for (int at = builder.length() - 1; at >= 0; at++) {
         if (builder.charAt(at) == '\n') {
           builder.insert(at, value);
           return;
         }
       }
     }
   }
   for (int i = value.length() - 1; i >= 0; i--) {
     if (value.charAt(i) == '\n') {
       builder.append(currentLine);
       builder.append(value.substring(0, i + 1));
       if (i != value.length() - 1) {
         currentLine = new StringBuilder(value.substring(i + 1));
       } else {
         currentLine = new StringBuilder();
       }
       return;
     }
   }
   currentLine.append(value);
 }
Пример #2
0
 @Override
 public void acceptForLoop(
     @NonNull JvmFormalParameter parameter, @NonNull XExpression expression) {
   if (!ignore()) {
     XMemberFeatureCall featureCall = (XMemberFeatureCall) expression;
     XStringLiteral receiver = (XStringLiteral) featureCall.getMemberCallTarget();
     int length = receiver.getValue().length();
     if (length != 0) forLoopStack.push(length * -1);
     else forLoopStack.push(null);
   }
 }