mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
Bug 387935 - Codan does not see symbols from pre-built indexes
This change fixes: 1. Codan no longer shows errors on symbols from pre-built indexes 2. Mark occurances in the editor no properly recognizes occurances of the same symbol. Change-Id: I1f3b347524a89f7a4c11b128f15f8fdcffe2afdf Reviewed-on: https://git.eclipse.org/r/7388 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
parent
88bccabd07
commit
fda18aa3a1
8 changed files with 32 additions and 6 deletions
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.model;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IIndexManager;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
|
||||
|
@ -204,7 +205,8 @@ public class ASTCache {
|
|||
ASTRunnable astRunnable) {
|
||||
IIndex index;
|
||||
try {
|
||||
index = CCorePlugin.getIndexManager().getIndex(tUnit.getCProject());
|
||||
index = CCorePlugin.getIndexManager().getIndex(tUnit.getCProject(),
|
||||
IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
|
||||
index.acquireReadLock();
|
||||
} catch (CoreException e) {
|
||||
return e.getStatus();
|
||||
|
|
|
@ -121,7 +121,8 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
|||
@Override
|
||||
public void parse(boolean quickParseMode) throws Exception {
|
||||
final IIndexManager indexManager= CCorePlugin.getIndexManager();
|
||||
IIndex index= indexManager.getIndex(fTranslationUnit.getCProject());
|
||||
IIndex index = indexManager.getIndex(fTranslationUnit.getCProject(),
|
||||
IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
|
||||
|
||||
try {
|
||||
if (index != null) {
|
||||
|
|
|
@ -112,6 +112,15 @@ public interface IIndexManager extends IPDOMManager {
|
|||
*/
|
||||
public static final int ADD_EXTENSION_FRAGMENTS_SEARCH = 0x200;
|
||||
|
||||
/**
|
||||
* Constant for passing to getIndex methods. This constant, when set, indicates that each index
|
||||
* content provided via the ReadOnlyIndexFragmentProvider or ReadOnlyPDOMProvider, which is not
|
||||
* disabled for the editor shall be included in the resulting index.
|
||||
*
|
||||
* @since 5.5
|
||||
*/
|
||||
public static final int ADD_EXTENSION_FRAGMENTS_EDITOR = 0x400;
|
||||
|
||||
/**
|
||||
* Constant for indicating that there is no time out period for joining the indexer job.
|
||||
* @see IIndexManager#joinIndexer(int, IProgressMonitor)
|
||||
|
|
|
@ -47,7 +47,8 @@ public class IndexFactory {
|
|||
private static final int ALL_FRAGMENT_OPTIONS = ADD_EXTENSION_FRAGMENTS_ADD_IMPORT
|
||||
| ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY | ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST
|
||||
| ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER | ADD_EXTENSION_FRAGMENTS_NAVIGATION
|
||||
| ADD_EXTENSION_FRAGMENTS_SEARCH | ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY;
|
||||
| ADD_EXTENSION_FRAGMENTS_SEARCH | ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY
|
||||
| ADD_EXTENSION_FRAGMENTS_EDITOR;
|
||||
|
||||
private PDOMManager fPDOMManager;
|
||||
|
||||
|
|
|
@ -76,7 +76,8 @@ public final class IndexProviderManager implements IElementChangedListener {
|
|||
ATTRIBUTE_CALL_HIERARCHY = "call_hierarchy",
|
||||
ATTRIBUTE_TYPE_HIERARCHY = "type_hierarchy",
|
||||
ATTRIBUTE_INCLUDE_BROWSER = "include_browser",
|
||||
ATTRIBUTE_SEARCH = "search";
|
||||
ATTRIBUTE_SEARCH = "search",
|
||||
ATTRIBUTE_EDITOR = "editor";
|
||||
|
||||
|
||||
private IIndexFragmentProvider[] fragmentProviders;
|
||||
|
@ -171,6 +172,7 @@ public final class IndexProviderManager implements IElementChangedListener {
|
|||
result |= getOption(elem, ATTRIBUTE_NAVIGATION, IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION);
|
||||
result |= getOption(elem, ATTRIBUTE_SEARCH, IIndexManager.ADD_EXTENSION_FRAGMENTS_SEARCH);
|
||||
result |= getOption(elem, ATTRIBUTE_TYPE_HIERARCHY, IIndexManager.ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY);
|
||||
result |= getOption(elem, ATTRIBUTE_EDITOR, IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -258,6 +258,13 @@ The only information needed for this extension point is the fully qualified name
|
|||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="editor" type="boolean" use="optional">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Whether the fragment provider shall be used for C/C++ editor.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.ltk.core.refactoring.RefactoringContext;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IIndexManager;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
|
@ -113,7 +114,8 @@ public class CRefactoringContext extends RefactoringContext {
|
|||
throw new IllegalStateException("CRefactoringContext is already disposed."); //$NON-NLS-1$
|
||||
if (fIndex == null) {
|
||||
ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
|
||||
IIndex index = CCorePlugin.getIndexManager().getIndex(projects);
|
||||
IIndex index = CCorePlugin.getIndexManager().getIndex(projects,
|
||||
IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
|
||||
try {
|
||||
index.acquireReadLock();
|
||||
} catch (InterruptedException e) {
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IIndexManager;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
|
||||
|
@ -305,7 +306,8 @@ public class CRenameProcessor extends RenameProcessor {
|
|||
if (indexLockCount == 0) {
|
||||
if (fIndex == null) {
|
||||
ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
|
||||
fIndex= CCorePlugin.getIndexManager().getIndex(projects);
|
||||
fIndex = CCorePlugin.getIndexManager().getIndex(projects,
|
||||
IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
|
||||
}
|
||||
fIndex.acquireReadLock();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue