Search in sources :

Example 11 with QualifiedName

use of org.eclipse.wst.common.core.search.pattern.QualifiedName in project webtools.sourceediting by eclipse.

the class RenameComponentProcessor method addOccurrences.

void addOccurrences(TextChangeManager manager, IProgressMonitor pm, RefactoringStatus status) throws CoreException {
    String fileStr = selectedComponent.getElement().getModel().getBaseLocation();
    IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fileStr));
    String componentName = selectedComponent.getName();
    String componentNamespace = selectedComponent.getNamespaceURI();
    QualifiedName elementQName = new QualifiedName(componentNamespace, componentName);
    QualifiedName typeQName = selectedComponent.getTypeQName();
    SearchEngine searchEngine = new SearchEngine();
    SearchScope scope = null;
    HashMap map = new HashMap();
    if (singleFileOnly) {
        map.put("searchDirtyContent", Boolean.TRUE);
        scope = new SelectionSearchScope(new IResource[] { file });
    } else {
        scope = new WorkspaceSearchScope();
    }
    SortingSearchRequestor requestor = new SortingSearchRequestor();
    SearchPattern pattern = new XMLComponentReferencePattern(file, elementQName, typeQName);
    searchEngine.search(pattern, requestor, scope, map, new NullProgressMonitor());
    references = requestor.getResults();
// for (Iterator iter = references.iterator(); iter.hasNext();) {
// SearchMatch match = (SearchMatch) iter.next();
// TextChange textChange = manager.get(match.getFile());
// String newName = getNewElementName();
// if(match.getObject() instanceof Node){
// Node node = (Node)match.getObject();
// if(node instanceof IDOMAttr){
// IDOMAttr attr = (IDOMAttr)node;
// IDOMElement element = (IDOMElement)attr.getOwnerElement() ;
// newName = getNewQName(element, componentNamespace, newName);
// }
// newName = quoteString(newName);
// }
// 
// ReplaceEdit replaceEdit = new ReplaceEdit(match.getOffset(),
// match.getLength(), newName );
// String editName =
// RefactoringMessages.getString("RenameComponentProcessor.Component_Refactoring_update_reference");
// TextChangeCompatibility.addTextEdit(textChange, editName,
// replaceEdit);
// }
}
Also used : Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) HashMap(java.util.HashMap) QualifiedName(org.eclipse.wst.common.core.search.pattern.QualifiedName) SelectionSearchScope(org.eclipse.wst.common.core.search.scope.SelectionSearchScope) XMLComponentReferencePattern(org.eclipse.wst.xml.core.internal.search.XMLComponentReferencePattern) WorkspaceSearchScope(org.eclipse.wst.common.core.search.scope.WorkspaceSearchScope) SearchEngine(org.eclipse.wst.common.core.search.SearchEngine) SearchScope(org.eclipse.wst.common.core.search.scope.SearchScope) SelectionSearchScope(org.eclipse.wst.common.core.search.scope.SelectionSearchScope) WorkspaceSearchScope(org.eclipse.wst.common.core.search.scope.WorkspaceSearchScope) SearchPattern(org.eclipse.wst.common.core.search.pattern.SearchPattern) IResource(org.eclipse.core.resources.IResource)

Aggregations

QualifiedName (org.eclipse.wst.common.core.search.pattern.QualifiedName)11 IFile (org.eclipse.core.resources.IFile)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 SearchMatch (org.eclipse.wst.common.core.search.SearchMatch)3 SearchScope (org.eclipse.wst.common.core.search.scope.SearchScope)3 WorkspaceSearchScope (org.eclipse.wst.common.core.search.scope.WorkspaceSearchScope)3 XMLComponentDeclarationPattern (org.eclipse.wst.xml.core.internal.search.XMLComponentDeclarationPattern)3 XSDSearchQuery (org.eclipse.wst.xsd.ui.internal.search.XSDSearchQuery)3 XSDNamedComponent (org.eclipse.xsd.XSDNamedComponent)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 List (java.util.List)2 IResource (org.eclipse.core.resources.IResource)2 SearchEngine (org.eclipse.wst.common.core.search.SearchEngine)2 SearchPattern (org.eclipse.wst.common.core.search.pattern.SearchPattern)2 SelectionSearchScope (org.eclipse.wst.common.core.search.scope.SelectionSearchScope)2 XMLComponentReferencePattern (org.eclipse.wst.xml.core.internal.search.XMLComponentReferencePattern)2 CoreException (org.eclipse.core.runtime.CoreException)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1