/** * Check if the current runtime allows Annotation usage. * * @return true if running on a 1.5+ runtime */ protected boolean isAnnotationCompatible() { return CompilerConfiguration.isPostJDK5(this.source.getConfiguration().getTargetBytecode()); }
/** * Resolve metadata and details of the annotation. * * @param unvisited the node to visit * @return the visited node */ private AnnotationNode visitAnnotation(AnnotationNode unvisited) { ErrorCollector errorCollector = new ErrorCollector(this.source.getConfiguration()); AnnotationVisitor visitor = new AnnotationVisitor(this.source, errorCollector); AnnotationNode visited = visitor.visit(unvisited); this.source.getErrorCollector().addCollectorContents(errorCollector); return visited; }
private void setScriptBaseClassFromConfig(ClassNode cn) { String baseClassName = null; if (unit != null) { baseClassName = unit.getConfig().getScriptBaseClass(); } else if (context != null) { baseClassName = context.getConfiguration().getScriptBaseClass(); } if (baseClassName != null) { if (!cn.getSuperClass().getName().equals(baseClassName)) { cn.setSuperClass(ClassHelper.make(baseClassName)); AnnotationNode annotationNode = new AnnotationNode(BaseScriptASTTransformation.MY_TYPE); cn.addAnnotation(annotationNode); } } }
/** * Parses the source to a CST. You can retrieve it with getCST(). */ public void parse() throws CompilationFailedException { if (this.phase > Phases.PARSING) { throw new GroovyBugError("parsing is already complete"); } if (this.phase == Phases.INITIALIZATION) { nextPhase(); } // // Create a reader on the source and run the parser. try (Reader reader = source.getReader()) { // let's recreate the parser each time as it tends to keep around state parserPlugin = getConfiguration().getPluginFactory().createParserPlugin(); cst = parserPlugin.parseCST(this, reader); } catch (IOException e) { getErrorCollector().addFatalError(new SimpleMessage(e.getMessage(), this)); } }
GroovyShell shell = new GroovyShell(transformLoader, new Binding(), config); script = (TypeCheckingDSL) shell.parse( new InputStreamReader(is, typeCheckingVisitor.getSourceUnit().getConfiguration().getSourceEncoding()) ); } catch (CompilationFailedException e) {
Integer stInt = Closure.OWNER_FIRST; if (strategy != null) { stInt = (Integer) evaluateExpression(castX(ClassHelper.Integer_TYPE, strategy), typeCheckingContext.source.getConfiguration());
private void visitConstructorOrMethod(MethodNode node, int methodTarget) { visitAnnotations(node, methodTarget); for (int i = 0; i < node.getParameters().length; i++) { Parameter parameter = node.getParameters()[i]; visitAnnotations(parameter, AnnotationNode.PARAMETER_TARGET); } if (this.currentClass.isAnnotationDefinition() && !node.isStaticConstructor()) { ErrorCollector errorCollector = new ErrorCollector(this.source.getConfiguration()); AnnotationVisitor visitor = new AnnotationVisitor(this.source, errorCollector); visitor.setReportClass(currentClass); visitor.checkReturnType(node.getReturnType(), node); if (node.getParameters().length > 0) { addError("Annotation members may not have parameters.", node.getParameters()[0]); } if (node.getExceptions().length > 0) { addError("Annotation members may not have a throws clause.", node.getExceptions()[0]); } ReturnStatement code = (ReturnStatement) node.getCode(); if (code != null) { visitor.visitExpression(node.getName(), code.getExpression(), node.getReturnType()); visitor.checkCircularReference(currentClass, node.getReturnType(), code.getExpression()); } this.source.getErrorCollector().addCollectorContents(errorCollector); } Statement code = node.getCode(); if (code != null) { code.visit(this); } }
/** * Check if the current runtime allows Annotation usage. * * @return true if running on a 1.5+ runtime */ protected boolean isAnnotationCompatible() { return CompilerConfiguration.POST_JDK5.equals(this.source.getConfiguration().getTargetBytecode()); }
/** * Check if the current runtime allows Annotation usage. */ protected boolean isAnnotationCompatible() { return CompilerConfiguration.POST_JDK5.equals(this.source.getConfiguration().getTargetBytecode()); }
/** * Check if the current runtime allows Annotation usage. */ protected boolean isAnnotationCompatible() { return CompilerConfiguration.POST_JDK5.equals(this.source.getConfiguration().getTargetBytecode()); }
/** * Check if the current runtime allows Annotation usage. */ protected boolean isAnnotationCompatible() { return CompilerConfiguration.POST_JDK5.equals(this.source.getConfiguration().getTargetBytecode()); }
/** * Resolve metadata and details of the annotation. */ private AnnotationNode visitAnnotation(AnnotationNode node) { ErrorCollector errorCollector = new ErrorCollector(this.source.getConfiguration()); AnnotationVisitor visitor = new AnnotationVisitor(this.source, errorCollector); AnnotationNode solvedAnnotation = visitor.visit(node); this.source.getErrorCollector().addCollectorContents(errorCollector); return solvedAnnotation; }
/** * Resolve metadata and details of the annotation. */ private AnnotationNode visitAnnotation(AnnotationNode node) { ErrorCollector errorCollector = new ErrorCollector(this.source.getConfiguration()); AnnotationVisitor visitor = new AnnotationVisitor(this.source, errorCollector); AnnotationNode solvedAnnotation = visitor.visit(node); this.source.getErrorCollector().addCollectorContents(errorCollector); return solvedAnnotation; }
/** * Resolve metadata and details of the annotation. */ private AnnotationNode visitAnnotation(AnnotationNode node) { ErrorCollector errorCollector = new ErrorCollector(this.source.getConfiguration()); AnnotationVisitor visitor = new AnnotationVisitor(this.source, errorCollector); AnnotationNode solvedAnnotation = visitor.visit(node); this.source.getErrorCollector().addCollectorContents(errorCollector); return solvedAnnotation; }
/** * Resolve metadata and details of the annotation. * * @param unvisited the node to visit * @return the visited node */ private AnnotationNode visitAnnotation(AnnotationNode unvisited) { ErrorCollector errorCollector = new ErrorCollector(this.source.getConfiguration()); AnnotationVisitor visitor = new AnnotationVisitor(this.source, errorCollector); AnnotationNode visited = visitor.visit(unvisited); this.source.getErrorCollector().addCollectorContents(errorCollector); return visited; }
@Override protected void initialize(ModuleNode moduleNode) { super.initialize(moduleNode); File outputDir = moduleNode.getContext().getConfiguration().getTargetDirectory(); persistence = new PropertyEditorPersistence(NAME, options.dir(), outputDir, logger); data = new PropertyEditorCollector(persistence.getInitializer(), logger); data.load(); }
@Override protected void initialize(ModuleNode moduleNode) { super.initialize(moduleNode); File outputDir = moduleNode.getContext().getConfiguration().getTargetDirectory(); persistence = new ArtifactPersistence(NAME, options.dir(), outputDir, logger); data = new ArtifactCollector(persistence.getInitializer(), logger); // Initialize if possible for (String artifactName : persistence.tryFind()) { data.getArtifact(artifactName); } //data.cache(); }
@Override protected void initialize(ModuleNode moduleNode) { super.initialize(moduleNode); File outputDir = moduleNode.getContext().getConfiguration().getTargetDirectory(); persistence = new TypePersistence(NAME, options.dir(), outputDir, logger); data = new TypeCollector(persistence.getInitializer(), logger); // Initialize if possible for (String typeName : persistence.tryFind()) { data.getType(typeName); } //data.cache(); }
@Override protected void initialize(ModuleNode moduleNode) { super.initialize(moduleNode); File outputDir = moduleNode.getContext().getConfiguration().getTargetDirectory(); persistence = new ServicePersistence(NAME, options.dir(), outputDir, logger); data = new ServiceCollector(persistence.getInitializer(), logger); // Initialize if possible for (String serviceName : persistence.tryFind()) { data.getService(serviceName); } // data.cache(); }
private void visitConstructorOrMethod(MethodNode node, int methodTarget) { visitAnnotations(node, methodTarget); for (int i = 0; i < node.getParameters().length; i++) { Parameter parameter = node.getParameters()[i]; visitAnnotations(parameter, AnnotationNode.PARAMETER_TARGET); } if (this.currentClass.isAnnotationDefinition()) { ErrorCollector errorCollector = new ErrorCollector(this.source.getConfiguration()); AnnotationVisitor visitor = new AnnotationVisitor(this.source, errorCollector); visitor.setReportClass(currentClass); visitor.checkReturnType(node.getReturnType(),node); if (node.getParameters().length>0) { addError ("Annotation members may not have parameters.",node.getParameters()[0]); } if (node.getExceptions().length>0) { addError ("Annotation members may not have a throws clause.",node.getExceptions()[0]); } ReturnStatement code = (ReturnStatement) node.getCode(); if (code!=null) { visitor.visitExpression(node.getName(),code.getExpression(),node.getReturnType()); visitor.checkcircularReference(currentClass,node.getReturnType(),code.getExpression()); } this.source.getErrorCollector().addCollectorContents(errorCollector); } }