use of org.eclipse.jdt.core.IOpenable in project flux by eclipse.
the class StubUtility method getLineDelimiterUsed.
/**
* @param elem a Java element (doesn't have to exist)
* @return the existing or default line delimiter for the element
*/
public static String getLineDelimiterUsed(IJavaElement elem) {
IOpenable openable = elem.getOpenable();
if (openable instanceof ITypeRoot) {
try {
return openable.findRecommendedLineSeparator();
} catch (JavaModelException exception) {
// Use project setting
}
}
IJavaProject project = elem.getJavaProject();
return getProjectLineDelimiter(project.exists() ? project : null);
}
use of org.eclipse.jdt.core.IOpenable in project xtext-eclipse by eclipse.
the class DeltaConverter method doForeachCompilationUnitChildType.
private boolean doForeachCompilationUnitChildType(ICompilationUnit compilationUnit, boolean stopAtFirstDerivedType, Consumer<IType> consumer) throws JavaModelException {
IOpenable openableUnit = compilationUnit.getOpenable();
boolean wasOpen = openableUnit.isOpen();
try {
for (IType type : compilationUnit.getTypes()) {
if (stopAtFirstDerivedType && isDerived(type))
return true;
consumer.accept(type);
}
return false;
} finally {
boolean isOpen = openableUnit.isOpen();
if (!wasOpen && isOpen) {
// getTypes has opened the compilationUnit. Close to avoid JavaModelCache.childrenCache leak
openableUnit.close();
}
}
}
use of org.eclipse.jdt.core.IOpenable in project eclipse.jdt.ls by eclipse.
the class CallHierarchyHandler method toCallRanges.
private List<Range> toCallRanges(Collection<CallLocation> callLocations) {
List<Range> ranges = new ArrayList<>();
if (callLocations != null) {
for (CallLocation location : callLocations) {
IOpenable openable = getOpenable(location);
Range callRange = getRange(openable, location);
ranges.add(callRange);
}
}
return ranges;
}
Aggregations