private ClassLoader getTransformLoader() { CompilationUnit compilationUnit = typeCheckingContext.getCompilationUnit(); return compilationUnit != null ? compilationUnit.getTransformLoader() : getSourceUnit().getClassLoader(); }
/** * Finds a class node given a string representing the type. Performs a lookup in the compilation unit to check if it is done in the same source unit. * @param sourceUnit source unit * @param compilationUnit compilation unit * @param className the name of the class we want to get a {@link org.codehaus.groovy.ast.ClassNode} for * @return a ClassNode representing the type */ protected ClassNode findClassNode(final SourceUnit sourceUnit, final CompilationUnit compilationUnit, final String className) { if (className.endsWith("[]")) { return findClassNode(sourceUnit, compilationUnit, className.substring(0, className.length() - 2)).makeArray(); } ClassNode cn = compilationUnit.getClassNode(className); if (cn == null) { try { cn = ClassHelper.make(Class.forName(className, false, sourceUnit.getClassLoader())); } catch (ClassNotFoundException e) { cn = ClassHelper.make(className); } } return cn; } }
public void visit(ASTNode[] nodes, SourceUnit source) { init(nodes, source); AnnotatedNode parent = (AnnotatedNode) nodes[1]; AnnotationNode anno = (AnnotationNode) nodes[0]; if (!MY_TYPE.equals(anno.getClassNode())) return; if (parent instanceof ClassNode) { final GroovyClassLoader classLoader = compilationUnit != null ? compilationUnit.getTransformLoader() : source.getClassLoader(); final PropertyHandler handler = PropertyHandler.createPropertyHandler(this, classLoader, (ClassNode) parent); if (handler == null) return; if (!handler.validateAttributes(this, anno)) return; doMakeImmutable((ClassNode) parent, anno, handler); } }
basicArgs.put("classLoader", loader != null ? loader : sourceUnit.getClassLoader()); if (!grabExcludeMaps.isEmpty()) basicArgs.put("excludes", grabExcludeMaps); if (autoDownload != null) basicArgs.put(AUTO_DOWNLOAD_SETTING, autoDownload);
public void visit(ASTNode[] nodes, SourceUnit source) { init(nodes, source); AnnotatedNode parent = (AnnotatedNode) nodes[1]; AnnotationNode anno = (AnnotationNode) nodes[0]; if (!MY_TYPE.equals(anno.getClassNode())) return; if (parent instanceof ClassNode || parent instanceof MethodNode) { if (parent instanceof ClassNode && !checkNotInterface((ClassNode) parent, MY_TYPE_NAME)) return; if (parent instanceof MethodNode && !checkStatic((MethodNode) parent, MY_TYPE_NAME)) return; final GroovyClassLoader classLoader = compilationUnit != null ? compilationUnit.getTransformLoader() : source.getClassLoader(); final BuilderStrategy strategy = createBuilderStrategy(anno, classLoader); if (strategy == null) return; strategy.build(this, parent, anno); } }
ic.addStaticStars("org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport"); config.addCompilationCustomizers(ic); final GroovyClassLoader transformLoader = compilationUnit!=null?compilationUnit.getTransformLoader():typeCheckingVisitor.getSourceUnit().getClassLoader(); ClassLoader cl = typeCheckingVisitor.getSourceUnit().getClassLoader();
MAP_TYPE.equals(rType) || rType.implementsInterface(MAP_TYPE) || LIST_TYPE.equals(rType) || rType.implementsInterface(LIST_TYPE); List<MethodNode> nodes = StaticTypeCheckingSupport.findDGMMethodsByNameAndArguments(controller.getSourceUnit().getClassLoader(), rType, message, args); if (nodes.isEmpty()) { nodes = StaticTypeCheckingSupport.findDGMMethodsByNameAndArguments(controller.getSourceUnit().getClassLoader(), rType, message, args);
AnnotationNode logAnnotation = (AnnotationNode) nodes[0]; final GroovyClassLoader classLoader = compilationUnit != null ? compilationUnit.getTransformLoader() : source.getClassLoader(); final LoggingStrategy loggingStrategy = createLoggingStrategy(logAnnotation, classLoader); if (loggingStrategy == null) return;
if (!checkPropertyList(cNode, excludes, "excludes", anno, MY_TYPE_NAME, includeFields, includeSuperProperties, allProperties, includeSuperFields, false)) return; final GroovyClassLoader classLoader = compilationUnit != null ? compilationUnit.getTransformLoader() : source.getClassLoader(); final PropertyHandler handler = PropertyHandler.createPropertyHandler(this, classLoader, cNode); if (handler == null) return;
List<MethodNode> asBoolean = findDGMMethodsByNameAndArguments(controller.getSourceUnit().getClassLoader(), top, "asBoolean", ClassNode.EMPTY_ARRAY); if (asBoolean.size() == 1) { MethodNode node = asBoolean.get(0);
List<MethodNode> methods = findDGMMethodsByNameAndArguments(controller.getSourceUnit().getClassLoader(), receiverType, getterName, ClassNode.EMPTY_ARRAY); for (MethodNode m: findDGMMethodsByNameAndArguments(controller.getSourceUnit().getClassLoader(), receiverType, altGetterName, ClassNode.EMPTY_ARRAY)) { if (Boolean_TYPE.equals(getWrapper(m.getReturnType()))) methods.add(m);
if (!checkPropertyList(cNode, excludes, "excludes", anno, MY_TYPE_NAME, includeFields, includeSuperProperties, allProperties)) return; final GroovyClassLoader classLoader = compilationUnit != null ? compilationUnit.getTransformLoader() : source.getClassLoader(); final PropertyHandler handler = PropertyHandler.createPropertyHandler(this, classLoader, cNode); if (handler == null) return;
public static boolean isVisible(SourceUnit source, String className) { try { source.getClassLoader().loadClass(className); return true; } catch (ClassNotFoundException e) { return false; } }
basicArgs.put("classLoader", loader != null ? loader : sourceUnit.getClassLoader()); if (!grabExcludeMaps.isEmpty()) basicArgs.put("excludes", grabExcludeMaps);
basicArgs.put("classLoader", sourceUnit.getClassLoader());
basicArgs.put("classLoader", sourceUnit.getClassLoader());