Tabnine Logo
ClassNode.getFields
Code IndexAdd Tabnine 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)

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

  • Reading from database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • getApplicationContext (Context)
  • findViewById (Activity)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • BoxLayout (javax.swing)
  • Top Vim plugins
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