use of org.eclipse.che.ide.ext.java.shared.dto.model.CompilationUnit in project che by eclipse.
the class FileStructurePresenter method show.
/**
* Shows the structure of the opened class.
*
* @param editorPartPresenter
* the active editor
*/
public void show(EditorPartPresenter editorPartPresenter) {
loader.show();
view.setTitle(editorPartPresenter.getEditorInput().getFile().getName());
if (!(editorPartPresenter instanceof TextEditor)) {
Log.error(getClass(), "Open Declaration support only TextEditor as editor");
return;
}
activeEditor = ((TextEditor) editorPartPresenter);
cursorOffset = activeEditor.getCursorOffset();
VirtualFile file = activeEditor.getEditorInput().getFile();
if (file instanceof Resource) {
final Optional<Project> project = ((Resource) file).getRelatedProject();
final Optional<Resource> srcFolder = ((Resource) file).getParentWithMarker(SourceFolderMarker.ID);
if (!srcFolder.isPresent()) {
return;
}
final String fqn = JavaUtil.resolveFQN((Container) srcFolder.get(), (Resource) file);
javaNavigationService.getCompilationUnit(project.get().getLocation(), fqn, showInheritedMembers).then(new Operation<CompilationUnit>() {
@Override
public void apply(CompilationUnit unit) throws OperationException {
view.setStructure(unit, showInheritedMembers);
showInheritedMembers = !showInheritedMembers;
loader.hide();
view.show();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
Log.error(FileStructurePresenter.class, arg.getMessage());
loader.hide();
}
});
}
}
use of org.eclipse.che.ide.ext.java.shared.dto.model.CompilationUnit in project che by eclipse.
the class PackageFragmentNode method getChildrenImpl.
@Override
protected Promise<List<Node>> getChildrenImpl() {
return createFromAsyncRequest(callback -> {
final List<Node> children = new ArrayList<>();
if (packageFragment.getKind() == PackageFragmentRoot.K_SOURCE) {
for (CompilationUnit compilationUnit : packageFragment.getCompilationUnits()) {
final List<Type> types = compilationUnit.getTypes();
final List<Node> nodes = types.stream().filter(Type::isPrimary).map(type -> nodeFactory.create(type, compilationUnit, null, matches)).collect(Collectors.toList());
children.addAll(nodes);
}
} else {
children.addAll(packageFragment.getClassFiles().stream().map(classFile -> nodeFactory.create(classFile.getType(), null, classFile, matches)).collect(Collectors.toList()));
}
callback.onSuccess(children);
});
}
Aggregations