Search in sources :

Example 1 with MembersOrderPreferenceCache

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;
}
Also used : MembersOrderPreferenceCache(org.eclipse.jdt.internal.ui.preferences.MembersOrderPreferenceCache)

Example 2 with MembersOrderPreferenceCache

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();
}
Also used : MembersOrderPreferenceCache(org.eclipse.jdt.internal.ui.preferences.MembersOrderPreferenceCache) JavaCorePreferenceInitializer(org.eclipse.jdt.internal.core.JavaCorePreferenceInitializer) JavaCore(org.eclipse.jdt.core.JavaCore) CheCodeFormatterInitializer(org.eclipse.jdt.internal.corext.format.CheCodeFormatterInitializer) PostConstruct(javax.annotation.PostConstruct)

Aggregations

MembersOrderPreferenceCache (org.eclipse.jdt.internal.ui.preferences.MembersOrderPreferenceCache)2 PostConstruct (javax.annotation.PostConstruct)1 JavaCore (org.eclipse.jdt.core.JavaCore)1 JavaCorePreferenceInitializer (org.eclipse.jdt.internal.core.JavaCorePreferenceInitializer)1 CheCodeFormatterInitializer (org.eclipse.jdt.internal.corext.format.CheCodeFormatterInitializer)1