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 is the way to bind local variable names to their type definitions and also references? Because the CDT UI is able to do this, I assumed there must be a programmatic way to do the same.

On Wed, Nov 25, 2015 at 6:58 PM, Sergey Prigogin <eclipse.sprigogin@xxxxxxxxx> wrote:
Local variables are not stored in index, but their types are.

-sergey

On Wed, Nov 25, 2015 at 7:17 AM, Krishna Narasimhan <krishna.nm86@xxxxxxxxx> wrote:
xobj. The IASTNAme.

But it doesnt matter, I tried a primitive type's name too. Did not detect any occurrences 

On Wed, Nov 25, 2015 at 4:15 PM, Sergey Prigogin <eclipse.sprigogin@xxxxxxxxx> wrote:
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


_______________________________________________
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


_______________________________________________
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


_______________________________________________
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