<commit_before>package jce.codemanipulation.ecore;

import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.TypeDeclaration;

/**
 * AST visitor that resolves the name of the package member type of the compilation unit.
 * @author <NAME>
 */
public class TypeNameResolver extends ASTVisitor {
    private String typeName;

    /**
     * Getter for the resolved type name.
     * @return the fully qualified name of the resolved type binding of the type declaration.
     */
    public String getTypeName() {
        if (typeName == null) {
            throw new IllegalStateException("Visit a compilation unit before retrieving the name.");
        }
        return typeName;
    }

    @Override
    public boolean visit(TypeDeclaration node) {
        if (node.isPackageMemberTypeDeclaration()) {
            typeName = node.getName().resolveTypeBinding().getQualifiedName(); // fully qualified name of class
        }
        return super.visit(node);
    }
}<commit_msg>EDIT: Added checks for the resolved type name.<commit_after>package jce.codemanipulation.ecore;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.EnumDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;

/**
 * AST visitor that resolves the name of the package member type of the compilation unit.
 * @author <NAME>
 */
public class TypeNameResolver extends ASTVisitor {
    private static final Logger logger = LogManager.getLogger(TypeNameResolver.class.getName());
    private String typeName;

    /**
     * Getter for the resolved type name.
     * @return the fully qualified name of the resolved type binding of the type declaration.
     */
    public String getTypeName() {
        if (typeName == null) {
            throw new IllegalStateException("Visit a compilation unit before retrieving the name.");
        }
        return typeName;
    }

    @Override
    public boolean visit(TypeDeclaration node) {
        resolve(node);
        return false;
    }

    @Override
    public boolean visit(EnumDeclaration node) {
        resolve(node);
        return false;
    }

    /**
     * Visits a {@link TypeDeclaration} or {@link EnumDeclaration} and resolves the name.
     */
    private void resolve(AbstractTypeDeclaration type) {
        if (type.isPackageMemberTypeDeclaration()) {
            typeName = type.getName().resolveTypeBinding().getQualifiedName(); // fully qualified name of class
            if (typeName == null || "".equals(typeName)) {
                logger.fatal("Could not resolve fully qualified name of " + type.getName());
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09288824383164006, 'fraction_numerical': 0.000725689404934688, 'mean_word_length': 2.8885754583921015, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '14535', 'n_tokens_mistral': 728, 'n_tokens_neox': 709, 'n_words': 227}