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

Some new index constants

Patch for Dave - IndexerView refactoring
This commit is contained in:
Bogdan Gheorghe 2005-05-03 03:43:13 +00:00
parent dade6639b1
commit bdb7bbaf87
5 changed files with 96 additions and 143 deletions

View file

@ -52,7 +52,7 @@ public interface ICIndexStorageConstants {
};
final static char [][] encodingTypes = {
"".toCharArray(), //$NON-NLS-1$
"".toCharArray(), // not used //$NON-NLS-1$
"Decl/".toCharArray(), // DECLARATIONS //$NON-NLS-1$
"Ref/".toCharArray(), // REFERENCES //$NON-NLS-1$
"Defn/".toCharArray() // DEFINTIONS //$NON-NLS-1$
@ -71,4 +71,35 @@ public interface ICIndexStorageConstants {
'H', // FWD_STRUCT
'I' // FWD_UNION
};
final static char [][] accessSpecifiers = {
"".toCharArray(), // not used //$NON-NLS-1$
"private".toCharArray(), // private //$NON-NLS-1$
"protected".toCharArray(), // protected //$NON-NLS-1$
"public".toCharArray() // public //$NON-NLS-1$
};
final static char [][] cvQualifiers = {
"".toCharArray(), // not used //$NON-NLS-1$
"const".toCharArray(), // const //$NON-NLS-1$
"volatile".toCharArray(), // volatile //$NON-NLS-1$
};
final static char [][] storageClassSpecifiers = {
"".toCharArray(), // not used //$NON-NLS-1$
"auto".toCharArray(), // auto //$NON-NLS-1$
"register".toCharArray(), // register //$NON-NLS-1$
"static".toCharArray(), // static //$NON-NLS-1$
"extern".toCharArray(), // extern //$NON-NLS-1$
"mutable".toCharArray(), // mutable //$NON-NLS-1$
};
final static char [][] functionSpecifiers = {
"".toCharArray(), // not used //$NON-NLS-1$
"inline".toCharArray(), // inline //$NON-NLS-1$
"virtual".toCharArray(), // virtual //$NON-NLS-1$
"explicit".toCharArray(), // explicit //$NON-NLS-1$
};
}

View file

@ -9,11 +9,6 @@
* IBM Rational Software - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.ui.tests.IndexerView;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.cdt.internal.core.index.cindexstorage.Index;
@ -46,10 +41,10 @@ public class FilterIndexerViewDialog extends Dialog {
private static String getStringDescription(int meta, int kind, int ref) {
return Index.getDescriptionOf(meta, kind, ref);
}
private static final int DECL_BUTTON_ID = 4;
private static final int REF_BUTTON_ID = 3;
private static final int TYPE_BUTTON_ID = 2;
private static final int ALL_BUTTON_ID = 1;
private static final int DECL_BUTTON_ID = 3;
private static final int REF_BUTTON_ID = 2;
private static final int TYPE_BUTTON_ID = 1;
private static final int ALL_BUTTON_ID = 0;
private static final String GROUPED_SELECTIONS_LABEL = "Grouped Selections:"; //$NON-NLS-1$
private static final String ALL_BUTTON = "All"; //$NON-NLS-1$
private static final String TYPE_BUTTON = "type"; //$NON-NLS-1$
@ -65,8 +60,8 @@ public class FilterIndexerViewDialog extends Dialog {
Text filterText = null;
private String pageSize = BLANK_STRING; //$NON-NLS-1$
Text pageSizeText = null;
protected Collection fFilterMatcher = new HashSet();
protected Collection groupedButtonSelections = new HashSet();
protected boolean [] fFilterMatcher = new boolean [iAllTypes.length];
protected boolean[] groupedButtonSelections;
private String message = "Filter Indexer Results (. = any character, .* = any string):"; //$NON-NLS-1$
@ -138,8 +133,6 @@ public class FilterIndexerViewDialog extends Dialog {
{IIndex.INCLUDE, IIndex.ANY, IIndex.REFERENCE}
};
private Set fKnownTypes = new HashSet(iAllTypes.length);
// keep track of the buttons to programmatically change their state
protected Button[] buttons = new Button[iAllTypes.length];
protected Button allButton = null;
@ -153,7 +146,13 @@ public class FilterIndexerViewDialog extends Dialog {
this.root = root;
this.projName = projName;
setVisibleTypes(iAllTypes.length);
for (int i = 0; i < iAllTypes.length; i++)
fFilterMatcher[i] = false;
groupedButtonSelections = new boolean[DECL_BUTTON_ID + 1];
for (int j = ALL_BUTTON_ID; j <= DECL_BUTTON_ID; j++)
groupedButtonSelections[j] = false;
setDialogSettings(DIALOG_SETTINGS);
}
@ -222,19 +221,6 @@ public class FilterIndexerViewDialog extends Dialog {
return label;
}
/**
* Sets which CElement types are visible in the dialog.
*
* @param types
* Array of CElement types.
*/
public void setVisibleTypes(int len) {
fKnownTypes.clear();
for (int i = 0; i < len; ++i) {
fKnownTypes.add(new Integer(i));
}
}
/**
* Creates a type filter checkbox.
*/
@ -247,20 +233,20 @@ public class FilterIndexerViewDialog extends Dialog {
layout.marginHeight = 0;
composite.setLayout(layout);
final Integer fTypeObject = new Integer(type);
final int type1 = type;
Button checkbox = new Button(composite, SWT.CHECK);
checkbox.setFont(composite.getFont());
checkbox.setText(name);
checkbox.setImage(icon);
checkbox.setSelection(fFilterMatcher.contains(fTypeObject));
checkbox.setSelection(fFilterMatcher[type]);
checkbox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.widget instanceof Button) {
Button aCheckbox = (Button) e.widget;
if (aCheckbox.getSelection())
fFilterMatcher.add(fTypeObject);
fFilterMatcher[type1] = true;
else
fFilterMatcher.remove(fTypeObject);
fFilterMatcher[type1] = false;
}
}
});
@ -311,7 +297,7 @@ public class FilterIndexerViewDialog extends Dialog {
allButton.setFont(upperRow.getFont());
allButton.setText(ALL_BUTTON);
allButton.setImage(IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_GROUPED_ALL));
allButton.setSelection(groupedButtonSelections.contains(new Integer(ALL_BUTTON_ID)));
allButton.setSelection(groupedButtonSelections[ALL_BUTTON_ID]);
allButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.widget instanceof Button) {
@ -331,24 +317,14 @@ public class FilterIndexerViewDialog extends Dialog {
}
// select/deselect the type, decl, ref buttons
if (isChecked) {
typeButton.setSelection(true);
groupedButtonSelections.add(new Integer(TYPE_BUTTON_ID));
declButton.setSelection(true);
groupedButtonSelections.add(new Integer(DECL_BUTTON_ID));
refButton.setSelection(true);
groupedButtonSelections.add(new Integer(REF_BUTTON_ID));
groupedButtonSelections.add(new Integer(ALL_BUTTON_ID));
}
else {
typeButton.setSelection(false);
groupedButtonSelections.remove(new Integer(TYPE_BUTTON_ID));
declButton.setSelection(false);
groupedButtonSelections.remove(new Integer(DECL_BUTTON_ID));
refButton.setSelection(false);
groupedButtonSelections.remove(new Integer(REF_BUTTON_ID));
groupedButtonSelections.remove(new Integer(ALL_BUTTON_ID));
}
typeButton.setSelection(isChecked);
groupedButtonSelections[TYPE_BUTTON_ID] = isChecked;
declButton.setSelection(isChecked);
groupedButtonSelections[DECL_BUTTON_ID] = isChecked;
refButton.setSelection(isChecked);
groupedButtonSelections[REF_BUTTON_ID] = isChecked;
groupedButtonSelections[ALL_BUTTON_ID] = isChecked;
}
}
});
@ -361,7 +337,7 @@ public class FilterIndexerViewDialog extends Dialog {
typeButton.setFont(upperRow.getFont());
typeButton.setText(TYPE_BUTTON);
typeButton.setImage(IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_GROUPED_TYPE));
typeButton.setSelection(groupedButtonSelections.contains(new Integer(TYPE_BUTTON_ID)));
typeButton.setSelection(groupedButtonSelections[TYPE_BUTTON_ID]);
typeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.widget instanceof Button) {
@ -382,9 +358,7 @@ public class FilterIndexerViewDialog extends Dialog {
}
}
if (isChecked) groupedButtonSelections.add(new Integer(TYPE_BUTTON_ID));
else groupedButtonSelections.remove(new Integer(TYPE_BUTTON_ID));
groupedButtonSelections[TYPE_BUTTON_ID] = isChecked;
checkAllButton();
}
}
@ -398,7 +372,7 @@ public class FilterIndexerViewDialog extends Dialog {
declButton.setFont(upperRow.getFont());
declButton.setText(DECL_BUTTON);
declButton.setImage(IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_GROUPED_DECL));
declButton.setSelection(groupedButtonSelections.contains(new Integer(DECL_BUTTON_ID)));
declButton.setSelection(groupedButtonSelections[DECL_BUTTON_ID]);
declButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.widget instanceof Button) {
@ -419,9 +393,7 @@ public class FilterIndexerViewDialog extends Dialog {
}
}
if (isChecked) groupedButtonSelections.add(new Integer(DECL_BUTTON_ID));
else groupedButtonSelections.remove(new Integer(DECL_BUTTON_ID));
groupedButtonSelections[DECL_BUTTON_ID] = isChecked;
checkAllButton();
}
}
@ -435,7 +407,7 @@ public class FilterIndexerViewDialog extends Dialog {
refButton.setFont(upperRow.getFont());
refButton.setText(REF_BUTTON);
refButton.setImage(IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_GROUPED_REF));
refButton.setSelection(groupedButtonSelections.contains(new Integer(REF_BUTTON_ID)));
refButton.setSelection(groupedButtonSelections[REF_BUTTON_ID]);
refButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.widget instanceof Button) {
@ -456,9 +428,7 @@ public class FilterIndexerViewDialog extends Dialog {
}
}
if (isChecked) groupedButtonSelections.add(new Integer(REF_BUTTON_ID));
else groupedButtonSelections.remove(new Integer(REF_BUTTON_ID));
groupedButtonSelections[REF_BUTTON_ID] = isChecked;
checkAllButton();
}
}
@ -479,14 +449,8 @@ public class FilterIndexerViewDialog extends Dialog {
}
}
if (isChecked) {
allButton.setSelection(true);
groupedButtonSelections.add(new Integer(ALL_BUTTON_ID));
}
else {
allButton.setSelection(false);
groupedButtonSelections.remove(new Integer(ALL_BUTTON_ID));
}
allButton.setSelection(isChecked);
groupedButtonSelections[ALL_BUTTON_ID] = isChecked;
}
/**
@ -586,13 +550,13 @@ public class FilterIndexerViewDialog extends Dialog {
for(int i = 0; i < iAllTypes.length; i++) {
section.put(
getStringDescription(iAllTypes[i][0], iAllTypes[i][1], iAllTypes[i][2]),
fFilterMatcher.contains(new Integer(i)) );
fFilterMatcher[i] );
}
section.put(ALL_BUTTON, groupedButtonSelections.contains(new Integer(ALL_BUTTON_ID)));
section.put(TYPE_BUTTON, groupedButtonSelections.contains(new Integer(TYPE_BUTTON_ID)));
section.put(REF_BUTTON, groupedButtonSelections.contains(new Integer(REF_BUTTON_ID)));
section.put(DECL_BUTTON, groupedButtonSelections.contains(new Integer(DECL_BUTTON_ID)));
section.put(ALL_BUTTON, groupedButtonSelections[ALL_BUTTON_ID]);
section.put(TYPE_BUTTON, groupedButtonSelections[TYPE_BUTTON_ID]);
section.put(REF_BUTTON, groupedButtonSelections[REF_BUTTON_ID]);
section.put(DECL_BUTTON, groupedButtonSelections[DECL_BUTTON_ID]);
section.put(PAGE_SIZE, pageSize);
}
@ -659,30 +623,14 @@ public class FilterIndexerViewDialog extends Dialog {
}
for(int i = 0; i < iAllTypes.length; i++) {
if (section.getBoolean(getStringDescription(iAllTypes[i][0], iAllTypes[i][1], iAllTypes[i][2]))) {
Integer typeObject = new Integer(i);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
fFilterMatcher[i] = section.getBoolean(getStringDescription(iAllTypes[i][0], iAllTypes[i][1], iAllTypes[i][2]));
}
// get the grouped button selection status
if (section.getBoolean(ALL_BUTTON)) {
Integer typeObject = new Integer(ALL_BUTTON_ID);
groupedButtonSelections.add(typeObject);
}
if (section.getBoolean(TYPE_BUTTON)) {
Integer typeObject = new Integer(TYPE_BUTTON_ID);
groupedButtonSelections.add(typeObject);
}
if (section.getBoolean(REF_BUTTON)) {
Integer typeObject = new Integer(REF_BUTTON_ID);
groupedButtonSelections.add(typeObject);
}
if (section.getBoolean(DECL_BUTTON)) {
Integer typeObject = new Integer(DECL_BUTTON_ID);
groupedButtonSelections.add(typeObject);
}
groupedButtonSelections[ALL_BUTTON_ID] = section.getBoolean(ALL_BUTTON);
groupedButtonSelections[TYPE_BUTTON_ID] = section.getBoolean(TYPE_BUTTON);
groupedButtonSelections[REF_BUTTON_ID] = section.getBoolean(REF_BUTTON);
groupedButtonSelections[DECL_BUTTON_ID] = section.getBoolean(DECL_BUTTON);
}
public IndexerFilterManager createFilterManager() {

View file

@ -10,42 +10,35 @@
**********************************************************************/
package org.eclipse.cdt.ui.tests.IndexerView;
import java.util.Collection;
/**
* @author dsteffle
*/
public class IndexerFilterManager {
private static final String BLANK_STRING = ""; //$NON-NLS-1$
private static final String COMMA_SEPARATOR = ","; //$NON-NLS-1$
Collection filters = null;
boolean [] filters = null;
String nameFilter = null;
String [] nameFilters;
public IndexerFilterManager(Collection filters, String nameFilter) {
public IndexerFilterManager(boolean [] filters, String nameFilter) {
this.filters = filters;
this.nameFilter = nameFilter;
}
public boolean isFiltered(IndexerNodeLeaf leaf) {
String[] nameFilters = nameFilter.split(COMMA_SEPARATOR);
nameFilters = nameFilter.split(COMMA_SEPARATOR);
for(int i=0; i<nameFilters.length; i++) {
if (nameFilters != null) nameFilters[i] = nameFilters[i].trim();
}
if (!filters.contains(new Integer(leaf.getFiltersType()))) return false;
}
public boolean isFiltered(IndexerNodeLeaf leaf) {
if (!filters[leaf.getFiltersType()])
return false;
if (leaf.getName() != null && nameFilters != null && nameFilters.length > 0) {
boolean matchesPattern=false;
for(int l=0; l<nameFilters.length; l++) {
if (nameFilters[l].equals(BLANK_STRING) || leaf.getShortName().matches(nameFilters[l])) {
matchesPattern=true;
break;
}
}
if (!matchesPattern)
for(int l=0; l<nameFilters.length; l++)
if (nameFilters[l].equals(BLANK_STRING) || leaf.getShortName().matches(nameFilters[l]))
return true;
return false;
}
return true;
}
}

View file

@ -16,7 +16,6 @@ import java.io.IOException;
import org.eclipse.cdt.core.browser.PathUtil;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.internal.core.index.cindexstorage.ICIndexStorageConstants;
import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
import org.eclipse.cdt.internal.core.index.cindexstorage.io.BlocksIndexInput;
import org.eclipse.cdt.internal.core.index.cindexstorage.io.IndexInput;
@ -33,24 +32,15 @@ public class IndexerNodeLeaf implements IAdaptable {
private int filtersType=0;
IEntryResult result = null;
String name = null;
File indexFile = null;
char type = EMPTY_SPACE;
private IndexerNodeParent parent = null;
public IndexerNodeLeaf(IEntryResult result, File indexFile) {
this.result = result;
this.indexFile = indexFile;
setNameAndFiltersFlag();
}
private void setNameAndFiltersFlag() {
if (result == null) return;
filtersType = IndexerView.getKey(result.getMetaKind(), result.getKind(), result.getRefKind());
name = result.getName();
if (result != null)
this.filtersType = IndexerView.getKey(result.getMetaKind(), result.getKind(), result.getRefKind());
}
public IndexerNodeParent getParent() {
@ -191,28 +181,21 @@ public class IndexerNodeLeaf implements IAdaptable {
}
public String toString() {
if (!parent.isDisplayFullName() && name.indexOf(ICIndexStorageConstants.SEPARATOR) > 0)
if (!parent.isDisplayFullName())
return getShortName();
return name;
return getName();
}
public int getFiltersType() {
return filtersType;
}
public char getType() {
return type;
}
public String getName() {
return name;
return result.getName();
}
public String getShortName() {
if (name.indexOf(ICIndexStorageConstants.SEPARATOR) > 0)
return name.substring(0, name.indexOf(ICIndexStorageConstants.SEPARATOR));
return name;
return result.extractSimpleName();
}
}

View file

@ -11,8 +11,6 @@
package org.eclipse.cdt.ui.tests.IndexerView;
import java.io.File;
import java.util.Collection;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
@ -225,7 +223,7 @@ public class IndexerNodeParent extends IndexerNodeLeaf {
isForward = direction;
}
public void setFilterManager(Collection filters, String filterName) {
public void setFilterManager(boolean [] filters, String filterName) {
this.filterManager = new IndexerFilterManager(filters, filterName);
}