use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class StandardJavaElementContentProvider method getFolderContent.
/**
* Evaluates all children of a given {@link IFolder}. Clients can override this method.
* @param folder The folder to evaluate the children for.
* @return The children of the given folder.
* @exception CoreException if the folder does not exist.
*
* @since 3.3
*/
protected Object[] getFolderContent(IFolder folder) throws CoreException {
IResource[] members = folder.members();
IJavaProject javaProject = JavaCore.create(folder.getProject());
if (javaProject == null || !javaProject.exists())
return members;
boolean isFolderOnClasspath = javaProject.isOnClasspath(folder);
List<IResource> nonJavaResources = new ArrayList<IResource>();
// Can be on classpath but as a member of non-java resource folder
for (int i = 0; i < members.length; i++) {
IResource member = members[i];
// of non-Java resources.
if (isFolderOnClasspath) {
if (javaProject.findPackageFragmentRoot(member.getFullPath()) == null) {
nonJavaResources.add(member);
}
} else if (!javaProject.isOnClasspath(member)) {
nonJavaResources.add(member);
} else {
IJavaElement element = JavaCore.create(member, javaProject);
if (element instanceof IPackageFragmentRoot && javaProject.equals(element.getJavaProject()) && ((IPackageFragmentRoot) element).getKind() != IPackageFragmentRoot.K_SOURCE) {
// don't skip libs and class folders on the classpath of their project
nonJavaResources.add(member);
}
}
}
return nonJavaResources.toArray();
}
use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class CompilerSetupService method getAllParameters.
/**
* Return java compiler preferences for current project by not empty path {@code projectpath}. If {@code projectpath} if empty then
* return java compile preferences for current workspace.
*
* @param projectPath project path
* @return java compiler preferences
*/
@GET
@Path("/all")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
public Map<String, String> getAllParameters(@QueryParam("projectpath") String projectPath) {
if (projectPath == null || projectPath.isEmpty()) {
//noinspection unchecked
CompilerOptions options = new CompilerOptions(new HashMap<>(JavaCore.getOptions()));
//noinspection unchecked
return options.getMap();
}
IJavaProject project = JAVA_MODEL.getJavaProject(projectPath);
//noinspection unchecked
Map<String, String> map = project.getOptions(true);
CompilerOptions options = new CompilerOptions(map);
//noinspection unchecked
return options.getMap();
}
use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class JavadocService method findJavadoc.
@GET
@Path("find")
@Produces("text/html")
public String findJavadoc(@QueryParam("fqn") String fqn, @QueryParam("projectpath") String projectPath, @QueryParam("offset") int offset) throws JavaModelException {
final IJavaProject project = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProject(projectPath);
final String urlPart = getUrlPart(projectPath);
return new JavadocFinder(urlPart).findJavadoc(project, fqn, offset);
}
use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class JavadocService method get.
@GET
@Path("get")
@Produces("text/html")
public String get(@QueryParam("handle") String handle, @QueryParam("projectpath") String projectPath) {
final IJavaProject project = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProject(projectPath);
final String urlPart = getUrlPart(projectPath);
return new JavadocFinder(urlPart).findJavadoc4Handle(project, handle);
}
use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class RefactoringService method createRenameRefactoring.
/**
* Create rename refactoring session.
*
* @param settings
* rename settings
* @return the rename refactoring session
* @throws CoreException
* when RenameSupport can't be created
* @throws RefactoringException
* when Java element was not found
*/
@POST
@Path("rename/create")
@Produces("application/json")
@Consumes("application/json")
public RenameRefactoringSession createRenameRefactoring(CreateRenameRefactoring settings) throws CoreException, RefactoringException {
IJavaProject javaProject = model.getJavaProject(settings.getProjectPath());
IJavaElement elementToRename;
ICompilationUnit cu = null;
switch(settings.getType()) {
case COMPILATION_UNIT:
elementToRename = javaProject.findType(settings.getPath()).getCompilationUnit();
break;
case PACKAGE:
elementToRename = javaProject.findPackageFragment(new org.eclipse.core.runtime.Path(settings.getPath()));
break;
case JAVA_ELEMENT:
cu = javaProject.findType(settings.getPath()).getCompilationUnit();
elementToRename = getSelectionElement(cu, settings.getOffset());
break;
default:
elementToRename = null;
}
if (elementToRename == null) {
throw new RefactoringException("Can't find java element to rename.");
}
return manager.createRenameRefactoring(elementToRename, cu, settings.getOffset(), settings.isRefactorLightweight());
}
Aggregations