1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 101344: problem markers are not being removed from header files

Fixed removing indexer problem markers originally created by indexing header files not included by any source files.
This commit is contained in:
Vladimir Hirsl 2005-06-27 03:26:53 +00:00
parent 230c1eafb1
commit 486931b62c
3 changed files with 54 additions and 11 deletions

View file

@ -1,3 +1,11 @@
2005-06-26 Vladimir Hirsl
Fix for 101344: problem markers are not being removed from header files
Fixed removing indexer problem markers originally created by indexing
header files not included by any source files.
* index/org/eclipse/cdt/internal/core/index/domsourceindexer/AbstractIndexerRunner.java
* index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMSourceIndexerRunner.java
2005-06-25 Alain Magloire
Fix PR 91069: BinaryRunner search improvements from Chris Wiebe.
* model/org/eclipse/cdt/internal/core/model/BinaryRunner.java

View file

@ -199,8 +199,23 @@ public abstract class AbstractIndexerRunner implements IIndexerRunner, ICSearchC
mark = markers[ i ];
try {
orig = (String) mark.getAttribute(INDEXER_MARKER_ORIGINATOR);
if( orig != null && orig.equals(origPath )) {
mark.delete();
if (orig != null) {
if (orig.equals(origPath)) {
mark.delete();
}
else {
// if a originator of the original marker is a header file and request to
// remove markers is coming from a c/c++ file then remove the marker
String id = null;
IContentType contentType = CCorePlugin.getContentType(resource.getProject(), orig);
if (contentType != null) {
id = contentType.getId();
if (CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)
|| CCorePlugin.CONTENT_TYPE_CHEADER.equals(id)) {
mark.delete();
}
}
}
}
} catch (CoreException e) {
}

View file

@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
import org.eclipse.cdt.core.dom.ast.IASTProblem;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
@ -118,6 +119,9 @@ public class DOMSourceIndexerRunner extends AbstractIndexerRunner {
if (AbstractIndexerRunner.TIMING)
parseTime = System.currentTimeMillis();
// first clear all problem markers on non-external include files
clearProblemMarkers(tu.getIncludeDirectives());
ASTVisitor visitor = null;
//C or CPP?
if (tu.getParserLanguage() == ParserLanguage.CPP) {
@ -194,7 +198,7 @@ public class DOMSourceIndexerRunner extends AbstractIndexerRunner {
}
}
/**
/**
* @param IFile
* @return boolean
*/
@ -227,6 +231,22 @@ public class DOMSourceIndexerRunner extends AbstractIndexerRunner {
return rc;
}
/**
* @param includeDirectives
*/
private void clearProblemMarkers(IASTPreprocessorIncludeStatement[] includeDirectives) {
if (areProblemMarkersEnabled()) {
for (int i = 0; i < includeDirectives.length; i++) {
IPath includePath = new Path(includeDirectives[i].getPath());
IFile includeFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(includePath);
if (includeFile != null) {
// include file in workspace; remove problem markers
requestRemoveMarkers(includeFile, resourceFile);
}
}
}
}
/**
* @param tree
*/
@ -251,14 +271,14 @@ public class DOMSourceIndexerRunner extends AbstractIndexerRunner {
String include = inclusion.getIncludeDirective().getPath();
if (areProblemMarkersEnabled()) {
IPath newPath = new Path(include);
IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(newPath);
if (tempFile != null) {
//File is in the workspace
requestRemoveMarkers(tempFile, resourceFile);
}
}
// if (areProblemMarkersEnabled()) {
// IPath newPath = new Path(include);
// IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(newPath);
// if (tempFile != null) {
// //File is in the workspace
// requestRemoveMarkers(tempFile, resourceFile);
// }
// }
getOutput().addIncludeRef(fileNumber, include);
getOutput().addRelatives(fileNumber, include,