Examples of IndexManager


Examples of org.apache.roller.weblogger.business.search.IndexManager

    public static Test suite() {
        return new TestSuite(IndexManagerTest.class);
    }
       
    public void testSearch() throws Exception {
        IndexManager imgr = WebloggerFactory.getWeblogger().getIndexManager();

        Weblog website = new Weblog();
        website.setHandle("trekker");

        User user = new User();
        user.setUserName("nimoy");

        WeblogEntry wd1 = new WeblogEntry();           
        wd1.setId("dummy1");
        wd1.setAnchor("dummy1");
        wd1.setCreator(user);
        wd1.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        wd1.setPubTime(new Timestamp(System.currentTimeMillis()));
        wd1.setTitle("The Tholian Web");
        wd1.setWebsite(website);
        wd1.setText(
         "When the Enterprise attempts to ascertain the fate of the  "
        +"U.S.S. Defiant which vanished 3 weeks ago, the warp engines  "
        +"begin to lose power, and Spock reports strange sensor readings.");
        imgr.executeIndexOperationNow(
            new AddEntryOperation(WebloggerFactory.getWeblogger(), (IndexManagerImpl)imgr, wd1));

        WeblogEntry wd2 = new WeblogEntry();
        wd2.setId("dummy2");
        wd2.setAnchor("dummy2");
        wd2.setCreator(user);
        wd2.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        wd2.setPubTime(new Timestamp(System.currentTimeMillis()));
        wd2.setTitle("A Piece of the Action");
        wd2.setWebsite(website);
        wd2.setText(
          "The crew of the Enterprise attempts to make contact with "
          +"the inhabitants of planet Sigma Iotia II, and Uhura puts Kirk "
          +"in communication with Boss Oxmyx.");
         imgr.executeIndexOperationNow(
             new AddEntryOperation(WebloggerFactory.getWeblogger(), (IndexManagerImpl)imgr, wd2));

        Thread.sleep(1000);

        SearchOperation search = new SearchOperation(imgr);
        search.setTerm("Enterprise");
        imgr.executeIndexOperationNow(search);
        assertEquals(2, search.getResultsCount());

        SearchOperation search2 = new SearchOperation(imgr);
        search2.setTerm("Tholian");
        imgr.executeIndexOperationNow(search2);
        assertEquals(1, search2.getResultsCount());

        // Clean up
        imgr.removeEntryIndexOperation(wd1);
        imgr.removeEntryIndexOperation(wd2);

        SearchOperation search3 = new SearchOperation(imgr);
        search3.setTerm("Enterprise");
        imgr.executeIndexOperationNow(search3);
        assertEquals(0, search3.getResultsCount());
    }   
View Full Code Here

Examples of org.apache.xindice.core.indexer.IndexManager

            }
         }

         // Index Manager
         try {
            indexManager = new IndexManager(this);
            Configuration idxConfig = config.getChild(INDEXES, true);
            indexManager.setConfig(idxConfig);
         }
         catch ( Exception e ) {
            if (log.isDebugEnabled()) {
View Full Code Here

Examples of org.apache.xindice.core.indexer.IndexManager

                }
            }

            // Index Manager
            try {
                indexManager = new IndexManager(this);
                Configuration idxConfig = config.getChild(INDEXES, true);
                indexManager.setConfig(idxConfig);
            } catch (Exception e) {
                if (log.isWarnEnabled()) {
                    log.warn("ignored exception", e);
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.core.search.indexing.IndexManager

   *
   * @param indexLocation the location in the file system to the index
   * @since 3.2
   */
  public void removeIndex(IPath indexLocation){
    IndexManager manager = JavaModelManager.getJavaModelManager().getIndexManager();
    manager.removeIndexPath(indexLocation);
  }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.core.search.indexing.IndexManager

    if (file instanceof IResource) {
      containerPath = ((IResource)file).getProject().getFullPath();
    } else if (file == null) {
      containerPath = documentPath.removeLastSegments(documentPath.segmentCount()-1);
    }
    IndexManager manager = JavaModelManager.getJavaModelManager().getIndexManager();
    // TODO (frederic) should not have to create index manually, should expose API that recreates index instead
    manager.ensureIndexExists(indexLocation, containerPath);
    manager.scheduleDocumentIndexing(document, containerPath, indexLocation, this);
  }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.core.search.indexing.IndexManager

  /**
   * Constructs a new JavaModelManager
   */
  private JavaModelManager() {
    // singleton: prevent others from creating a new instance
    if (Platform.isRunning()) this.indexManager = new IndexManager();
  }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.core.search.indexing.IndexManager

      // will need delta since this save (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658)
      context.needDelta();
     
      // clean up indexes on workspace full save
      // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=52347)
      IndexManager manager = this.indexManager;
      if (manager != null
          // don't force initialization of workspace scope as we could be shutting down
          // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=93941)
          && this.workspaceScope != null) {
        manager.cleanUpIndexes();
      }
    }
 
    IProject savedProject = context.getProject();
    if (savedProject != null) {
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.core.search.indexing.IndexManager

  /* embed constructs inside arrays so as to pass them to (inner) collector */
  final Queue queue = new Queue();
  final HashtableOfObject foundSuperNames = new HashtableOfObject(5);

  IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager();

  /* use a special collector to collect paths and queue new subtype names */
  IndexQueryRequestor searchRequestor = new IndexQueryRequestor() {
    public boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access) {
      SuperTypeReferencePattern record = (SuperTypeReferencePattern)indexRecord;
      boolean isLocalOrAnonymous = record.enclosingTypeName == IIndexConstants.ONE_ZERO;
      pathRequestor.acceptPath(documentPath, isLocalOrAnonymous);
      char[] typeName = record.simpleName;
      int suffix = documentPath.toLowerCase().lastIndexOf(SUFFIX_STRING_class);
      if (suffix != -1){
        HierarchyBinaryType binaryType = (HierarchyBinaryType)binariesFromIndexMatches.get(documentPath);
        if (binaryType == null){
          char[] enclosingTypeName = record.enclosingTypeName;
          if (isLocalOrAnonymous) {
            int lastSlash = documentPath.lastIndexOf('/');
            int lastDollar = documentPath.lastIndexOf('$');
            if (lastDollar == -1) {
              // malformed local or anonymous type: it doesn't contain a $ in its name
              // treat it as a top level type
              enclosingTypeName = null;
              typeName = documentPath.substring(lastSlash+1, suffix).toCharArray();
            } else {
              enclosingTypeName = documentPath.substring(lastSlash+1, lastDollar).toCharArray();
              typeName = documentPath.substring(lastDollar+1, suffix).toCharArray();
            }
          }
          binaryType = new HierarchyBinaryType(record.modifiers, record.pkgName, typeName, enclosingTypeName, record.typeParameterSignatures, record.classOrInterface);
          binariesFromIndexMatches.put(documentPath, binaryType);
        }
        binaryType.recordSuperType(record.superSimpleName, record.superQualification, record.superClassOrInterface);
      }
      if (!isLocalOrAnonymous // local or anonymous types cannot have subtypes outside the cu that define them
          && !foundSuperNames.containsKey(typeName)){
        foundSuperNames.put(typeName, typeName);
        queue.add(typeName);
      }
      return true;
    }   
  };

  int superRefKind;
  try {
    superRefKind = type.isClass() ? SuperTypeReferencePattern.ONLY_SUPER_CLASSES : SuperTypeReferencePattern.ALL_SUPER_TYPES;
  } catch (JavaModelException e) {
    superRefKind = SuperTypeReferencePattern.ALL_SUPER_TYPES;
  }
  SuperTypeReferencePattern pattern =
    new SuperTypeReferencePattern(null, null, superRefKind, SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE);
  MatchLocator.setFocus(pattern, type);
  SubTypeSearchJob job = new SubTypeSearchJob(
    pattern,
    new JavaSearchParticipant(), // java search only
    scope,
    searchRequestor);

  int ticks = 0;
  queue.add(type.getElementName().toCharArray());
  try {
    while (queue.start <= queue.end) {
      if (progressMonitor != null && progressMonitor.isCanceled()) return;

      // all subclasses of OBJECT are actually all types
      char[] currentTypeName = queue.retrieve();
      if (CharOperation.equals(currentTypeName, IIndexConstants.OBJECT))
        currentTypeName = null;

      // search all index references to a given supertype
      pattern.superSimpleName = currentTypeName;
      indexManager.performConcurrentJob(job, waitingPolicy, progressMonitor == null ? null : new NullProgressMonitor() {
        // don't report progress since this is too costly for deep hierarchies
        // just handle isCanceled() (seehttps://bugs.eclipse.org/bugs/show_bug.cgi?id=179511)
        public void setCanceled(boolean value) {
          progressMonitor.setCanceled(value);
        }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.core.search.indexing.IndexManager

protected String[] getPathsOfDeclaringType() {
  if (this.typeQualification == null && this.typeSimpleName == null) return null;

  final PathCollector pathCollector = new PathCollector();
  IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
  IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager();
  SearchPattern searchPattern = new TypeDeclarationPattern(
    this.typeSimpleName != null ? null : this.typeQualification, // use the qualification only if no simple name
    null, // do find member types
    this.typeSimpleName,
    IIndexConstants.TYPE_SUFFIX,
    this.pattern.getMatchRule());
  IndexQueryRequestor searchRequestor = new IndexQueryRequestor(){
    public boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access) {
      TypeDeclarationPattern record = (TypeDeclarationPattern)indexRecord;
      if (record.enclosingTypeNames != IIndexConstants.ONE_ZERO_CHAR) {  // filter out local and anonymous classes
        pathCollector.acceptIndexMatch(documentPath, indexRecord, participant, access);
      }
      return true;
    }   
  };   

  indexManager.performConcurrentJob(
    new PatternSearchJob(
      searchPattern,
      new JavaSearchParticipant(),
      scope,
      searchRequestor),
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.core.search.indexing.IndexManager

      // project doesn't exist
      return;
    }
   
    JavaModelManager manager = JavaModelManager.getJavaModelManager();
    IndexManager indexManager = manager.indexManager;
    if (indexManager == null)
      return;
    DeltaProcessingState state = manager.deltaState;

    int newLength = newResolvedClasspath.length;
    int oldLength = this.oldResolvedClasspath.length;   
    for (int i = 0; i < oldLength; i++) {
      int index = classpathContains(newResolvedClasspath, this.oldResolvedClasspath[i]);
      if (index == -1) {
        // remote projects are not indexed in this project
        if (this.oldResolvedClasspath[i].getEntryKind() == IClasspathEntry.CPE_PROJECT){
          continue;
        }

        // Remove the .java files from the index for a source folder
        // For a lib folder or a .jar file, remove the corresponding index if not shared.
        IClasspathEntry oldEntry = this.oldResolvedClasspath[i];
        final IPath path = oldEntry.getPath();
        int changeKind = this.oldResolvedClasspath[i].getEntryKind();
        switch (changeKind) {
          case IClasspathEntry.CPE_SOURCE:
            char[][] inclusionPatterns = ((ClasspathEntry)oldEntry).fullInclusionPatternChars();
            char[][] exclusionPatterns = ((ClasspathEntry)oldEntry).fullExclusionPatternChars();
            indexManager.removeSourceFolderFromIndex(this.project, path, inclusionPatterns, exclusionPatterns);
            break;
          case IClasspathEntry.CPE_LIBRARY:
            if (state.otherRoots.get(path) == null) { // if root was not shared
              indexManager.discardJobs(path.toString());
              indexManager.removeIndex(path);
              // TODO (kent) we could just remove the in-memory index and have the indexing check for timestamps
            }
            break;
        }
      }
    }

    for (int i = 0; i < newLength; i++) {
      int index = classpathContains(this.oldResolvedClasspath, newResolvedClasspath[i]);
      if (index == -1) {
        // remote projects are not indexed in this project
        if (newResolvedClasspath[i].getEntryKind() == IClasspathEntry.CPE_PROJECT){
          continue;
        }
       
        // Request indexing
        int entryKind = newResolvedClasspath[i].getEntryKind();
        switch (entryKind) {
          case IClasspathEntry.CPE_LIBRARY:
            boolean pathHasChanged = true;
            IPath newPath = newResolvedClasspath[i].getPath();
            for (int j = 0; j < oldLength; j++) {
              IClasspathEntry oldEntry = this.oldResolvedClasspath[j];
              if (oldEntry.getPath().equals(newPath)) {
                pathHasChanged = false;
                break;
              }
            }
            if (pathHasChanged) {
              indexManager.indexLibrary(newPath, this.project.getProject());
            }
            break;
          case IClasspathEntry.CPE_SOURCE:
            IClasspathEntry entry = newResolvedClasspath[i];
            IPath path = entry.getPath();
            char[][] inclusionPatterns = ((ClasspathEntry)entry).fullInclusionPatternChars();
            char[][] exclusionPatterns = ((ClasspathEntry)entry).fullExclusionPatternChars();
            indexManager.indexSourceFolder(this.project, path, inclusionPatterns, exclusionPatterns);
            break;
        }
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.