Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 316836 - Ast provided in codan checker out of sync with indexer
Summary: Ast provided in codan checker out of sync with indexer
Status: RESOLVED WONTFIX
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 7.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-14 17:41 EDT by Lukas Felber CLA
Modified: 2010-06-25 04:18 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Felber CLA 2010-06-14 17:41:42 EDT
Build Identifier: Build id: I20100312-1448

The AST provided in the AbstractIndexAstChecker.processAst(IASTTranslationUnit ast) method is allways up to date (independent if active file was saved or not in the editor).
The index however is not aware of the current (unsaved) state of the current file.

This causes the indexer to yield IIndexInclude instances that are in real ony there anymore or the other way around.

Reproducible: Always

Steps to Reproduce:
1. create class that implements AbstractIndexAstChecker and add the xml code to plugin.xml so it implements a codan checker (or edit an existing checker)
2. execute: 
IIndexFile indexFile =
index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getIFLExpensive(ast.getFileLocation().getFileName()));
IIndexInclude[] includesToAdd = index.findIncludes(file);
3. create a source file which contains ony "#include <string>".
4. remove the include statement (without saving) -> this will cause the codan checker to trigger with an empty translation unit. -> 0 includes
5. the indexer will yield 1 include to <string>
Comment 1 Elena Laskavaia CLA 2010-06-16 21:14:27 EDT
I am not sure what you suggesting? AST is available for editor for unsaved changes, but indexer updates only on save. Not much I can about it.
Comment 2 Lukas Felber CLA 2010-06-24 07:52:51 EDT
Well I do understand why the situation is as it is now.

It would be very nice if the indexer could not only be updated on file change, but also with the unsave file before codan checkers are triggered.
Otherwise chodan checker can only be implemented reliably if they do not use the indexer at all. And considering static analysis the indexer is a very mighty tool which codan should be able to make (reliable) use of.
Comment 3 Elena Laskavaia CLA 2010-06-24 14:47:53 EDT
Sergey comment on the forum:

"Although the index reflects the state of saved files only, it is possible to get ASTs for all dirty editors. When an index returns a file location corresponding to a dirty file, it should not be taken for the face value, but instead used as a trigger to do additional lookup in the AST of the corresponding dirty file. This is how the C/C++ Search works."
Comment 4 Elena Laskavaia CLA 2010-06-24 14:48:53 EDT
resolved as won't fix because nothing I can do about it. It had to be programmed in a  certain way to avoid this issue.