Bug 72219 - [Scanner] Exit Inclusion occurs too soon
Summary: [Scanner] Exit Inclusion occurs too soon
Status: VERIFIED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 2.0.1   Edit
Assignee: Andrew Niefer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-18 17:19 EDT by Sean Evoy CLA
Modified: 2004-08-27 11:37 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sean Evoy CLA 2004-08-18 17:19:40 EDT
This is a wierd one. If I define something in an exteranl file, F3 (Open 
Declaration) gives the proper result, but searching All Declarations > 
Workspace gives a bad result. 

Testing environment:
M200408111300
I200408120400
J9 JRE

1. Create mgd C++ project (problem in properly configure std project too but 
this is faster)
2. Add the following to a main.cpp file
#include <iostream>
#include "findme.h"
using namespace std;

int main(int argc, char **argv) {
	cout << "Find code is: " << FOUND_ME << endl;
	return (0);
}

3. Create an external file, findme.h, somewhere on your machine (not in the 
workspace) with contents:

const int FOUND_ME =1;

4. Add the path to the file to the project's build properties do something to 
trigger an index
5. Do an F3 on FOUND_ME and the header file will be opened in an editor. Cool.
6. Now try All Declarations > Workspace. You will see that the result will be 
the main file at offset 11. This is the offset of the symbol in the header 
file. It's almost as though the search has the offset right, but the file 
wrong. Anyway, this seems like a bug.
Comment 1 Andrew Niefer CLA 2004-08-19 15:39:38 EDT
Because the scanner is 1 token ahead of the parser, when we get the semi colon 
to complete the FOUND_ME declaration, the scanner immediately gets the next 
token and encounters the end of the include file and does the callback 
exitInclusion before the parser processed the semi-colon and does the callback 
for the variable declaration.  

The result is that clients think that this variable declaration is happening 
outside the inclusion instead of being the last thing in the inclusion.
Comment 2 John Camelon CLA 2004-08-20 09:56:34 EDT
What is your proposed solution, oh stealer of defects?
Comment 3 John Camelon CLA 2004-08-20 09:57:23 EDT
This should be fixed for 2.0.1, it will affect more than just Search/Index.
Comment 4 Andrew Niefer CLA 2004-08-23 15:32:28 EDT
fixed in head and 2.0.1

Fix postpones the reporting of callback if we were getting the token one ahead.
Comment 5 Tanya Wolff CLA 2004-08-26 17:51:43 EDT
Verified fixed in cdt 2.0.1 build 20040826
Comment 6 Sean Evoy CLA 2004-08-27 11:37:00 EDT
Marking verified for Tanya.