use of org.eclipse.jdt.core.IJavaElement in project che by eclipse.
the class ReorgPolicyFactory method processReorgExecutionRecord.
private static void processReorgExecutionRecord(ReorgExecutionLog log, JavaRefactoringArguments arguments, String token) {
final StringTokenizer tokenizer = new StringTokenizer(token, DELIMITER_ELEMENT, false);
String value = null;
if (tokenizer.hasMoreTokens()) {
value = tokenizer.nextToken();
Object element = JavaRefactoringDescriptorUtil.handleToElement(arguments.getProject(), value);
if (element == null)
element = JavaRefactoringDescriptorUtil.handleToResource(arguments.getProject(), value);
if (tokenizer.hasMoreTokens()) {
final boolean processed = Boolean.valueOf(tokenizer.nextToken()).booleanValue();
if (processed) {
log.markAsProcessed(element);
if (element instanceof IJavaElement)
log.markAsProcessed(JavaElementResourceMapping.create((IJavaElement) element));
}
if (tokenizer.hasMoreTokens()) {
final boolean renamed = Boolean.valueOf(tokenizer.nextToken()).booleanValue();
if (renamed && tokenizer.hasMoreTokens()) {
final String name = tokenizer.nextToken();
log.setNewName(element, name);
if (element instanceof IJavaElement)
log.setNewName(JavaElementResourceMapping.create((IJavaElement) element), name);
}
}
}
}
}
use of org.eclipse.jdt.core.IJavaElement in project che by eclipse.
the class ReorgUtils method isParentInWorkspaceOrOnDisk.
public static boolean isParentInWorkspaceOrOnDisk(IPackageFragmentRoot root, IJavaProject javaProject) {
if (root == null)
return false;
IJavaElement rootParent = root.getParent();
if (rootParent == null)
return false;
if (rootParent.equals(root))
return true;
IResource packageResource = ResourceUtil.getResource(root);
IResource packageRootResource = ResourceUtil.getResource(javaProject);
return isParentInWorkspaceOrOnDisk(packageResource, packageRootResource);
}
use of org.eclipse.jdt.core.IJavaElement in project che by eclipse.
the class ReorgUtils method containsElementOrParent.
public static boolean containsElementOrParent(Set<IAdaptable> elements, IResource element) {
IResource curr = element;
do {
if (elements.contains(curr))
return true;
IJavaElement jElement = JavaCore.create(curr);
if (jElement != null && jElement.exists()) {
return containsElementOrParent(elements, jElement);
}
curr = curr.getParent();
} while (curr != null);
return false;
}
use of org.eclipse.jdt.core.IJavaElement in project che by eclipse.
the class ReorgUtils method groupByCompilationUnit.
/* List<IJavaElement> javaElements
* return ICompilationUnit -> List<IJavaElement>
*/
public static Map<ICompilationUnit, List<IJavaElement>> groupByCompilationUnit(List<IJavaElement> javaElements) {
Map<ICompilationUnit, List<IJavaElement>> result = new HashMap<ICompilationUnit, List<IJavaElement>>();
for (Iterator<IJavaElement> iter = javaElements.iterator(); iter.hasNext(); ) {
IJavaElement element = iter.next();
ICompilationUnit cu = ReorgUtils.getCompilationUnit(element);
if (cu != null) {
if (!result.containsKey(cu))
result.put(cu, new ArrayList<IJavaElement>(1));
result.get(cu).add(element);
}
}
return result;
}
use of org.eclipse.jdt.core.IJavaElement in project che by eclipse.
the class ReorgUtils method isArchiveOrExternalMember.
public static boolean isArchiveOrExternalMember(IJavaElement[] elements) {
for (int i = 0; i < elements.length; i++) {
IJavaElement element = elements[i];
IPackageFragmentRoot root = (IPackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
if (root != null && (root.isArchive() || root.isExternal()))
return true;
}
return false;
}
Aggregations