Package org.eclipse.jdt.core.search

Examples of org.eclipse.jdt.core.search.SearchEngine


    List<String> results = new ArrayList<String>();
   
    try {
      IType singleton = javaProject.findType("javax.ejb.Singleton");
     
      SearchEngine searchEngine = new SearchEngine();
      SearchPattern pattern = SearchPattern.createPattern(singleton, IJavaSearchConstants.REFERENCES);
      SearchParticipant[] participants = new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() };
      IJavaSearchScope scope = SearchEngine.createWorkspaceScope();

      SingletonBeanSearchRequestor requestor = new SingletonBeanSearchRequestor();
      searchEngine.search(pattern, participants, scope, requestor, null);

      SearchMatch[] matches = requestor.getMatches();

      for (SearchMatch searchMatch : matches) {
        IType type = (IType) searchMatch.getElement();
View Full Code Here


        final Collection col = (Collection) fit.next();
        for (final Iterator cit = col.iterator(); cit.hasNext();) {
          final IJavaElement elem = (IJavaElement) cit.next();

          // The search engine.
          final SearchEngine engine = new SearchEngine();

          // The search pattern corresponding to the entities whose
          // type must be altered.
          SearchPattern pattern = SearchPattern.createPattern(elem,
              IJavaSearchConstants.DECLARATIONS,
View Full Code Here

          }
        }
      }
    };

    final SearchEngine searchEngine = new SearchEngine();
    searchEngine.search(pattern, new SearchParticipant[] { SearchEngine
        .getDefaultSearchParticipant() }, this.scope, requestor, null);
  }
View Full Code Here

    CompareTypeSearchRequestor requestor = new CompareTypeSearchRequestor(
        (IType) method.getParent());
    SearchPattern pattern = SearchPattern.createPattern(method,
        IJavaSearchConstants.REFERENCES, GENERICS_AGNOSTIC_MATCH_RULE);
    IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
    SearchEngine searchEngine = new SearchEngine();
    searchEngine
        .search(pattern, new SearchParticipant[] { SearchEngine
            .getDefaultSearchParticipant() }, scope, requestor,
            null /* progress monitor */);

    return requestor.isCalledFromOutside();
View Full Code Here

      }
      else if (isPrimitive(expandedClassName)) {
        // ignore primitives
      }
      else {
        SearchEngine searchEngine = new SearchEngine();
        IJavaSearchScope searchScope = JavaSearchScopeFactory.getInstance().createJavaProjectSearchScope(javaProject, JavaSearchScopeFactory.ALL);
        NullProgressMonitor progressMonitor = new NullProgressMonitor();
        TypeNameCollector typeNameCollector = new TypeNameCollector(javaProject, false);
        searchEngine.searchAllTypeNames(null, SearchPattern.R_EXACT_MATCH, shortClassName.toCharArray(), IJavaSearchConstants.TYPE, IJavaSearchConstants.TYPE, searchScope, typeNameCollector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, progressMonitor);
        Set<String> typeNames = typeNameCollector.getTypeNames();
        if (typeNames.size() == 1) {
          expandedClassName = typeNames.iterator().next();
        }
        else if (typeNames.size() == 0) {
View Full Code Here

    return type;
  }

  public static void findMatchingElementClassNames(String elementTypeName, int matchType, TypeNameCollector typeNameCollector, IProgressMonitor progressMonitor) throws JavaModelException {
    if (elementTypeName != null) {
      SearchEngine searchEngine = new SearchEngine();
      //IJavaSearchScope searchScope = new WOHierarchyScope(typeNameCollector.getSuperclassType(), typeNameCollector.getProject());
      IJavaSearchScope searchScope = WOHierarchyScope.hierarchyScope(typeNameCollector.getSuperclassType(), typeNameCollector.getProject().getProject());
      int lastDotIndex = elementTypeName.lastIndexOf('.');
      char[] packageName;
      char[] typeName;
      if (lastDotIndex == -1) {
        packageName = null;
        typeName = elementTypeName.toCharArray();
      }
      else {
        packageName = elementTypeName.substring(0, lastDotIndex).toCharArray();
        typeName = elementTypeName.substring(lastDotIndex + 1).toCharArray();
      }
      searchEngine.searchAllTypeNames(packageName, SearchPattern.R_EXACT_MATCH, typeName, matchType, IJavaSearchConstants.CLASS, searchScope, typeNameCollector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, progressMonitor);
    }
  }
View Full Code Here

      manager.deltaState.initializeRoots(true/*initAfteLoad*/);

      // dummy query for waiting until the indexes are ready
      if (monitor != null)
        monitor.subTask(Messages.javamodel_configuring_searchengine);
      SearchEngine engine = new SearchEngine();
      IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
      try {
        engine.searchAllTypeNames(
          null,
          SearchPattern.R_EXACT_MATCH,
          "!@$#!@".toCharArray(), //$NON-NLS-1$
          SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
          IJavaSearchConstants.CLASS,
View Full Code Here

        if (oldContainer != null && !oldContainer.equals(containerName)) {
          onDemandConflicts.add(name);
        }
      }
    };
    new SearchEngine().searchAllTypeNames(allPackages, allTypes, scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor);
    return onDemandConflicts;
  }
View Full Code Here

    }
  }
 
  @Test
  public void learning_SearchEngine() throws Exception {
    SearchEngine engine = new SearchEngine();
    IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
    SearchPattern pattern = SearchPattern.createPattern("TestClass2", IJavaSearchConstants.CLASS, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_FULL_MATCH);
    SearchParticipant[] participants = new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()};
    SearchRequestor requestor = new SearchRequestor(){
   
      @Override
      public void acceptSearchMatch(SearchMatch match) throws CoreException {
        Object element = match.getElement();
        System.out.println(element.getClass().getName());
        System.out.println(element);
      }
    };
    engine.search(pattern, participants, scope, requestor, new NullProgressMonitor());
  }
View Full Code Here

  }

  private void waitForIndexer() throws JavaModelException {
    TypeNameRequestor nameRequestor = new TypeNameRequestor(){};
    new SearchEngine().searchAllTypeNames(
        null,
        SearchPattern.R_EXACT_MATCH,
        null,
        SearchPattern.R_EXACT_MATCH,
        IJavaSearchConstants.CLASS,
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.search.SearchEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.