Example usage for org.eclipse.jdt.internal.core.index EntryResult getWord

List of usage examples for org.eclipse.jdt.internal.core.index EntryResult getWord

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.index EntryResult getWord.

Prototype

public char[] getWord() 

Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.core.search.SearchPattern.java

License:Open Source License

/**
 * Query a given index for matching entries. Assumes the sender has opened the index and will close when finished.
 *
 * @noreference This method is not intended to be referenced by clients.
 * @nooverride This method is not intended to be re-implemented or extended by clients.
 *//*  w  ww .  j  av  a2  s .com*/
public void findIndexMatches(Index index, IndexQueryRequestor requestor, SearchParticipant participant,
        IJavaSearchScope scope, IProgressMonitor monitor) throws IOException {
    if (monitor != null && monitor.isCanceled())
        throw new OperationCanceledException();
    try {
        index.startQuery();
        SearchPattern pattern = currentPattern();
        EntryResult[] entries = pattern.queryIn(index);
        if (entries == null)
            return;

        SearchPattern decodedResult = pattern.getBlankPattern();
        String containerPath = index.containerPath;
        char separator = index.separator;
        for (int i = 0, l = entries.length; i < l; i++) {
            if (monitor != null && monitor.isCanceled())
                throw new OperationCanceledException();

            EntryResult entry = entries[i];
            decodedResult.decodeIndexKey(entry.getWord());
            if (pattern.matchesDecodedKey(decodedResult)) {
                // TODO (kent) some clients may not need the document names
                String[] names = entry.getDocumentNames(index);
                for (int j = 0, n = names.length; j < n; j++)
                    acceptMatch(names[j], containerPath, separator, decodedResult, requestor, participant,
                            scope, monitor);
            }
        }
    } finally {
        index.stopQuery();
    }
}

From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.IntersectingPattern.java

License:Open Source License

public void findIndexMatches(Index index, IndexQueryRequestor requestor, SearchParticipant participant,
        IJavaSearchScope scope, IProgressMonitor progressMonitor) throws IOException {
    if (progressMonitor != null && progressMonitor.isCanceled())
        throw new OperationCanceledException();

    resetQuery();/*  w  w  w . java2s  .  c o  m*/
    SimpleSet intersectedNames = null;
    try {
        index.startQuery();
        do {
            SearchPattern pattern = currentPattern();
            EntryResult[] entries = pattern.queryIn(index);
            if (entries == null)
                return;

            SearchPattern decodedResult = pattern.getBlankPattern();
            SimpleSet newIntersectedNames = new SimpleSet(3);
            for (int i = 0, l = entries.length; i < l; i++) {
                if (progressMonitor != null && progressMonitor.isCanceled())
                    throw new OperationCanceledException();

                EntryResult entry = entries[i];
                decodedResult.decodeIndexKey(entry.getWord());
                if (pattern.matchesDecodedKey(decodedResult)) {
                    String[] names = entry.getDocumentNames(index);
                    if (intersectedNames != null) {
                        for (int j = 0, n = names.length; j < n; j++)
                            if (intersectedNames.includes(names[j]))
                                newIntersectedNames.add(names[j]);
                    } else {
                        for (int j = 0, n = names.length; j < n; j++)
                            newIntersectedNames.add(names[j]);
                    }
                }
            }

            if (newIntersectedNames.elementSize == 0)
                return;
            intersectedNames = newIntersectedNames;
        } while (hasNextQuery());
    } finally {
        index.stopQuery();
    }

    String containerPath = index.containerPath;
    char separator = index.separator;
    Object[] names = intersectedNames.values;
    for (int i = 0, l = names.length; i < l; i++)
        if (names[i] != null)
            acceptMatch((String) names[i], containerPath, separator, null/*no pattern*/, requestor, participant,
                    scope, progressMonitor); // AndPatterns cannot provide the decoded result
}