Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] IASTTranslationUnit.getTranslationUnit returns null

Greetings.

I am new to CDT.
I would like to programmatically have CDT parse some C++ code.
However, IASTTranslationUnit.getTranslationUnit returns null.
The little bit of code up to this point includes the following:

 IFile file = ... // Is valid
 CDOM dom = CDOM.getInstance();
 IASTServiceProvider ast = dom.getASTService();
 IASTTranslationUnit atu = ast.getTranslationUnit(file);

I have also tried specifing an ICodeReaderFactory as below, but with
the same results:
 IASTTranslationUnit atu = ast.getTranslationUnit(file,
dom.getCodeReaderFactory(CDOM.PARSE_SAVED_RESOURCES));

Using the source code, it is ultimately failing in the peek method in
org.eclipse.cdt.internal.core.util.OverflowingLRUCache:

 public Object peek(Object key)  {
	LRUCacheEntry entry = (LRUCacheEntry) fEntryTable.get(key);
	if (entry == null) {
		return null;
	}
	return entry._fValue;
 }

The key is apparently not in the fEntryTable hashtable, thus returning null.

What am I doing wrong?
Is there some kind of initialization that I am missing?
Do I need to add it to the cache first? If so, how?

Any help would be appreciated.
Thanks.
Ben Monroe


Back to the top