Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdan Gheorghe2004-03-31 07:57:18 +0000
committerBogdan Gheorghe2004-03-31 07:57:18 +0000
commit5c3d8fdb41948b0b9be7acf9eded59d2ea88c0d8 (patch)
treefcd945d717e94748f165c8ae71f9703c7905d679 /core/org.eclipse.cdt.core
parent5cfae571a109b24d6837d75b3c63dd39058a055f (diff)
downloadorg.eclipse.cdt-5c3d8fdb41948b0b9be7acf9eded59d2ea88c0d8.tar.gz
org.eclipse.cdt-5c3d8fdb41948b0b9be7acf9eded59d2ea88c0d8.tar.xz
org.eclipse.cdt-5c3d8fdb41948b0b9be7acf9eded59d2ea88c0d8.zip
Fix annotations in overview bar, added index IProblem markers, added new preference page for controlling external search markers
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/index/ChangeLog4
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java3
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java102
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICModelMarker.java2
-rw-r--r--core/org.eclipse.cdt.core/plugin.properties2
-rw-r--r--core/org.eclipse.cdt.core/plugin.xml14
6 files changed, 122 insertions, 5 deletions
diff --git a/core/org.eclipse.cdt.core/index/ChangeLog b/core/org.eclipse.cdt.core/index/ChangeLog
index 36b42a21696..0b155241b46 100644
--- a/core/org.eclipse.cdt.core/index/ChangeLog
+++ b/core/org.eclipse.cdt.core/index/ChangeLog
@@ -1,3 +1,7 @@
+2004-03-31 Bogdan Gheorghe
+ Modified SourceIndexer and SourceIndexerRequestor to place IProblem markers
+ on resources.
+
2004-03-15 Andrew Niefer
updated SourceIndexerRequestor with acceptTemplateParameterReference
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
index 52d33aa1cb3..a4c529e3264 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
@@ -73,7 +73,8 @@ public class SourceIndexer extends AbstractIndexer {
// Add the name of the file to the index
output.addDocument(document);
// Create a new Parser
- SourceIndexerRequestor requestor = new SourceIndexerRequestor(this, document);
+ SourceIndexerRequestor requestor = new SourceIndexerRequestor(this, resourceFile);
+ requestor.removeMarkers(resourceFile);
//Get the scanner info
IProject currentProject = resourceFile.getProject();
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
index a37674d0a36..b490bf3008b 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
@@ -18,6 +18,8 @@ package org.eclipse.cdt.internal.core.search.indexing;
import java.io.Reader;
import java.util.LinkedList;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.parser.DefaultProblemHandler;
import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
@@ -58,7 +60,12 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
-import org.eclipse.cdt.internal.core.index.IDocument;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
/**
* @author bgheorgh
@@ -69,7 +76,7 @@ import org.eclipse.cdt.internal.core.index.IDocument;
public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexConstants {
SourceIndexer indexer;
- IDocument document;
+ IFile resourceFile;
char[] packageName;
char[][] enclosingTypeNames = new char[5][];
@@ -79,15 +86,39 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
private IASTInclusion currentInclude = null;
private LinkedList includeStack = new LinkedList();
- public SourceIndexerRequestor(SourceIndexer indexer, IDocument document) {
+ public SourceIndexerRequestor(SourceIndexer indexer, IFile resourceFile) {
super();
this.indexer = indexer;
- this.document= document;
+ this.resourceFile = resourceFile;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
*/
public boolean acceptProblem(IProblem problem) {
+
+ IASTInclusion include = peekInclude();
+ IFile tempFile = resourceFile;
+ int lineNumber = problem.getSourceLineNumber();
+
+ //If we are in an include file, get the include file
+ if (include != null){
+
+ IPath newPath = new Path(include.getFullFileName());
+ IPath problemPath = new Path(new String(problem.getOriginatingFileName()));
+
+
+ tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(newPath);
+ //Needed for external files
+ if (tempFile == null)
+ tempFile = resourceFile;
+
+ if (!newPath.equals(problemPath)){
+ lineNumber = include.getStartingLine();
+ }
+ }
+
+ addMarkers(tempFile,problem, lineNumber);
+
return DefaultProblemHandler.ruleOnProblem( problem, ParserMode.COMPLETE_PARSE );
}
@@ -188,6 +219,15 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
*/
public void enterInclusion(IASTInclusion inclusion) {
// TODO Auto-generated method stub
+ IPath newPath = new Path(inclusion.getFullFileName());
+ IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(newPath);
+ if (tempFile !=null){
+ removeMarkers(tempFile);
+ }
+ else{
+ //File is out of workspace
+
+ }
IASTInclusion parent = peekInclude();
indexer.addInclude(inclusion, parent);
@@ -491,6 +531,59 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
public Reader createReader(String finalPath) {
return ParserUtil.createReader(finalPath);
}
+
+ /**
+ *
+ */
+ public void removeMarkers(IFile resource) {
+ int depth = IResource.DEPTH_INFINITE;
+ try {
+ resource.deleteMarkers(ICModelMarker.INDEXER_MARKER, true, depth);
+ } catch (CoreException e) {
+ // something went wrong
+ }
+
+ }
+
+ private void addMarkers(IFile tempFile, IProblem problem, int lineNumber){
+ try {
+ IMarker[] markers = tempFile.findMarkers(ICModelMarker.INDEXER_MARKER, true,IResource.DEPTH_INFINITE);
+
+ 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.intValue()==problem.getSourceLineNumber() &&
+ tempMsgString.equals(problem.getMessage())){
+ newProblem = false;
+ break;
+ }
+ }
+ }
+
+ if (newProblem){
+ IMarker marker = tempFile.createMarker(ICModelMarker.INDEXER_MARKER);
+
+ marker.setAttribute(IMarker.LOCATION, problem.getSourceLineNumber());
+ marker.setAttribute(IMarker.MESSAGE, /*"Resource File: " + resourceFile.getName() + " - " +*/ problem.getMessage());
+ marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
+ marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
+ marker.setAttribute(IMarker.CHAR_START,-1);
+ marker.setAttribute(IMarker.CHAR_END, -1);
+ }
+
+ } catch (CoreException e) {
+ // You need to handle the cases where attribute value is rejected
+ }
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#parserTimeout()
*/
@@ -498,4 +591,5 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
// TODO Auto-generated method stub
return false;
}
+
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICModelMarker.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICModelMarker.java
index 11d8fe88c22..9013059705a 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICModelMarker.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICModelMarker.java
@@ -39,6 +39,8 @@ public interface ICModelMarker {
* option <code>"org.eclipse.cdt.core.translation.taskTag"</code>.
*/
public static final String TASK_MARKER = CCorePlugin.PLUGIN_ID + ".task"; //$NON-NLS-1$
+
+ public static final String INDEXER_MARKER = CCorePlugin.PLUGIN_ID + ".indexermarker"; //$NON-NLS-1$
}
diff --git a/core/org.eclipse.cdt.core/plugin.properties b/core/org.eclipse.cdt.core/plugin.properties
index bec5ed9bb8c..8f49c510116 100644
--- a/core/org.eclipse.cdt.core/plugin.properties
+++ b/core/org.eclipse.cdt.core/plugin.properties
@@ -13,6 +13,8 @@ ErrorParser.name=Error Parser
CTaskName=C/C++ Task
+IndexerMarker=Indexer Marker
+
ElfParser.name=Elf Parser
GNUElfParser.name=GNU Elf Parser
PEWindowsParser.name=PE Windows Parser
diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml
index cb41df5a023..76653bc99e9 100644
--- a/core/org.eclipse.cdt.core/plugin.xml
+++ b/core/org.eclipse.cdt.core/plugin.xml
@@ -268,5 +268,19 @@
value="true">
</persistent>
</extension>
+ <extension
+ id="indexermarker"
+ name="%IndexerMarker"
+ point="org.eclipse.core.resources.markers">
+ <super
+ type="org.eclipse.core.resources.problemmarker">
+ </super>
+ <persistent
+ value="true">
+ </persistent>
+ <super
+ type="org.eclipse.core.resources.textmarker">
+ </super>
+ </extension>
</plugin>

Back to the top