INRIA / INRIA/spoon

[ Question ] - How can i get CtField assignemnt without its package and class name

Open
#5,110 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2k
Forks
392
Avg merge
11h 24m
Merged PRs (30d)
36

Description

I am trying to get a Constant field's value, while trying so it is giving me the value along with its package and class name.

The code I am scanning using a spoon is as,

```
package com.mywells.admin.services.ecm.alarmcfg;

public class EcmConfigMgmtDAO {
final Logger logger = Logger.getLogger(EcmConfigMgmtDAO.class);
final static String RULESETS_SQL = "select distinct ser.ruleset_id, r.ruleset_id ,ses.ruleset_id, "
+ "nvl((select 1 from ruleset where screens is not null and ruleset.ruleset_id = r.ruleset_id),0) "
+ "from stg_ecm_ruleset ser left outer join stg_ecm_screens ses on ser.ruleset_id=ses.ruleset_id "
+ "left outer join ruleset r on r.ruleset_id=ser.ruleset_id order by ser.ruleset_id";
public List fetchRulesets() throws Exception {
List rulesets = new ArrayList();
ResultSet rs = null;
try {
rs = dataService.getJDBCRowSet(RULESETS_SQL);

while (rs.next()) {
EcmRuleSetBean ruleSet = new EcmRuleSetBean();
ruleSet.setNewRuleSetId(rs.getString(1));
ruleSet.setExistingRuleSetId(rs.getString(2));
ruleSet.setScreenRuleSetId(rs.getString(3));
ruleSet.setScreenExists(rs.getBoolean(4));
rulesets.add(ruleSet);
}
} catch (Exception e) {
throw new Exception("-->EcmConfigMgmtDAO.fetchProductInfo(): " + e.toString());
} finally {
if (rs != null) {
rs.close();
}
}

return rulesets;
}
}

```

I am trying to get the variable assignment of the **Resultset rs** in the code like this rs = **dataService.getJDBCRowSet(RULESETS_SQL);**

I am using CtField to get the constant's value and CtLocalVariable to get other fields value and getting the output as
```
dataService.getJDBCRowSet(com.mywells.admin.services.ecm.alarmcfg.EcmConfigMgmtDAO.RULESETS_SQL)
```
This above is for the variable **rs**

But I am expecting the output as
```
dataService.getJDBCRowSet(RULESETS_SQL)
```
without the **RULESETS_SQL** package and class name with it.
Please suggest a way to achieve this.

Contributor guide

Open the contributing guide

Research direction

Reproduce the supplied Spoon example and inspect how CtField references are rendered in the assignment to rs. Compare that rendering with the expected unqualified RULESETS_SQL form; done means the requested expression is produced without the package and class name.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.