congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
ClassNode.isScript
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: org.codehaus.groovy/groovy

/**
 * @return true if we are in a script body, where all variables declared are no longer
 *         local variables but are properties
 */
public boolean isInScriptBody() {
  if (classNode.isScriptBody()) {
    return true;
  } else {
    return classNode.isScript() && methodNode != null && methodNode.getName().equals("run");
  }
}
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: remkop/picocli

if (!baseScriptType.isScript()) {
  addError("Declared type " + baseScriptType + " does not extend groovy.lang.Script class!", parent);
  return;
origin: remkop/picocli

private void changeBaseScriptTypeFromDeclaration(final SourceUnit source, final DeclarationExpression de, final AnnotationNode node) {
  if (de.isMultipleAssignmentDeclaration()) {
    addError("Annotation " + MY_TYPE_NAME + " not supported with multiple assignment notation.", de);
    return;
  }
  ClassNode cNode = de.getDeclaringClass();
  ClassNode baseScriptType = de.getVariableExpression().getType().getPlainNodeReference();
  if (baseScriptType.isScript()) {
    if (!(de.getRightExpression() instanceof EmptyExpression)) {
      addError("Annotation " + MY_TYPE_NAME + " not supported with variable assignment.", de);
      return;
    }
    de.setRightExpression(new VariableExpression("this"));
  } else {
    baseScriptType = BASE_SCRIPT_TYPE;
  }
  Expression value = node.getMember("value");
  if (value != null) {
    addError("Annotation " + MY_TYPE_NAME + " cannot have member 'value' if used on a declaration.", value);
    return;
  }
  changeBaseScriptType(source, de, cNode, baseScriptType, node);
}
origin: org.codehaus.groovy/groovy

if (!baseScriptType.isScript()) {
  addError("Declared type " + baseScriptType + " does not extend groovy.lang.Script class!", parent);
  return;
origin: org.codehaus.groovy/groovy

final List<ClassNode> classes = tree.getClasses();
for (ClassNode classNode : classes) {
  if (classNode.isScript()) {
    visitClass(classNode);
origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

/**
 * @return true if we are in a script body, where all variables declared are no longer
 *         local variables but are properties
 */
public boolean isInScriptBody() {
  if (classNode.isScriptBody()) {
    return true;
  } else {
    return classNode.isScript() && methodNode != null && methodNode.getName().equals("run");
  }
}

origin: groovy/groovy-core

public void visitModuleNode(ModuleNode moduleNode) {
  
  //visit imports like import java.io.File and import java.io.File as MyFile
  for (ImportNode importNode : moduleNode.getImports()) {
    visitNode(importNode.getType());
  }
  
  //visit static imports like import java.lang.Math.*
  for (ImportNode importNode : moduleNode.getStaticStarImports().values()) {
    visitNode(importNode.getType());
  }
  
  //visit static imports like import java.lang.Math.cos
  for (ImportNode importNode : moduleNode.getStaticImports().values()) {
    visitNode(importNode.getType());
  }
  for (ClassNode classNode : moduleNode.getClasses()) {
    if (!classNode.isScript()) {
      visitClass(classNode);
    } else {
      for (MethodNode method : moduleNode.getMethods()) {
        visitMethod(method);
      }
    }
  }
  //visit Statements that are not inside a class
  if (!moduleNode.getStatementBlock().isEmpty()) {
    visitBlockStatement(moduleNode.getStatementBlock());
  }
}
origin: org.kohsuke.droovy/groovy

/**
 * @return true if we are in a script body, where all variables declared are no longer
 *         local variables but are properties
 */
protected boolean isInScriptBody() {
  if (classNode.isScriptBody()) {
    return true;
  } else {
    return classNode.isScript() && methodNode != null && methodNode.getName().equals("run");
  }
}
origin: org.codehaus.groovy/groovy

DeclarationExpression de = (DeclarationExpression) parent;
ClassNode cNode = de.getDeclaringClass();
if (!cNode.isScript()) {
  addError("Annotation " + MY_TYPE_NAME + " can only be used within a Script.", parent);
  return;
origin: org.codehaus.groovy/groovy-all-minimal

/**
 * @return true if we are in a script body, where all variables declared are no longer
 *         local variables but are properties
 */
protected boolean isInScriptBody() {
  if (classNode.isScriptBody()) {
    return true;
  } else {
    return classNode.isScript() && methodNode != null && methodNode.getName().equals("run");
  }
}
origin: org.codehaus.groovy/groovy

ClassExpression ce = (ClassExpression) left;
String error = "you tried to assign a value to the class '" + ce.getType().getName() + "'";
if (ce.getType().isScript()) {
  error += ". Do you have a script with this name?";
origin: org.codehaus.groovy/groovy-jdk14

/**
 * @return true if we are in a script body, where all variables declared are no longer
 *         local variables but are properties
 */
protected boolean isInScriptBody() {
  if (classNode.isScriptBody()) {
    return true;
  } else {
    return classNode.isScript() && methodNode != null && methodNode.getName().equals("run");
  }
}
origin: org.codenarc/CodeNarc

/**
 * @return true if the ASTNode was generated (synthetic) rather than from the "real" input source code.
 */
public static boolean isFromGeneratedSourceCode(ASTNode node) {
  return node.getLineNumber() < 0 || (node instanceof ClassNode && ((ClassNode)node).isScript());
}
origin: org.gcontracts/gcontracts-core

/**
 * Checks whether the given {@link org.codehaus.groovy.ast.ClassNode} is a candidate
 * for applying interface contracts.
 *
 * @param type the {@link org.codehaus.groovy.ast.ClassNode} to be checked
 * @return whether the given <tt>type</tt> is a candidate for applying interface contract assertions
 */
public static boolean isInterfaceContractsCandidate(final ClassNode type)  {
  return type != null && type.isInterface() && !type.isSynthetic() && !type.isEnum() && !type.isGenericsPlaceHolder() && !type.isScript() && !type.isScriptBody() && !isRuntimeClass(type);
}
origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

/**
 * @return true if this method is the run method from a script
 */
public boolean isScriptBody() {
  return getDeclaringClass() != null &&
      getDeclaringClass().isScript() &&
      getName().equals("run") &&
      getColumnNumber() == -1;
}
origin: org.kohsuke.droovy/groovy

public void visitClass(ClassNode node) {
  pushState();
  currentClass = node;
  boolean dynamicMode = node.isScript();
  currentScope.setDynamicResolving(dynamicMode);
  currentScope.setClassScope(node);
  super.visitClass(node);
  popState();
}
origin: org.codehaus.groovy/groovy-all-minimal

public void visitClass(ClassNode node) {
  pushState();
  currentClass = node;
  boolean dynamicMode = node.isScript();
  currentScope.setDynamicResolving(dynamicMode);
  currentScope.setClassScope(node);
  super.visitClass(node);
  popState();
}
origin: org.chromattic/chromattic.groovy

public void visit(ASTNode[] nodes, SourceUnit sourceUnit) throws ChromatticASTTransformationException {
 for (ClassNode classNode : (List<ClassNode>) sourceUnit.getAST().getClasses()) {
  if (!classNode.isScript() && !classNode.isInterface() && isInChromatticHierarchy(classNode)) {
   visitClass(classNode);
  }
 }
}
origin: org.codehaus.groovy/groovy-jdk14

public void visitClass(ClassNode node) {
  pushState();
  currentClass = node;
  boolean dynamicMode = node.isScript();
  currentScope.setDynamicResolving(dynamicMode);
  currentScope.setClassScope(node);
  super.visitClass(node);
  popState();
}
org.codehaus.groovy.astClassNodeisScript

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,
  • getDeclaredMethod,
  • getGenericsTypes,
  • getDeclaredConstructors,
  • getModifiers,
  • getTypeClass

Popular in Java

  • Start an intent from android
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getResourceAsStream (ClassLoader)
  • getExternalFilesDir (Context)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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