[Question]: Will Spoon add extra space in between variable assignments using '+' concatenation
- Dominant language
- Java
- Stars
- 2k
- Forks
- 393
- Avg merge
- 11h 24m
- Merged PRs (30d)
- 36
Description
I am trying to get the variable value from the below source code,
```
public class HibernateIPAccessListDao extends HibernateGenericDao implements IIPAccessListDao {
@Override
public String getSubUrNo(String urNo) {
Session session = getSessionFactory().getCurrentSession();
System.out.println("Find Sub Ur For URNO >> "+urNo);
String testString = "a"+session;
String subUrNo = (String) session.createSQLQuery("SELECT NVL(MAX(T1.SUB_UR_NO),0) AS MAX_SUB_UR_NO FROM IP_UR_ACCESS_LIST_CDN T1 WHERE T1.UR_NO='"+urNo.trim()+"'")
.addScalar("MAX_SUB_UR_NO", Hibernate.STRING).uniqueResult();
return subUrNo;
}
```
i am trying to get the variable value of **subUrNo ** and **testString** using the spoons **CtLocalVariable.getAssignment().toString()** and storing it for further processing.
Actual output i am getting as,
**"a" + session** for **testString** and
**(java.lang.String) (session.createSQLQuery("SELECT NVL(MAX(T1.SUB_UR_NO),0) AS MAX_SUB_UR_NO FROM IP_UR_ACCESS_LIST_CDN T1 WHERE T1.UR_NO='" + urNo.trim() + "'").addScalar("MAX_SUB_UR_NO", Hibernate.STRING).uniqueResult()))** for **subUrNo**
The issue is it is adding extra space near the '+' concatenation in the variable value. Is there any way to bypass it, so that I can get a variable value without any spaces added?
Contributor guide
Research direction
Start with CtLocalVariable.getAssignment().toString() and inspect how Spoon represents or prints concatenated expressions. Compare the output for testString and subUrNo with the original source, then determine whether the spacing behavior is expected and whether a documented API can provide the requested representation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100