3434import java .util .ArrayList ;
3535import java .util .Collections ;
3636import java .util .EnumSet ;
37+ import java .util .HashSet ;
3738import java .util .Iterator ;
3839import java .util .List ;
3940import java .util .Set ;
5758import org .netbeans .api .project .ProjectUtils ;
5859import org .netbeans .api .project .SourceGroup ;
5960import org .netbeans .api .project .Sources ;
61+ import org .openide .filesystems .FileObject ;
6062import 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