本文整理了Java中org.codehaus.groovy.ast.ClassNode.isScript()
方法的一些代码示例,展示了ClassNode.isScript()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassNode.isScript()
方法的具体详情如下:
包路径:org.codehaus.groovy.ast.ClassNode
类名称:ClassNode
方法名:isScript
暂无
代码示例来源: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();
}
内容来源于网络,如有侵权,请联系作者删除!