Ejemplo n.º 1
0
 private boolean performNewSearch() throws CoreException {
   final SearchPatternData data = getPatternData();
   final int includeMask = getIncludeMask();
   // Setup search scope
   ErlSearchScope scope = EMPTY_SCOPE;
   String scopeDescription = null;
   final boolean searchSources = (includeMask & SearchUtil.SEARCH_IN_SOURCES) != 0;
   final boolean searchExternals = (includeMask & SearchUtil.SEARCH_IN_EXTERNALS) != 0;
   final boolean searchOtp = (includeMask & SearchUtil.SEARCH_IN_OTP_LIBRARIES) != 0;
   final int selectedScope = getContainer().getSelectedScope();
   switch (selectedScope) {
     case ISearchPageContainer.WORKSPACE_SCOPE:
       if (searchSources) {
         scope = SearchCoreUtil.getWorkspaceScope(searchExternals, searchOtp);
       }
       scopeDescription = SearchUtil.getWorkspaceScopeDescription();
       break;
     case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
       final String[] projectNames = getContainer().getSelectedProjectNames();
       if (searchSources) {
         scope =
             SearchCoreUtil.getProjectsScope(
                 SearchCoreUtil.getProjects(projectNames), searchExternals, searchOtp);
       }
       scopeDescription =
           SearchUtil.getProjectScopeDescription(SearchCoreUtil.getProjects(projectNames));
       break;
     case ISearchPageContainer.SELECTION_SCOPE:
       if (searchSources) {
         scope =
             SearchUtil.getSelectionScope(
                 getContainer().getSelection(), searchExternals, searchOtp);
       }
       scopeDescription = SearchUtil.getSelectionScopeDescription(getContainer().getSelection());
       break;
     case ISearchPageContainer.WORKING_SET_SCOPE:
       {
         final IWorkingSet[] workingSets = getContainer().getSelectedWorkingSets();
         // should not happen - just to be sure
         if (workingSets == null || workingSets.length < 1) {
           return false;
         }
         scopeDescription = SearchUtil.getWorkingSetsScopeDescription(workingSets);
         if (searchSources) {
           scope = SearchUtil.getWorkingSetsScope(workingSets, searchExternals, searchOtp);
         }
         SearchUtil.updateLRUWorkingSets(workingSets);
       }
   }
   final ErlangSearchPattern searchPattern =
       SearchUtil.getSearchPattern(
           null, data.getSearchFor(), data.getPattern(), data.getLimitTo());
   SearchUtil.runQuery(searchPattern, scope, scopeDescription, getShell());
   return true;
 }
Ejemplo n.º 2
0
 private SearchPatternData trySimpleTextSelection(final ITextSelection selection) {
   final String selectedText = selection.getText();
   if (selectedText != null && selectedText.length() > 0) {
     int i = 0;
     while (i < selectedText.length()
         && !SearchCoreUtil.isLineDelimiterChar(selectedText.charAt(i))) {
       i++;
     }
     if (i > 0) {
       final String s = selectedText.substring(0, i);
       // FIXME find the module from the editor somehow
       return new SearchPatternData(
           s,
           getContainer().getSelectedScope(),
           getLimitTo(),
           getSearchFor(),
           getContainer().getSelectedWorkingSets(),
           getLastIncludeMask());
     }
   }
   return null;
 }