Codota Logo
ClassNode.getFields
Code IndexAdd Codota to your IDE (free)

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

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

  • Common ways to obtain ClassNode
private void myMethod () {
ClassNode c =
  • Codota IconExpression expression;expression.getType()
  • Codota IconMethodNode methodNode;methodNode.getReturnType()
  • Codota IconString name;ClassHelper.make(name)
  • Smart code suggestions by Codota
}
origin: org.codehaus.groovy/groovy

@Override
public List<FieldNode> getFields() {
  List<FieldNode> nodes = new LinkedList<FieldNode>();
  for (ClassNode delegate : delegates) {
    List<FieldNode> fields = delegate.getFields();
    if (fields != null) nodes.addAll(fields);
  }
  return nodes;
}
origin: org.codehaus.groovy/groovy

@Override
public List<FieldNode> getFields() {
  lazyInitMembers();
  return super.getFields();
}
origin: org.codehaus.groovy/groovy

/**
 * @return the list of FieldNode's associated with this ClassNode
 */
public List<FieldNode> getFields() {
  if (redirect!=null) return redirect().getFields();
  lazyClassInit();
  if (fields == null)
    fields = new LinkedList<FieldNode> ();
  return fields;
}
origin: org.codehaus.groovy/groovy

public static List<FieldNode> getInstanceNonPropertyFields(ClassNode cNode) {
  final List<FieldNode> result = new ArrayList<FieldNode>();
  for (FieldNode fNode : cNode.getFields()) {
    if (!fNode.isStatic() && cNode.getProperty(fNode.getName()) == null) {
      result.add(fNode);
    }
  }
  return result;
}
origin: org.codehaus.groovy/groovy

private void printFields(PrintWriter out, ClassNode classNode) {
  boolean isInterface = isInterfaceOrTrait(classNode);
  List<FieldNode> fields = classNode.getFields();
  if (fields == null) return;
  List<FieldNode> enumFields = new ArrayList<FieldNode>(fields.size());
  List<FieldNode> normalFields = new ArrayList<FieldNode>(fields.size());
  for (FieldNode field : fields) {
    boolean isSynthetic = (field.getModifiers() & Opcodes.ACC_SYNTHETIC) != 0;
    if (field.isEnum()) {
      enumFields.add(field);
    } else if (!isSynthetic) {
      normalFields.add(field);
    }
  }
  printEnumFields(out, enumFields);
  for (FieldNode normalField : normalFields) {
    printField(out, normalField, isInterface);
  }
}
origin: org.codehaus.groovy/groovy

public static List<FieldNode> getSuperNonPropertyFields(ClassNode cNode) {
  final List<FieldNode> result;
  if (cNode == ClassHelper.OBJECT_TYPE) {
    result = new ArrayList<FieldNode>();
  } else {
    result = getSuperNonPropertyFields(cNode.getSuperClass());
  }
  for (FieldNode fNode : cNode.getFields()) {
    if (!fNode.isStatic() && cNode.getProperty(fNode.getName()) == null) {
      result.add(fNode);
    }
  }
  return result;
}
origin: org.codehaus.groovy/groovy

/**
 * If we are in a constructor, that is static compiled, but in a class, that
 * is not, it may happen that init code from object initializers, fields
 * or properties is added into the constructor code. The backend assumes
 * a purely static constructor, so it may fail if it encounters dynamic
 * code here. Thus we make this kind of code fail
 */
private void checkForConstructorWithCSButClassWithout(MethodNode node) {
  if (!(node instanceof ConstructorNode)) return;
  Object meta = node.getNodeMetaData(STATIC_COMPILE_NODE);
  if (!Boolean.TRUE.equals(meta)) return;
  ClassNode clz = typeCheckingContext.getEnclosingClassNode();
  meta = clz.getNodeMetaData(STATIC_COMPILE_NODE);
  if (Boolean.TRUE.equals(meta)) return;
  if (    clz.getObjectInitializerStatements().isEmpty() &&
      clz.getFields().isEmpty() &&
      clz.getProperties().isEmpty())
  {
    return;
  }
  addStaticTypeError("Cannot statically compile constructor implicitly including non static elements from object initializers, properties or fields.",node);
}
origin: org.codehaus.groovy/groovy

private static void addProperty(ClassNode cNode, PropertyNode pNode) {
  final FieldNode fn = pNode.getField();
  cNode.getFields().remove(fn);
  cNode.addProperty(pNode.getName(), pNode.getModifiers() | ACC_FINAL, pNode.getType(),
      pNode.getInitialExpression(), pNode.getGetterBlock(), pNode.getSetterBlock());
  final FieldNode newfn = cNode.getField(fn.getName());
  cNode.getFields().remove(newfn);
  cNode.addField(fn);
}
origin: org.codehaus.groovy/groovy

  pList.remove(pNode);
final List<FieldNode> fList = cNode.getFields();
for (FieldNode fNode : fList) {
  if (foundNames.contains(fNode.getName())) {
origin: org.codehaus.groovy/groovy

for (FieldNode fNode : cNode.getFields()) {
  if ((fNode.isStatic() && !includeStatic) || fNode.isSynthetic() || cNode.getProperty(fNode.getName()) != null || names.contains(fNode.getName())) {
    continue;
origin: org.codehaus.groovy/groovy

for (FieldNode fieldNode : node.getFields()) {
  if (!fieldNode.isSynthetic() && fieldNode.isStatic() && fieldNode.getType() != node) {
    explicitStaticPropsInEnum.add(fieldNode.getName());
for (FieldNode fn : node.getFields()) {
  addFieldInitialization(statements, staticStatements, fn, isEnum,
      initStmtsAfterEnumValuesInit, explicitStaticPropsInEnum);
origin: org.codehaus.groovy/groovy

public void visitContents(GroovyClassVisitor visitor) {
  // now let's visit the contents of the class
  for (PropertyNode pn : getProperties()) {
    visitor.visitProperty(pn);
  }
  for (FieldNode fn : getFields()) {
    visitor.visitField(fn);
  }
  for (ConstructorNode cn : getDeclaredConstructors()) {
    visitor.visitConstructor(cn);
  }
  for (MethodNode mn : getMethods()) {
    visitor.visitMethod(mn);
  }
}
origin: org.codehaus.groovy/groovy

private static boolean ensureNoInstanceFieldOrProperty(final SourceUnit source, final ClassNode parent) {
  boolean valid = true;
  for (FieldNode fieldNode : parent.getFields()) {
    if (!fieldNode.isStatic() && fieldNode.getLineNumber()>0) {
      // if <0, probably an AST transform or internal code (like generated metaclass field, ...)
      addUnsupportedError(fieldNode,  source);
      valid = false;
    }
  }
  for (PropertyNode propertyNode : parent.getProperties()) {
    if (!propertyNode.isStatic() && propertyNode.getLineNumber()>0) {
      // if <0, probably an AST transform or internal code (like generated metaclass field, ...)
      addUnsupportedError(propertyNode, source);
      valid = false;
    }
  }
  return valid;
}
origin: org.codehaus.groovy/groovy

while (consideredClass!=null) {
  if (hasVetoableAnnotation(consideredClass)) return false;
  for (FieldNode field : consideredClass.getFields()) {
    if (hasVetoableAnnotation(field)) return false;
origin: org.codehaus.groovy/groovy

while (consideredClass!=null) {
  if (hasBindableAnnotation(consideredClass)) return false;
  for (FieldNode field : consideredClass.getFields()) {
    if (hasBindableAnnotation(field)) return false;
origin: org.codehaus.groovy/groovy

  addProperty(cNode, pNode);
final List<FieldNode> fList = cNode.getFields();
for (FieldNode fNode : fList) {
  ensureNotPublic(this, cName, fNode);
origin: org.codehaus.groovy/groovy

private Variable findClassMember(ClassNode cn, String name) {
  if (cn == null) return null;
  if (cn.isScript()) {
    return new DynamicVariable(name, false);
  }
  for (FieldNode fn : cn.getFields()) {
    if (fn.getName().equals(name)) return fn;
  }
  for (MethodNode mn : cn.getMethods()) {
    String pName = getPropertyName(mn);
    if (name.equals(pName)) {
      PropertyNode property = new PropertyNode(name, mn.getModifiers(), ClassHelper.OBJECT_TYPE, cn, null, null, null);
      property.getField().setHasNoRealSourcePosition(true);
      property.getField().setSynthetic(true);
      property.getField().setDeclaringClass(cn);
      property.setDeclaringClass(cn);
      return property;
    }
  }
  for (PropertyNode pn : cn.getProperties()) {
    if (pn.getName().equals(name)) return pn;
  }
  Variable ret = findClassMember(cn.getSuperClass(), name);
  if (ret != null) return ret;
  return findClassMember(cn.getOuterClass(), name);
}
origin: org.codehaus.groovy/groovy

privateFieldMutators = mutatedFields != null ? new HashMap<String, MethodNode>() : null;
final int access = Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC;
for (FieldNode fieldNode : node.getFields()) {
  boolean generateAccessor = accessedFields != null && accessedFields.contains(fieldNode);
  boolean generateMutator = mutatedFields != null && mutatedFields.contains(fieldNode);
origin: org.codehaus.groovy/groovy

classNode.getFields().remove(storedNode);
classNode.getFields().remove(pn.getField());
pn.setField(fieldNode);
origin: org.codehaus.groovy/groovy

for (FieldNode fn : node.getFields()) {
  if (!fn.isStatic() || !fn.isSynthetic() || !fn.getName().startsWith("$const$")) continue;
  if (fn.getInitialExpression() == null) continue;
org.codehaus.groovy.astClassNodegetFields

Javadoc

Returns a list containing FieldNode objects for each field in the class represented by this ClassNode

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
  • 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.
  • isInterface
  • getMethod,
  • isInterface,
  • getNameWithoutPackage,
  • isScript,
  • getDeclaredMethod,
  • getGenericsTypes,
  • getDeclaredConstructors,
  • getModifiers,
  • getTypeClass

Popular in Java

  • Finding current android device location
  • notifyDataSetChanged (ArrayAdapter)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • putExtra (Intent)
  • BigInteger (java.math)
    Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Table (org.hibernate.mapping)
    A relational table
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now