Returns all the {@link JavaClassSource} objects from the given {@link Project}
806
public List<JavaResource> getProjectClasses(Project project)
   {
      final List<JavaResource> classes = new ArrayList<>();
      if (project != null)
      {
         project.getFacet(JavaSourceFacet.class).visitJavaSources(new JavaClassSourceVisitor(classes));
      }
      return classes;
   }
850138
private Class<?>[] getClassList(List<Object> objects) {
        Class<?>[] classes = new Class<?>[objects.size()];
        for (int i = 0; i < objects.size(); i++) {
            classes[i] = objects.get(i).getClass();
        }
        return classes;
    }
12938
public static Class<?> loadProjectClass(Project project, String className) {
        URLClassLoader classLoader = getProjectClassLoader(project);
        if (classLoader != null ){
            try {
                return classLoader.loadClass(className);
            } catch (ClassNotFoundException e) {
                // ignore
            } finally {
                try {
                    classLoader.close();
                } catch (IOException e) {
                    // ignore
                }
            }
        }
        return null;
    }
40485
private List<String> getSourceRoots( final MavenProject project, final String scope )
    {
        if ( SCOPE_COMPILE.equals( scope ) || SCOPE_RUNTIME.equals( scope ) )
        {
            return project.getCompileSourceRoots();
        }
        else if ( SCOPE_TEST.equals( scope ) )
        {
            List<String> sourceRoots = new ArrayList<String>();
            sourceRoots.addAll( project.getTestCompileSourceRoots() );
            sourceRoots.addAll( project.getCompileSourceRoots() );
            return sourceRoots;
        }
        else
        {
            throw new RuntimeException( "Not allowed scope " + scope );
        }
    }
947977
protected List<String> getClasspathDirectories()
    {
        return Arrays.asList( project.getBuild().getOutputDirectory(),
            project.getBuild().getTestOutputDirectory() );
    }
327498
private void findAllModifiedClasses(String name,
                                      PathImpl sourceDir,
                                      PathImpl classDir,
                                      String sourcePath,
                                      ArrayList<String> sources)
    throws IOException, ClassNotFoundException
  {
    String []list;

    try {
      list = sourceDir.list();
    } catch (IOException e) {
      return;
    }

    for (int i = 0; list != null && i < list.length; i++) {
      if (list[i].startsWith("."))
        continue;

      if (_excludedDirectories.contains(list[i]))
        continue;
      
      PathImpl subSource = sourceDir.lookup(list[i]);

      if (subSource.isDirectory()) {
        findAllModifiedClasses(name + list[i] + "/", subSource,
                               classDir.lookup(list[i]), sourcePath, sources);
      }
      else if (list[i].endsWith(_sourceExt)) {
        int tail = list[i].length() - _sourceExt.length();
        String prefix = list[i].substring(0, tail);
        PathImpl subClass = classDir.lookup(prefix + ".class");

        if (subClass.getLastModified() < subSource.getLastModified()) {
          sources.add(name + list[i]);
        }
      }
    }

    if (! _requireSource)
      return;
    
    try {
      list = classDir.list();
    } catch (IOException e) {
      return;
    }

    for (int i = 0; list != null && i < list.length; i++) {
      if (list[i].startsWith("."))
        continue;

      if (_excludedDirectories.contains(list[i]))
        continue;
      
      PathImpl subClass = classDir.lookup(list[i]);

      if (list[i].endsWith(".class")) {
        String prefix = list[i].substring(0, list[i].length() - 6);
        PathImpl subSource = sourceDir.lookup(prefix + _sourceExt);

        if (! subSource.exists()) {
          String tail = subSource.getTail();
          boolean doRemove = true;

          if (tail.indexOf('$') > 0) {
            String subTail = tail.substring(0, tail.indexOf('$')) + _sourceExt;
            PathImpl subJava = subSource.getParent().lookup(subTail);

            if (subJava.exists())
              doRemove = false;
          }

          if (doRemove) {
            log.finer(L.l("removing obsolete class '{0}'.", subClass.getPath()));

            subClass.remove();
          }
        }
      }
    }
  }
403957
public TypeFinder toTypeFinder(final IJavaProject project) {
		return new TypeFinder() {
			@Override
			public IType findType(String typeName) throws JavaModelException {
				return project.findType(typeName);
			}
		};
	}
668889
public static List<Class<?>> getAllClasses(Class<?> clazz) {
        List<Class<?>> types = new ArrayList<>();
        while (clazz != null) {
            types.add(clazz);
            clazz = clazz.getSuperclass();
        }
        return types;
    }
967623
public List<Project> getAllProjects() {
        try {
            sessionService.startSession();

            List<Project> projects = projectDao.getAll();

            log.debug("Retrieved All Projects number: " + projects.size());
            return projects;
        } finally {
            sessionService.closeSession();
        }
    }
804377
@SuppressWarnings("unchecked")
    @VisibleForTesting
    Map<String, Class<? extends Service>> mapEventSources() throws IOException {

        /* Obtains all classpath's top level classes */
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        Set<ClassPath.ClassInfo> classes = ClassPath.from(classLoader).getAllClasses();
        ClassLoaderRepository repository = new ClassLoaderRepository(classLoader);
        LOGGER.info("Scanning classpath for EventHandlers....");

        /* iterates over all classes, filter by HandlesEvent annotation and transforms stream to needed form */
        Map<String, Class<? extends Service>> collected = classes.parallelStream()
                /* loads class infos */
                .map(classInfo -> {
                    try {
                        /* sometimes exception occurs during class loading. Return empty/absent in this case */
                        return Optional.of(repository.loadClass(classInfo.getName()));
                    } catch (ClassNotFoundException e) {
                        LOGGER.trace("Class cannot be loaded: {}", classInfo.getName(), e);
                        return Optional.<JavaClass>empty();
                    }
                })
                /* filters classes which is present and marked with EventSource annotation */
                .filter(((Predicate<Optional<JavaClass>>) Optional::isPresent)
                        .and(javaClassOptional -> {
                            return Arrays.stream(javaClassOptional.get().getAnnotationEntries()).anyMatch(annotationEntry -> {
                                return Type.getType(annotationEntry.getAnnotationType()).toString().equals(EventSource.class.getCanonicalName());
                            });
                        })
                        .and(javaClassOptional -> {
                            try {
                                return Arrays.stream(javaClassOptional.get().getAllInterfaces()).anyMatch(iface -> {
                                    return iface.getClassName().equals(Service.class.getCanonicalName());
                                });
                            } catch (ClassNotFoundException e) {
                                LOGGER.trace("Class annotations cannot be loaded: {}", javaClassOptional.get().getClassName(), e);
                                return false;
                            }
                        }))
                /* transforms from Optional<JavaClass> to Class (obtaining values from Optionals) */
                .map(javaClassOptional -> {
                    try {
                        return (Class<? extends Service>) classLoader.loadClass(javaClassOptional.get().getClassName());
                    } catch (ClassNotFoundException e) {
                        LOGGER.trace("Class cannot be loaded: {}", javaClassOptional.get().getClassName(), e);
                        return null;
                    }
                })
                .filter(Objects::nonNull)
                .collect(Collectors.toMap(clazz -> clazz.getAnnotation(EventSource.class).value(), clazz -> clazz));

        LOGGER.info("Found {} event handlers", collected.size());
        return collected;
    }
1250403
public static Resources getClassResources( Class clazz, Locale locale )
    {
        return getBaseResources( getClassResourcesBaseName( clazz ), locale, clazz.getClassLoader() );
    }
439306
protected SortedSources getSources() {
        SortedSources sources = new SortedSources(getUserSources());
        if (addDefaultSourcesFlag()) {
            sources.addAll(DefaultSources.getDefaultSources(getClassLoader()));
        }
        if (addDiscoveredSourcesFlag()) {
            sources.addAll(DefaultSources.getDiscoveredSources(getClassLoader()));
        }
        sources = sources.unmodifiable();
        return sources;
    }
1163410
public static List<LasSource> getLasSources( ASpatialDb db ) throws Exception {
        List<LasSource> sources = new ArrayList<>();
        String sql = "SELECT " + COLUMN_GEOM + "," + COLUMN_ID + "," + COLUMN_NAME + "," + COLUMN_RESOLUTION + "," + COLUMN_FACTOR
                + "," + COLUMN_LEVELS + "," + COLUMN_MINZ + "," + COLUMN_MAXZ + "," + COLUMN_MININTENSITY + ","
                + COLUMN_MAXINTENSITY + " FROM " + TABLENAME;

        return db.execOnConnection(connection -> {
            IGeometryParser gp = db.getType().getGeometryParser();
            try (IHMStatement stmt = connection.createStatement(); IHMResultSet rs = stmt.executeQuery(sql)) {
                while( rs.next() ) {
                    LasSource lasSource = new LasSource();
                    int i = 1;
                    Geometry geometry = gp.fromResultSet(rs, i++);
                    if (geometry instanceof Polygon) {
                        Polygon polygon = (Polygon) geometry;
                        lasSource.polygon = polygon;
                        lasSource.id = rs.getLong(i++);
                        lasSource.name = rs.getString(i++);
                        lasSource.resolution = rs.getDouble(i++);
                        lasSource.levelFactor = rs.getDouble(i++);
                        lasSource.levels = rs.getInt(i++);
                        lasSource.minElev = rs.getDouble(i++);
                        lasSource.maxElev = rs.getDouble(i++);
                        lasSource.minIntens = rs.getDouble(i++);
                        lasSource.maxIntens = rs.getDouble(i++);
                        sources.add(lasSource);
                    }
                }
                return sources;
            }
        });

    }
977842
@Override
	public Set<Class<?>> getClasses()
	{
		Set<Class<?>> classes = new HashSet<>();
		classes.add(HelloResource.class);
		return classes;
	}
1167652
private void inspectClassProperties(final String type,
            Map<String, Property> properties)
   {

      JavaSource<?> clazz = sourceForName(this.project, type);

      if (clazz instanceof MethodHolder<?>)
      {
         lookupGetters(properties, (MethodHolder<?>) clazz);
         lookupSetters(properties, (MethodHolder<?>) clazz);

         if (clazz instanceof JavaClass)
         {
            JavaClassSource source = Roaster.parse(JavaClassSource.class,
                     clazz.toString());
            if (!source.getSuperType().equals("java.lang.Object"))
            {
               inspectClassProperties(source.getSuperType(), properties);
            }
         }
      }
   }
399686
@Override
    public SourceLineAnnotation getSourceLines() {
        if (sourceLines == null) {
            this.sourceLines = getSourceLinesForClass(className, sourceFileName);
        }
        return sourceLines;
    }
794972
protected static IJavaProject[] getProjectSearchOrder(String projectName) {

		ArrayList<String> projectNames= new ArrayList<>();
		projectNames.add(projectName);

		int nextProject= 0;
		while (nextProject < projectNames.size()) {
			String nextProjectName= projectNames.get(nextProject);
			IJavaProject jproject= getJavaProject(nextProjectName);

			if (jproject != null) {
				try {
					String[] childProjectNames= jproject.getRequiredProjectNames();
					for (int i= 0; i < childProjectNames.length; i++) {
						if (!projectNames.contains(childProjectNames[i])) {
							projectNames.add(childProjectNames[i]);
						}
					}
				} catch (JavaModelException e) {
					JavaPlugin.log(e);
				}
			}
			nextProject+= 1;
		}

		ArrayList<IJavaProject> result= new ArrayList<>();
		for (int i= 0, size= projectNames.size(); i < size; i++) {
			String name= projectNames.get(i);
			IJavaProject project= getJavaProject(name);
			if (project != null)
				result.add(project);
		}

		return result.toArray(new IJavaProject[result.size()]);
	}