use of org.eclipse.jdt.core.IMethod 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.jdt.core.IMethod in project che by eclipse.
the class RenameMethodRefactoringContribution method createRefactoring.
/**
* {@inheritDoc}
*/
@Override
public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws JavaModelException {
JavaRefactoringArguments arguments = new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));
String input = arguments.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT);
IMethod method = (IMethod) JavaRefactoringDescriptorUtil.handleToElement(arguments.getProject(), input);
if (method == null) {
status.addFatalError(Messages.format(RefactoringCoreMessages.RenameMethodRefactoringContribution_could_not_create, new Object[] { BasicElementLabels.getResourceName(arguments.getProject()), input }));
return null;
}
JavaRenameProcessor processor;
if (MethodChecks.isVirtual(method)) {
processor = new RenameVirtualMethodProcessor(method, arguments, status);
} else {
processor = new RenameNonVirtualMethodProcessor(method, arguments, status);
}
return new RenameRefactoring(processor);
}
use of org.eclipse.jdt.core.IMethod in project che by eclipse.
the class RippleMethodFinder2 method createHierarchyOfDeclarations.
private void createHierarchyOfDeclarations(IProgressMonitor pm, WorkingCopyOwner owner) throws JavaModelException {
IRegion region = JavaCore.newRegion();
for (Iterator<IMethod> iter = fDeclarations.iterator(); iter.hasNext(); ) {
IType declaringType = iter.next().getDeclaringType();
region.add(declaringType);
}
fHierarchy = JavaCore.newTypeHierarchy(region, owner, pm);
}
use of org.eclipse.jdt.core.IMethod in project che by eclipse.
the class JavadocTest method binaryMethodDoc.
@Test
public void binaryMethodDoc() throws JavaModelException {
IType type = project.findType("java.lang.Object");
assertThat(type).isNotNull();
IMethod method = type.getMethod("hashCode", null);
assertThat(method).isNotNull();
String htmlContent = JavadocContentAccess2.getHTMLContent(method, true, urlPart);
assertThat(htmlContent).isNotNull().isNotEmpty().contains("Returns a hash code value for the object.");
}
use of org.eclipse.jdt.core.IMethod in project che by eclipse.
the class StubCreator method appendMembers.
protected void appendMembers(final IType type, final IProgressMonitor monitor) throws JavaModelException {
try {
monitor.beginTask(RefactoringCoreMessages.StubCreationOperation_creating_type_stubs, 1);
final IJavaElement[] children = type.getChildren();
for (int index = 0; index < children.length; index++) {
final IMember child = (IMember) children[index];
final int flags = child.getFlags();
final boolean isPrivate = Flags.isPrivate(flags);
final boolean isDefault = !Flags.isPublic(flags) && !Flags.isProtected(flags) && !isPrivate;
final boolean stub = fStubInvisible || (!isPrivate && !isDefault);
if (child instanceof IType) {
if (stub)
appendTypeDeclaration((IType) child, new SubProgressMonitor(monitor, 1));
} else if (child instanceof IField) {
if (stub && !Flags.isEnum(flags) && !Flags.isSynthetic(flags))
appendFieldDeclaration((IField) child);
} else if (child instanceof IMethod) {
final IMethod method = (IMethod) child;
final String name = method.getElementName();
if (method.getDeclaringType().isEnum()) {
final int count = method.getNumberOfParameters();
if (//$NON-NLS-1$
count == 0 && "values".equals(name))
continue;
if (//$NON-NLS-1$ //$NON-NLS-2$
count == 1 && "valueOf".equals(name) && "Ljava.lang.String;".equals(method.getParameterTypes()[0]))
continue;
if (method.isConstructor())
continue;
}
//$NON-NLS-1$
boolean skip = !stub || name.equals("<clinit>");
if (method.isConstructor())
skip = false;
skip = skip || Flags.isSynthetic(flags) || Flags.isBridge(flags);
if (!skip)
appendMethodDeclaration(method);
}
//$NON-NLS-1$
fBuffer.append("\n");
}
} finally {
monitor.done();
}
}
Aggregations