Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Standalone indexer works for C not C++

Hi guys,

You might recall that I asked how to parse and index C projects with
CDT standalone.

Well I succeeded thanks to your help.

However, I also want the same thing for C++ and strangely enough,
things appear to behave differently :-(

Would you have a suggestion?

Following is an excerpt of the code:
---
List<String> tus = // all C (resp. C++) files in the project
directory. this includes .h
IIndexLocationConverter locationConverter = new
URILocationConverter(projectDir.toURI());  // note
URILocationConverter is based on URIRelativeLocationConverter
macroDefinitions = Collections.emptyMap();
scannerInfo = new ScannerInfo(macroDefinitions, includePaths);
indexer = 	new StandaloneFastIndexer(new File("xyz"),
locationConverter, linkageFactoryMap, scannerInfo,
/*FileEncodingRegistry*/null, mapper, LOG);
indexer.rebuild(tus, new NullProgressMonitor());
foreach C /* resp. C++ */ file
  FileContent fc = FileContent.createForExternalFileLocation(srcfile);
  IASTTranslationUnit unit =
mapper.getLanguage(srcfile).getASTTranslationUnit(fc, scannerInfo,
ExternalFilesProvider.getInstance(), indexer.getIndex(), 0, LOG);
---

The problem is that with C++ name.resolveBinding() is null in the following:
---
IASTName name = // some ASTName from the unit
indexer.getIndex().findDeclarations(name.resolveBinding())
---


With C projects it does work :-(

I understand it is a lot of uncomplete code. If you need the whole
thing I can send it.

I believe the main question is: Why is it working for C and not C++?
What is the difference?
any suggestion where I should look?

thanks

nicolas

-- 
Nicolas Anquetil        Univ. Lille1 / INRIA-equipe RMod


Back to the top