mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-02 05:45:58 +02:00
Generation of problem markers for DOM AST based indexer.
Removing indexer problem markers when problem reporting is deselected.
This commit is contained in:
parent
2e76470f0f
commit
568c1dd81e
7 changed files with 252 additions and 92 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2005-03-29 Vladimir Hirsl
|
||||||
|
Problem markers for DOM AST based indexer.
|
||||||
|
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMSourceIndexerRunner.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/search/indexing/IIndexEncodingConstants.java
|
||||||
|
|
||||||
2005-03-28 Bogdan Gheorghe
|
2005-03-28 Bogdan Gheorghe
|
||||||
Modified DeltaProcessor to make use of ICDTIndexer elements when requesting an index for an element.
|
Modified DeltaProcessor to make use of ICDTIndexer elements when requesting an index for an element.
|
||||||
Added indextiming option to trace options in CCorePlugin.
|
Added indextiming option to trace options in CCorePlugin.
|
||||||
|
|
|
@ -13,11 +13,13 @@ package org.eclipse.cdt.internal.core.index.domsourceindexer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
|
@ -34,6 +36,7 @@ import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants.EntryType;
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants.EntryType;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
public class CGenerateIndexVisitor extends CASTVisitor {
|
public class CGenerateIndexVisitor extends CASTVisitor {
|
||||||
private DOMSourceIndexerRunner indexer;
|
private DOMSourceIndexerRunner indexer;
|
||||||
|
@ -88,7 +91,21 @@ public class CGenerateIndexVisitor extends CASTVisitor {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTProblem)
|
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTProblem)
|
||||||
*/
|
*/
|
||||||
public int visit(IASTProblem problem) {
|
public int visit(IASTProblem problem) {
|
||||||
problems.add(problem);
|
if (indexer.areProblemMarkersEnabled() && indexer.shouldRecordProblem(problem)){
|
||||||
|
IFile tempFile = resourceFile;
|
||||||
|
|
||||||
|
//If we are in an include file, get the include file
|
||||||
|
IASTNodeLocation[] locs = problem.getNodeLocations();
|
||||||
|
if (locs[0] instanceof IASTFileLocation) {
|
||||||
|
IASTFileLocation fileLoc = (IASTFileLocation) locs[0];
|
||||||
|
String fileName = fileLoc.getFileName();
|
||||||
|
tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if( tempFile != null ){
|
||||||
|
indexer.generateMarkerProblem(tempFile, resourceFile, problem);
|
||||||
|
}
|
||||||
|
}
|
||||||
return super.visit(problem);
|
return super.visit(problem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,9 +119,20 @@ public class CGenerateIndexVisitor extends CASTVisitor {
|
||||||
// check for IProblemBinding
|
// check for IProblemBinding
|
||||||
if (binding instanceof IProblemBinding) {
|
if (binding instanceof IProblemBinding) {
|
||||||
IProblemBinding problem = (IProblemBinding) binding;
|
IProblemBinding problem = (IProblemBinding) binding;
|
||||||
problems.add(problem);
|
if (indexer.areProblemMarkersEnabled() && indexer.shouldRecordProblem(problem)){
|
||||||
if (indexer.isProblemReportingEnabled()) {
|
IFile tempFile = resourceFile;
|
||||||
// TODO report problem
|
|
||||||
|
//If we are in an include file, get the include file
|
||||||
|
IASTNodeLocation[] locs = name.getNodeLocations();
|
||||||
|
if (locs[0] instanceof IASTFileLocation) {
|
||||||
|
IASTFileLocation fileLoc = (IASTFileLocation) locs[0];
|
||||||
|
String fileName = fileLoc.getFileName();
|
||||||
|
tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if( tempFile != null ){
|
||||||
|
indexer.generateMarkerProblem(tempFile, resourceFile, problem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -125,16 +153,14 @@ public class CGenerateIndexVisitor extends CASTVisitor {
|
||||||
ASTNodeProperty prop = name.getPropertyInParent();
|
ASTNodeProperty prop = name.getPropertyInParent();
|
||||||
switch (compositeKey) {
|
switch (compositeKey) {
|
||||||
case ICompositeType.k_struct:
|
case ICompositeType.k_struct:
|
||||||
if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
|
entryType = IIndexEncodingConstants.STRUCT;
|
||||||
|
if (name.isDeclaration() && prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
|
||||||
entryType = IIndexEncodingConstants.FWD_STRUCT;
|
entryType = IIndexEncodingConstants.FWD_STRUCT;
|
||||||
else if (prop == IASTCompositeTypeSpecifier.TYPE_NAME)
|
|
||||||
entryType = IIndexEncodingConstants.STRUCT;
|
|
||||||
break;
|
break;
|
||||||
case ICompositeType.k_union:
|
case ICompositeType.k_union:
|
||||||
if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
|
entryType = IIndexEncodingConstants.UNION;
|
||||||
|
if (name.isDeclaration() && prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
|
||||||
entryType = IIndexEncodingConstants.FWD_UNION;
|
entryType = IIndexEncodingConstants.FWD_UNION;
|
||||||
else if (prop == IASTCompositeTypeSpecifier.TYPE_NAME)
|
|
||||||
entryType = IIndexEncodingConstants.UNION;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,6 +201,18 @@ public class CGenerateIndexVisitor extends CASTVisitor {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private char[][] getFullyQualifiedName(IASTName name) {
|
private char[][] getFullyQualifiedName(IASTName name) {
|
||||||
|
IBinding binding = name.resolveBinding();
|
||||||
|
if (!(binding instanceof IField))
|
||||||
|
return new char[][] {name.toCharArray()};
|
||||||
|
// special case for fields
|
||||||
|
IASTName parent = null;
|
||||||
|
try {
|
||||||
|
parent = binding.getScope().getScopeName();
|
||||||
|
}
|
||||||
|
catch (DOMException e) {
|
||||||
|
}
|
||||||
|
if (parent != null)
|
||||||
|
return new char[][] {parent.toCharArray(), name.toCharArray()};
|
||||||
return new char[][] {name.toCharArray()};
|
return new char[][] {name.toCharArray()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,13 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index.domsourceindexer;
|
package org.eclipse.cdt.internal.core.index.domsourceindexer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
|
@ -44,11 +43,11 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBaseClause.CPPBaseProblem
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants.EntryType;
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants.EntryType;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
private DOMSourceIndexerRunner indexer;
|
private DOMSourceIndexerRunner indexer;
|
||||||
private IFile resourceFile;
|
private IFile resourceFile;
|
||||||
private List problems;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
shouldVisitNames = true;
|
shouldVisitNames = true;
|
||||||
|
@ -73,7 +72,6 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
super();
|
super();
|
||||||
this.indexer = indexer;
|
this.indexer = indexer;
|
||||||
this.resourceFile = resourceFile;
|
this.resourceFile = resourceFile;
|
||||||
problems = new ArrayList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -101,7 +99,21 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTProblem)
|
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTProblem)
|
||||||
*/
|
*/
|
||||||
public int visit(IASTProblem problem) {
|
public int visit(IASTProblem problem) {
|
||||||
problems.add(problem);
|
if (indexer.areProblemMarkersEnabled() && indexer.shouldRecordProblem(problem)){
|
||||||
|
IFile tempFile = resourceFile;
|
||||||
|
|
||||||
|
//If we are in an include file, get the include file
|
||||||
|
IASTNodeLocation[] locs = problem.getNodeLocations();
|
||||||
|
if (locs[0] instanceof IASTFileLocation) {
|
||||||
|
IASTFileLocation fileLoc = (IASTFileLocation) locs[0];
|
||||||
|
String fileName = fileLoc.getFileName();
|
||||||
|
tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if( tempFile != null ){
|
||||||
|
indexer.generateMarkerProblem(tempFile, resourceFile, problem);
|
||||||
|
}
|
||||||
|
}
|
||||||
return super.visit(problem);
|
return super.visit(problem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,9 +127,20 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
// check for IProblemBinding
|
// check for IProblemBinding
|
||||||
if (binding instanceof IProblemBinding) {
|
if (binding instanceof IProblemBinding) {
|
||||||
IProblemBinding problem = (IProblemBinding) binding;
|
IProblemBinding problem = (IProblemBinding) binding;
|
||||||
problems.add(problem);
|
if (indexer.areProblemMarkersEnabled() && indexer.shouldRecordProblem(problem)){
|
||||||
if (indexer.isProblemReportingEnabled()) {
|
IFile tempFile = resourceFile;
|
||||||
// TODO report problem
|
|
||||||
|
//If we are in an include file, get the include file
|
||||||
|
IASTNodeLocation[] locs = name.getNodeLocations();
|
||||||
|
if (locs[0] instanceof IASTFileLocation) {
|
||||||
|
IASTFileLocation fileLoc = (IASTFileLocation) locs[0];
|
||||||
|
String fileName = fileLoc.getFileName();
|
||||||
|
tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempFile != null) {
|
||||||
|
indexer.generateMarkerProblem(tempFile, resourceFile, name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -162,22 +185,19 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
ASTNodeProperty prop = name.getPropertyInParent();
|
ASTNodeProperty prop = name.getPropertyInParent();
|
||||||
switch (compositeKey) {
|
switch (compositeKey) {
|
||||||
case ICPPClassType.k_class:
|
case ICPPClassType.k_class:
|
||||||
if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
|
entryType = IIndexEncodingConstants.CLASS;
|
||||||
|
if (name.isDeclaration() && prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
|
||||||
entryType = IIndexEncodingConstants.FWD_CLASS;
|
entryType = IIndexEncodingConstants.FWD_CLASS;
|
||||||
else if (prop == IASTCompositeTypeSpecifier.TYPE_NAME)
|
|
||||||
entryType = IIndexEncodingConstants.CLASS;
|
|
||||||
break;
|
break;
|
||||||
case ICompositeType.k_struct:
|
case ICompositeType.k_struct:
|
||||||
if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
|
entryType = IIndexEncodingConstants.STRUCT;
|
||||||
|
if (name.isDeclaration() && prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
|
||||||
entryType = IIndexEncodingConstants.FWD_STRUCT;
|
entryType = IIndexEncodingConstants.FWD_STRUCT;
|
||||||
else if (prop == IASTCompositeTypeSpecifier.TYPE_NAME)
|
|
||||||
entryType = IIndexEncodingConstants.STRUCT;
|
|
||||||
break;
|
break;
|
||||||
case ICompositeType.k_union:
|
case ICompositeType.k_union:
|
||||||
if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
|
entryType = IIndexEncodingConstants.UNION;
|
||||||
|
if (name.isDeclaration() && prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
|
||||||
entryType = IIndexEncodingConstants.FWD_UNION;
|
entryType = IIndexEncodingConstants.FWD_UNION;
|
||||||
else if (prop == IASTCompositeTypeSpecifier.TYPE_NAME)
|
|
||||||
entryType = IIndexEncodingConstants.UNION;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,16 @@ import org.eclipse.cdt.core.ICLogConstants;
|
||||||
import org.eclipse.cdt.core.dom.CDOM;
|
import org.eclipse.cdt.core.dom.CDOM;
|
||||||
import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
|
import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
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.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
import org.eclipse.cdt.core.parser.ParseError;
|
import org.eclipse.cdt.core.parser.ParseError;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
|
@ -29,7 +34,10 @@ import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer;
|
||||||
import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer;
|
import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,7 +57,6 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
|
|
||||||
private IFile resourceFile;
|
private IFile resourceFile;
|
||||||
private SourceIndexer indexer;
|
private SourceIndexer indexer;
|
||||||
private boolean problemReportingEnabled = false;
|
|
||||||
|
|
||||||
public DOMSourceIndexerRunner(IFile resource, SourceIndexer indexer) {
|
public DOMSourceIndexerRunner(IFile resource, SourceIndexer indexer) {
|
||||||
this.resourceFile = resource;
|
this.resourceFile = resource;
|
||||||
|
@ -60,13 +67,6 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
return resourceFile;
|
return resourceFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the problemReportingEnabled.
|
|
||||||
*/
|
|
||||||
public boolean isProblemReportingEnabled() {
|
|
||||||
return problemReportingEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFileTypes(String[] fileTypes) {
|
public void setFileTypes(String[] fileTypes) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
@ -75,7 +75,9 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
protected void indexFile(IDocument document) throws IOException {
|
protected void indexFile(IDocument document) throws IOException {
|
||||||
// Add the name of the file to the index
|
// Add the name of the file to the index
|
||||||
output.addDocument(document);
|
output.addDocument(document);
|
||||||
problemReportingEnabled = indexer.indexProblemsEnabled(resourceFile.getProject()) != 0;
|
int problems = indexer.indexProblemsEnabled(resourceFile.getProject());
|
||||||
|
setProblemMarkersEnabled(problems);
|
||||||
|
requestRemoveMarkers(resourceFile, null);
|
||||||
|
|
||||||
//C or CPP?
|
//C or CPP?
|
||||||
ParserLanguage language = CoreModel.hasCCNature(resourceFile.getProject()) ?
|
ParserLanguage language = CoreModel.hasCCNature(resourceFile.getProject()) ?
|
||||||
|
@ -112,12 +114,7 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
endTime = System.currentTimeMillis();
|
endTime = System.currentTimeMillis();
|
||||||
System.out.println("DOM Indexer - Total Parse Time for " + resourceFile.getName() + ": " + (parseTime - startTime)); //$NON-NLS-1$ //$NON-NLS-2$
|
System.out.println("DOM Indexer - Total Parse Time for " + resourceFile.getName() + ": " + (parseTime - startTime)); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
System.out.println("DOM Indexer - Total Visit Time for " + resourceFile.getName() + ": " + (endTime - parseTime)); //$NON-NLS-1$ //$NON-NLS-2$
|
System.out.println("DOM Indexer - Total Visit Time for " + resourceFile.getName() + ": " + (endTime - parseTime)); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
long currentTime = endTime - startTime;
|
System.out.println("DOM Indexer - Total Index Time for " + resourceFile.getName() + ": " + (endTime - startTime)); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
System.out.println("DOM Indexer - Total Index Time for " + resourceFile.getName() + ": " + currentTime); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
long tempTotaltime = indexer.getTotalIndexTime() + currentTime;
|
|
||||||
indexer.setTotalIndexTime(tempTotaltime);
|
|
||||||
System.out.println("DOM Indexer - Overall Index Time: " + tempTotaltime); //$NON-NLS-1$
|
|
||||||
System.out.flush();
|
|
||||||
}
|
}
|
||||||
if (AbstractIndexer.VERBOSE){
|
if (AbstractIndexer.VERBOSE){
|
||||||
AbstractIndexer.verbose("DOM AST TRAVERSAL FINISHED " + resourceFile.getName().toString()); //$NON-NLS-1$
|
AbstractIndexer.verbose("DOM AST TRAVERSAL FINISHED " + resourceFile.getName().toString()); //$NON-NLS-1$
|
||||||
|
@ -139,15 +136,16 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
throw (IOException) ex;
|
throw (IOException) ex;
|
||||||
}
|
}
|
||||||
finally{
|
finally{
|
||||||
//if the user disable problem reporting since we last checked, don't report the collected problems
|
// if the user disable problem reporting since we last checked, don't report the collected problems
|
||||||
// if( manager.indexProblemsEnabled( resourceFile.getProject() ) != 0 )
|
if (areProblemMarkersEnabled()) {
|
||||||
// requestor.reportProblems();
|
reportProblems();
|
||||||
//
|
}
|
||||||
// //Report events
|
|
||||||
|
// Report events
|
||||||
// ArrayList filesTrav = requestor.getFilesTraversed();
|
// ArrayList filesTrav = requestor.getFilesTraversed();
|
||||||
// IndexDelta indexDelta = new IndexDelta(resourceFile.getProject(),filesTrav, IIndexDelta.INDEX_FINISHED_DELTA);
|
// IndexDelta indexDelta = new IndexDelta(resourceFile.getProject(),filesTrav, IIndexDelta.INDEX_FINISHED_DELTA);
|
||||||
// CCorePlugin.getDefault().getCoreModel().getIndexManager().notifyListeners(indexDelta);
|
// CCorePlugin.getDefault().getCoreModel().getIndexManager().notifyListeners(indexDelta);
|
||||||
//Release all resources
|
// Release all resources
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,8 +205,94 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
* @see org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer#addMarkers(org.eclipse.core.resources.IFile, org.eclipse.core.resources.IFile, java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer#addMarkers(org.eclipse.core.resources.IFile, org.eclipse.core.resources.IFile, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
protected void addMarkers(IFile tempFile, IFile originator, Object problem) {
|
protected void addMarkers(IFile tempFile, IFile originator, Object problem) {
|
||||||
// TODO Auto-generated method stub
|
String fileName;
|
||||||
|
int sourceLineNumber = -1;
|
||||||
|
String errorMessage = ""; //$NON-NLS-1$
|
||||||
|
IASTNodeLocation location = null;
|
||||||
|
|
||||||
|
if (problem instanceof IASTProblem) {
|
||||||
|
IASTProblem astProblem = (IASTProblem) problem;
|
||||||
|
errorMessage = astProblem.getMessage();
|
||||||
|
location = astProblem.getNodeLocations()[0];
|
||||||
|
}
|
||||||
|
else if (problem instanceof IASTName) { // semantic error specified in IProblemBinding
|
||||||
|
IASTName name = (IASTName) problem;
|
||||||
|
if (name.resolveBinding() instanceof IProblemBinding) {
|
||||||
|
IProblemBinding problemBinding = (IProblemBinding) name.resolveBinding();
|
||||||
|
errorMessage = problemBinding.getMessage();
|
||||||
|
location = name.getNodeLocations()[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (location != null) {
|
||||||
|
if (location instanceof IASTFileLocation) {
|
||||||
|
IASTFileLocation fileLoc = (IASTFileLocation) location;
|
||||||
|
fileName = fileLoc.getFileName();
|
||||||
|
try {
|
||||||
|
//we only ever add index markers on the file, so DEPTH_ZERO is far enough
|
||||||
|
IMarker[] markers = tempFile.findMarkers(ICModelMarker.INDEXER_MARKER, true,IResource.DEPTH_ZERO);
|
||||||
|
|
||||||
|
boolean newProblem = true;
|
||||||
|
|
||||||
|
if (markers.length > 0) {
|
||||||
|
IMarker tempMarker = null;
|
||||||
|
Integer tempInt = null;
|
||||||
|
String tempMsgString = null;
|
||||||
|
|
||||||
|
for (int i=0; i<markers.length; i++) {
|
||||||
|
tempMarker = markers[i];
|
||||||
|
tempInt = (Integer) tempMarker.getAttribute(IMarker.LINE_NUMBER);
|
||||||
|
tempMsgString = (String) tempMarker.getAttribute(IMarker.MESSAGE);
|
||||||
|
if (tempInt != null && tempInt.intValue()== sourceLineNumber &&
|
||||||
|
tempMsgString.equalsIgnoreCase(INDEXER_MARKER_PREFIX + errorMessage)) {
|
||||||
|
newProblem = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newProblem) {
|
||||||
|
IMarker marker = tempFile.createMarker(ICModelMarker.INDEXER_MARKER);
|
||||||
|
int start = fileLoc.getNodeOffset();
|
||||||
|
int end = start + fileLoc.getNodeLength();
|
||||||
|
// marker.setAttribute(IMarker.LOCATION, iProblem.getSourceLineNumber());
|
||||||
|
marker.setAttribute(IMarker.LOCATION, 1);
|
||||||
|
marker.setAttribute(IMarker.MESSAGE, INDEXER_MARKER_PREFIX + errorMessage);
|
||||||
|
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
|
||||||
|
// marker.setAttribute(IMarker.LINE_NUMBER, iProblem.getSourceLineNumber());
|
||||||
|
marker.setAttribute(IMarker.LINE_NUMBER, 1);
|
||||||
|
marker.setAttribute(IMarker.CHAR_START, start);
|
||||||
|
marker.setAttribute(IMarker.CHAR_END, end);
|
||||||
|
marker.setAttribute(INDEXER_MARKER_ORIGINATOR, originator.getFullPath().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// You need to handle the cases where attribute value is rejected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldRecordProblem(IASTProblem problem) {
|
||||||
|
boolean preprocessor = (getProblemMarkersEnabled() & SourceIndexer.PREPROCESSOR_PROBLEMS_BIT ) != 0;
|
||||||
|
boolean semantics = (getProblemMarkersEnabled() & SourceIndexer.SEMANTIC_PROBLEMS_BIT ) != 0;
|
||||||
|
boolean syntax = (getProblemMarkersEnabled() & SourceIndexer.SYNTACTIC_PROBLEMS_BIT ) != 0;
|
||||||
|
|
||||||
|
if (problem.checkCategory(IASTProblem.PREPROCESSOR_RELATED) ||
|
||||||
|
problem.checkCategory(IASTProblem.SCANNER_RELATED))
|
||||||
|
return preprocessor && problem.getID() != IASTProblem.PREPROCESSOR_CIRCULAR_INCLUSION;
|
||||||
|
else if (problem.checkCategory(IASTProblem.SEMANTICS_RELATED))
|
||||||
|
return semantics;
|
||||||
|
else if (problem.checkCategory(IASTProblem.SYNTAX_RELATED))
|
||||||
|
return syntax;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param binding
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean shouldRecordProblem(IProblemBinding problem) {
|
||||||
|
return (getProblemMarkersEnabled() & SourceIndexer.SEMANTIC_PROBLEMS_BIT) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,46 +44,46 @@ public interface IIndexEncodingConstants {
|
||||||
|
|
||||||
final static char[][] encodedTypeNames_Decl = {
|
final static char[][] encodedTypeNames_Decl = {
|
||||||
new char[] {' '}, // not used
|
new char[] {' '}, // not used
|
||||||
"typeDecl/C/".toCharArray(), // CLASS //$NON-NLS-1$
|
"typeDecl/C/".toCharArray(), // CLASS //$NON-NLS-1$
|
||||||
"typeDecl/S/".toCharArray(), // STRUCT //$NON-NLS-1$
|
"typeDecl/S/".toCharArray(), // STRUCT //$NON-NLS-1$
|
||||||
"typeDecl/U/".toCharArray(), // UNION //$NON-NLS-1$
|
"typeDecl/U/".toCharArray(), // UNION //$NON-NLS-1$
|
||||||
"typeDecl/E/".toCharArray(), // ENUM //$NON-NLS-1$
|
"typeDecl/E/".toCharArray(), // ENUM //$NON-NLS-1$
|
||||||
"typeDecl/V/".toCharArray(), // VAR //$NON-NLS-1$
|
"typeDecl/V/".toCharArray(), // VAR //$NON-NLS-1$
|
||||||
"typeDecl/T/".toCharArray(), // TYPEDEF //$NON-NLS-1$
|
"typeDecl/T/".toCharArray(), // TYPEDEF //$NON-NLS-1$
|
||||||
"typeDecl/D/".toCharArray(), // DERIVED //$NON-NLS-1$
|
"typeDecl/D/".toCharArray(), // DERIVED //$NON-NLS-1$
|
||||||
"typeDecl/F/".toCharArray(), // FIREND //$NON-NLS-1$
|
"typeDecl/F/".toCharArray(), // FIREND //$NON-NLS-1$
|
||||||
"typeDecl/G/".toCharArray(), // FWD_CLASS //$NON-NLS-1$
|
"typeDecl/G/".toCharArray(), // FWD_CLASS //$NON-NLS-1$
|
||||||
"typeDecl/H/".toCharArray(), // FWD_STRUCT //$NON-NLS-1$
|
"typeDecl/H/".toCharArray(), // FWD_STRUCT //$NON-NLS-1$
|
||||||
"typeDecl/I/".toCharArray(), // FWD_UNION //$NON-NLS-1$
|
"typeDecl/I/".toCharArray(), // FWD_UNION //$NON-NLS-1$
|
||||||
"namespaceDecl/".toCharArray(), // NAMESPACE //$NON-NLS-1$
|
"namespaceDecl/".toCharArray(), // NAMESPACE //$NON-NLS-1$
|
||||||
"enumtorDecl/".toCharArray(), // ENUMERATOR //$NON-NLS-1$
|
"enumtorDecl/".toCharArray(), // ENUMERATOR //$NON-NLS-1$
|
||||||
"fieldDecl/".toCharArray(), // FIELD //$NON-NLS-1$
|
"fieldDecl/".toCharArray(), // FIELD //$NON-NLS-1$
|
||||||
"methodDecl/".toCharArray(), // METHOD //$NON-NLS-1$
|
"methodDecl/".toCharArray(), // METHOD //$NON-NLS-1$
|
||||||
"functionDecl/".toCharArray(), // FUNCTION //$NON-NLS-1$
|
"functionDecl/".toCharArray(), // FUNCTION //$NON-NLS-1$
|
||||||
"macroDecl/".toCharArray(), // MACRO //$NON-NLS-1$
|
"macroDecl/".toCharArray(), // MACRO //$NON-NLS-1$
|
||||||
"includeDecl/".toCharArray() // INCLUDE-unused //$NON-NLS-1$
|
"includeDecl/".toCharArray() // INCLUDE-unused //$NON-NLS-1$
|
||||||
};
|
};
|
||||||
|
|
||||||
final static char[][] encodedTypeNames_Ref = {
|
final static char[][] encodedTypeNames_Ref = {
|
||||||
new char[] {' '}, // not used
|
new char[] {' '}, // not used
|
||||||
"typeRef/C/".toCharArray(), // CLASS //$NON-NLS-1$
|
"typeRef/C/".toCharArray(), // CLASS //$NON-NLS-1$
|
||||||
"typeRef/S/".toCharArray(), // STRUCT //$NON-NLS-1$
|
"typeRef/S/".toCharArray(), // STRUCT //$NON-NLS-1$
|
||||||
"typeRef/U/".toCharArray(), // UNION //$NON-NLS-1$
|
"typeRef/U/".toCharArray(), // UNION //$NON-NLS-1$
|
||||||
"typeRef/E/".toCharArray(), // ENUM //$NON-NLS-1$
|
"typeRef/E/".toCharArray(), // ENUM //$NON-NLS-1$
|
||||||
"typeRef/V/".toCharArray(), // VAR //$NON-NLS-1$
|
"typeRef/V/".toCharArray(), // VAR //$NON-NLS-1$
|
||||||
"typeRef/T/".toCharArray(), // TYPEDEF //$NON-NLS-1$
|
"typeRef/T/".toCharArray(), // TYPEDEF //$NON-NLS-1$
|
||||||
"typeRef/D/".toCharArray(), // DERIVED //$NON-NLS-1$
|
"typeRef/D/".toCharArray(), // DERIVED //$NON-NLS-1$
|
||||||
"typeRef/F/".toCharArray(), // FIREND //$NON-NLS-1$
|
"typeRef/F/".toCharArray(), // FIREND //$NON-NLS-1$
|
||||||
"typeRef/G/".toCharArray(), // FWD_CLASS //$NON-NLS-1$
|
"typeRef/G/".toCharArray(), // FWD_CLASS-unused //$NON-NLS-1$
|
||||||
"typeRef/H/".toCharArray(), // FWD_STRUCT //$NON-NLS-1$
|
"typeRef/H/".toCharArray(), // FWD_STRUCT-unused //$NON-NLS-1$
|
||||||
"typeRef/I/".toCharArray(), // FWD_UNION //$NON-NLS-1$
|
"typeRef/I/".toCharArray(), // FWD_UNION-unused //$NON-NLS-1$
|
||||||
"namespaceRef/".toCharArray(), // NAMESPACE //$NON-NLS-1$
|
"namespaceRef/".toCharArray(), // NAMESPACE //$NON-NLS-1$
|
||||||
"enumtorRef/".toCharArray(), // ENUMERATOR //$NON-NLS-1$
|
"enumtorRef/".toCharArray(), // ENUMERATOR //$NON-NLS-1$
|
||||||
"fieldRef/".toCharArray(), // FIELD //$NON-NLS-1$
|
"fieldRef/".toCharArray(), // FIELD //$NON-NLS-1$
|
||||||
"methodRef/".toCharArray(), // METHOD //$NON-NLS-1$
|
"methodRef/".toCharArray(), // METHOD //$NON-NLS-1$
|
||||||
"functionRef/".toCharArray(), // FUNCTION //$NON-NLS-1$
|
"functionRef/".toCharArray(), // FUNCTION //$NON-NLS-1$
|
||||||
"macroRef/".toCharArray(), // MACRO-unused //$NON-NLS-1$
|
"macroRef/".toCharArray(), // MACRO-unused //$NON-NLS-1$
|
||||||
"includeRef/".toCharArray() // INCLUDE //$NON-NLS-1$
|
"includeRef/".toCharArray() // INCLUDE //$NON-NLS-1$
|
||||||
};
|
};
|
||||||
|
|
||||||
final static char SEPARATOR= '/';
|
final static char SEPARATOR= '/';
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2005-03-29 Vladimir Hirsl
|
||||||
|
Removing indexer problem markers when problem reporting is deselected.
|
||||||
|
|
||||||
|
* src/org/eclipse/cdt/ui/dialogs/SourceIndexerBlock.java
|
||||||
|
|
||||||
2005-03-28 Bogdan Gheorghe
|
2005-03-28 Bogdan Gheorghe
|
||||||
Added CTagsIndexer block - some more ironing of the indexer block.
|
Added CTagsIndexer block - some more ironing of the indexer block.
|
||||||
* src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java
|
* src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java
|
||||||
|
|
|
@ -63,6 +63,8 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
|
||||||
monitor.beginTask(CUIMessages.getString("IndexerOptiosn.task.savingAttributes "), 1); //$NON-NLS-1$
|
monitor.beginTask(CUIMessages.getString("IndexerOptiosn.task.savingAttributes "), 1); //$NON-NLS-1$
|
||||||
ICOptionContainer container = getContainer();
|
ICOptionContainer container = getContainer();
|
||||||
IProject proj = null;
|
IProject proj = null;
|
||||||
|
String indexEnabled = getIndexerEnabledString();
|
||||||
|
String indexMarkers = getIndexerProblemsValuesString();
|
||||||
|
|
||||||
if (container != null){
|
if (container != null){
|
||||||
proj = container.getProject();
|
proj = container.getProject();
|
||||||
|
@ -80,7 +82,6 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
|
||||||
String id = cext[i].getID();
|
String id = cext[i].getID();
|
||||||
//if (cext[i].getID().equals(parserID)) {
|
//if (cext[i].getID().equals(parserID)) {
|
||||||
String orig = cext[i].getExtensionData("indexenabled"); //$NON-NLS-1$
|
String orig = cext[i].getExtensionData("indexenabled"); //$NON-NLS-1$
|
||||||
String indexEnabled = getIndexerEnabledString();
|
|
||||||
if (orig == null || !orig.equals(indexEnabled)) {
|
if (orig == null || !orig.equals(indexEnabled)) {
|
||||||
cext[i].setExtensionData("indexenabled", indexEnabled); //$NON-NLS-1$
|
cext[i].setExtensionData("indexenabled", indexEnabled); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -99,19 +100,23 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (store != null) {
|
if (store != null) {
|
||||||
String indexEnabled = getIndexerEnabledString();
|
|
||||||
String indexMarkers = getIndexerProblemsValuesString();
|
|
||||||
store.setValue(PREF_INDEX_ENABLED, indexEnabled);
|
store.setValue(PREF_INDEX_ENABLED, indexEnabled);
|
||||||
store.setValue(PREF_INDEX_MARKERS, indexMarkers);
|
store.setValue(PREF_INDEX_MARKERS, indexMarkers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ICDTIndexer indexer = CCorePlugin.getDefault().getCoreModel().getIndexManager().getIndexerForProject(currentProject);
|
||||||
|
|
||||||
|
int indexMarkersInt = Integer.parseInt(indexMarkers);
|
||||||
|
if (indexMarkersInt != oldIndexerProblemsValue && indexMarkersInt == 0)
|
||||||
|
if (indexer instanceof SourceIndexer)
|
||||||
|
((SourceIndexer) indexer).removeIndexerProblems(currentProject);
|
||||||
|
|
||||||
boolean indexProject = getIndexerValue();
|
boolean indexProject = getIndexerValue();
|
||||||
|
|
||||||
if ((indexProject != oldIndexerValue)
|
if ((indexProject != oldIndexerValue)
|
||||||
&& (currentProject != null)
|
&& (currentProject != null)
|
||||||
&& indexProject) {
|
&& indexProject) {
|
||||||
ICDTIndexer indexer = CCorePlugin.getDefault().getCoreModel().getIndexManager().getIndexerForProject(currentProject);
|
|
||||||
if (indexer instanceof SourceIndexer)
|
if (indexer instanceof SourceIndexer)
|
||||||
((SourceIndexer) indexer).indexAll(currentProject);
|
((SourceIndexer) indexer).indexAll(currentProject);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue