Exemple #1
0
 private void processMethod(String methodName, Node argsNode, Node body) {
   sb.append("(method ").append(methodName).append(' ');
   // JRUBY-4301, include filename and line in sexp
   sb.append("(file ").append(new File(body.getPosition().getFile()).getName()).append(") ");
   sb.append("(line ").append(body.getPosition().getStartLine()).append(") ");
   process(argsNode);
   sb.append(" ");
   process(body);
   sb.append(")");
 }
Exemple #2
0
 public static IRubyObject INTERPRET_EVAL(
     Ruby runtime, ThreadContext context, Node node, String name, IRubyObject self, Block block) {
   try {
     ThreadContext.pushBacktrace(context, name, node.getPosition());
     return node.interpret(runtime, context, self, block);
   } finally {
     ThreadContext.popBacktrace(context);
   }
 }
Exemple #3
0
 public void setFlag(Node node, Flag modifier) {
   if (dump) {
     LOG.info(
         "[ASTInspector] "
             + name
             + "\n\tset flag "
             + modifier
             + " because of "
             + node.getNodeType()
             + " at "
             + node.getPosition());
   }
   flags |= modifier.flag;
 }
 @Override
 public Object visitIfNode(IfNode iVisited) {
   String src = getSource(iVisited);
   Node elseBody;
   Node thenBody;
   if (src.startsWith("unless")) {
     // then we need to "swap" the then and else nodes
     elseBody = iVisited.getThenBody();
     thenBody = iVisited.getElseBody();
   } else {
     elseBody = iVisited.getElseBody();
     thenBody = iVisited.getThenBody();
   }
   boolean isUnlessModifier = (iVisited.getThenBody() == null);
   if (elseBody != null && !isUnlessModifier) {
     if (alwaysExplicitReturn(thenBody)) {
       createProblem(elseBody.getPosition(), "Unnecessary else"); // $NON-NLS-1$
     }
   }
   return super.visitIfNode(iVisited);
 }
  private static String calculateFilename(ArgsNode argsNode, Node bodyNode) {
    if (bodyNode != null) return bodyNode.getPosition().getFile();
    if (argsNode != null) return argsNode.getPosition().getFile();

    return "__eval__";
  }