use of org.eclipse.jdt.internal.ui.preferences.MembersOrderPreferenceCache in project che by eclipse.
the class ASTNodes method getInsertionIndex.
/**
* Computes the insertion index to be used to add the given member to the
* the list <code>container</code>.
* @param member the member to add
* @param container a list containing objects of type <code>BodyDeclaration</code>
* @return the insertion index to be used
*/
public static int getInsertionIndex(BodyDeclaration member, List<? extends BodyDeclaration> container) {
int containerSize = container.size();
MembersOrderPreferenceCache orderStore = JavaPlugin.getDefault().getMemberOrderPreferenceCache();
int orderIndex = getOrderPreference(member, orderStore);
int insertPos = containerSize;
int insertPosOrderIndex = -1;
for (int i = containerSize - 1; i >= 0; i--) {
int currOrderIndex = getOrderPreference(container.get(i), orderStore);
if (orderIndex == currOrderIndex) {
if (insertPosOrderIndex != orderIndex) {
// no perfect match yet
// after a same kind
insertPos = i + 1;
// perfect match
insertPosOrderIndex = orderIndex;
}
} else if (insertPosOrderIndex != orderIndex) {
// not yet a perfect match
if (currOrderIndex < orderIndex) {
// we are bigger
if (insertPosOrderIndex == -1) {
// after
insertPos = i + 1;
insertPosOrderIndex = currOrderIndex;
}
} else {
// before
insertPos = i;
insertPosOrderIndex = currOrderIndex;
}
}
}
return insertPos;
}
use of org.eclipse.jdt.internal.ui.preferences.MembersOrderPreferenceCache in project che by eclipse.
the class JavaPlugin method start.
@PostConstruct
public void start() {
// WorkingCopyOwner.setPrimaryBufferProvider(new WorkingCopyOwner() {
// @Override
// public IBuffer createBuffer(ICompilationUnit workingCopy) {
// ICompilationUnit original = workingCopy.getPrimary();
// IResource resource = original.getResource();
// if (resource instanceof IFile)
// return new DocumentAdapter(workingCopy, (IFile)resource);
// return DocumentAdapter.NULL;
// }
// });
new JavaCore();
fMembersOrderPreferenceCache = new MembersOrderPreferenceCache();
PreferenceConstants.initializeDefaultValues(PreferenceConstants.getPreferenceStore());
new JavaCorePreferenceInitializer().initializeDefaultPreferences();
new CheCodeFormatterInitializer().initializeDefaultPreferences();
}
Aggregations