1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

Final fix for 95641: [Scanner Config] Per file scanner info not available for header files and not compiled source files.

- For include files and source files that are not compiled per file discovered scanner info defaults to project's discovered scanner info.
- A new method is added to CoreModel to determine if per resource scanner info is empty. This method will take into account effective per file discovered scanner info.
This commit is contained in:
Vladimir Hirsl 2005-05-19 20:08:18 +00:00
parent 68e0514086
commit d92ccd3e38
7 changed files with 142 additions and 27 deletions

View file

@ -65,6 +65,10 @@ public interface IDiscoveredPathManager {
* Get macro files (gcc option -imacros) for the specific path (file)
*/
IPath[] getMacroFiles(IPath path);
/**
* Returns if there is any discovered scanner info for the path
*/
boolean isEmpty(IPath path);
}
interface IDiscoveredScannerInfoSerializable {

View file

@ -82,4 +82,20 @@ public class PerFileDiscoveredPathContainer extends DiscoveredPathContainer
return (IPathEntry[]) entries.toArray(new IPathEntry[entries.size()]);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IPathEntryContainerExtension#isEmpty(org.eclipse.core.runtime.IPath)
*/
public boolean isEmpty(IPath path) {
IDiscoveredPathInfo info;
try {
info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
if (info instanceof IPerFileDiscoveredPathInfo) {
IPerFileDiscoveredPathInfo filePathInfo = (IPerFileDiscoveredPathInfo) info;
return filePathInfo.isEmpty(path);
}
} catch (CoreException e) {
}
return false;
}
}

View file

@ -149,6 +149,13 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
IPath[] includeFiles;
IPath[] macrosFiles;
Map definedSymbols;
public boolean isEmpty() {
return (includePaths.length == 0 &&
quoteIncludePaths.length == 0 &&
includeFiles.length == 0 &&
macrosFiles.length == 0 &&
definedSymbols.size() == 0);
}
}
public static final String COLLECTOR_ID = MakeCorePlugin.getUniqueIdentifier() + ".PerFileSICollector"; //$NON-NLS-1$
@ -676,6 +683,23 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
return sid;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#isEmpty(org.eclipse.core.runtime.IPath)
*/
public boolean isEmpty(IPath path) {
boolean rc = true;
IResource resource = project.getWorkspace().getRoot().findMember(path);
if (resource != null) {
if (resource instanceof IFile) {
rc = (getCommand((IFile)resource) == null);
}
else if (resource instanceof IProject) {
rc = (psi == null || psi.isEmpty());
}
}
return rc;
}
}
/**

View file

@ -1,3 +1,15 @@
2005-05-19 Vladimir Hirsl
Final fix for 95641: [Scanner Config] Per file scanner info not available for header files
and not compiled source files.
For include files and source files that are not compiled per file discovered scanner info
defaults to project's discovered scanner info.
A new method is added to CoreModel to determine if per resource scanner info is empty.
This method will take into account effective per file discovered scanner info.
* index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMSourceIndexerRunner.java
* model/org/eclipse/cdt/core/model/CoreModel.java
* model/org/eclipse/cdt/core/model/IPathEntryContainerExtension.java
2005-05-17 Vladimir Hirsl
Fixed problem marker updating for files that are not indexed due to
empty scanner info. Some refactoring of problem marker generation code.

View file

@ -188,37 +188,30 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
*/
private boolean isScannerInfoEmpty(IFile file) {
boolean rc = true;
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(file.getProject());
if (provider != null){
IScannerInfo scanInfo = provider.getScannerInformation(file);
if (scanInfo != null) {
if (!scanInfo.getDefinedSymbols().isEmpty() ||
scanInfo.getIncludePaths().length > 0) {
rc = false;
}
if (scanInfo instanceof IExtendedScannerInfo) {
IExtendedScannerInfo extScanInfo = (IExtendedScannerInfo) scanInfo;
if (extScanInfo.getLocalIncludePath().length > 0)
rc = false;
if (!CoreModel.isScannerInformationEmpty(file)) {
rc = false;
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(file.getProject());
if (provider != null) {
IScannerInfo scanInfo = provider.getScannerInformation(file);
if (scanInfo != null && scanInfo instanceof IExtendedScannerInfo) {
IExtendedScannerInfo extScanInfo = (IExtendedScannerInfo) scanInfo;
if (extScanInfo.getIncludeFiles().length > 0) {
rc = false;
for (int i = 0; i < extScanInfo.getIncludeFiles().length; i++) {
String includeFile = extScanInfo.getIncludeFiles()[i];
/* See if this file has been encountered before */
indexer.haveEncounteredHeader(resourceFile.getProject().getFullPath(), new Path(includeFile));
}
for (int i = 0; i < extScanInfo.getIncludeFiles().length; i++) {
String includeFile = extScanInfo.getIncludeFiles()[i];
/* See if this file has been encountered before */
indexer.haveEncounteredHeader(resourceFile.getProject().getFullPath(), new Path(includeFile));
}
}
if (extScanInfo.getMacroFiles().length > 0) {
rc = false;
for (int i = 0; i < extScanInfo.getIncludeFiles().length; i++) {
String macrosFile = extScanInfo.getMacroFiles()[i];
/* See if this file has been encountered before */
indexer.haveEncounteredHeader(resourceFile.getProject().getFullPath(), new Path(macrosFile));
}
for (int i = 0; i < extScanInfo.getIncludeFiles().length; i++) {
String macrosFile = extScanInfo.getMacroFiles()[i];
/* See if this file has been encountered before */
indexer.haveEncounteredHeader(resourceFile.getProject().getFullPath(), new Path(macrosFile));
}
}
}
}
}
}
}
}
return rc;
}

View file

@ -1085,5 +1085,59 @@ public class CoreModel {
return manager.getIndexManager();
}
/**
* The method returns whether scanner information for a resource is empty or not.
* <p>
* Although this looks like IScannerInfoProvider method, eventually this interface
* will be deprecated and the service will be moved to CoreModel.
* </p>
*
* @param resource
* @since 3.0
*/
public static boolean isScannerInformationEmpty(IResource resource) {
final int PATH_ENTRY_MASK = IPathEntry.CDT_INCLUDE | IPathEntry.CDT_MACRO |
IPathEntry.CDT_INCLUDE_FILE | IPathEntry.CDT_MACRO_FILE;
boolean rc = true;
IPath resPath = resource.getFullPath();
IProject project = resource.getProject();
ICProject cProject = CoreModel.getDefault().create(project);
if (cProject != null) {
try {
IPathEntry[] resolvedPE = CoreModel.getRawPathEntries(cProject);
for (int i = 0; i < resolvedPE.length; i++) {
IPathEntry pe = resolvedPE[i];
// first check all containers
if (pe.getEntryKind() == IPathEntry.CDT_CONTAINER) {
IPathEntryContainer peContainer = CoreModel.getPathEntryContainer(
pe.getPath(), cProject);
if (peContainer instanceof IPathEntryContainerExtension) {
IPathEntryContainerExtension contExt = (IPathEntryContainerExtension) peContainer;
if (!contExt.isEmpty(resPath)) {
rc = false;
break;
}
}
else if (peContainer.getPathEntries().length > 0) {
rc = false;
break;
}
}
// then the user specified scanner info
else if ((pe.getEntryKind() & PATH_ENTRY_MASK) != 0) {
IPath affectedPath = pe.getPath();
if (affectedPath.isPrefixOf(resource.getFullPath())) {
rc = false;
break;
}
}
}
} catch (CModelException e) {
}
}
return rc;
}
}

View file

@ -23,9 +23,21 @@ public interface IPathEntryContainerExtension extends IPathEntryContainer {
* and empty array if none.
*
* @param path Workspace relative path.
* @param typeMask type of path entries:
* <li><code>IPathEntry.CDT_INCLUDE</code></li>
* <li><code>IPathEntry.CDT_INCLUDE_FILE</code></li>
* <li><code>IPathEntry.CDT_MACRO_FILE</code></li>
* <li><code>IPathEntry.CDT_MACRO</code></li>
* @return IPathEntry[] - the entries or empty set if none
* @see IPathEntry
*/
IPathEntry[] getPathEntries(IPath path, int typesMask);
/**
* Returns whether there are any path entries for the resource.
*
* @param path Workspace relative path.
* @return
*/
boolean isEmpty(IPath path);
}