mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
Refactored CIndexStorage to persist modifier bit fields and function signatures
Updated method search pattern to make use of the newly stored info
This commit is contained in:
parent
121b48c3d1
commit
98ac994722
15 changed files with 353 additions and 82 deletions
|
@ -52,34 +52,44 @@ public class IndexerOffsetTests extends TestCase {
|
|||
word.addOffset(512,3,2,IIndex.OFFSET);
|
||||
word.addOffset(512,3,2,IIndex.OFFSET);
|
||||
word.addOffset(512,3,2,IIndex.OFFSET);
|
||||
word.addModifiers(18,2);
|
||||
word.addRef(5);
|
||||
word.addOffset(43,6,5,IIndex.OFFSET);
|
||||
word.addOffset(2,3,5,IIndex.LINE);
|
||||
word.addOffset(89,8,5,IIndex.OFFSET);
|
||||
word.addOffset(63,2,5,IIndex.LINE);
|
||||
word.addOffset(124,7,5,IIndex.OFFSET);
|
||||
word.addModifiers(4,5);
|
||||
word.addRef(9);
|
||||
word.addOffset(433,5,9,IIndex.OFFSET);
|
||||
word.addOffset(234,3,9,IIndex.OFFSET);
|
||||
word.addModifiers(1,9);
|
||||
word.addRef(11);
|
||||
word.addOffset(4233,2,11,IIndex.OFFSET);
|
||||
word.addOffset(2314,7,11,IIndex.OFFSET);
|
||||
word.addModifiers(8,11);
|
||||
word.addRef(17);
|
||||
word.addOffset(2,7,17,IIndex.OFFSET);
|
||||
word.addOffset(52,8,17,IIndex.OFFSET);
|
||||
word.addModifiers(32,17);
|
||||
|
||||
int[] test =word.getOffsets(1);
|
||||
|
||||
int[] modifierTest=word.getModifiers();
|
||||
|
||||
WordEntry word2 = new WordEntry("typeDecl/C/Test".toCharArray());
|
||||
word2.addRef(4);
|
||||
word2.addOffset(13,4,4, IIndex.OFFSET);
|
||||
word2.addOffset(17,3,4, IIndex.OFFSET);
|
||||
word2.addOffset(20,6,4,IIndex.OFFSET);
|
||||
word2.addModifiers(64,4);
|
||||
word2.addRef(7);
|
||||
word2.addOffset(21,2,7, IIndex.OFFSET);
|
||||
word2.addOffset(24,3,7, IIndex.OFFSET);
|
||||
word2.addOffset(28,7,7,IIndex.OFFSET);
|
||||
word2.addModifiers(128,7);
|
||||
|
||||
word.addWordInfo(word2.getRefs(), word2.getOffsets(), word2.getOffsetLengths(), word2.getOffsetCount());
|
||||
word.addWordInfo(word2.getRefs(), word2.getOffsets(), word2.getOffsetLengths(), word2.getOffsetCount(),word2.getModifiers());
|
||||
|
||||
word.mapRefs(new int[]{-1, 1, 17, 3, 4, 11, 6, 7, 8, 24, 10, 5, 12, 13, 14, 15, 16, 2});
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.core.index;
|
|||
|
||||
import org.eclipse.cdt.internal.core.index.IIndex;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexer;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IndexDelta;
|
||||
import org.eclipse.cdt.internal.core.search.processing.IIndexJob;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
|
@ -104,7 +105,13 @@ public interface ICDTIndexer extends IIndexer {
|
|||
*/
|
||||
public void notifyIndexerChange(IProject project);
|
||||
|
||||
|
||||
/**
|
||||
* Called by the index manager when a project has switched indexers to this
|
||||
* type of indexer - can be used by the indexer to schedule initial jobs
|
||||
* @param project - the project that has changed indexers
|
||||
*/
|
||||
public void notifyListeners(IndexDelta indexDelta);
|
||||
|
||||
/**
|
||||
* Returns if this indexer is enabled
|
||||
* @param project
|
||||
|
|
|
@ -39,5 +39,5 @@ public class FunctionEntry extends NamedEntry implements IFunctionEntry {
|
|||
public void serialize(IIndexerOutput output) {
|
||||
output.addIndexEntry(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,5 @@ package org.eclipse.cdt.internal.core.index;
|
|||
public interface IFunctionEntry extends INamedEntry {
|
||||
|
||||
public char[][] getSignature();
|
||||
|
||||
public char[] getReturnType();
|
||||
|
||||
public char[] getReturnType();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
import org.eclipse.cdt.internal.core.index.cindexstorage.IndexEntryNotSupportedException;
|
||||
import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +20,11 @@ import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
|
|||
|
||||
public interface IIndexerOutput {
|
||||
|
||||
public void addIndexEntry(IIndexEntry indexEntry);
|
||||
public void addIndexEntry(IIndexEntry indexEntry) throws IndexEntryNotSupportedException;
|
||||
|
||||
public void addIndexEntry(ITypeEntry indexEntry);
|
||||
public void addIndexEntry(INamedEntry indexEntry);
|
||||
public void addIndexEntry(IFunctionEntry indexEntry);
|
||||
|
||||
public IndexedFileEntry getIndexedFile(String path);
|
||||
public IndexedFileEntry addIndexedFile(String path);
|
||||
|
|
|
@ -17,7 +17,7 @@ public interface ICIndexStorageConstants {
|
|||
* The signature of the index file.
|
||||
*/
|
||||
|
||||
public static final String SIGNATURE= "INDEX FILE 0.016"; //$NON-NLS-1$
|
||||
public static final String SIGNATURE= "INDEX FILE 0.017"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The size of a block for a <code>Block</code>.
|
||||
|
@ -86,7 +86,7 @@ public interface ICIndexStorageConstants {
|
|||
"FWD Union" //$NON-NLS-1$
|
||||
};
|
||||
|
||||
final static String[] allSpecifiers = {
|
||||
final static String[] allSpecifiers = {"", //not used //$NON-NLS-1$
|
||||
"private", // private //$NON-NLS-1$
|
||||
"public", // public //$NON-NLS-1$
|
||||
"protected", // protected //$NON-NLS-1$
|
||||
|
|
|
@ -103,28 +103,30 @@ public class InMemoryIndex {
|
|||
* If the word does not exist, it adds it in the index.
|
||||
* @param indexFlags
|
||||
*/
|
||||
protected void addRef(char[] word, int fileNum, int offset, int offsetLength, int offsetType) {
|
||||
protected void addRef(char[] word, int fileNum, int offset, int offsetLength, int offsetType, int modifiers) {
|
||||
WordEntry entry= this.words.get(word);
|
||||
|
||||
if (entry == null) {
|
||||
entry= new WordEntry(word);
|
||||
entry.addRef(fileNum);
|
||||
entry.addOffset(offset, offsetLength, fileNum, offsetType);
|
||||
entry.addModifiers(modifiers, fileNum);
|
||||
this.words.add(entry);
|
||||
this.sortedWordEntries= null;
|
||||
this.footprint += entry.footprint();
|
||||
} else {
|
||||
this.footprint += entry.addRef(fileNum);
|
||||
entry.addOffset(offset, offsetLength, fileNum, offsetType);
|
||||
entry.addModifiers(modifiers, fileNum);
|
||||
}
|
||||
}
|
||||
|
||||
public void addRef(IndexedFileEntry indexedFile, char[] word, int offset, int offsetLength, int offsetType) {
|
||||
addRef(word, indexedFile.getFileID(), offset, offsetLength, offsetType);
|
||||
public void addRef(IndexedFileEntry indexedFile, char[] word, int offset, int offsetLength, int offsetType, int modifiers) {
|
||||
addRef(word, indexedFile.getFileID(), offset, offsetLength, offsetType, modifiers);
|
||||
}
|
||||
|
||||
public void addRef(IndexedFileEntry indexedFile, String word, int offset, int offsetLength, int offsetType) {
|
||||
addRef(word.toCharArray(), indexedFile.getFileID(), offset, offsetLength, offsetType);
|
||||
public void addRef(IndexedFileEntry indexedFile, String word, int offset, int offsetLength, int offsetType, int modifiers) {
|
||||
addRef(word.toCharArray(), indexedFile.getFileID(), offset, offsetLength, offsetType, modifiers);
|
||||
}
|
||||
|
||||
public void addRelatives(int fileNumber, String inclusion, String parent) {
|
||||
|
|
|
@ -32,10 +32,8 @@ import org.eclipse.cdt.internal.core.index.cindexstorage.io.IndexInput;
|
|||
import org.eclipse.cdt.internal.core.index.cindexstorage.io.IndexOutput;
|
||||
import org.eclipse.cdt.internal.core.index.cindexstorage.io.MergeFactory;
|
||||
import org.eclipse.cdt.internal.core.index.cindexstorage.io.SimpleIndexInput;
|
||||
import org.eclipse.cdt.internal.core.index.ctagsindexer.CTagsIndexer;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IndexDelta;
|
||||
import org.eclipse.cdt.internal.core.index.impl.Int;
|
||||
import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
|
@ -313,13 +311,8 @@ public class Index implements IIndex, ICIndexStorageConstants, ICSearchConstants
|
|||
CCorePlugin.getDefault().cdtLog.flushLog();
|
||||
|
||||
//Send out notification to listeners;
|
||||
if (indexer instanceof SourceIndexer){
|
||||
IndexDelta indexDelta = new IndexDelta(null,null,IIndexDelta.MERGE_DELTA);
|
||||
((SourceIndexer) indexer).notifyListeners(indexDelta);
|
||||
} else if (indexer instanceof CTagsIndexer) {
|
||||
IndexDelta indexDelta = new IndexDelta(null,null,IIndexDelta.MERGE_DELTA);
|
||||
((CTagsIndexer) indexer).notifyListeners(indexDelta);
|
||||
}
|
||||
IndexDelta indexDelta = new IndexDelta(null,null,IIndexDelta.MERGE_DELTA);
|
||||
indexer.notifyListeners(indexDelta);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package org.eclipse.cdt.internal.core.index.cindexstorage;
|
||||
|
||||
public class IndexEntryNotSupportedException extends Exception {
|
||||
|
||||
public IndexEntryNotSupportedException(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 3257002138168211513L;
|
||||
|
||||
}
|
|
@ -32,7 +32,7 @@ public class IndexerOutput implements ICIndexStorageConstants, IIndexerOutput {
|
|||
this.index= index;
|
||||
}
|
||||
|
||||
protected void addRef(int indexedFileNumber, char [][] name, char suffix, int type, int offset, int offsetLength, int offsetType) {
|
||||
protected void addRef(int indexedFileNumber, char [][] name, char suffix, int type, int offset, int offsetLength, int offsetType, int modifiers) {
|
||||
if (indexedFileNumber == 0) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
@ -40,12 +40,15 @@ public class IndexerOutput implements ICIndexStorageConstants, IIndexerOutput {
|
|||
if (offsetLength <= 0)
|
||||
offsetLength = 1;
|
||||
|
||||
if (modifiers <=0)
|
||||
modifiers = 1;
|
||||
|
||||
index.addRef(
|
||||
encodeTypeEntry(name, suffix, type),
|
||||
indexedFileNumber, offset, offsetLength, offsetType);
|
||||
indexedFileNumber, offset, offsetLength, offsetType, modifiers);
|
||||
}
|
||||
|
||||
protected void addRef(int indexedFileNumber, char[][] name, int meta_kind, int ref, int offset, int offsetLength, int offsetType) {
|
||||
protected void addRef(int indexedFileNumber, char[][] name, int meta_kind, int ref, int offset, int offsetLength, int offsetType, int modifiers) {
|
||||
if (indexedFileNumber == 0) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
@ -53,9 +56,12 @@ public class IndexerOutput implements ICIndexStorageConstants, IIndexerOutput {
|
|||
if (offsetLength <= 0)
|
||||
offsetLength = 1;
|
||||
|
||||
if (modifiers <=0)
|
||||
modifiers = 1;
|
||||
|
||||
index.addRef(
|
||||
encodeEntry(name, meta_kind, ref),
|
||||
indexedFileNumber, offset, offsetLength, offsetType);
|
||||
indexedFileNumber, offset, offsetLength, offsetType, modifiers);
|
||||
|
||||
}
|
||||
|
||||
|
@ -90,7 +96,7 @@ public class IndexerOutput implements ICIndexStorageConstants, IIndexerOutput {
|
|||
}
|
||||
|
||||
public void addIncludeRef(int indexedFileNumber, char[][] name, int offset, int offsetLength, int offsetType) {
|
||||
addRef(indexedFileNumber, name, IIndex.INCLUDE, IIndex.REFERENCE, offset,offsetLength, offsetType);
|
||||
addRef(indexedFileNumber, name, IIndex.INCLUDE, IIndex.REFERENCE, offset,offsetLength, offsetType,1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,59 +189,150 @@ public class IndexerOutput implements ICIndexStorageConstants, IIndexerOutput {
|
|||
return result;
|
||||
}
|
||||
|
||||
public void addIndexEntry(IIndexEntry indexEntry) {
|
||||
public void addIndexEntry(IIndexEntry indexEntry) throws IndexEntryNotSupportedException {
|
||||
|
||||
if (indexEntry == null)
|
||||
return;
|
||||
|
||||
if (indexEntry instanceof ITypeEntry){
|
||||
ITypeEntry typeEntry = (ITypeEntry) indexEntry;
|
||||
int indexedFileNumber=typeEntry.getFileNumber();
|
||||
int meta_type = typeEntry.getMetaKind();
|
||||
int type_kind = typeEntry.getTypeKind();
|
||||
int entryType = typeEntry.getEntryType();
|
||||
int modifiers = typeEntry.getModifiers();
|
||||
|
||||
char[][]name=typeEntry.getFullName();
|
||||
|
||||
int nameOffset=typeEntry.getNameOffset();
|
||||
int nameOffsetLength=typeEntry.getNameLength();
|
||||
int nameOffsetType=typeEntry.getNameOffsetType();
|
||||
|
||||
int elementOffset=typeEntry.getElementOffset();
|
||||
int elementOffsetLength=typeEntry.getElementLength();
|
||||
int elementOffsetType=typeEntry.getElementOffsetType();
|
||||
|
||||
addRef(indexedFileNumber, name, ICIndexStorageConstants.typeConstants[type_kind], entryType, nameOffset,nameOffsetLength, nameOffsetType);
|
||||
|
||||
} else if (indexEntry instanceof IFunctionEntry) {
|
||||
IFunctionEntry functionEntry = (IFunctionEntry) indexEntry;
|
||||
int indexedFileNumber=functionEntry.getFileNumber();
|
||||
int meta_type = functionEntry.getMetaKind();
|
||||
int entryType = functionEntry.getEntryType();
|
||||
int modifiers = functionEntry.getModifiers();
|
||||
char[][] sig=functionEntry.getSignature();
|
||||
char[][]name=functionEntry.getFullName();
|
||||
int nameOffset=functionEntry.getNameOffset();
|
||||
int nameOffsetLength=functionEntry.getNameLength();
|
||||
int nameOffsetType=functionEntry.getNameOffsetType();
|
||||
addRef(indexedFileNumber, name, meta_type, entryType, nameOffset,nameOffsetLength, nameOffsetType);
|
||||
}
|
||||
else if (indexEntry instanceof INamedEntry){
|
||||
INamedEntry nameEntry = (INamedEntry) indexEntry;
|
||||
int indexedFileNumber=nameEntry.getFileNumber();
|
||||
int meta_type = nameEntry.getMetaKind();
|
||||
int entryType = nameEntry.getEntryType();
|
||||
int modifiers = nameEntry.getModifiers();
|
||||
char[][]name=nameEntry.getFullName();
|
||||
int nameOffset=nameEntry.getNameOffset();
|
||||
int nameOffsetLength=nameEntry.getNameLength();
|
||||
int nameOffsetType=nameEntry.getNameOffsetType();
|
||||
int elementOffset=nameEntry.getElementOffset();
|
||||
int elementOffsetLength=nameEntry.getElementLength();
|
||||
int elementOffsetType=nameEntry.getElementOffsetType();
|
||||
addRef(indexedFileNumber, name, meta_type, entryType, nameOffset,nameOffsetLength, nameOffsetType);
|
||||
throw new IndexEntryNotSupportedException("Index Entry type not supported - need to add handler"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void addIndexEntry(ITypeEntry typeEntry) {
|
||||
int indexedFileNumber=typeEntry.getFileNumber();
|
||||
int meta_type = typeEntry.getMetaKind();
|
||||
int type_kind = typeEntry.getTypeKind();
|
||||
int entryType = typeEntry.getEntryType();
|
||||
int modifiers = typeEntry.getModifiers();
|
||||
|
||||
char[][]name=typeEntry.getFullName();
|
||||
|
||||
int nameOffset=typeEntry.getNameOffset();
|
||||
int nameOffsetLength=typeEntry.getNameLength();
|
||||
int nameOffsetType=typeEntry.getNameOffsetType();
|
||||
|
||||
int elementOffset=typeEntry.getElementOffset();
|
||||
int elementOffsetLength=typeEntry.getElementLength();
|
||||
int elementOffsetType=typeEntry.getElementOffsetType();
|
||||
|
||||
if (modifiers <= 0)
|
||||
modifiers = 1;
|
||||
|
||||
addRef(indexedFileNumber, name, ICIndexStorageConstants.typeConstants[type_kind], entryType, nameOffset,nameOffsetLength, nameOffsetType, modifiers);
|
||||
|
||||
IIndexEntry[] baseClasses = typeEntry.getBaseTypes();
|
||||
if (baseClasses != null &&
|
||||
baseClasses.length > 0){
|
||||
for (int i=0; i<baseClasses.length; i++){
|
||||
char[][] baseName= ((INamedEntry) baseClasses[i]).getFullName();
|
||||
addRef(indexedFileNumber, baseName, ICIndexStorageConstants.DERIVED_SUFFIX, IIndex.DECLARATION, nameOffset,nameOffsetLength, nameOffsetType, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addIndexEntry(INamedEntry nameEntry) {
|
||||
int indexedFileNumber=nameEntry.getFileNumber();
|
||||
int meta_type = nameEntry.getMetaKind();
|
||||
int entryType = nameEntry.getEntryType();
|
||||
int modifiers = nameEntry.getModifiers();
|
||||
char[][]name=nameEntry.getFullName();
|
||||
int nameOffset=nameEntry.getNameOffset();
|
||||
int nameOffsetLength=nameEntry.getNameLength();
|
||||
int nameOffsetType=nameEntry.getNameOffsetType();
|
||||
int elementOffset=nameEntry.getElementOffset();
|
||||
int elementOffsetLength=nameEntry.getElementLength();
|
||||
int elementOffsetType=nameEntry.getElementOffsetType();
|
||||
|
||||
if (modifiers <= 0)
|
||||
modifiers = 1;
|
||||
|
||||
addRef(indexedFileNumber, name, meta_type, entryType, nameOffset,nameOffsetLength, nameOffsetType, modifiers);
|
||||
}
|
||||
|
||||
public void addIndexEntry(IFunctionEntry functionEntry) {
|
||||
int indexedFileNumber=functionEntry.getFileNumber();
|
||||
int meta_type = functionEntry.getMetaKind();
|
||||
int entryType = functionEntry.getEntryType();
|
||||
int modifiers = functionEntry.getModifiers();
|
||||
char[][] sig=functionEntry.getSignature();
|
||||
char[][]name=functionEntry.getFullName();
|
||||
char[]returnName=functionEntry.getReturnType();
|
||||
int sigL=0, nameL=0, returnNameL=0;
|
||||
|
||||
int totalSize=0;
|
||||
|
||||
//Get the size of the signature
|
||||
if (sig != null){
|
||||
sigL=sig.length;
|
||||
totalSize+=sigL + 2;
|
||||
}
|
||||
//Get the size of the name
|
||||
if (name != null ){
|
||||
nameL=name.length;
|
||||
totalSize+=nameL;
|
||||
}
|
||||
//If return type is included it will be only 1 element
|
||||
if (returnName != null ){
|
||||
returnNameL=1;
|
||||
totalSize+=returnNameL + 2;
|
||||
}
|
||||
char[][] finalName = new char[totalSize][];
|
||||
|
||||
int positionCounter=0;
|
||||
if (sig != null){
|
||||
char[][] startParm= new char[1][];
|
||||
char[] tempParm = {'('};
|
||||
startParm[0] = tempParm;
|
||||
|
||||
char[][] endParm= new char[1][];
|
||||
char[] tempParm2 = {')'};
|
||||
endParm[0] = tempParm2;
|
||||
|
||||
//Copy the signature delimiter in the final array starting where the name left off, length 1
|
||||
System.arraycopy(startParm, 0, finalName,positionCounter, 1);
|
||||
positionCounter+=1;
|
||||
//Copy the signature to the final array starting where the name left off + 1 for the delimiter, length signature length
|
||||
System.arraycopy(sig, 0, finalName, positionCounter, sigL);
|
||||
positionCounter+=sigL;
|
||||
//Copy the signature delimiter in the final array starting where the name left off, length 1
|
||||
System.arraycopy(endParm, 0, finalName, positionCounter, 1);
|
||||
positionCounter+=1;
|
||||
}
|
||||
|
||||
if (returnName != null){
|
||||
char[][] startParm= new char[1][];
|
||||
String tempParm = "R("; //$NON-NLS-1$
|
||||
startParm[0] = tempParm.toCharArray();
|
||||
|
||||
char[][] endParm= new char[1][];
|
||||
String tempParm2 = ")R"; //$NON-NLS-1$
|
||||
endParm[0] = tempParm2.toCharArray();
|
||||
|
||||
char[][] tempReturn = new char[1][];
|
||||
tempReturn[0] = returnName;
|
||||
|
||||
//Copy the signature delimiter in the final array starting where the name left off, length 1
|
||||
System.arraycopy(startParm, 0, finalName,positionCounter, 1);
|
||||
positionCounter+=1;
|
||||
//Copy the signature to the final array starting where the name left off + 1 for the delimiter, length signature length
|
||||
System.arraycopy(tempReturn, 0, finalName, positionCounter, returnNameL);
|
||||
positionCounter+=returnNameL;
|
||||
//Copy the signature delimiter in the final array starting where the name left off, length 1
|
||||
System.arraycopy(endParm, 0, finalName, positionCounter, 1);
|
||||
positionCounter+=1;
|
||||
}
|
||||
|
||||
//copy name to first part of the array
|
||||
if (name != null)
|
||||
System.arraycopy(name, 0, finalName,positionCounter, nameL);
|
||||
|
||||
int nameOffset=functionEntry.getNameOffset();
|
||||
int nameOffsetLength=functionEntry.getNameLength();
|
||||
int nameOffsetType=functionEntry.getNameOffsetType();
|
||||
|
||||
if (modifiers <= 0)
|
||||
modifiers = 1;
|
||||
|
||||
addRef(indexedFileNumber, finalName, meta_type, entryType, nameOffset,nameOffsetLength, nameOffsetType, modifiers);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,6 +29,9 @@ public class WordEntry {
|
|||
//File reference id's
|
||||
private int[] fileRefs;
|
||||
|
||||
//Modifier bit fields - one for each fileRef
|
||||
private int[] modifiers;
|
||||
|
||||
//Offset arrays - each fileRef's position in the fileRef array is the
|
||||
//key into the offsets
|
||||
//Offsets are prefixed with LINE or OFFSET designation
|
||||
|
@ -47,6 +50,7 @@ public class WordEntry {
|
|||
this.word= word;
|
||||
fileRefCount= 0;
|
||||
fileRefs= new int[1];
|
||||
modifiers= new int[1];
|
||||
offsets = new int [1][1];
|
||||
offsetLengths = new int[1][1];
|
||||
offsetCount = new int[1];
|
||||
|
@ -71,6 +75,8 @@ public class WordEntry {
|
|||
int newSize= fileRefCount < 4 ? 4 : fileRefCount * 2;
|
||||
//Grow the fileRefs array
|
||||
System.arraycopy(fileRefs, 0, fileRefs= new int[newSize], 0, fileRefCount);
|
||||
//Grow the modifier array
|
||||
System.arraycopy(modifiers, 0, modifiers= new int[newSize], 0, fileRefCount);
|
||||
//Grow the offset array
|
||||
System.arraycopy(offsets, 0, offsets= new int[newSize][1], 0, fileRefCount);
|
||||
//Grow the offsetLengths array
|
||||
|
@ -94,13 +100,15 @@ public class WordEntry {
|
|||
/**
|
||||
* Adds a set of references and records the change in footprint.
|
||||
* @param passedOffsetCount
|
||||
* @param modifers
|
||||
* @param offsets
|
||||
*/
|
||||
public void addWordInfo(int[] refs, int[][] passedOffsets, int[][] passedOffsetLengths, int[] passedOffsetCount) {
|
||||
public void addWordInfo(int[] refs, int[][] passedOffsets, int[][] passedOffsetLengths, int[] passedOffsetCount, int[] passedModifers) {
|
||||
int[] newRefs= new int[fileRefCount + refs.length];
|
||||
int[][] newOffsets = new int[fileRefCount + refs.length][];
|
||||
int[][] newOffsetLengths = new int[fileRefCount + refs.length][];
|
||||
int[] newOffSetCount= new int[fileRefCount + refs.length];
|
||||
int[] newModifiers = new int[fileRefCount + refs.length];
|
||||
|
||||
int pos1= 0;
|
||||
int pos2= 0;
|
||||
|
@ -127,6 +135,7 @@ public class WordEntry {
|
|||
newOffsets[posNew]= offsets[pos1];
|
||||
newOffsetLengths[posNew]=offsetLengths[pos1];
|
||||
newOffSetCount[posNew]=offsetCount[pos1];
|
||||
newModifiers[posNew]=modifiers[pos1];
|
||||
posNew++;
|
||||
pos1++;
|
||||
} else {
|
||||
|
@ -135,6 +144,7 @@ public class WordEntry {
|
|||
newOffsets[posNew]=passedOffsets[pos2];
|
||||
newOffsetLengths[posNew]=passedOffsetLengths[pos2];
|
||||
newOffSetCount[posNew]=passedOffsetCount[pos2];
|
||||
newModifiers[posNew]=passedModifers[pos2];
|
||||
posNew++;
|
||||
}
|
||||
pos2++;
|
||||
|
@ -144,6 +154,7 @@ public class WordEntry {
|
|||
offsets= newOffsets;
|
||||
offsetLengths=newOffsetLengths;
|
||||
offsetCount=newOffSetCount;
|
||||
modifiers=newModifiers;
|
||||
fileRefCount= posNew;
|
||||
}
|
||||
|
||||
|
@ -203,6 +214,22 @@ public class WordEntry {
|
|||
return (newSize - fileRefCount + 1) * 4;
|
||||
}
|
||||
|
||||
public int addModifiers(int modifier, int fileNum){
|
||||
//Get the position in the fileRefs array for this file number - the
|
||||
//position acts as an index into the offsets array
|
||||
int filePosition = getPositionForFile(fileNum);
|
||||
//File Number wasn't found
|
||||
if (filePosition == -1)
|
||||
return -1;
|
||||
|
||||
if (modifier <= 0){
|
||||
int x=4;
|
||||
}
|
||||
|
||||
modifiers[filePosition]=modifier;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param offsetType
|
||||
* @param offset
|
||||
|
@ -330,6 +357,7 @@ public class WordEntry {
|
|||
System.arraycopy(offsets, 0, (offsets = new int[fileRefCount][]), 0,fileRefCount);
|
||||
System.arraycopy(offsetLengths, 0, (offsetLengths = new int[fileRefCount][]), 0,fileRefCount);
|
||||
System.arraycopy(offsetCount, 0,(offsetCount=new int[fileRefCount]),0,fileRefCount);
|
||||
System.arraycopy(modifiers, 0, (modifiers=new int[fileRefCount]),0,fileRefCount);
|
||||
|
||||
//Store original ref positions in order to generate map
|
||||
int[] originalRefs;
|
||||
|
@ -341,6 +369,7 @@ public class WordEntry {
|
|||
int[] mapping = new int[fileRefs.length];
|
||||
figureOutMapping(originalRefs, fileRefs, mapping);
|
||||
mapOffsets(mapping);
|
||||
mapModiers(mapping);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -364,6 +393,17 @@ public class WordEntry {
|
|||
System.arraycopy(tempOffsetCountArray, 0, offsetCount,0, fileRefLength);
|
||||
}
|
||||
|
||||
private void mapModiers(int[] mapping) {
|
||||
int fileRefLength = fileRefs.length;
|
||||
int[] tempModifierArray = new int[fileRefLength];
|
||||
|
||||
for (int i=0; i<mapping.length; i++){
|
||||
int moveTo = mapping[i];
|
||||
tempModifierArray [moveTo] = modifiers[i];
|
||||
}
|
||||
|
||||
System.arraycopy(tempModifierArray, 0, modifiers,0, fileRefLength);
|
||||
}
|
||||
private void figureOutMapping(int[] originalRefs, int[] sortedRefs, int[] mapping){
|
||||
int position = 0;
|
||||
for (int i=0; i<originalRefs.length; i++){
|
||||
|
@ -460,5 +500,29 @@ public class WordEntry {
|
|||
//Put the newly grown array back in place
|
||||
offsetLengths[index]=selectedOffsets;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the modifier in the i position in the list of references.
|
||||
*/
|
||||
public int getModifiers(int i) {
|
||||
if (i < fileRefCount) return modifiers[i];
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
/**
|
||||
* Returns the modifiers of the word entry
|
||||
*/
|
||||
public int[] getModifiers() {
|
||||
int[] result= new int[fileRefCount];
|
||||
System.arraycopy(modifiers, 0, result, 0, fileRefCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param index
|
||||
* @param modifier
|
||||
*/
|
||||
public void setModifier(int index, int modifier) {
|
||||
modifiers[index]=modifier;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,6 +85,14 @@ public class GammaCompressedIndexBlock extends IndexBlock {
|
|||
codeStream.writeGamma(ref);
|
||||
}
|
||||
}
|
||||
//encode modifiers
|
||||
//number of modifiers same as number of files
|
||||
for (int i= 0; i < n; ++i) {
|
||||
int ref= entry.getModifiers(i);
|
||||
if (ref <= 0)
|
||||
throw new IllegalArgumentException();
|
||||
codeStream.writeGamma(ref);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see IndexBlock#addEntry
|
||||
|
@ -191,6 +199,12 @@ public class GammaCompressedIndexBlock extends IndexBlock {
|
|||
}
|
||||
entry.setOffsetLengths(i, tempOffsetLengthArray);
|
||||
}
|
||||
|
||||
//read in modifiers
|
||||
for (int i= 0; i < n; ++i) {
|
||||
int ref= readCodeStream.readGamma();
|
||||
entry.setModifier(i,ref);
|
||||
}
|
||||
|
||||
offset= readCodeStream.byteLength();
|
||||
prevWord= word;
|
||||
|
|
|
@ -214,7 +214,7 @@ public class MergeFactory {
|
|||
} else {
|
||||
word1.mapRefs(mappingOld);
|
||||
word2.mapRefs(mappingAdds);
|
||||
word1.addWordInfo(word2.getRefs(), word2.getOffsets(),word2.getOffsetLengths(), word2.getOffsetCount());
|
||||
word1.addWordInfo(word2.getRefs(), word2.getOffsets(),word2.getOffsetLengths(), word2.getOffsetCount(), word2.getModifiers());
|
||||
mergeOutput.addWord(word1);
|
||||
addsInput.moveToNextWordEntry();
|
||||
oldInput.moveToNextWordEntry();
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.eclipse.cdt.core.index.ICDTIndexer;
|
|||
import org.eclipse.cdt.core.index.IIndexStorage;
|
||||
import org.eclipse.cdt.internal.core.index.IIndex;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexerOutput;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IndexDelta;
|
||||
import org.eclipse.cdt.internal.core.search.processing.IIndexJob;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -81,4 +82,9 @@ public class NullIndexer extends AbstractCExtension implements ICDTIndexer {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void notifyListeners(IndexDelta indexDelta) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.internal.core.index.IEntryResult;
|
|||
import org.eclipse.cdt.internal.core.index.IIndex;
|
||||
import org.eclipse.cdt.internal.core.index.cindexstorage.Index;
|
||||
import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
|
||||
import org.eclipse.cdt.internal.core.index.cindexstorage.Util;
|
||||
import org.eclipse.cdt.internal.core.index.cindexstorage.io.IndexInput;
|
||||
import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
@ -54,7 +55,8 @@ public class MethodDeclarationPattern extends CSearchPattern {
|
|||
|
||||
private char[] decodedSimpleName;
|
||||
private char[][] decodedQualifications;
|
||||
|
||||
private char[][] decodedParameters;
|
||||
|
||||
public MethodDeclarationPattern(char[] name, char[][] qual, char [][] params, int matchMode, SearchFor search, LimitTo limitTo, boolean caseSensitive) {
|
||||
//super( name, params, matchMode, limitTo, caseSensitive );
|
||||
super( matchMode, caseSensitive, limitTo );
|
||||
|
@ -148,10 +150,43 @@ public class MethodDeclarationPattern extends CSearchPattern {
|
|||
this.decodedSimpleName = entryResult.extractSimpleName().toCharArray();
|
||||
String []missmatch = entryResult.getEnclosingNames();
|
||||
if(missmatch != null) {
|
||||
this.decodedQualifications = new char[missmatch.length][];
|
||||
for (int i = 0; i < missmatch.length; i++)
|
||||
this.decodedQualifications[i] = missmatch[i].toCharArray();
|
||||
|
||||
//Find the first opening braces
|
||||
int start=0;
|
||||
int end=0;
|
||||
boolean parmsExist=false;
|
||||
for (int i=0; i<missmatch.length; i++){
|
||||
if (missmatch[i].equals("(")){ //$NON-NLS-1$
|
||||
start=i;
|
||||
parmsExist=true;
|
||||
}
|
||||
|
||||
if (missmatch[i].equals(")")){ //$NON-NLS-1$
|
||||
end=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (parmsExist){
|
||||
this.decodedParameters = new char[end - (start + 1)][];
|
||||
|
||||
int counter=0;
|
||||
for (int i=start+1; i<end; i++){
|
||||
decodedParameters[counter++]=missmatch[i].toCharArray();
|
||||
}
|
||||
this.decodedQualifications = new char[missmatch.length - (end + 1)][];
|
||||
counter=0;
|
||||
for (int i = end + 1; i < missmatch.length; i++)
|
||||
this.decodedQualifications[counter++] = missmatch[i].toCharArray();
|
||||
} else {
|
||||
this.decodedParameters = new char[0][];
|
||||
this.decodedQualifications = new char[missmatch.length][];
|
||||
for (int i = 0; i < missmatch.length; i++)
|
||||
this.decodedQualifications[i] = missmatch[i].toCharArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected boolean matchIndexEntry() {
|
||||
|
@ -166,9 +201,38 @@ public class MethodDeclarationPattern extends CSearchPattern {
|
|||
return false;
|
||||
}
|
||||
|
||||
if( !matchParameters( parameterNames, decodedParameters ) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean matchParameters(char[][] parameterNames2, char[][] decodedParameters2) {
|
||||
|
||||
if (parameterNames2.length == 0)
|
||||
return true;
|
||||
|
||||
//Check lengths of decoded
|
||||
if (decodedParameters2.length != parameterNames2.length)
|
||||
return false;
|
||||
|
||||
for (int i=0; i<parameterNames2.length; i++){
|
||||
boolean matchFound=false;
|
||||
for (int j=0; j<decodedParameters2.length; j++){
|
||||
if (Util.compare(parameterNames2[i],decodedParameters[j])==0){
|
||||
matchFound=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!matchFound)
|
||||
return false;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] fileRefs, int[][] offsets, int[][] offsetLengths,IndexInput input, ICSearchScope scope) throws IOException {
|
||||
|
||||
for (int i = 0, max = fileRefs.length; i < max; i++) {
|
||||
|
|
Loading…
Add table
Reference in a new issue