mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 12:55:40 +02:00
Bug 292851. Changed WAIT_IF_OPEN to WAIT_ACTIVE_ONLY and parsing options to match org.eclipse.cdt.internal.core.model.ASTCache.
This commit is contained in:
parent
2177e1988b
commit
335422ecee
1 changed files with 7 additions and 4 deletions
|
@ -42,6 +42,11 @@ import org.eclipse.cdt.internal.ui.editor.ASTProvider;
|
||||||
* This class is thread-safe.
|
* This class is thread-safe.
|
||||||
*/
|
*/
|
||||||
public class RefactoringASTCache implements IDisposable {
|
public class RefactoringASTCache implements IDisposable {
|
||||||
|
private static final int PARSE_MODE = ITranslationUnit.AST_SKIP_ALL_HEADERS
|
||||||
|
| ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT
|
||||||
|
| ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS
|
||||||
|
| ITranslationUnit.AST_PARSE_INACTIVE_CODE;
|
||||||
|
|
||||||
private final Map<ITranslationUnit, IASTTranslationUnit> fASTCache;
|
private final Map<ITranslationUnit, IASTTranslationUnit> fASTCache;
|
||||||
private final Object astBuildMutex;
|
private final Object astBuildMutex;
|
||||||
private IIndex fIndex;
|
private IIndex fIndex;
|
||||||
|
@ -76,7 +81,7 @@ public class RefactoringASTCache implements IDisposable {
|
||||||
if (ast == null) {
|
if (ast == null) {
|
||||||
// Try to get a shared AST before creating our own.
|
// Try to get a shared AST before creating our own.
|
||||||
final IASTTranslationUnit[] astHolder = new IASTTranslationUnit[1];
|
final IASTTranslationUnit[] astHolder = new IASTTranslationUnit[1];
|
||||||
ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, pm, new ASTRunnable() {
|
ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_ACTIVE_ONLY, pm, new ASTRunnable() {
|
||||||
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
|
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
|
||||||
// Leaking of AST outside of runOnAST method is dangerous, but it does not cause
|
// Leaking of AST outside of runOnAST method is dangerous, but it does not cause
|
||||||
// harm here since the index remains locked for the duration of the AST life span.
|
// harm here since the index remains locked for the duration of the AST life span.
|
||||||
|
@ -92,9 +97,7 @@ public class RefactoringASTCache implements IDisposable {
|
||||||
if (ast == null) {
|
if (ast == null) {
|
||||||
if (pm != null && pm.isCanceled())
|
if (pm != null && pm.isCanceled())
|
||||||
throw new OperationCanceledException();
|
throw new OperationCanceledException();
|
||||||
int options= ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT |
|
ast= tu.getAST(fIndex, PARSE_MODE);
|
||||||
ITranslationUnit.AST_SKIP_INDEXED_HEADERS;
|
|
||||||
ast= tu.getAST(fIndex, options);
|
|
||||||
fASTCache.put(tu, ast);
|
fASTCache.put(tu, ast);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue