diff --git a/core/org.eclipse.cdt.core/search/ChangeLog b/core/org.eclipse.cdt.core/search/ChangeLog index 38275c5cac7..6ad215b6581 100644 --- a/core/org.eclipse.cdt.core/search/ChangeLog +++ b/core/org.eclipse.cdt.core/search/ChangeLog @@ -1,3 +1,17 @@ +2004-03-24 Bogdan Gheorghe + Modified BasicSearchMatch to keep track of what files contained the match in order + to create file links to support external file markers. + + Modified MatchLocator to pass in the referring file path to BasicSearchMatch if the + match has no resource attached to it (ie. the match is external). + + * search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java + * search/org/eclipse/cdt/core/search/BasicSearchMatch.java + * search/org/eclipse/cdt/core/search/ICSearchResultCollector.java + * search/org/eclipse/cdt/core/search/IMatch.java + * search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java + + 2004-03-08 Bogdan Gheorghe BasicSearchResultCollector patch from Chris Wiebe - adds setProgressMonitor method, cleans up some of the CoreException warnings diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchMatch.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchMatch.java index f0a3421bfef..457aad5f9a8 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchMatch.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchMatch.java @@ -35,6 +35,7 @@ public class BasicSearchMatch implements IMatch, Comparable { path = basicMatch.path; startOffset = basicMatch.startOffset; endOffset = basicMatch.endOffset; + referringElement = basicMatch.referringElement; } public int hashCode(){ @@ -134,6 +135,8 @@ public class BasicSearchMatch implements IMatch, Comparable { boolean isVolatile = false; boolean isStatic = false; + public IPath referringElement = null; + public int getElementType() { return type; } @@ -165,6 +168,10 @@ public class BasicSearchMatch implements IMatch, Comparable { return path; else return null; } + + public IPath getReferenceLocation() { + return referringElement; + } public int getStartOffset() { return startOffset; diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java index 8df00fb88ca..1f981591b15 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java @@ -77,13 +77,13 @@ public class BasicSearchResultCollector implements ICSearchResultCollector { fProgressMonitor = monitor; } - public IMatch createMatch(Object fileResource, int start, int end, ISourceElementCallbackDelegate node ) + public IMatch createMatch(Object fileResource, int start, int end, ISourceElementCallbackDelegate node, IPath referringElement) { BasicSearchMatch result = new BasicSearchMatch(); - return createMatch( result, fileResource, start, end, node ); + return createMatch( result, fileResource, start, end, node, referringElement); } - public IMatch createMatch( BasicSearchMatch result, Object fileResource, int start, int end, ISourceElementCallbackDelegate node ) { + public IMatch createMatch( BasicSearchMatch result, Object fileResource, int start, int end, ISourceElementCallbackDelegate node, IPath referringElement ) { if( fileResource instanceof IResource ) result.resource = (IResource) fileResource; else if( fileResource instanceof IPath ) @@ -92,6 +92,7 @@ public class BasicSearchResultCollector implements ICSearchResultCollector { result.startOffset = start; result.endOffset = end; result.parentName = ""; //$NON-NLS-1$ + result.referringElement = referringElement; IASTOffsetableNamedElement offsetable = null; diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchResultCollector.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchResultCollector.java index e0fb0b463f9..1b4726ee66f 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchResultCollector.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchResultCollector.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.core.search; import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; /** @@ -47,7 +48,7 @@ public interface ICSearchResultCollector { public void done(); public IMatch createMatch( Object fileResource, int start, int end, - ISourceElementCallbackDelegate node ) throws CoreException; + ISourceElementCallbackDelegate node, IPath referringElement) throws CoreException; //return whether or not the match was accepted public boolean acceptMatch( IMatch match ) throws CoreException; @@ -58,15 +59,4 @@ public interface ICSearchResultCollector { * @return a progress monitor or null if no progress monitor is provided */ public IProgressMonitor getProgressMonitor(); - - - /** - * returns an IMatch object that contains any information the client cared - * to extract from the IAST node. - * Note that clients should not reference information in the node itself so - * that it can be garbage collected - * @param node - * @return - */ - //public IMatch createMatch(ISourceElementCallbackDelegate node, IASTScope parent ); } diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/IMatch.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/IMatch.java index b76e43b8ffc..b2259335aeb 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/IMatch.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/IMatch.java @@ -35,6 +35,8 @@ public interface IMatch { IResource getResource(); IPath getLocation(); + + IPath getReferenceLocation(); int getStartOffset(); diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java index 23ae942fc6e..44008b6ba6a 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java @@ -389,7 +389,7 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants Reader reader = null; - IPath realPath = null; + realPath = null; IProject project = null; if( workspaceRoot != null ){ @@ -525,11 +525,11 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants object = node; } } - + if( currentResource != null ){ - match = resultCollector.createMatch( currentResource, offset, end, object ); + match = resultCollector.createMatch( currentResource, offset, end, object, null ); } else if( currentPath != null ){ - match = resultCollector.createMatch( currentPath, offset, end, object ); + match = resultCollector.createMatch( currentPath, offset, end, object, realPath ); } if( match != null ){ //Save till later @@ -584,6 +584,7 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants private IPath currentPath = null; private ICSearchScope searchScope; private IWorkspaceRoot workspaceRoot; + private IPath realPath; private IResource currentResource = null; private LinkedList resourceStack = new LinkedList(); diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index 6f14c0985d5..1faad12f2df 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,13 @@ +2004-03-24 Bogdan Gheorghe + + Modified CSearchResultCollector to create markers on external matches. + Modified RenameRefactoringAction to get the openInclude working again (changes approved by Hoda). + Updated TypeSearchResultCollector to reflect changes made to BasicSearchResultCollector. + + * src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java + * refactor/org/eclipse/cdt/internal/ui/refactoring/actions/RenameRefactoringACtion.java + * browser/org/eclipse/cdt/ui/browser/typeinfo/AllTypesCache.java + 2004-03-23 Alain Magloire Show the objects on the IOuputEntry path should diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/AllTypesCache.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/AllTypesCache.java index e216797526e..1cc81b43f1d 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/AllTypesCache.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/AllTypesCache.java @@ -34,10 +34,12 @@ import org.eclipse.cdt.internal.ui.browser.util.ArrayUtil; import org.eclipse.cdt.internal.ui.browser.util.ProgressMonitorMultiWrapper; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.jobs.IJobManager; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.Job; @@ -98,10 +100,10 @@ public class AllTypesCache { super(monitor); } - public IMatch createMatch(Object fileResource, int start, int end, ISourceElementCallbackDelegate node ) + public IMatch createMatch(Object fileResource, int start, int end, ISourceElementCallbackDelegate node, IPath realPath ) { TypeInfo result= new TypeInfo(); - return super.createMatch( result, fileResource, start, end, node ); + return super.createMatch( result, fileResource, start, end, node, realPath); } public boolean acceptMatch(IMatch match) throws CoreException { diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/RenameRefactoringAction.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/RenameRefactoringAction.java index 432bb70a5af..6aa3d5bc137 100644 --- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/RenameRefactoringAction.java +++ b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/RenameRefactoringAction.java @@ -59,16 +59,22 @@ public class RenameRefactoringAction extends SelectionDispatchAction { try { element = SelectionConverter.getElementAtOffset(fEditor); }catch (CModelException e) { - enable = false; + setEnabled(false); } if((element == null) || (element instanceof ITranslationUnit)){ + setEnabled(false); + return; + } + ITextSelection textSelection= (ITextSelection)fEditor.getSelectionProvider().getSelection(); + + if (textSelection == null) { + setEnabled(false); + return; + } + + if( (((CElement)element).getIdStartPos() != textSelection.getOffset()) + || (((CElement)element).getIdLength() != textSelection.getLength())) { enable = false; - } else { - ITextSelection textSelection= (ITextSelection)fEditor.getSelectionProvider().getSelection(); - if( (((CElement)element).getIdStartPos() != textSelection.getOffset()) - || (((CElement)element).getIdLength() != textSelection.getLength())) { - enable = false; - } } setEnabled(enable); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java index 41afa70d1e8..afa3be82e1f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java @@ -16,13 +16,23 @@ package org.eclipse.cdt.internal.ui.search; import java.text.MessageFormat; import java.util.HashMap; +import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.search.BasicSearchMatch; import org.eclipse.cdt.core.search.BasicSearchResultCollector; import org.eclipse.cdt.core.search.IMatch; -import org.eclipse.cdt.ui.*; +import org.eclipse.cdt.ui.CSearchResultLabelProvider; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IPathVariableManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Path; import org.eclipse.search.ui.IGroupByKeyComputer; import org.eclipse.search.ui.ISearchResultView; import org.eclipse.search.ui.SearchUI; @@ -83,28 +93,60 @@ public class CSearchResultCollector extends BasicSearchResultCollector{ public boolean acceptMatch( IMatch match ) throws CoreException { BasicSearchMatch searchMatch = (BasicSearchMatch) match; - + if( !super.acceptMatch( match ) ) return false; - if( searchMatch.resource == null ) + if( searchMatch.resource == null && + searchMatch.path == null) return false; - IMarker marker = searchMatch.resource.createMarker( SearchUI.SEARCH_MARKER ); - - HashMap markerAttributes = new HashMap( 2 ); + if (searchMatch.resource != null){ + IMarker marker = searchMatch.resource.createMarker( SearchUI.SEARCH_MARKER ); - //we can hang any other info we want off the marker - markerAttributes.put( IMarker.CHAR_START, new Integer( Math.max( searchMatch.startOffset, 0 ) ) ); - markerAttributes.put( IMarker.CHAR_END, new Integer( Math.max( searchMatch.endOffset, 0 ) ) ); - markerAttributes.put( IMATCH, searchMatch ); + HashMap markerAttributes = new HashMap( 2 ); + + //we can hang any other info we want off the marker + markerAttributes.put( IMarker.CHAR_START, new Integer( Math.max( searchMatch.startOffset, 0 ) ) ); + markerAttributes.put( IMarker.CHAR_END, new Integer( Math.max( searchMatch.endOffset, 0 ) ) ); + markerAttributes.put( IMATCH, searchMatch ); - marker.setAttributes( markerAttributes ); - - if( _view != null ){ - _view.addMatch( searchMatch.name, _computer.computeGroupByKey( marker ), searchMatch.resource, marker ); - } + marker.setAttributes( markerAttributes ); + + if( _view != null ){ + _view.addMatch( searchMatch.name, _computer.computeGroupByKey( marker ), searchMatch.resource, marker ); + } + } + else { + //Create Link in referring file's project + IPath refLocation = searchMatch.getReferenceLocation(); + IFile refFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(refLocation); + IProject refProject = refFile.getProject(); + IPath externalMatchLocation = searchMatch.getLocation(); + IFile linksFile = refProject.getFile(externalMatchLocation.lastSegment()); + + //Check to see if the file already exists - create if doesn't, mark team private + if (!linksFile.exists()){ + linksFile.createLink(externalMatchLocation,IResource.NONE,null); + //linksFile.setTeamPrivateMember(true); + linksFile.setDerived(true); + } + + IMarker marker = linksFile.createMarker( SearchUI.SEARCH_MARKER ); + + HashMap markerAttributes = new HashMap( 2 ); + + markerAttributes.put( IMarker.CHAR_START, new Integer( Math.max( searchMatch.startOffset, 0 ) ) ); + markerAttributes.put( IMarker.CHAR_END, new Integer( Math.max( searchMatch.endOffset, 0 ) ) ); + markerAttributes.put( IMATCH, searchMatch ); + marker.setAttributes( markerAttributes ); + + if( _view != null ){ + _view.addMatch( searchMatch.name, _computer.computeGroupByKey( marker ), linksFile, marker ); + } + + } _matchCount++; return true;