use of org.eclipse.jdt.core.IMember in project che by eclipse.
the class JavaElementLabelComposer method appendTypeParameterLabel.
/**
* Appends the styled label for a type parameter.
*
* @param typeParameter the element to render
* @param flags the rendering flags. Flags with names starting with 'T_' are considered.
*/
public void appendTypeParameterLabel(ITypeParameter typeParameter, long flags) {
try {
appendTypeParameterWithBounds(typeParameter, flags);
// post qualification
if (getFlag(flags, JavaElementLabels.TP_POST_QUALIFIED)) {
fBuffer.append(JavaElementLabels.CONCAT_STRING);
IMember declaringMember = typeParameter.getDeclaringMember();
appendElementLabel(declaringMember, JavaElementLabels.M_PARAMETER_TYPES | JavaElementLabels.M_FULLY_QUALIFIED | JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
}
} catch (JavaModelException e) {
// NotExistsException will not reach this point
JavaPlugin.log(e);
}
}
use of org.eclipse.jdt.core.IMember in project flux by eclipse.
the class JavaDocService method getJavadoc.
public JSONObject getJavadoc(String username, String requestorResourcePath, int offset, int length) {
try {
ICompilationUnit liveEditUnit = liveEditUnits.getLiveEditUnit(username, requestorResourcePath);
if (liveEditUnit != null) {
IJavaElement[] elements = liveEditUnit.codeSelect(offset, length);
if (elements != null && elements.length > 0) {
JSONObject result = new JSONObject();
IJavaElement element = elements[0];
String javadoc = null;
if (element instanceof IMember && !((IMember) element).isBinary()) {
javadoc = getJavadocFromSourceElement((IMember) element);
} else {
javadoc = element.getAttachedJavadoc(null);
}
result.put("javadoc", javadoc);
return result;
}
}
} catch (JavaModelException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
use of org.eclipse.jdt.core.IMember in project che by eclipse.
the class RenameTypeTest method checkMappers.
private void checkMappers(Refactoring refactoring, IType type, String newCUName, IJavaElement[] someClassMembers) {
RenameTypeProcessor rtp = (RenameTypeProcessor) ((RenameRefactoring) refactoring).getProcessor();
ICompilationUnit newUnit = (ICompilationUnit) rtp.getRefactoredJavaElement(type.getCompilationUnit());
TestCase.assertTrue(newUnit.exists());
TestCase.assertTrue(newUnit.getElementName().equals(newCUName));
IFile newFile = (IFile) rtp.getRefactoredResource(type.getResource());
TestCase.assertTrue(newFile.exists());
TestCase.assertTrue(newFile.getName().equals(newCUName));
if ((type.getParent().getElementType() == IJavaElement.COMPILATION_UNIT) && type.getCompilationUnit().getElementName().equals(type.getElementName() + ".java")) {
Assert.assertFalse(type.getCompilationUnit().exists());
Assert.assertFalse(type.getResource().exists());
}
IPackageFragment oldPackage = (IPackageFragment) type.getCompilationUnit().getParent();
IPackageFragment newPackage = (IPackageFragment) rtp.getRefactoredJavaElement(oldPackage);
Assert.assertEquals(oldPackage, newPackage);
for (int i = 0; i < someClassMembers.length; i++) {
IMember member = (IMember) someClassMembers[i];
IJavaElement refactoredMember = rtp.getRefactoredJavaElement(member);
if (member instanceof IMethod && member.getElementName().equals(type.getElementName()))
// constructor
continue;
TestCase.assertTrue(refactoredMember.exists());
Assert.assertEquals(member.getElementName(), refactoredMember.getElementName());
Assert.assertFalse(refactoredMember.equals(member));
}
}
Aggregations