Skip to content

Commit 39f65d3

Browse files
committed
Improve code
1 parent 45b1752 commit 39f65d3

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewCustomControlVisualPanel1.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.ArrayList;
3535
import java.util.Collections;
3636
import java.util.EnumSet;
37+
import java.util.HashSet;
3738
import java.util.Iterator;
3839
import java.util.List;
3940
import java.util.Set;
@@ -57,6 +58,7 @@
5758
import org.netbeans.api.project.ProjectUtils;
5859
import org.netbeans.api.project.SourceGroup;
5960
import org.netbeans.api.project.Sources;
61+
import org.openide.filesystems.FileObject;
6062
import org.openide.util.Exceptions;
6163

6264
@SuppressWarnings({"unchecked", "rawtypes"})
@@ -97,7 +99,7 @@ private List<String> getSources() {
9799
return Collections.emptyList();
98100
}
99101

100-
List<String> list = new ArrayList<>();
102+
Set<String> list = new HashSet<>();
101103
for (Project project : projects) {
102104
Sources sources = project.getLookup().lookup(Sources.class);
103105
if (sources == null) {
@@ -110,9 +112,10 @@ private List<String> getSources() {
110112
}
111113

112114
for (SourceGroup sourceGroup : groups) {
113-
final ClasspathInfo cpInfo = ClasspathInfo.create(ClassPath.getClassPath(sourceGroup.getRootFolder(), ClassPath.BOOT),
114-
ClassPath.getClassPath(sourceGroup.getRootFolder(), ClassPath.COMPILE),
115-
ClassPath.getClassPath(sourceGroup.getRootFolder(), ClassPath.SOURCE));
115+
FileObject rootFolder = sourceGroup.getRootFolder();
116+
final ClasspathInfo cpInfo = ClasspathInfo.create(ClassPath.getClassPath(rootFolder, ClassPath.BOOT),
117+
ClassPath.getClassPath(rootFolder, ClassPath.COMPILE),
118+
ClassPath.getClassPath(rootFolder, ClassPath.SOURCE));
116119

117120
Set<SearchScope> set = EnumSet.of(ClassIndex.SearchScope.SOURCE);
118121
Set<ElementHandle<TypeElement>> types = cpInfo.getClassIndex().getDeclaredTypes("", NameKind.PREFIX, set);
@@ -143,10 +146,8 @@ public void run(CompilationController control)
143146
//Check if it implements control interface
144147
for (TypeMirror typeMirror : elem.getInterfaces()) {
145148
String interfaceName = typeMirror.toString();
146-
if ("com.jme3.scene.control.Control".equals(interfaceName)) {
147-
if (!list.contains(elementName)) {
148-
list.add(elementName);
149-
}
149+
if ("com.jme3.scene.control.Control".equals(interfaceName) && !list.contains(elementName)) {
150+
list.add(elementName);
150151
break;
151152
}
152153
}
@@ -174,7 +175,7 @@ public void run(CompilationController control)
174175
}
175176
}
176177

177-
return list;
178+
return new ArrayList<>(list);
178179
}
179180

180181
public void load(Project proj) {

0 commit comments

Comments
 (0)