Package org.python.pydev.parser.visitors.scope

Examples of org.python.pydev.parser.visitors.scope.CodeFoldingVisitor


     */
    public static List<FoldingEntry> getMarks(IDocument doc, SimpleNode ast) {

        List<FoldingEntry> ret = new ArrayList<FoldingEntry>();

        CodeFoldingVisitor visitor = CodeFoldingVisitor.create(ast);
        //(re) insert annotations.
        List<Class> elementList = new ArrayList<Class>();
        IPreferenceStore prefs = getPreferences();

        if (prefs.getBoolean(PyDevCodeFoldingPrefPage.FOLD_IMPORTS)) {
            elementList.add(Import.class);
            elementList.add(ImportFrom.class);
        }
        if (prefs.getBoolean(PyDevCodeFoldingPrefPage.FOLD_CLASSDEF)) {
            elementList.add(ClassDef.class);
        }
        if (prefs.getBoolean(PyDevCodeFoldingPrefPage.FOLD_FUNCTIONDEF)) {
            elementList.add(FunctionDef.class);
        }
        if (prefs.getBoolean(PyDevCodeFoldingPrefPage.FOLD_STRINGS)) {
            elementList.add(Str.class);
        }
        if (prefs.getBoolean(PyDevCodeFoldingPrefPage.FOLD_WHILE)) {
            elementList.add(While.class);
        }
        if (prefs.getBoolean(PyDevCodeFoldingPrefPage.FOLD_IF)) {
            elementList.add(If.class);
        }
        if (prefs.getBoolean(PyDevCodeFoldingPrefPage.FOLD_FOR)) {
            elementList.add(For.class);
        }
        if (prefs.getBoolean(PyDevCodeFoldingPrefPage.FOLD_WITH)) {
            elementList.add(With.class);
        }
        if (prefs.getBoolean(PyDevCodeFoldingPrefPage.FOLD_TRY)) {
            elementList.add(TryExcept.class);
            elementList.add(TryFinally.class);
        }

        List<ASTEntry> nodes = visitor.getAsList(elementList.toArray(new Class[elementList.size()]));

        for (ASTEntry entry : nodes) {
            createFoldingEntries((ASTEntryWithChildren) entry, ret);
        }

View Full Code Here

TOP

Related Classes of org.python.pydev.parser.visitors.scope.CodeFoldingVisitor

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.