Package org.noname.designer.core.internal.evaluators

Source Code of org.noname.designer.core.internal.evaluators.MethodEvaluator

package org.noname.designer.core.internal.evaluators;

import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.core.dom.Block;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.noname.designer.core.interfaces.EvaluationContext;
import org.noname.designer.core.interfaces.IEvaluator;

public class MethodEvaluator implements IEvaluator {
  private MethodDeclaration method;

  public MethodEvaluator(MethodDeclaration method) {
    this.method = method;
  }

  /**
   * @return RETURN | THROW | RETURN_VALUE
   */
  @Override
  public int evaluate(EvaluationContext context) {
    Block body = method.getBody();
    IEvaluator evaluator = (IEvaluator) Platform.getAdapterManager()
        .getAdapter(body, IEvaluator.class);
    int result = evaluator.evaluate(context);
    switch (result) {
    case RETURN:
      return RETURN;
    case RETURN_VALUE:
      return RETURN_VALUE;
    case THROW:
      return THROW;
    }
    return RETURN;
  }

}
TOP

Related Classes of org.noname.designer.core.internal.evaluators.MethodEvaluator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.