<commit_before>package polyglot.ext.jl.ast;

import polyglot.ast.*;
import polyglot.types.*;
import polyglot.util.*;
import polyglot.visit.*;
import polyglot.main.Options;

/**
 * A <code>CanonicalTypeNode</code> is a type node for a canonical type.
 */
public class CanonicalTypeNode_c extends TypeNode_c implements CanonicalTypeNode
{
  public CanonicalTypeNode_c(Position pos, Type type) {
    super(pos);
    this.type = type;
  }

  /**
   * If the "use-fully-qualified-class-names" options is used, then the
   * fully qualified names is written out (<code>java.lang.Object</code>).
   * Otherwise, the string that originally represented the type in the
   * source file is used.
   */
  public void prettyPrint(CodeWriter w, PrettyPrinter tr) {
    if (type == null) w.write("<unknown-type>");
    else w.write(type.toString());
  }

  public void translate(CodeWriter w, Translator tr) {
    TypeSystem ts = tr.typeSystem();


    if (tr.outerClass() != null) {
      w.write(type.translate(ts.classContextResolver(tr.outerClass())));
    }
    else if (type.isClass() && type.toClass().isMember()) {
      w.write(type.translate(null));
    }
    else if (! Options.global.fully_qualified_names) {
      w.write(type.translate(tr.context()));
    }
    else {
      w.write(type.translate(null));
    }
  }

  public String toString() {
    if (type == null) return "<unknown-type>";
    return type.toString();
  }

  public void dump(CodeWriter w) {
    super.dump(w);
    w.allowBreak(4, " ");
    w.begin(0);
    w.write("(type " + type + ")");
    w.end();
  }
}<commit_msg>Comments about some strange type translation code. Steve will look into it.  Please Steve.<commit_after>package polyglot.ext.jl.ast;

import polyglot.ast.*;
import polyglot.types.*;
import polyglot.util.*;
import polyglot.visit.*;
import polyglot.main.Options;

/**
 * A <code>CanonicalTypeNode</code> is a type node for a canonical type.
 */
public class CanonicalTypeNode_c extends TypeNode_c implements CanonicalTypeNode
{
  public CanonicalTypeNode_c(Position pos, Type type) {
    super(pos);
    this.type = type;
  }

  /**
   * If the "use-fully-qualified-class-names" options is used, then the
   * fully qualified names is written out (<code>java.lang.Object</code>).
   * Otherwise, the string that originally represented the type in the
   * source file is used.
   */
  public void prettyPrint(CodeWriter w, PrettyPrinter tr) {
    if (type == null) w.write("<unknown-type>");
    else w.write(type.toString());
  }

  public void translate(CodeWriter w, Translator tr) {
    TypeSystem ts = tr.typeSystem();

    if (tr.outerClass() != null) {
      w.write(type.translate(ts.classContextResolver(tr.outerClass())));
    }
    else if (type.isClass() && type.toClass().isMember()) {
      // tr.context()?  eliminate this case?
      // passing null forces the name to be fully qualified
      w.write(type.translate(null));
    }
    else if (! Options.global.fully_qualified_names) {
      w.write(type.translate(tr.context()));
    }
    else {
      // FIXME: variable capture bug?
      // What if a field in this context shadows the package name?
      w.write(type.translate(null));
    }
  }

  public String toString() {
    if (type == null) return "<unknown-type>";
    return type.toString();
  }

  public void dump(CodeWriter w) {
    super.dump(w);
    w.allowBreak(4, " ");
    w.begin(0);
    w.write("(type " + type + ")");
    w.end();
  }
}
{'fraction_non_alphanumeric': 0.14240323512420566, 'fraction_numerical': 0.0011554015020219526, 'mean_word_length': 3.1874244256348248, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '964823', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1089, 'n_words': 285}