All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.codetrans.VisitContext Maven / Gradle / Ivy

There is a newer version: 4.1.0.Beta1
Show newest version
package io.vertx.codetrans;

import com.sun.tools.javac.code.Symbol;
import io.vertx.codetrans.expression.ExpressionModel;

import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

/**
 * @author Julien Viet
 */
public class VisitContext {

  final CodeBuilder builder;
  private final Map aliases;
  private final Set referencedMethods;
  private final Set referencedFields;

  public VisitContext(CodeBuilder builder) {
    this.builder = builder;
    this.aliases = Collections.emptyMap();
    this.referencedMethods = new LinkedHashSet<>();
    this.referencedFields = new LinkedHashSet<>();
  }

  private VisitContext(CodeBuilder builder, Map aliases, Set referencedMethods, Set referencedFields) {
    this.builder = builder;
    this.aliases = aliases;
    this.referencedMethods = referencedMethods;
    this.referencedFields = referencedFields;
  }

  public VisitContext putAlias(Symbol symbol, ExpressionModel builder) {
    HashMap clone = new HashMap<>(aliases);
    clone.put(symbol, builder);
    return new VisitContext(this.builder, clone, referencedMethods, referencedFields);
  }

  public ExpressionModel getAlias(Symbol symbol) {
    return aliases.get(symbol);
  }

  public Set getReferencedMethods() {
    return referencedMethods;
  }

  public Set getReferencedFields() {
    return referencedFields;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy