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

com.strobel.decompiler.languages.java.ast.Keys Maven / Gradle / Ivy

There is a newer version: 2.5.0.Final
Show newest version
/*
 * Keys.java
 *
 * Copyright (c) 2013 Mike Strobel
 *
 * This source code is based on Mono.Cecil from Jb Evain, Copyright (c) Jb Evain;
 * and ILSpy/ICSharpCode from SharpDevelop, Copyright (c) AlphaSierraPapa.
 *
 * This source code is subject to terms and conditions of the Apache License, Version 2.0.
 * A copy of the license can be found in the License.html file at the root of this distribution.
 * By using this source code in any fashion, you are agreeing to be bound by the terms of the
 * Apache License, Version 2.0.
 *
 * You must not remove this notice, or any other, from this software.
 */

package com.strobel.decompiler.languages.java.ast;

import com.strobel.assembler.metadata.*;
import com.strobel.componentmodel.Key;
import com.strobel.core.ArrayUtilities;
import com.strobel.core.ExceptionUtilities;
import com.strobel.decompiler.ast.Variable;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public final class Keys {
    public final static Key VARIABLE = Key.create("Variable");
    public final static Key VARIABLE_DEFINITION = Key.create("VariableDefinition");
    public final static Key PARAMETER_DEFINITION = Key.create("ParameterDefinition");
    public final static Key MEMBER_REFERENCE = Key.create("MemberReference");
    public final static Key PACKAGE_REFERENCE = Key.create("PackageReference");
    public final static Key FIELD_DEFINITION = Key.create("FieldDefinition");
    public final static Key METHOD_DEFINITION = Key.create("MethodDefinition");
    public final static Key TYPE_DEFINITION = Key.create("TypeDefinition");
    public final static Key TYPE_REFERENCE = Key.create("TypeReference");
    public final static Key ANONYMOUS_BASE_TYPE_REFERENCE = Key.create("AnonymousBaseTypeReference");
    public final static Key DYNAMIC_CALL_SITE = Key.create("DynamicCallSite");
    public final static Key AST_BUILDER = Key.create("AstBuilder");
    public final static Key CONSTANT_VALUE = Key.create("ConstantValue");

    public final static List> ALL_KEYS;

    static {
        final ArrayList> keys = new ArrayList<>();

        try {
            for (final Field field : Keys.class.getDeclaredFields()) {
                if (field.getType() == Key.class) {
                    keys.add((Key) field.get(null));
                }
            }

            ALL_KEYS = ArrayUtilities.>asUnmodifiableList(keys.toArray(new Key[keys.size()]));
        }
        catch (final Throwable t) {
            throw ExceptionUtilities.asRuntimeException(t);
        }
    }
}