INRIA / INRIA/spoon

[Bug]: When you import a static inner class, spoon converts it to a non-static import

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

Description

### Describe the bug

When you import a static inner class, spoon converts it to a non-static import

### Source code you are trying to analyze/transform

```Java
import static StaticTest3.StaticInnerTest1;

public class ImportsTest {
void funT1(){
int i = StaticInnerTest1.destInnerTest1_static_var1;
}
}
-----------------------------------------------------------
public class StaticTest3 {
public static class StaticInnerTest1 {
public static int destInnerTest1_static_var1 = 0;
}
}
```

### Source code for your Spoon processing

```Java
Launcher launcher = new Launcher();
launcher.getEnvironment().setComplianceLevel(11);
launcher.getEnvironment().setAutoImports(true);
launcher.getEnvironment().setIgnoreDuplicateDeclarations(true);
launcher.addInputResource("");
model = launcher.buildModel();

Iterator> iterator = model.getAllTypes().iterator();
while(iterator.hasNext()){
CtType type = iterator.next();
for (CtImport anImport : type.getPosition().getCompilationUnit().getImports()) {
if("import StaticTest3.StaticInnerTest1;".equals(anImport.toString())){
System.out.println("exists error");
}
}
}
```

### Actual output

```Java
import StaticTest3.StaticInnerTest1;
```

### Expected output

```Java
import static StaticTest3.StaticInnerTest1;
```

### Spoon Version

10.4.3-beta-2

### JVM Version

11

### What operating system are you using?

windows

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.