code-gnu-global icon indicating copy to clipboard operation
code-gnu-global copied to clipboard

find all references for class member variables returns empty results

Open wkorbe opened this issue 8 years ago • 8 comments

seems like a limitation of using gnu global for "C++ Indexing". this is one of my most used features with eclipse/cdt, it saves a ton of time when you need to do a lot of reverse engineering for a large code base.

$ global --version global (GNU GLOBAL) 6.5.6

wkorbe avatar May 10 '17 02:05 wkorbe

Same here, but after try several configurations now works if:

  • Set the codepage in your user setting, ex: "codegnuglobal.encoding": "windows1252"
  • Add global to PATH, is not working if I only use the setting "codegnuglobal.executable", it has to be in the PATH envvar.

This way it work, in my configuration: VS Code 1.15.1 with Windows 7 Pro. C++ Intellisense 0.2.2 Global 6.5.6

I hope it helps you.

fazaldegui avatar Aug 21 '17 11:08 fazaldegui

I also have same problem. I can only find the references for function. But when find references for class member variables and local variables, tool returns empty results. but I can find those var in GRTAGS with tool gtags --dump

my configuration: VS Code 1.15.1 with Mac Sierra 10.12.6. C++ Intellisense 0.2.2 Global 6.5.6

global --version global (GNU GLOBAL) 6.5.7

vihist avatar Aug 22 '17 08:08 vihist

Hi vihist, You're right, I have the same problem when find references for variables (member or local) :-(

fazaldegui avatar Aug 23 '17 05:08 fazaldegui

so when the issue can be solved? This feature is very useful. Thanks

vihist avatar Aug 23 '17 06:08 vihist

I think has more information about the issue:

  • The command that the extension executes is the same command for functions and for variables global --encode-path " " -rax <symbol>
    • The switch "-r" in the command means that global searches through symbols defined in GTAGS file.

But the variables are not defined in GTAGS file, is a future plan for global:

https://www.gnu.org/software/global/plans.html

The following command works for variables but not for functions: global -sax <variable> The switch "-s" in the command means to locate symbols which are not defined in 'GTAGS'.

But if the both switches are written works for functions and variables! global -srax <function> global -srax <variable>

So the solutions for the extension to work with both, as I see is:

  • Execute different global commands for functions and variables: Difficult for the extension to know what is selected.
  • Modify the command and add the "-s" switch.
  • Wait to global plan for add variables to GTAGS file

I made the 2nd solution that is quite simple:

  • Open file "C:\Users\XXXX.vscode\extensions\austin.code-gnu-global-0.2.2\out\src\referenceProvider.js"
  • Replace the line: return this._global.run(['--encode-path', '" "', '-rax', word]) with return this._global.run(['--encode-path', '" "', '-srax', word])
  • Restart VSCode.

Hope that helps.

fazaldegui avatar Aug 23 '17 07:08 fazaldegui

The problem is solved. Thanks a lot!

vihist avatar Aug 24 '17 03:08 vihist

But there still some problems, for example:

void DisPlay1()
{
    int aTest = 0;
    
    std::cout << "git Learn!\n" << aTest;
}

void DisPlay2()
{
    int aTest = 0;
    
    std::cout << "git Learn!\n" << aTest;
}

when I use find all references for var aTest in function DisPlay2, result return with the references of aTest in function DisPlay2 and DisPlay1

vihist avatar Aug 25 '17 03:08 vihist

True, same with function, ex:

class CAA
{
	int Init() { return 0; }
};

class CBB
{
	int Init() { return 0; }
};

void DisPlay1()
{
    int aTest = 0;
	
	CAA aa;
	aa.Init();
    
    std::cout << "git Learn!\n" << aTest;
}

void DisPlay2()
{
    int aTest = 0;
    
	CBB bb;
	bb.Init();

    std::cout << "git Learn!\n" << aTest;
}

Finding references for Init() in CAA class, it executes the command:

global --encode-path " " -srax Init

giving references for Init() of CBB class too. Finding references for CAA::Init nothing is shown.

I think that this is more "global" problem that the extension's. I don't know how to solved or workaround this one.

fazaldegui avatar Aug 25 '17 05:08 fazaldegui