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

Patch for David Daoust.

Cleaning up the Indexer View.
This commit is contained in:
John Camelon 2005-05-31 19:23:26 +00:00
parent b208d1adfd
commit e5610988d7

View file

@ -10,7 +10,6 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.ui.tests.IndexerView; package org.eclipse.cdt.ui.tests.IndexerView;
import org.eclipse.cdt.core.browser.PathUtil;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.index.IEntryResult; import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.internal.core.index.IIndex; import org.eclipse.cdt.internal.core.index.IIndex;
@ -60,14 +59,12 @@ public class IndexerNodeLeaf implements IAdaptable {
private class IndexerPropertySource implements IPropertySource { private class IndexerPropertySource implements IPropertySource {
private static final String IENTRYRESULT = "IEntryResult"; //$NON-NLS-1$ private static final String IENTRYRESULT = "IEntryResult"; //$NON-NLS-1$
private static final String NAME = "Name"; //$NON-NLS-1$
private static final String IENTRYRESULT_GETWORD__ = "IEntryResult#getWord()"; //$NON-NLS-1$ private static final String IENTRYRESULT_GETWORD__ = "IEntryResult#getWord()"; //$NON-NLS-1$
private static final String REFERENCES = "References"; //$NON-NLS-1$ private static final String REFS = "References"; //$NON-NLS-1$
private static final String REFERENCE_NUMBER_ = "reference# "; //$NON-NLS-1$
private static final String OFFSETS = "Offsets"; //$NON-NLS-1$
private static final String OFFSETS_NUMBER = "offsets for #"; //$NON-NLS-1$
private static final String OFFSETS_LINE = "Line "; //$NON-NLS-1$ private static final String OFFSETS_LINE = "Line "; //$NON-NLS-1$
private static final String OFFSETS_OFFSET = "Offset "; //$NON-NLS-1$ private static final String OFFSETS_OFFSET = "Offset "; //$NON-NLS-1$
private static final int DEFAULT_DESCRIPTOR_SIZE = 4; private static final int DEFAULT_DESCRIPTOR_SIZE = 64;
IEntryResult entryResult = null; IEntryResult entryResult = null;
public IndexerPropertySource(IEntryResult result) { public IndexerPropertySource(IEntryResult result) {
@ -83,62 +80,51 @@ public class IndexerNodeLeaf implements IAdaptable {
TextPropertyDescriptor text = null; TextPropertyDescriptor text = null;
// get the reference descriptors // Add reference block
int[] references = entryResult.getFileReferences(); int[] references = entryResult.getFileReferences();
if (references != null) { int[][]offsets = entryResult.getOffsets();
for (int j = 0; j < references.length; ++j) { int[][]offsetLengths = entryResult.getOffsetLengths();
String file = fileMap[references[j]]; if (offsets != null){
if (file != null) { for (int j=0; j<offsets.length; j++){
String id = REFERENCE_NUMBER_ + String.valueOf(j); String id = fileMap[references[j]];
text = new TextPropertyDescriptor(new TextDescriptorId(id, PathUtil.getWorkspaceRelativePath(file).toOSString()), id); String offsetString = ""; //$NON-NLS-1$
text.setCategory(REFERENCES); for (int k=0; k<offsets[j].length; k++){
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text); String rawOffset = String.valueOf(offsets[j][k]) ;
String offsetLocation = String.valueOf(offsetLengths[j][k]);
switch(rawOffset.charAt(0)){
case '1':
offsetString += OFFSETS_LINE + rawOffset.substring(1) + " "; //$NON-NLS-1$
break;
case '2':
offsetString += OFFSETS_OFFSET + rawOffset.substring(1) + ":" + offsetLocation + " "; //$NON-NLS-1$ //$NON-NLS-2$
break;
} }
} }
text = new TextPropertyDescriptor(new TextDescriptorId(id, offsetString), id);
text.setCategory(REFS);
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
} }
}
//offsets
int[][]offsets = entryResult.getOffsets(); // add Name Block
int[][]offsetLengths = entryResult.getOffsetLengths(); text = new TextPropertyDescriptor(new TextDescriptorId(NAME, entryResult.getName()), NAME);
if (offsets != null){ text.setCategory(IENTRYRESULT);
for (int j=0; j<offsets.length; j++){ descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
String id = OFFSETS_NUMBER + j;
String offsetString = ""; //$NON-NLS-1$ // add IEntryResult
for (int k=0; k<offsets[j].length; k++){ text = new TextPropertyDescriptor(new TextDescriptorId("MetaKind", entryResult.getStringMetaKind()), "MetaKind");
String rawOffset = String.valueOf(offsets[j][k]) ; text.setCategory(IENTRYRESULT);
String offsetLocation = String.valueOf(offsetLengths[j][k]); descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
switch(rawOffset.charAt(0)){
case '1': if (entryResult.getMetaKind() == IIndex.TYPE) {
offsetString += OFFSETS_LINE + rawOffset.substring(1) + " "; //$NON-NLS-1$ text = new TextPropertyDescriptor(new TextDescriptorId("TypeKind", entryResult.getStringKind()), "TypeKind");
break; text.setCategory(IENTRYRESULT);
case '2': descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
offsetString += OFFSETS_OFFSET + rawOffset.substring(1) + ":" + offsetLocation + " "; //$NON-NLS-1$ //$NON-NLS-2$ }
break; text = new TextPropertyDescriptor(new TextDescriptorId("ReferenceKind", entryResult.getStringRefKind()), "ReferenceKind");
} text.setCategory(IENTRYRESULT);
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
}
text = new TextPropertyDescriptor(new TextDescriptorId(id, offsetString), id);
text.setCategory(OFFSETS);
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
}
}
// add a word descriptor
text = new TextPropertyDescriptor(new TextDescriptorId("MetaKind", entryResult.getStringMetaKind()), "MetaKind");
text.setCategory(IENTRYRESULT);
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
// add a word descriptor
if (entryResult.getMetaKind() == IIndex.TYPE) {
text = new TextPropertyDescriptor(new TextDescriptorId("TypeKind", entryResult.getStringKind()), "TypeKind");
text.setCategory(IENTRYRESULT);
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
}
// add a word descriptor
text = new TextPropertyDescriptor(new TextDescriptorId("ReferenceKind", entryResult.getStringRefKind()), "ReferenceKind");
text.setCategory(IENTRYRESULT);
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
return (IPropertyDescriptor[])ArrayUtil.trim(IPropertyDescriptor.class, descriptors); return (IPropertyDescriptor[])ArrayUtil.trim(IPropertyDescriptor.class, descriptors);
} }