From 5c3d8fdb41948b0b9be7acf9eded59d2ea88c0d8 Mon Sep 17 00:00:00 2001 From: Bogdan Gheorghe Date: Wed, 31 Mar 2004 07:57:18 +0000 Subject: [PATCH] Fix annotations in overview bar, added index IProblem markers, added new preference page for controlling external search markers --- core/org.eclipse.cdt.core/index/ChangeLog | 4 + .../core/search/indexing/SourceIndexer.java | 3 +- .../indexing/SourceIndexerRequestor.java | 102 +++++++++- .../eclipse/cdt/core/model/ICModelMarker.java | 2 + core/org.eclipse.cdt.core/plugin.properties | 2 + core/org.eclipse.cdt.core/plugin.xml | 14 ++ core/org.eclipse.cdt.ui/ChangeLog | 14 ++ core/org.eclipse.cdt.ui/plugin.properties | 2 + core/org.eclipse.cdt.ui/plugin.xml | 99 ++++++---- .../cdt/internal/ui/editor/CEditor.java | 4 +- .../ui/preferences/CEditorPreferencePage.java | 45 ++++- .../PreferencesMessages.properties | 1 + .../WorkInProgressPreferencePage.java | 181 ++++++++++++++++++ .../cdt/internal/ui/search/CSearchPage.java | 5 + .../ui/search/CSearchResultCollector.java | 70 ++++--- .../src/org/eclipse/cdt/ui/CUIPlugin.java | 4 + 16 files changed, 480 insertions(+), 72 deletions(-) create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java 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"org.eclipse.cdt.core.translation.taskTag". */ 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"> + + + + + + + + diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index ba7248d7fae..e4b2ed4790d 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,17 @@ +2004-03-31 Bogdan Gheorghe + Fixed the overview annotations in the Overview bar in the CEditor + Modified the CEditorPreferencePage to add the Index Marker annotation + Created a new Preference Page to contain the options for placing markers + on external files + Modified CSearchResultCollector to use external marker search prefs + + * src/org/eclipse/cdt/internal/ui/editor/CEditor.java + * src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java + * src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java + * src/org/eclipse/cdt/internal/ui/search/CSearchPage.java + * src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java + * plugin.xml + 2004-03-30 Bogdan Gheorghe Modified the AnnotationModel to solve all annotation refresh problems. diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index f45059c03a2..67c6ed52ca1 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -146,3 +146,5 @@ HideCFiles.description= Hides all C files HideHeaderFiles.label= Header files HideHeaderFiles.description= Hides all Header files + +WorkInProgress.name=Work In Progress \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index e5beca4553b..3d45df2fe1b 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -96,14 +96,6 @@ class="org.eclipse.cdt.internal.ui.filters.NonCElementFilter" id="org.eclipse.cdt.internal.ui.CView.NonCElementFilter"> - @@ -196,35 +188,35 @@ id="org.eclipse.cdt.ui.ceditor" point="org.eclipse.ui.editors"> @@ -293,16 +285,16 @@ @@ -313,16 +305,16 @@ @@ -352,24 +344,24 @@ @@ -410,8 +402,8 @@ @@ -470,8 +462,8 @@ @@ -483,24 +475,24 @@ pageId="org.eclipse.cdt.ui.CSearchPage" label="%ElementNameSorter.label" icon="icons/full/clcl16/search_sortmatch.gif" - tooltip="%ElementNameSorter.tooltip" class="org.eclipse.cdt.internal.ui.search.ElementNameSorter" + tooltip="%ElementNameSorter.tooltip" id="org.eclipse.cdt.search.internal.ui.ElementNameSorter"> @@ -553,16 +545,16 @@ @@ -586,6 +578,43 @@ + + + + + + + + + + + + +