Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] getASTTranslationUnit and oSGI

Hello!
I'm currently working on a project that utilizes CDT's parsing tools. To be more specific - it's mainly the getASTTranslationUnit method. This method can be used without oSGI running and until recently it's worked for me that way just fine. However, lately I've come across an interesting issue. When the file we want to parse has any include statements with "" quotation marks ( for instance, I want to parse an Example.cpp file that has a line: #include "Example.h" ) and the files being included exist, I get an exception saying:

java.lang.NoClassDefFoundError: org/osgi/framework/BundleActivator

So, it seems CDT needs oSGI in this situation. I think it's because that include statement makes getASTTranslationUnit execute the resource manager plugin's methods, which definitely can't be run without oSGI. Am I right? The question is - is there a clean way to make it work without having to run the framework? Here's the code:

FileContent fc = FileContent.createForExternalFileLocation(filePath);
            ILanguage language = GPPLanguage.getDefault();
            IASTTranslationUnit ast = language.getASTTranslationUnit(
                fc,
                new ScannerInfo(null),
                IncludeFileContentProvider.getSavedFilesProvider(),
                EmptyCIndex.INSTANCE,
                ILanguage.OPTION_NO_IMAGE_LOCATIONS | ILanguage.OPTION_SKIP_FUNCTION_BODIES,
                new DefaultLogService());

I get the exception mentioned above in the third line.

Best Regards

Back to the top