Questions tagged [inria-spoon]

Spoon is an open-source library that enables you to transform and analyze Java source code.

Spoon is an open-source library that enables you to transform and analyze Java source code . Spoon provides a complete and fine-grained Java metamodel where any program element (classes, methods, fields, statements, expressions...) can be accessed both for reading and modification. Spoon takes as input source code and produces transformed source code ready to be compiled.

51 questions
1
vote
1 answer

What is the --precompile flag supposed to do?

I am using Spoon to generate code on annotated classes so I can reduce the boilerplate and code repetitions on a project I am working on. As the project is pretty small I was looking for ways so I do not have to split the whole thing into two or…
dot_Sp0T
  • 389
  • 4
  • 26
1
vote
2 answers

generating a class within a method with spoon

I've been working on a processor that injects an inner class inside a method, and I'm having a lot of trouble figuring out just how to generate the class and accompanying object initialization without incurring auto-generation of an incorrect…
Luke
  • 33
  • 5
1
vote
1 answer

How to gain access to "this" variable in INRIA-SPOON

I'm working with INRIA Spoon. I have some dynamic methods invocations like the following one: a.doSomething(); I can obtain to the variable access a using the getTarget() method of the CtInvocation instance. My task is to generate code to store a…
El Marce
  • 3,144
  • 1
  • 26
  • 40
1
vote
0 answers

Wrap SpoonLoader as a Java AnnotationProcessor

I would like to deploy my Spoon code as an AnnotationProcessor in order to ease deployment into arbitrary build environments. Has somebody tried to wrap the existing SpoonLoader to act like an annotation processor already? I'm thinking an extension…
Jurgen Vinju
  • 6,393
  • 1
  • 15
  • 26
1
vote
1 answer

How to disable (deactivate ) log in Spoon?

I was wondering how can I deactivate log in Spoon (library for analyzing and transforming Java source code)? For example, I want to disable debug log messages. However, I do not know how to set log to Info (log.setLevel(Level.INFO);)
0
votes
1 answer

Spoon Inria. Not resolving CtExecutableReference type and declared type depending on environment (Docker and local Spring Boot)

Good day. I encountered very strange issue using Spoon analysis library in my Java project. I get different parsing results when running same code, that uses Spoon Launcher in different environments 1 Environment - Spring Boot Project that is run…
0
votes
1 answer

Any possible ways to add a java code to existing java file programatically?

I have an interface and class file auto-generated using a custom maven plugin I created. The plugin will read the necessary data from a JSON file and create me a Java files using Jenesis4Java (Mojo code provided below). REQUIREMENT - i have to…
0
votes
1 answer

Building Spoon CtElements for a CtCodeSnippetStatement without strict compiling

Is there a way to build CtElement’s for a CtCodeSnippetStatement without fully compiling? I have snippets I’d like to be able to scan and further process, before inserting them into a class with the rest of their dependencies (methods / global…
J.H.
  • 3
  • 1
0
votes
1 answer

API function `replace` doesn't replace a class with a CtClass instance

I am trying to execute the following piece of code. System.out.println(originalElement); System.out.println(uniqueParent); ((CtClass) originalElement).replace((CtClass) uniqueParent); where originalElement is class Already {} and uniqueParent…
Aman Sharma
  • 257
  • 2
  • 11
0
votes
0 answers

Prevent spoon from accessing the JVM class path

Is there any way, i can prevent spoon parser from accessing the JVM classpath and provide necessary jars (rt.jar etc) in launcher.setSouceClassPath() ?
0
votes
1 answer

How to Access folder in spring boot application

directory structure image i want to access CFRDecompiler folder under decompiled folder from a java main function, how can i do that
behlHardik
  • 21
  • 3
  • 4
0
votes
1 answer

Build AST Model Using Spoon when input project files are located in memory and not saved as files in disk

I am working with Spoon Inria to parse and analyze Java applications. Currently, I am using the below code to create input project model. This code works when project files are saved in the disk. Launcher spoonAPI = new…
Iman
  • 91
  • 7
0
votes
1 answer

How do I pretty print generated source in maven project using spoon?

After creating a class using Factory, how can I pretty print the generated class source code ?
0
votes
1 answer

How to automate tracing concern implementation in Java

Consider the common problem of adding tracing to your code. Suppose AspectJ or Spring AOP approach is NOT something you want to do - what other approaches are possible, besides simply adding the traces manually? Supposedly Spoon or JavaParser are…
aleksander_si
  • 1,021
  • 10
  • 28
0
votes
1 answer

How to remove Comments from a java Class using Spoon?

I am using SequenceR to parse my Java code files. It uses Spoon library of Java which is a popular code analysis library. What I need is, I will give a buggy line number to the analyzer, it will detect the line and find out the method or class of it…
shamiul97
  • 315
  • 1
  • 3
  • 13