org.eclipse.search.ui.text.FileTextSearchScope Java Examples

The following examples show how to use org.eclipse.search.ui.text.FileTextSearchScope. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GoSearchPage.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
public FileTextSearchScope createTextSearchScope() {
  // Setup search scope
  switch (getContainer().getSelectedScope()) {
    case ISearchPageContainer.WORKSPACE_SCOPE:
      return FileTextSearchScope.newWorkspaceScope(getExtensions(), false);
    case ISearchPageContainer.SELECTION_SCOPE:
      return getSelectedResourcesScope();
    case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
      return getEnclosingProjectScope();
    case ISearchPageContainer.WORKING_SET_SCOPE:
      IWorkingSet[] workingSets = getContainer().getSelectedWorkingSets();
      return FileTextSearchScope.newSearchScope(workingSets, getExtensions(), false);
    default:
      // unknown scope
      return FileTextSearchScope.newWorkspaceScope(getExtensions(), false);
  }
}
 
Example #2
Source File: ModulaSearchPage.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
public FileTextSearchScope createTextSearchScope() {
    // Setup search scope
    switch (container.getSelectedScope()) {
        case ISearchPageContainer.WORKSPACE_SCOPE:
            return FileTextSearchScope.newWorkspaceScope(new String[]{"*"}, false); //$NON-NLS-1$
        case ISearchPageContainer.SELECTION_SCOPE:
            return getSelectedResourcesScope();
        case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
            return getEnclosingProjectScope();
        case ISearchPageContainer.WORKING_SET_SCOPE:
            IWorkingSet[] workingSets= container.getSelectedWorkingSets();
            return FileTextSearchScope.newSearchScope(workingSets, new String[]{"*"}, false); //$NON-NLS-1$
        default:
            // unknown scope
            return FileTextSearchScope.newWorkspaceScope(new String[]{"*"}, false); //$NON-NLS-1$
    }
}
 
Example #3
Source File: TagsSearchHandler.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Set up the search object
 * 
 * @param searchStr
 * @param scope
 * @return
 */
private TextSearchInput getTextInput(final String searchStr, final boolean caseSensitive, final FileTextSearchScope scope) {
	return new TextSearchInput() {

		public String getSearchText() {
			return searchStr;
		}

		public boolean isCaseSensitiveSearch() {
			return caseSensitive;
		}

		public boolean isRegExSearch() {
			return true;
		}

		public FileTextSearchScope getScope() {
			return scope;
		}
	};
}
 
Example #4
Source File: OccurHandler.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected FileTextSearchScope getInputObject(ITextEditor editor) {
	// TODO Auto-generated method stub
	IResource file = getCurrentResource(editor);
	if (file != null) {
		return FileTextSearchScope.newSearchScope(new IResource[]{file}, new String[]{((IFile)file).getName()}, false);
	} else {
		return super.getInputObject(editor);
	}
}
 
Example #5
Source File: GoSearchPage.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
private FileTextSearchScope getEnclosingProjectScope() {
  String[] enclosingProjectName = getContainer().getSelectedProjectNames();
  if (enclosingProjectName == null) {
    return FileTextSearchScope.newWorkspaceScope(getExtensions(), false);
  }

  IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
  IResource[] res = new IResource[enclosingProjectName.length];
  for (int i = 0; i < res.length; i++) {
    res[i] = root.getProject(enclosingProjectName[i]);
  }

  return FileTextSearchScope.newSearchScope(res, getExtensions(), false);
}
 
Example #6
Source File: GoSearchPage.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public TextSearchPageInput(String searchText, boolean isCaseSensitive, boolean isRegEx,
    FileTextSearchScope scope) {
  fSearchText = searchText;
  fIsCaseSensitive = isCaseSensitive;
  fIsRegEx = isRegEx;
  fScope = scope;
}
 
Example #7
Source File: AbstractPythonSearchQuery.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public AbstractPythonSearchQuery(String searchText, boolean isRegEx, boolean isCaseSensitive, boolean isWholeWord,
        FileTextSearchScope scope) {
    fSearchText = searchText;
    fIsRegEx = isRegEx;
    fIsCaseSensitive = isCaseSensitive;
    fIsWholeWord = isWholeWord;
    fScope = scope;
}
 
Example #8
Source File: TagsSetHandler.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Set up working set scope, if present, else workspace
 * 
 * @see com.mulgasoft.emacsplus.commands.TagsSearchHandler#getInputObject(org.eclipse.ui.texteditor.ITextEditor)
 */
protected FileTextSearchScope getInputObject(ITextEditor editor) {
	IWorkingSet set = (wset != null ? wset : getWorkingSet(editor));
	if (set != null) {
		return FileTextSearchScope.newSearchScope(new IWorkingSet[] { set }, new String[0], false);			
	} else {
		return super.getInputObject(editor);
	}
}
 
Example #9
Source File: TagsProjectHandler.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Set up project search scope
 * 
 * @see com.mulgasoft.emacsplus.commands.TagsSearchHandler#getInputObject(org.eclipse.ui.texteditor.ITextEditor)
 */
protected FileTextSearchScope getInputObject(ITextEditor editor) {
	IProject project= getCurrentProject(editor);
	if (project != null) {
		return FileTextSearchScope.newSearchScope(new IProject[] { project }, new String[0], false);			
	} else {
		return super.getInputObject(editor);
	}
}
 
Example #10
Source File: FindHelper.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private static void performFind(final String searchText, final boolean caseSensitive, final boolean isRegEx,
		final FileTextSearchScope searchScope)
{
	try
	{
		ISearchQuery query = TextSearchQueryProvider.getPreferred().createQuery(new TextSearchInput()
		{

			public boolean isRegExSearch()
			{
				return isRegEx;
			}

			public boolean isCaseSensitiveSearch()
			{
				return caseSensitive;
			}

			public String getSearchText()
			{
				return searchText;
			}

			public FileTextSearchScope getScope()
			{
				return searchScope; //$NON-NLS-1$
			}
		});
		NewSearchUI.runQueryInBackground(query);
	}
	catch (CoreException e1)
	{
		FindBarPlugin.log(e1);
	}
}
 
Example #11
Source File: FindHelper.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * The active editor's project is used as the search scope
 */
public static void findInWorkspace(final String searchText, final boolean caseSensitive, final boolean wholeWord,
		final boolean isRegEx, IStatusLineManager statusLineManager)
{
	if (getActivePage(statusLineManager) == null)
	{
		return;
	}

	performFind(searchText, caseSensitive, isRegEx, FileTextSearchScope.newSearchScope(
			new IResource[] { ResourcesPlugin.getWorkspace().getRoot() }, new String[] { "*" }, true)); //$NON-NLS-1$
}
 
Example #12
Source File: SearchWholeWordAction.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void run(IAction action) {
   	final String pattern = getPattern();
   	if (pattern.isEmpty()) {
   		return;
   	}
       
       try {
       	ISearchQuery query = TextSearchQueryProvider.getPreferred().createQuery(new TextSearchInput() {
			
			@Override
			public boolean isRegExSearch() {
				return true;
			}
			
			@Override
			public boolean isCaseSensitiveSearch() {
				return true;
			}
			
			@Override
			public String getSearchText() {
				return pattern;
			}
			
			@Override
			public FileTextSearchScope getScope() {
				return SearchWholeWordAction.this.getScope(); //$NON-NLS-1$
			}
		});
       	NewSearchUI.runQueryInBackground(query);
	} catch (CoreException e) {
		e.printStackTrace();
	}
       
	return;
}
 
Example #13
Source File: ModulaSearchPage.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private FileTextSearchScope getEnclosingProjectScope() {
    String[] enclosingProjectName= container.getSelectedProjectNames();
    if (enclosingProjectName == null) {
        return FileTextSearchScope.newWorkspaceScope(new String[]{"*"}, false); //$NON-NLS-1$
    }

    IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
    IResource[] res= new IResource[enclosingProjectName.length];
    for (int i= 0; i < res.length; i++) {
        res[i]= root.getProject(enclosingProjectName[i]);
    }

    return FileTextSearchScope.newSearchScope(res, new String[]{"*"}, false); //$NON-NLS-1$
}
 
Example #14
Source File: SearchWholeWordInProjectAction.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public FileTextSearchScope getScope() {
	IFile activeIFile = WorkbenchUtils.getActiveFile();
	if (activeIFile != null) {
		return FileTextSearchScope.newSearchScope(
				new IResource[] { activeIFile.getProject() },
				new String[] { "*.*" }, false); //$NON-NLS-1$
	}
	else{
		return FileTextSearchScope.newWorkspaceScope(new String[]{"*.*"}, false); //$NON-NLS-1$
	}
}
 
Example #15
Source File: FindAction.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private ModulaSearchInput getInput(IModulaSymbol symbol, IResource searchScope) {
	ModulaSearchInput m2SearchInput = new ModulaSearchInput(searchScope.getProject());
	m2SearchInput.setCaseSensitive(false);
	m2SearchInput.setLimitTo(getLimitTo());
	m2SearchInput.setSearchFor(ModulaSearchInput.SEARCH_FOR_ANY_ELEMENT);
	m2SearchInput.setSearchInFlags(ModulaSearchInput.SEARCH_IN_ALL_SOURCES);
	m2SearchInput.setSearchScope(FileTextSearchScope.newSearchScope(new IResource[]{searchScope}, new String[]{"*"}, false)); //$NON-NLS-1$
	m2SearchInput.setSymbolToSearchFor(symbol);
	m2SearchInput.setSearchString(symbol.getName());
	return m2SearchInput;
}
 
Example #16
Source File: SearchWholeWordInWorkspaceAction.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public FileTextSearchScope getScope() {
	return FileTextSearchScope.newWorkspaceScope(new String[]{"*.*"}, false); //$NON-NLS-1$
}
 
Example #17
Source File: ModulaSearchInput.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public FileTextSearchScope getSearchScope() {
    return searchScope;
}
 
Example #18
Source File: AbstractPythonSearchQuery.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
public FileTextSearchScope getSearchScope() {
    return fScope;
}
 
Example #19
Source File: FindInOpenDocuments.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Here, all the editors available will be gotten and searched (if possible).
 *
 * Note that editors that are not in the workspace may not be searched (it should be possible
 * to do, but one may have to reimplement large portions of the search for that to work).
 */
public static void findInOpenDocuments(final String searchText, final boolean caseSensitive,
        final boolean wholeWord, final boolean isRegEx, IStatusLineManager statusLineManager) {

    final List<Object> opened = EditorUtils.getFilesInOpenEditors(statusLineManager);
    final List<IFile> files = new ArrayList<>(opened.size());
    for (Object object : opened) {
        if (object instanceof IFile) {
            files.add((IFile) object);
        }
    }

    if (files.size() == 0) {
        if (statusLineManager != null) {
            statusLineManager
                    .setMessage(
                            "No file was found to perform the search (editors not in the workspace cannot be searched).");
        }
        return;
    }

    try {
        ISearchQuery query = TextSearchQueryProvider.getPreferred().createQuery(new TextSearchInput() {

            @Override
            public boolean isRegExSearch() {
                return isRegEx;
            }

            @Override
            public boolean isCaseSensitiveSearch() {
                return caseSensitive;
            }

            @Override
            public String getSearchText() {
                return searchText;
            }

            @Override
            public FileTextSearchScope getScope() {
                return FileTextSearchScope.newSearchScope(files.toArray(new IResource[files.size()]),
                        new String[] { "*" }, true);
            }
        });
        NewSearchUI.runQueryInBackground(query);
    } catch (CoreException e1) {
        Log.log(e1);
    }
}
 
Example #20
Source File: RenameRefactoringProcessor.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
protected RefactoringStatus findMatches(IProgressMonitor monitor,
		CheckConditionsContext context) {
	ifile2SymbolMatches.clear();
	
	
	IModulaSymbol symbol = renameRefactoringInfo.getSymbolFromSelection();
	IFile activeIFile = renameRefactoringInfo.getActiveIFile();
	
	if (symbol.isAttributeSet(SymbolAttribute.ALREADY_DEFINED)) {
		if (symbol instanceof IBlockSymbolTextBinding) {
			IBlockSymbolTextBinding binding = (IBlockSymbolTextBinding) symbol;
			Collection<ITextRegion> nameTextRegions = binding.getNameTextRegions();
			for (ITextRegion textRegion : nameTextRegions) {
				putMatchIfAbsent(new ModulaSymbolMatch(activeIFile, symbol, new TextPosition(-1, -1, textRegion.getOffset())));
			}
		}
		else {
			putMatchIfAbsent(new ModulaSymbolMatch(activeIFile, symbol, symbol.getPosition()));
		}
	}
	else {
		SymbolModelManager.instance().waitUntilModelIsUpToDate();
		ModulaSearchInput m2SearchInput = new ModulaSearchInput(ResourceUtils.getProject(activeIFile));
		m2SearchInput.setLimitTo(ModulaSearchInput.LIMIT_TO_USAGES | ModulaSearchInput.LIMIT_TO_DECLARATIONS);
		m2SearchInput.setSearchFor(ModulaSearchInput.SEARCH_FOR_ANY_ELEMENT);
		m2SearchInput.setSearchInFlags(ModulaSearchInput.SEARCH_IN_ALL_SOURCES);
		m2SearchInput.setSearchModifiers(ModulaSearchInput.MODIFIER_ALL_NAME_OCCURENCES);
		IProject project = renameRefactoringInfo.getProject();
		m2SearchInput.setSearchScope(FileTextSearchScope.newSearchScope(new IResource[]{project}, new String[]{"*"}, false)); //$NON-NLS-1$
		m2SearchInput.setSearchFor(ModulaSearchUtils.getSearchForConstant(symbol));
		Set<String> symbolQualifiedNames = ModulaSearchUtils.getSymbolQualifiedNames(symbol);
		m2SearchInput.setSymbolQualifiedNames(symbolQualifiedNames);
		
		ISearchResultCollector searchResultCollector = new ISearchResultCollector() {
			@Override
			public void accept(Object objMatch) {
				if (objMatch instanceof ModulaSymbolMatch) {
					ModulaSymbolMatch match = (ModulaSymbolMatch)objMatch;
					putMatchIfAbsent(match);
				}
			}
		};
		ModulaSearchOperation op = new ModulaSearchOperation(m2SearchInput, searchResultCollector);
		MultiStatus status = new MultiStatus(CoreRefactoringPlugin.PLUGIN_ID, IStatus.OK, Messages.RenameRefactoringProcessor_ErrorWhileComputingLocationsToRename, null);
		op.execute(monitor, status);
		
		SymbolModelManager.instance().waitUntilModelIsUpToDate();
		
		if (ifile2SymbolMatches.keySet().size() > 0) {
			IConditionChecker checker = context.getChecker( ValidateEditChecker.class );
			ValidateEditChecker editChecker = ( ValidateEditChecker )checker;
			editChecker.addFiles( ifile2SymbolMatches.keySet().toArray(new IFile[0]) );
		}
		
		monitor.done();
	}
	
	return new RefactoringStatus();
}
 
Example #21
Source File: GoSearchPage.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public FileTextSearchScope getScope() {
  return fScope;
}
 
Example #22
Source File: ModulaSearchInput.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public void setSearchScope(FileTextSearchScope scope) {
    searchScope = scope;
}
 
Example #23
Source File: TagsSearchHandler.java    From e4macs with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Search workspace by default
 * 
 * @param editor
 * @return a workspace scope object
 */
protected FileTextSearchScope getInputObject(ITextEditor editor) {
	return FileTextSearchScope.newWorkspaceScope(new String[0], false);
}
 
Example #24
Source File: SearchWholeWordAction.java    From xds-ide with Eclipse Public License 1.0 votes vote down vote up
public abstract FileTextSearchScope getScope();