Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Indexer not detecting any definitions(or occurences) in custom refactoring

Just an FYI,
    the index.isFullyInitialized() returns true and index.getAllFIles() also contains the file I am working under. 

On Wed, Nov 25, 2015 at 1:49 PM, Krishna Narasimhan <krishna.nm86@xxxxxxxxx> wrote:
Hi all,
    I am implementing a custom refactoring. And I am using getIndex() in an extension of CRefactoring. And trying to detect all the occurences of a selected name. The code is very simple. 

public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
throws CoreException, OperationCanceledException {
selectedNode = getAST(getTranslationUnit(), pm).getNodeSelector(null).findNode(selectedRegion.getOffset(),
if (selectedNode instanceof IASTName) {
System.out.println("Resolving  Bindings");
IBinding nameBinding = ((IASTName) selectedNode).resolveBinding();
IIndex index = getIndex();
IIndexName[] resolutions = index.findNames(nameBinding, IIndex.FIND_ALL_OCCURRENCES); // LINE A
for (IIndexName resolution : resolutions) {
IASTNode definition = getAST(getTranslationUnit(), pm).getNodeSelector(null)
.findNode(resolution.getNodeOffset(), resolution.getNodeLength());
System.out.println("Printing occurence");

And the input selection is xobj in the following code

class XYZ{
int x;
int y;
float xy;

void fn()
int x;
XYZ xobj; //Selection is here
x = xobj.x + 10;

Somehow neither the definition nor the declaration nor the references are printed. I even debugged it, the resolutions array is empty in line A

Is there some indexing initialization that I am missing here?

Back to the top