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

What node is selected, XYZ or xobj?

On Wed, Nov 25, 2015 at 4:49 AM, 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(),
selectedRegion.getLength());
System.out.println(selectedNode.getClass().getName());
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");
System.out.println(definition.getRawSignature());
}
}
}



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?



_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top