1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-09-11 18:54:40 -07:00
parent 7d5892884b
commit 775c95143c
2 changed files with 19 additions and 26 deletions

View file

@ -9,7 +9,6 @@
* Anton Leherbauer (Wind River Systems) - initial API and implementation * Anton Leherbauer (Wind River Systems) - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.browser.opentype; package org.eclipse.cdt.internal.ui.browser.opentype;
import java.util.Arrays; import java.util.Arrays;
@ -62,12 +61,10 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
*/ */
public class ElementSelectionDialog extends TypeSelectionDialog { public class ElementSelectionDialog extends TypeSelectionDialog {
/** /**
* Job to update the element list in the background. * Job to update the element list in the background.
*/ */
private class UpdateElementsJob extends Job { private class UpdateElementsJob extends Job {
/** /**
* The last used prefix to query the index. <code>null</code> means * The last used prefix to query the index. <code>null</code> means
* the query result should be empty. * the query result should be empty.
@ -111,14 +108,12 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
} }
return Status.CANCEL_STATUS; return Status.CANCEL_STATUS;
} }
} }
/** /**
* A job listener for simple job status reporting. * A job listener for simple job status reporting.
*/ */
private final class UpdateJobListener extends JobChangeAdapter { private final class UpdateJobListener extends JobChangeAdapter {
boolean fDone; boolean fDone;
private IProgressMonitor fMonitor; private IProgressMonitor fMonitor;
@ -290,7 +285,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
return null; return null;
} }
HashSet<IndexTypeInfo> types = new HashSet<IndexTypeInfo>(); HashSet<IndexTypeInfo> types = new HashSet<IndexTypeInfo>();
if(prefix != null) { if (prefix != null) {
final IndexFilter filter= new IndexFilter() { final IndexFilter filter= new IndexFilter() {
@Override @Override
public boolean acceptBinding(IBinding binding) throws CoreException { public boolean acceptBinding(IBinding binding) throws CoreException {
@ -305,7 +300,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
index.acquireReadLock(); index.acquireReadLock();
try { try {
IIndexBinding[] bindings= index.findBindingsForPrefix(prefix, false, filter, monitor); IIndexBinding[] bindings= index.findBindingsForPrefix(prefix, false, filter, monitor);
for(int i=0; i<bindings.length; i++) { for (int i= 0; i < bindings.length; i++) {
if (i % 0x1000 == 0 && monitor.isCanceled()) { if (i % 0x1000 == 0 && monitor.isCanceled()) {
return null; return null;
} }
@ -315,7 +310,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
if (isVisibleType(ICElement.C_MACRO)) { if (isVisibleType(ICElement.C_MACRO)) {
IIndexMacro[] macros= index.findMacrosForPrefix(prefix, IndexFilter.ALL_DECLARED, monitor); IIndexMacro[] macros= index.findMacrosForPrefix(prefix, IndexFilter.ALL_DECLARED, monitor);
for(int i=0; i<macros.length; i++) { for (int i= 0; i < macros.length; i++) {
if (i % 0x1000 == 0 && monitor.isCanceled()) { if (i % 0x1000 == 0 && monitor.isCanceled()) {
return null; return null;
} }
@ -326,10 +321,10 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
} finally { } finally {
index.releaseReadLock(); index.releaseReadLock();
} }
} catch(CoreException ce) { } catch (CoreException e) {
CUIPlugin.log(ce); CUIPlugin.log(e);
} catch(InterruptedException ie) { } catch (InterruptedException e) {
CUIPlugin.log(ie); CUIPlugin.log(e);
} }
} }
return types.toArray(new ITypeInfo[types.size()]); return types.toArray(new ITypeInfo[types.size()]);
@ -377,7 +372,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
newPrefix= null; newPrefix= null;
needQuery= needQuery || currentPrefix != null; needQuery= needQuery || currentPrefix != null;
} }
if(needQuery || jobState == Job.WAITING || jobState == Job.SLEEPING) { if (needQuery || jobState == Job.WAITING || jobState == Job.SLEEPING) {
fUpdateJob.cancel(); fUpdateJob.cancel();
fUpdateJob.scheduleQuery(newPrefix); fUpdateJob.scheduleQuery(newPrefix);
} }
@ -393,9 +388,9 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
} }
int asterisk= userFilter.indexOf("*"); //$NON-NLS-1$ int asterisk= userFilter.indexOf("*"); //$NON-NLS-1$
int questionMark= userFilter.indexOf("?"); //$NON-NLS-1$ int questionMark= userFilter.indexOf("?"); //$NON-NLS-1$
int prefixEnd = asterisk < 0 ? questionMark int prefixEnd = asterisk < 0 ? questionMark :
: (questionMark < 0 ? asterisk : Math.min(asterisk, questionMark)); questionMark < 0 ? asterisk : Math.min(asterisk, questionMark);
return (prefixEnd==-1 ? userFilter : userFilter.substring(0, prefixEnd)).toCharArray(); return (prefixEnd == -1 ? userFilter : userFilter.substring(0, prefixEnd)).toCharArray();
} }
private boolean isEquivalentPrefix(char[] currentPrefix, char[] newPrefix) { private boolean isEquivalentPrefix(char[] currentPrefix, char[] newPrefix) {
@ -406,5 +401,4 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
} }
return new String(currentPrefix).equals(new String(newPrefix, 0, currentPrefix.length)); return new String(currentPrefix).equals(new String(newPrefix, 0, currentPrefix.length));
} }
} }

View file

@ -15,7 +15,6 @@ import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
public class NamespaceSelectionDialog extends TypeSelectionDialog { public class NamespaceSelectionDialog extends TypeSelectionDialog {
private static final String DIALOG_SETTINGS = NamespaceSelectionDialog.class.getName(); private static final String DIALOG_SETTINGS = NamespaceSelectionDialog.class.getName();
private static final int[] VISIBLE_TYPES = { ICElement.C_NAMESPACE }; private static final int[] VISIBLE_TYPES = { ICElement.C_NAMESPACE };