Package com.python.pydev.ui.search

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


                            PySelection ps = new PySelection(doc, offset);
                            int lineNumber = ps.getLineOfOffset();
                            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));
                        }
                    }
                }
View Full Code Here


        }
    }

    private boolean hasMatches(Object element) {
        if (element instanceof LineElement) {
            LineElement lineElement = (LineElement) element;
            return lineElement.getNumberOfMatches(fResult) > 0;
        }
        return fResult.getMatchCount(element) > 0;
    }
View Full Code Here

                    insert(updatedElements[i], true);
                else
                    remove(updatedElements[i], true);
            } else {
                // change events to line elements are reported in text search
                LineElement lineElement = (LineElement) updatedElements[i];
                int nMatches = lineElement.getNumberOfMatches(fResult);
                if (nMatches > 0) {
                    if (hasChild(lineElement.getParent(), lineElement)) {
                        fTreeViewer.update(new Object[] { lineElement, lineElement.getParent() }, null);
                    } else {
                        insert(lineElement, true);
                    }
                } else {
                    remove(lineElement, 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);
            }
View Full Code Here

            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();
                lineNumber = lineElement.getLine() + 1;
            }
            if (offset < lineStart) {
                return null; // offset before the last line
            }

            int i = lineStart;
            int contentLength = matchRequestor.getFileContentLength();
            while (i < contentLength) {
                char ch = matchRequestor.getFileContentChar(i++);
                if (ch == '\n' || ch == '\r') {
                    if (ch == '\r' && i < contentLength && matchRequestor.getFileContentChar(i) == '\n') {
                        i++;
                    }
                    if (offset < i) {
                        String lineContent = getContents(matchRequestor, lineStart, i); // include line delimiter
                        return new LineElement(matchRequestor.getFile(), lineNumber, lineStart, lineContent);
                    }
                    lineNumber++;
                    lineStart = i;
                }
            }
            if (offset < i) {
                String lineContent = getContents(matchRequestor, lineStart, i); // until end of file
                return new LineElement(matchRequestor.getFile(), lineNumber, lineStart, lineContent);
            }
            return null; // offset outside of range
        }
View Full Code Here

    }

    public int getDisplayedMatchCount(Object element) {
        if (showLineMatches()) {
            if (element instanceof LineElement) {
                LineElement lineEntry = (LineElement) element;
                return lineEntry.getNumberOfMatches(getInput());
            }
            return 0;
        }
        return super.getDisplayedMatchCount(element);
    }
View Full Code Here

    }

    public Match[] getDisplayedMatches(Object element) {
        if (showLineMatches()) {
            if (element instanceof LineElement) {
                LineElement lineEntry = (LineElement) element;
                return lineEntry.getMatches(getInput());
            }
            return new Match[0];
        }
        return super.getDisplayedMatches(element);
    }
View Full Code Here

            if (cat1 != cat2) {
                return cat1 - cat2;
            }

            if (e1 instanceof LineElement && e2 instanceof LineElement) {
                LineElement m1 = (LineElement) e1;
                LineElement m2 = (LineElement) e2;
                return m1.getOffset() - m2.getOffset();
            }

            String name1 = fLabelProvider.getText(e1);
            String name2 = fLabelProvider.getText(e2);
            if (name1 == null)
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    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);
                }
View Full Code Here

TOP

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

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.