mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 18:56: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.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
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.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
|
||||||
|
@ -204,7 +205,8 @@ public class ASTCache {
|
||||||
ASTRunnable astRunnable) {
|
ASTRunnable astRunnable) {
|
||||||
IIndex index;
|
IIndex index;
|
||||||
try {
|
try {
|
||||||
index = CCorePlugin.getIndexManager().getIndex(tUnit.getCProject());
|
index = CCorePlugin.getIndexManager().getIndex(tUnit.getCProject(),
|
||||||
|
IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
return e.getStatus();
|
return e.getStatus();
|
||||||
|
|
|
@ -121,7 +121,8 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
@Override
|
@Override
|
||||||
public void parse(boolean quickParseMode) throws Exception {
|
public void parse(boolean quickParseMode) throws Exception {
|
||||||
final IIndexManager indexManager= CCorePlugin.getIndexManager();
|
final IIndexManager indexManager= CCorePlugin.getIndexManager();
|
||||||
IIndex index= indexManager.getIndex(fTranslationUnit.getCProject());
|
IIndex index = indexManager.getIndex(fTranslationUnit.getCProject(),
|
||||||
|
IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (index != null) {
|
if (index != null) {
|
||||||
|
|
|
@ -111,6 +111,15 @@ public interface IIndexManager extends IPDOMManager {
|
||||||
* @since 5.4
|
* @since 5.4
|
||||||
*/
|
*/
|
||||||
public static final int ADD_EXTENSION_FRAGMENTS_SEARCH = 0x200;
|
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.
|
* Constant for indicating that there is no time out period for joining the indexer job.
|
||||||
|
|
|
@ -47,7 +47,8 @@ public class IndexFactory {
|
||||||
private static final int ALL_FRAGMENT_OPTIONS = ADD_EXTENSION_FRAGMENTS_ADD_IMPORT
|
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_CALL_HIERARCHY | ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST
|
||||||
| ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER | ADD_EXTENSION_FRAGMENTS_NAVIGATION
|
| 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;
|
private PDOMManager fPDOMManager;
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,8 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
ATTRIBUTE_CALL_HIERARCHY = "call_hierarchy",
|
ATTRIBUTE_CALL_HIERARCHY = "call_hierarchy",
|
||||||
ATTRIBUTE_TYPE_HIERARCHY = "type_hierarchy",
|
ATTRIBUTE_TYPE_HIERARCHY = "type_hierarchy",
|
||||||
ATTRIBUTE_INCLUDE_BROWSER = "include_browser",
|
ATTRIBUTE_INCLUDE_BROWSER = "include_browser",
|
||||||
ATTRIBUTE_SEARCH = "search";
|
ATTRIBUTE_SEARCH = "search",
|
||||||
|
ATTRIBUTE_EDITOR = "editor";
|
||||||
|
|
||||||
|
|
||||||
private IIndexFragmentProvider[] fragmentProviders;
|
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_NAVIGATION, IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION);
|
||||||
result |= getOption(elem, ATTRIBUTE_SEARCH, IIndexManager.ADD_EXTENSION_FRAGMENTS_SEARCH);
|
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_TYPE_HIERARCHY, IIndexManager.ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY);
|
||||||
|
result |= getOption(elem, ATTRIBUTE_EDITOR, IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,6 +258,13 @@ The only information needed for this extension point is the fully qualified name
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</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>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.ltk.core.refactoring.RefactoringContext;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
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.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
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$
|
throw new IllegalStateException("CRefactoringContext is already disposed."); //$NON-NLS-1$
|
||||||
if (fIndex == null) {
|
if (fIndex == null) {
|
||||||
ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
|
ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
|
||||||
IIndex index = CCorePlugin.getIndexManager().getIndex(projects);
|
IIndex index = CCorePlugin.getIndexManager().getIndex(projects,
|
||||||
|
IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
|
||||||
try {
|
try {
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
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.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
|
||||||
|
@ -305,7 +306,8 @@ public class CRenameProcessor extends RenameProcessor {
|
||||||
if (indexLockCount == 0) {
|
if (indexLockCount == 0) {
|
||||||
if (fIndex == null) {
|
if (fIndex == null) {
|
||||||
ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
|
ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
|
||||||
fIndex= CCorePlugin.getIndexManager().getIndex(projects);
|
fIndex = CCorePlugin.getIndexManager().getIndex(projects,
|
||||||
|
IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
|
||||||
}
|
}
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue