Author Topic: Find references filter for instantiations in C++?  (Read 407 times)

rowbearto

  • Senior Community Member
  • Posts: 1598
  • Hero Points: 116
Find references filter for instantiations in C++?
« on: November 13, 2019, 07:36:20 pm »
Lets say I have a class:

Code: [Select]
class MyClass
{
}

When I do "find references", is there a way I can filter to see just the instantiations of the class, such as:

Code: [Select]
void someFunction()
{
...
  MyClass instance1;   <--- filter to find this
...
}

or

Code: [Select]
class MySecondClass
{
 ...
 MyClass classInst;  <--- Filter to find this too
 ...
}

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2893
  • Hero Points: 436
Re: Find references filter for instantiations in C++?
« Reply #1 on: November 20, 2019, 03:34:35 pm »
This is an approximation, because there are implicit instantiations when a class is passed to a function requiring a conversion, and a slew of other cases too many to mention, but for your particular case, you can click on > Filters > Quick Filters > Data Only to narrow down the results.

rowbearto

  • Senior Community Member
  • Posts: 1598
  • Hero Points: 116
Re: Find references filter for instantiations in C++?
« Reply #2 on: November 20, 2019, 03:42:50 pm »
Dennis: I think I tried but it doesn't work because it is looking for the name of the instance, not the type of the instance.

So for example, if I have:
Code: [Select]
ClassType classInstance
If my reference search was for "classInstance" and I filtered for data, it would find this.

But I don't know the names of all the instances ahead of time.

If I'm searching for "ClassType", I thought I found that "data only" did not find it.

Please consider this as a feature request.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2893
  • Hero Points: 436
Re: Find references filter for instantiations in C++?
« Reply #3 on: November 20, 2019, 03:47:00 pm »
The filters are looking at the type of the symbol where the referenced symbol is found.  But, you do have a point, in the case of a local variable, the type of the containing symbol is going to be a function, so the filter is not going to cut it for you.  I should have looked at your example a bit more closely.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2893
  • Hero Points: 436
Re: Find references filter for instantiations in C++?
« Reply #4 on: November 20, 2019, 03:52:42 pm »
If your class has a constructor (which is not implicit), you can search for references to the constructor function.  That will catch some of the local variable cases.  I have to admit, it is pretty fragile, there is a chance it will miss some other instantiations.  I will look into that, I have a good test case.

rowbearto

  • Senior Community Member
  • Posts: 1598
  • Hero Points: 116
Re: Find references filter for instantiations in C++?
« Reply #5 on: November 20, 2019, 04:06:20 pm »
Thanks Dennis. Yes I think one of my more recent bug report postings (that you haven't gotten to yet) has an example of a constructor tag not found.