Examples of PySourceViewer


Examples of org.python.pydev.editor.codefolding.PySourceViewer

    public List<ICompletionProposal> getProps(PySelection ps, ImageCache imageCache, File f, IPythonNature nature,
            PyEdit edit, int offset) throws BadLocationException {
        fillParticipants();

        PySourceViewer s = edit.getPySourceViewer();

        int line = ps.getLineOfOffset(offset);
        OrderedSet<MarkerAnnotationAndPosition> markersAtLine = new OrderedSet<MarkerAnnotationAndPosition>();

        //Add it to a set to make sure that the entries are unique.
        //-- i.e.: the code analysis seems to be creating 2 markers in the following case (when sys is undefined):
        //sys.call1().call2()
        //So, we add it to a set to make sure we'll only analyze unique markers.
        //Note that it'll check equality by the marker type and text (not by position), so, if a given error
        //appears twice in the same line being correct, we'll only show the options once here (which is what
        //we want).
        List<MarkerAnnotationAndPosition> markersAtLine2 = s.getMarkersAtLine(line,
                AnalysisRunner.PYDEV_ANALYSIS_PROBLEM_MARKER);
        markersAtLine.addAll(markersAtLine2);

        ArrayList<ICompletionProposal> props = new ArrayList<ICompletionProposal>();
View Full Code Here

Examples of org.python.pydev.editor.codefolding.PySourceViewer

                }
                super.apply(viewer, trigger, stateMask, offset);
                if (forceReparseOnApply) {
                    //and after applying it, let's request a reanalysis
                    if (viewer instanceof PySourceViewer) {
                        PySourceViewer sourceViewer = (PySourceViewer) viewer;
                        PyEdit edit = sourceViewer.getEdit();
                        if (edit != null) {
                            edit.getParser().forceReparse(
                                    new Tuple<String, Boolean>(AnalysisParserObserver.ANALYSIS_PARSER_OBSERVER_FORCE,
                                            true));
                        }
View Full Code Here

Examples of org.python.pydev.editor.codefolding.PySourceViewer

    public synchronized String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
        buf.clear();

        if (!pythonCommentOrMultiline) {
            if (textViewer instanceof PySourceViewer) {
                PySourceViewer s = (PySourceViewer) textViewer;
                PySelection ps = new PySelection(s.getDocument(), hoverRegion.getOffset() + hoverRegion.getLength());

                List<IPyHoverParticipant> participants = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_HOVER);
                for (IPyHoverParticipant pyHoverParticipant : participants) {
                    try {
                        String hoverText = pyHoverParticipant.getHoverText(hoverRegion, s, ps, textSelection);
View Full Code Here

Examples of org.python.pydev.editor.codefolding.PySourceViewer

            Log.log(e1);
            return true; //just go on
        }
        List<ASTEntry> availableImports = visitor.getAsList(new Class[] { ImportFrom.class, Import.class });

        PySourceViewer s = edit.getPySourceViewer();

        ArrayList<Tuple<MarkerAnnotationAndPosition, ASTEntry>> unusedImportsMarkers = new ArrayList<Tuple<MarkerAnnotationAndPosition, ASTEntry>>();
        ArrayList<Tuple<MarkerAnnotationAndPosition, ASTEntry>> unusedWildImportsMarkers = new ArrayList<Tuple<MarkerAnnotationAndPosition, ASTEntry>>();
        ArrayList<Tuple<MarkerAnnotationAndPosition, ASTEntry>> unresolvedImportsMarkers = new ArrayList<Tuple<MarkerAnnotationAndPosition, ASTEntry>>();

        ArrayList<MarkerAnnotationAndPosition> undefinedVariablesMarkers = new ArrayList<MarkerAnnotationAndPosition>();

        //get the markers we are interested in and the related ast elements
        for (Iterator<MarkerAnnotationAndPosition> it = s.getMarkerIterator(); it.hasNext();) {
            MarkerAnnotationAndPosition marker = it.next();
            try {
                String type = marker.markerAnnotation.getMarker().getType();
                if (type != null && type.equals(AnalysisRunner.PYDEV_ANALYSIS_PROBLEM_MARKER)) {
                    Integer attribute = marker.markerAnnotation.getMarker().getAttribute(
View Full Code Here

Examples of org.python.pydev.editor.codefolding.PySourceViewer

    /**
     * @return the markers representing undefined variables found in the editor.
     */
    private ArrayList<MarkerAnnotationAndPosition> getUndefinedVariableMarkers(final PyEdit edit) {
        PySourceViewer s = edit.getPySourceViewer();

        ArrayList<MarkerAnnotationAndPosition> undefinedVariablesMarkers = new ArrayList<MarkerAnnotationAndPosition>();

        //get the markers we are interested in (undefined variables)
        for (Iterator<MarkerAnnotationAndPosition> it = s.getMarkerIterator(); it.hasNext();) {
            MarkerAnnotationAndPosition m = it.next();
            IMarker marker = m.markerAnnotation.getMarker();
            try {
                String type = marker.getType();
                if (type != null && type.equals(AnalysisRunner.PYDEV_ANALYSIS_PROBLEM_MARKER)) {
View Full Code Here

Examples of org.python.pydev.editor.codefolding.PySourceViewer

     * This is the apply that should actually be called!
     */
    public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
        IDocument document = viewer.getDocument();
        if (viewer instanceof PySourceViewer) {
            PySourceViewer pySourceViewer = (PySourceViewer) viewer;
            PyEdit pyEdit = pySourceViewer.getEdit();
            this.indentString = pyEdit.getIndentPrefs().getIndentationString();
        } else {
            //happens on compare editor
            this.indentString = new DefaultIndentPrefs().getIndentationString();
        }
View Full Code Here

Examples of org.python.pydev.editor.codefolding.PySourceViewer

    public int applyOnDocument(ITextViewer viewer, IDocument document, char trigger, int stateMask, int offset) {
        IGrammarVersionProvider versionProvider = null;
        PyEdit edit = null;
        if (viewer instanceof PySourceViewer) {
            PySourceViewer pySourceViewer = (PySourceViewer) viewer;
            versionProvider = edit = pySourceViewer.getEdit();
        } else {
            versionProvider = new IGrammarVersionProvider() {

                public int getGrammarVersion() throws MisconfigurationException {
                    return IGrammarVersionProvider.LATEST_GRAMMAR_VERSION;
View Full Code Here

Examples of org.python.pydev.editor.codefolding.PySourceViewer

    }

    public String getModuleName() {
        if (this.viewer instanceof PySourceViewer) {
            try {
                PySourceViewer pyViewer = (PySourceViewer) this.viewer;
                PyEdit edit = pyViewer.getEdit();
                IPythonNature nature = edit.getPythonNature();
                if (nature != null) {
                    return nature.resolveModule(edit.getEditorFile());
                }
            } catch (MisconfigurationException e) {
View Full Code Here

Examples of org.python.pydev.editor.codefolding.PySourceViewer

    /**
     * @return the indent preferences to be used.
     */
    private static IIndentPrefs getIndentPrefs(ITextViewer viewer) {
        if (viewer instanceof PySourceViewer) {
            PySourceViewer pyViewer = (PySourceViewer) viewer;
            return pyViewer.getEdit().getIndentPrefs();
        } else {
            return DefaultIndentPrefs.get();
        }
    }
View Full Code Here

Examples of org.python.pydev.editor.codefolding.PySourceViewer

    /**
     * @see org.python.pydev.editor.correctionassist.heuristics.IAssistProps#getProps
     */
    public List<ICompletionProposal> getProps(PySelection ps, ImageCache imageCache, File f, IPythonNature nature,
            PyEdit edit, int offset) throws BadLocationException {
        PySourceViewer viewer = null;
        if (edit != null) { //only in tests it's actually null
            viewer = edit.getPySourceViewer();
        }

        return this.getProps(ps, imageCache, viewer, offset, PyAction.getLineWithoutComments(ps),
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.