Search in sources :

Example 1 with SearchEngine

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

the class XSDAttributeSearchListProvider method populateComponentListUsingSearch.

private void populateComponentListUsingSearch(IComponentList list, SearchScope scope, IProgressMonitor pm, HashMap files) {
    SearchEngine searchEngine = new SearchEngine();
    InternalSearchRequestor requestor = new InternalSearchRequestor(list, files);
    findMatches(searchEngine, requestor, scope, IXSDSearchConstants.ATTRIBUTE_META_NAME);
}
Also used : SearchEngine(org.eclipse.wst.common.core.search.SearchEngine)

Example 2 with SearchEngine

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

the class XSDElementsSearchListProvider method populateComponentListUsingSearch.

private void populateComponentListUsingSearch(IComponentList list, SearchScope scope, IProgressMonitor pm, HashMap files) {
    SearchEngine searchEngine = new SearchEngine();
    InternalSearchRequestor requestor = new InternalSearchRequestor(list, files);
    findMatches(searchEngine, requestor, scope, IXSDSearchConstants.ELEMENT_META_NAME);
}
Also used : SearchEngine(org.eclipse.wst.common.core.search.SearchEngine)

Example 3 with SearchEngine

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

the class RenameComponentProcessor method addDeclarationUpdate.

final void addDeclarationUpdate(TextChangeManager manager, IFile file) throws CoreException {
    String componentName = selectedComponent.getName();
    String componentNamespace = selectedComponent.getNamespaceURI();
    QualifiedName elementQName = new QualifiedName(componentNamespace, componentName);
    QualifiedName typeQName = selectedComponent.getTypeQName();
    SearchScope scope = new WorkspaceSearchScope();
    if (file != null) {
        scope = new SelectionSearchScope(new IResource[] { file });
    }
    CollectingSearchRequestor requestor = new CollectingSearchRequestor();
    SearchPattern pattern = new XMLComponentDeclarationPattern(file, elementQName, typeQName);
    SearchEngine searchEngine = new SearchEngine();
    HashMap map = new HashMap();
    if (singleFileOnly) {
        map.put("searchDirtyContent", Boolean.TRUE);
    }
    searchEngine.search(pattern, requestor, scope, map, new NullProgressMonitor());
    List results = requestor.getResults();
    // more than one declaration found, so use offset as additional check
    Position offsetPosition = null;
    if (results.size() > 1) {
        IDOMElement selectedElement = selectedComponent.getElement();
        if (selectedElement != null) {
            int startOffset = selectedElement.getStartOffset();
            offsetPosition = new Position(startOffset, (selectedElement.getEndOffset() - startOffset));
        }
    }
    for (Iterator iter = results.iterator(); iter.hasNext(); ) {
        SearchMatch match = (SearchMatch) iter.next();
        if (match != null) {
            boolean addTextChange = true;
            // additional check to verify correct declaration is changed
            if (offsetPosition != null) {
                addTextChange = offsetPosition.overlapsWith(match.getOffset(), match.getLength());
            }
            if (addTextChange) {
                TextChange textChange = manager.get(match.getFile());
                String newName = getNewElementName();
                newName = quoteString(newName);
                ReplaceEdit replaceEdit = new ReplaceEdit(match.getOffset(), match.getLength(), newName);
                String editName = RefactoringMessages.getString("RenameComponentProcessor.Component_Refactoring_update_declatation");
                TextChangeCompatibility.addTextEdit(textChange, editName, replaceEdit);
            }
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SearchMatch(org.eclipse.wst.common.core.search.SearchMatch) HashMap(java.util.HashMap) Position(org.eclipse.jface.text.Position) QualifiedName(org.eclipse.wst.common.core.search.pattern.QualifiedName) SelectionSearchScope(org.eclipse.wst.common.core.search.scope.SelectionSearchScope) TextChange(org.eclipse.ltk.core.refactoring.TextChange) WorkspaceSearchScope(org.eclipse.wst.common.core.search.scope.WorkspaceSearchScope) IDOMElement(org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement) 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) Iterator(java.util.Iterator) ReplaceEdit(org.eclipse.text.edits.ReplaceEdit) ArrayList(java.util.ArrayList) List(java.util.List) CollectingSearchRequestor(org.eclipse.wst.common.core.search.util.CollectingSearchRequestor) XMLComponentDeclarationPattern(org.eclipse.wst.xml.core.internal.search.XMLComponentDeclarationPattern) IResource(org.eclipse.core.resources.IResource)

Example 4 with SearchEngine

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

the class XSDTypesSearchListProvider method populateComponentListUsingSearch.

private void populateComponentListUsingSearch(IComponentList list, SearchScope scope, IProgressMonitor pm, HashMap files) {
    SearchEngine searchEngine = new SearchEngine();
    InternalSearchRequestor requestor = new InternalSearchRequestor(list, files);
    if (showComplexTypes) {
        findMatches(searchEngine, requestor, scope, IXSDSearchConstants.COMPLEX_TYPE_META_NAME);
    }
    findMatches(searchEngine, requestor, scope, IXSDSearchConstants.SIMPLE_TYPE_META_NAME);
}
Also used : SearchEngine(org.eclipse.wst.common.core.search.SearchEngine)

Example 5 with SearchEngine

use of org.eclipse.wst.common.core.search.SearchEngine 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

SearchEngine (org.eclipse.wst.common.core.search.SearchEngine)5 HashMap (java.util.HashMap)2 IResource (org.eclipse.core.resources.IResource)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 QualifiedName (org.eclipse.wst.common.core.search.pattern.QualifiedName)2 SearchPattern (org.eclipse.wst.common.core.search.pattern.SearchPattern)2 SearchScope (org.eclipse.wst.common.core.search.scope.SearchScope)2 SelectionSearchScope (org.eclipse.wst.common.core.search.scope.SelectionSearchScope)2 WorkspaceSearchScope (org.eclipse.wst.common.core.search.scope.WorkspaceSearchScope)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 IFile (org.eclipse.core.resources.IFile)1 Path (org.eclipse.core.runtime.Path)1 Position (org.eclipse.jface.text.Position)1 TextChange (org.eclipse.ltk.core.refactoring.TextChange)1 ReplaceEdit (org.eclipse.text.edits.ReplaceEdit)1 SearchMatch (org.eclipse.wst.common.core.search.SearchMatch)1 CollectingSearchRequestor (org.eclipse.wst.common.core.search.util.CollectingSearchRequestor)1 IDOMElement (org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement)1