[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| Re: [cdt-dev] Standalone indexer works for C not C++ | 
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
![Inactive hide details for Nicolas Anquetil ---07/16/2010 05:58:47 AM---Hi guys, You might recall that I asked how to parse and]() 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
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

