congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ClassNode.getTypeClass
Code IndexAdd Tabnine to your IDE (free)

How to use
getTypeClass
method
in
org.codehaus.groovy.ast.ClassNode

Best Java code snippets using org.codehaus.groovy.ast.ClassNode.getTypeClass (Showing top 20 results out of 315)

origin: org.codehaus.groovy/groovy

@Override
public Class getTypeClass() {
  return super.getTypeClass();
}
origin: org.codehaus.groovy/groovy

@Override
public Class getTypeClass() {
  return compileTimeClassNode.getTypeClass();
}
origin: org.codehaus.groovy/groovy

private static Annotation getTransformClassAnnotation(ClassNode annotatedType) {
  if (!annotatedType.isResolved()) return null;
  for (Annotation ann : annotatedType.getTypeClass().getAnnotations()) {
    // because compiler clients are free to choose any GroovyClassLoader for
    // resolving ClassNodeS such as annotatedType, we have to compare by name,
    // and cannot cast the return value to GroovyASTTransformationClass
    if (ann.annotationType().getName().equals(GroovyASTTransformationClass.class.getName())) {
      return ann;
    }
  }
  return null;
}
origin: org.codehaus.groovy/groovy

private void setGenericsTypes(ClassNode cn) {
  TypeVariable[] tvs = cn.getTypeClass().getTypeParameters();
  GenericsType[] gts = configureTypeVariable(tvs);
  cn.setGenericsTypes(gts);
}
origin: org.codehaus.groovy/groovy

/**
 * box top level operand
 */
@Deprecated
public static boolean box(MethodVisitor mv, ClassNode type) {
  if (type.isPrimaryClassNode()) return false;
  return box(mv, type.getTypeClass());
}
origin: org.codehaus.groovy/groovy

protected static List<PropertyInfo> getPropertyInfoFromBeanInfo(ClassNode cNode, List<String> includes, List<String> excludes, boolean allNames) {
  final List<PropertyInfo> result = new ArrayList<PropertyInfo>();
  try {
    BeanInfo beanInfo = Introspector.getBeanInfo(cNode.getTypeClass());
    for (PropertyDescriptor descriptor : beanInfo.getPropertyDescriptors()) {
      if (shouldSkipUndefinedAware(descriptor.getName(), excludes, includes, allNames)) continue;
      // skip hidden and read-only props
      if (descriptor.isHidden() || descriptor.getWriteMethod() == null) continue;
      result.add(new PropertyInfo(descriptor.getName(), ClassHelper.make(descriptor.getPropertyType())));
    }
  } catch (IntrospectionException ignore) {
  }
  return result;
}
origin: org.codehaus.groovy/groovy

/**
 * get the time stamp of a class
 * NOTE: copied from GroovyClassLoader
 */
private static long getTimeStamp(ClassNode cls) {
  if (!(cls instanceof DecompiledClassNode)) {
    return Verifier.getTimestamp(cls.getTypeClass());
  }
  return ((DecompiledClassNode) cls).getCompilationTimeStamp();
}
origin: org.codehaus.groovy/groovy

/**
 * Returns the concrete class this classnode relates to. However, this method
 * is inherently unsafe as it may return null depending on the compile phase you are
 * using. AST transformations should never use this method directly, but rather obtain
 * a new class node using {@link #getPlainNodeReference()}.
 * @return the class this classnode relates to. May return null.
 */
public Class getTypeClass(){
  if (clazz != null) return clazz;
  if (redirect != null) return redirect.getTypeClass();
  ClassNode component = redirect().componentType;
  if (component!=null && component.isResolved()){
    return Array.newInstance(component.getTypeClass(), 0).getClass();
  }
  throw new GroovyBugError("ClassNode#getTypeClass for "+getName()+" is called before the type class is set ");
}
origin: org.codehaus.groovy/groovy

private static List<AnnotationNode> getTargetListFromClass(ClassNode alias) {
  alias = getSerializeClass(alias);
  Class<?> c = alias.getTypeClass();
  Object[][] data;
  try {
    Method m = c.getMethod("value");
    data = (Object[][]) m.invoke(null);
  } catch (Exception e) {
    throw new GroovyBugError(e);
  }
  return makeListOfAnnotations(data);
}
origin: org.codehaus.groovy/groovy

private static boolean hasClosureMember(AnnotationNode annotation) {
  Map<String, Expression> members = annotation.getMembers();
  for (Map.Entry<String, Expression> member : members.entrySet())  {
    if (member.getValue() instanceof ClosureExpression) return true;
    if (member.getValue() instanceof ClassExpression)  {
      ClassExpression classExpression = (ClassExpression) member.getValue();
      Class<?> typeClass = classExpression.getType().isResolved() ? classExpression.getType().redirect().getTypeClass() : null;
      if (typeClass != null && GeneratedClosure.class.isAssignableFrom(typeClass)) return true;
    }
  }
  return false;
}
origin: org.codehaus.groovy/groovy

public static void unbox(MethodVisitor mv, ClassNode type) {
  if (type.isPrimaryClassNode()) return;
  unbox(mv, type.getTypeClass());
}
origin: org.codehaus.groovy/groovy

private static Expression providedOrDefaultInitialValue(FieldNode fNode) {
  Expression initialExp = fNode.getInitialExpression() != null ? fNode.getInitialExpression() : ConstantExpression.NULL;
  final ClassNode paramType = fNode.getType();
  if (ClassHelper.isPrimitiveType(paramType) && initialExp.equals(ConstantExpression.NULL)) {
    initialExp = primitivesInitialValues.get(paramType.getTypeClass());
  }
  return initialExp;
}
origin: org.codehaus.groovy/groovy

public void configureClassNode(CompileUnit compileUnit, ClassNode classNode) {
  try {
    Class clazz = classNode.getTypeClass();
    Field[] fields = clazz.getDeclaredFields();
    for (Field f : fields) {
    if (sc != null) classNode.setUnresolvedSuperClass(makeClassNode(compileUnit, clazz.getGenericSuperclass(), sc));
    makeInterfaceTypes(compileUnit, classNode, clazz);
    setAnnotationMetaData(classNode.getTypeClass().getAnnotations(), classNode);
      setAnnotationMetaData(classNode.getTypeClass().getPackage().getAnnotations(), packageNode);
origin: org.codehaus.groovy/groovy

final ClassLoader classLoader = trait.getTypeClass().getClassLoader();
String helperClassName = Traits.helperClassName(trait);
helperClassNode = ClassHelper.make(Class.forName(helperClassName, false, classLoader));
origin: org.codehaus.groovy/groovy

public void visitAnnotations(AnnotatedNode node) {
  List<AnnotationNode> annotations = node.getAnnotations();
  if (annotations.isEmpty()) return;
  Map<String, AnnotationNode> tmpAnnotations = new HashMap<String, AnnotationNode>();
  ClassNode annType;
  for (AnnotationNode an : annotations) {
    // skip built-in properties
    if (an.isBuiltIn()) continue;
    annType = an.getClassNode();
    resolveOrFail(annType, ",  unable to find class for annotation", an);
    for (Map.Entry<String, Expression> member : an.getMembers().entrySet()) {
      Expression newValue = transform(member.getValue());
      Expression adjusted = transformInlineConstants(newValue);
      member.setValue(adjusted);
      checkAnnotationMemberValue(adjusted);
    }
    if (annType.isResolved()) {
      Class annTypeClass = annType.getTypeClass();
      Retention retAnn = (Retention) annTypeClass.getAnnotation(Retention.class);
      if (retAnn != null && retAnn.value().equals(RetentionPolicy.RUNTIME) && !isRepeatable(annTypeClass)) {
        // remember runtime/non-repeatable annos (auto collecting of Repeatable annotations is handled elsewhere)
        AnnotationNode anyPrevAnnNode = tmpAnnotations.put(annTypeClass.getName(), an);
        if (anyPrevAnnNode != null) {
          addError("Cannot specify duplicate annotation on the same member : " + annType.getName(), an);
        }
      }
    }
  }
}
origin: org.codehaus.groovy/groovy

public static String getClassInternalName(ClassNode t) {
  if (t.isPrimaryClassNode() || t instanceof DecompiledClassNode) {
    if (t.isArray()) return "[L"+getClassInternalName(t.getComponentType())+";";
    return getClassInternalName(t.getName());
  }
  return getClassInternalName(t.getTypeClass());
}
origin: org.codehaus.groovy/groovy

if (cn == null && declaringClass.isResolved()) {
  Class typeClass = declaringClass.getTypeClass();
  typeClass = typeClass.getEnclosingClass();
  if (typeClass != null) {
origin: spockframework/spock

private Expression createDefaultValueInitializer(DeclarationExpression expr) {
 TupleExpression tupleExpr = ObjectUtil.asInstance(expr.getLeftExpression(), TupleExpression.class);
 if (tupleExpr == null) {
  return EmptyExpression.INSTANCE;
 }
 assert expr.isMultipleAssignmentDeclaration();
 // initializing to empty list only works when none of the element types is primitive,
 // so create a proper list expression
 ListExpression listExpr = new ListExpression();
 for (Expression elementExpr : tupleExpr.getExpressions()) {
  Variable variable = (Variable) elementExpr;
  listExpr.addExpression(new ConstantExpression(
    ReflectionUtil.getDefaultValue(variable.getOriginType().getTypeClass())));
 }
 return listExpr;
}
origin: org.codehaus.groovy/groovy

Field field = type.redirect().getTypeClass().getField(pe.getPropertyAsString());
if (field != null && Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers())) {
  ConstantExpression ce3 = new ConstantExpression(field.get(null), true);
origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

/**
 * box top level operand
 */
public static boolean box(MethodVisitor mv, ClassNode type) {
  if (type.isPrimaryClassNode()) return false;
  return box(mv, type.getTypeClass());
}
org.codehaus.groovy.astClassNodegetTypeClass

Javadoc

Returns the concrete class this classnode relates to. However, this method is inherently unsafe as it may return null depending on the compile phase you are using. AST transformations should never use this method directly, but rather obtain a new class node using #getPlainNodeReference().

Popular methods of ClassNode

  • getName
  • getMethods
    This methods creates a list of all methods with this name of the current class and of all super clas
  • <init>
    Constructor used by makeArray() if no real class is available
  • getSuperClass
  • equals
  • addMethod
  • getAnnotations
  • addField
  • getFields
    Returns a list containing FieldNode objects for each field in the class represented by this ClassNod
  • getPlainNodeReference
  • getField
    Finds a field matching the given name in this class or a parent class.
  • getMethod
    Finds a method matching the given name and parameters in this class or any parent class.
  • getField,
  • getMethod,
  • isInterface,
  • getNameWithoutPackage,
  • isScript,
  • getDeclaredMethod,
  • getGenericsTypes,
  • getDeclaredConstructors,
  • getModifiers

Popular in Java

  • Running tasks concurrently on multiple threads
  • notifyDataSetChanged (ArrayAdapter)
  • getResourceAsStream (ClassLoader)
  • getExternalFilesDir (Context)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • JButton (javax.swing)
  • IsNull (org.hamcrest.core)
    Is the value null?
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now