Package com.python.pydev.ui.search

Examples of com.python.pydev.ui.search.FileMatch


                            String lineContents = ps.getLine(lineNumber);
                            int lineStartOffset = ps.getLineOffset(lineNumber);

                            LineElement element = new LineElement(workspaceFile, lineNumber, lineStartOffset,
                                    lineContents);
                            findOccurrencesSearchResult.addMatch(new FileMatch(workspaceFile, offset, length, element));
                        }
                    }
                }
            } finally {
                req.popMonitor().done();
View Full Code Here


        if (element instanceof LineElement) {
            return ((LineElement) element).getParent();
        }

        if (element instanceof FileMatch) {
            FileMatch match = (FileMatch) element;
            return match.getLineElement();
        }
        return null;
    }
View Full Code Here

        }

        public boolean acceptFile(IFile file) throws CoreException {
            if (fIsFileSearchOnly) {
                fResult.addMatch(new FileMatch(file));
            }
            flushMatches();
            return true;
        }
View Full Code Here

        public boolean acceptPatternMatch(TextSearchMatchAccess matchRequestor) throws CoreException {
            int matchOffset = matchRequestor.getMatchOffset();

            LineElement lineElement = getLineElement(matchOffset, matchRequestor);
            if (lineElement != null) {
                FileMatch fileMatch = new FileMatch(matchRequestor.getFile(), matchOffset,
                        matchRequestor.getMatchLength(), lineElement);
                fCachedMatches.add(fileMatch);
            }
            return true;
        }
View Full Code Here

        private LineElement getLineElement(int offset, TextSearchMatchAccess matchRequestor) {
            int lineNumber = 1;
            int lineStart = 0;
            if (!fCachedMatches.isEmpty()) {
                // match on same line as last?
                FileMatch last = (FileMatch) fCachedMatches.get(fCachedMatches.size() - 1);
                LineElement lineElement = last.getLineElement();
                if (lineElement.contains(offset)) {
                    return lineElement;
                }
                // start with the offset and line information from the last match
                lineStart = lineElement.getOffset() + lineElement.getLength();
View Full Code Here

    private void collectMatches(Object object) throws CoreException {
        if (object instanceof LineElement) {
            LineElement lineElement = (LineElement) object;
            FileMatch[] matches = lineElement.getMatches(fResult);
            for (int i = 0; i < matches.length; i++) {
                FileMatch fileMatch = matches[i];
                if (!isSkipped(fileMatch)) {
                    getBucket(fileMatch.getFile()).add(fileMatch);
                }
            }
        } else if (object instanceof IContainer) {
            IContainer container = (IContainer) object;
            IResource[] members = container.members();
            for (int i = 0; i < members.length; i++) {
                collectMatches(members[i]);
            }
        } else if (object instanceof IFile) {
            Match[] matches = fResult.getMatches(object);
            if (matches.length > 0) {
                Collection bucket = null;
                for (int i = 0; i < matches.length; i++) {
                    FileMatch fileMatch = (FileMatch) matches[i];
                    if (!isSkipped(fileMatch)) {
                        if (bucket == null) {
                            bucket = getBucket((IFile) object);
                        }
                        bucket.add(fileMatch);
View Full Code Here

            }
            IDocument document = textFileBuffer.getDocument();
            String lineDelimiter = TextUtilities.getDefaultLineDelimiter(document);

            for (Iterator iterator = matches.iterator(); iterator.hasNext();) {
                FileMatch match = (FileMatch) iterator.next();
                int offset = match.getOffset();
                int length = match.getLength();
                Position currentPosition = tracker.getCurrentPosition(match);
                if (currentPosition != null) {
                    offset = currentPosition.offset;
                    if (length != currentPosition.length) {
                        resultingStatus.addError(Messages.format(
View Full Code Here

        int length = content.length();

        int charsToCut = getCharsToCut(length, matches); // number of characters to leave away if the line is too long
        for (int i = 0; i < matches.length; i++) {
            FileMatch match = (FileMatch) matches[i];
            int start = Math.max(match.getOriginalOffset() - lineElement.getOffset(), 0);
            // append gap between last match and the new one
            if (pos < start) {
                if (charsToCut > 0) {
                    charsToCut = appendShortenedGap(content, pos, start, charsToCut, i == 0, str);
                } else {
                    str += content.substring(pos, start);
                }
            }
            // append match
            int end = Math.min(match.getOriginalOffset() + match.getOriginalLength() - lineElement.getOffset(),
                    lineElement.getLength());
            str += content.substring(start, end);
            pos = end;
        }
        // append rest of the line
View Full Code Here

    }

    private int evaluateLineStart(Match[] matches, String lineContent, int lineOffset) {
        int max = lineContent.length();
        if (matches.length > 0) {
            FileMatch match = (FileMatch) matches[0];
            max = match.getOriginalOffset() - lineOffset;
            if (max < 0) {
                return 0;
            }
        }
        for (int i = 0; i < max; i++) {
View Full Code Here

TOP

Related Classes of com.python.pydev.ui.search.FileMatch

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.