[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-dev] Standalone indexer works for C not C++
|
Well what you have for a language mapper should work "good enough" for an experiment, but it looks like you got that from an older version of RDT. RDT doesn't hardcode the file extension->language mappings any more.
Probably what you should do is enable progress reporting (there is a StdoutProgresMonitor class in RDT you can use to output the progress info to the console) and turn on all the logging on the indexer. That might lead to more information about what's actually going wrong.
Here is a thought too that comes to mind, as this problem has bitten me before. If you are producing your AST name by parsing a working copy buffer, and the filename in your AST file location does not exactly match the filename as the indexer saw it, index queries using that name will fail. Although, I would tend to think that if that was the problem, you would have that same problem for C. How did you obtain your AST name?
===========================
Chris Recoskie
Team Lead, IBM CDT and RDT
IBM Toronto
Nicolas Anquetil ---07/16/2010 08:25:18 AM---I got these from PTP-RDT: private static final Map<String,IPDOMLinkageFactory> linkageFactoryMap
![]()
From: | ![]()
Nicolas Anquetil <anquetil.nicolas@xxxxxxxxx> |
![]()
To: | ![]()
"CDT General developers list." <cdt-dev@xxxxxxxxxxx> |
![]()
Date: | ![]()
07/16/2010 08:25 AM |
![]()
Subject: | ![]()
Re: [cdt-dev] Standalone indexer works for C not C++ |
![]()
Sent by: | ![]()
cdt-dev-bounces@xxxxxxxxxxx |
I got these from PTP-RDT:
private static final Map<String,IPDOMLinkageFactory> linkageFactoryMap = new HashMap<String,IPDOMLinkageFactory>() {{
put(ILinkage.C_LINKAGE_NAME, new PDOMCLinkageFactory());
put(ILinkage.CPP_LINKAGE_NAME, new PDOMCPPLinkageFactory());
}};
private static final ILanguageMapper languageMapper = new ILanguageMapper(){
public ILanguage getLanguage(String file) {
if(file.endsWith(".c"))
return GCCLanguage.getDefault();
else if ( file.endsWith(".cpp") || file.endsWith(".C") || file.endsWith(".c++") )
return GPPLanguage.getDefault();
return null;
}
};
Well, I am not peculiar on the way to use the standalone indexer.
I arrived at this solution by copy-and-paste and trial-and-error.
I don't pretend I am understanding everything it does.
If you can share a better (in the sense that does work) way to do it, I would gladly (and humbly) accept it.
thank
nicolas
On Fri, Jul 16, 2010 at 2:18 PM, Chris Recoskie <recoskie@xxxxxxxxxx> wrote:
What language is returned by the language mapper?
We don't use the standalone indexer in quite the same way you are using it, so there may be a subtle difference somewhere in some of the code you don't show.
===========================
Chris Recoskie
Team Lead, IBM CDT and RDT
IBM Toronto
Nicolas Anquetil ---07/16/2010 05:58:47 AM---Hi guys, You might recall that I asked how to parse and index C projects with
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
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev
--
Nicolas Anquetil Univ. Lille1 / INRIA-equipe RMod_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev

