use of org.eclipse.che.ide.ext.java.shared.dto.model.MethodParameters in project che by eclipse.
the class ParametersHints method findHints.
private void findHints(IJavaElement method, IJavaElement parent, List<MethodParameters> result) throws JavaModelException {
String methodName = method.getElementName();
for (IMethod iMethod : ((IType) parent).getMethods()) {
int methodFlag = iMethod.getFlags();
if (Flags.isPrivate(methodFlag) || !methodName.equals(iMethod.getElementName())) {
continue;
}
MethodParameters methodParameters = DtoFactory.newDto(MethodParameters.class);
String parameters = getMethodParametersAsString(iMethod);
methodParameters.setMethodName(methodName);
methodParameters.setParameters(parameters);
if (!result.contains(methodParameters)) {
result.add(methodParameters);
}
}
}
use of org.eclipse.che.ide.ext.java.shared.dto.model.MethodParameters in project che by eclipse.
the class ParametersHintsPresenter method show.
/**
* The method gets method parameters via {@link JavaNavigationService} and then call special method on view to display them.
*
* @param activeEditor
* active editor which contains method or constructor for which parameters will be displayed
*/
public void show(final TextEditor activeEditor) {
final int offset = activeEditor.getCursorOffset();
if (!isCursorInRightPlace(activeEditor, offset)) {
return;
}
VirtualFile file = activeEditor.getEditorInput().getFile();
if (file instanceof Resource) {
final Optional<Project> project = ((Resource) file).getRelatedProject();
final int lineStartOffset = getLineStartOffset(activeEditor, offset);
navigationService.getMethodParametersHints(project.get().getLocation(), JavaUtil.resolveFQN(file), offset, lineStartOffset).then(new Operation<List<MethodParameters>>() {
@Override
public void apply(List<MethodParameters> parameters) throws OperationException {
if (parameters.isEmpty()) {
return;
}
PositionConverter.PixelCoordinates coordinates = activeEditor.getPositionConverter().offsetToPixel(offset);
view.show(parameters, coordinates.getX(), coordinates.getY());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
Log.error(getClass(), error.getMessage());
}
});
}
}
use of org.eclipse.che.ide.ext.java.shared.dto.model.MethodParameters in project che by eclipse.
the class ParametersHintsViewImpl method show.
@Override
public void show(List<MethodParameters> parametersList, int x, int y) {
parametersPanel.clear();
for (MethodParameters parameters : parametersList) {
FlowPanel widget = panelsProvider.get();
String parametersLine = parameters.getParameters();
if (parametersLine.isEmpty()) {
parametersLine = "<no parameters>";
}
String result = parametersLine.replace("<", "<").replace(">", ">");
Element element = widget.getElement();
element.setInnerHTML(result);
element.getStyle().setColor("yellow");
parametersPanel.add(widget);
}
setPopupPosition(x, y);
show();
}
use of org.eclipse.che.ide.ext.java.shared.dto.model.MethodParameters in project che by eclipse.
the class ParametersHints method findHints.
public List<MethodParameters> findHints(IJavaProject project, String fqn, int offset, int lineStartOffset) throws JavaModelException {
IType type = project.findType(fqn);
if (type.isBinary()) {
return Collections.emptyList();
}
IJavaElement element = getSelectedElement(type, offset, lineStartOffset);
if (element == null) {
return Collections.emptyList();
}
IJavaElement parent = element.getParent();
if (!(parent instanceof IType) || !(element.getElementType() == METHOD)) {
return Collections.emptyList();
}
List<MethodParameters> result = new ArrayList<>();
findHintsRecursive(element, parent, result);
return result;
}
Aggregations