Package org.python.pydev.parser.jython

Examples of org.python.pydev.parser.jython.SimpleNode


    protected abstract SimpleNode getEditNode() throws MisconfigurationException;

    public abstract TextEdit getEdit() throws MisconfigurationException;

    protected String getFormattedNode() throws MisconfigurationException {
        SimpleNode node = getEditNode().createCopy();
        try {
            MakeAstValidForPrettyPrintingVisitor.makeValid(node);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
View Full Code Here


        if (tokenAndQual != null && selected.size() > 0) {
            for (IDefinition d : selected) {
                Definition def = (Definition) d;

                SimpleNode astToPrint = null;
                if (def.ast != null) {
                    astToPrint = def.ast;
                    if ((astToPrint instanceof Name || astToPrint instanceof NameTok) && def.scope != null) {
                        //There's no real point in just printing the name, let's see if we're able to actually find
                        //the scope where it's in and print that scope.
                        FastStack<SimpleNode> scopeStack = def.scope.getScopeStack();
                        if (scopeStack != null && scopeStack.size() > 0) {
                            SimpleNode peek = scopeStack.peek();
                            if (peek != null) {
                                stmtType stmt = NodeUtils.findStmtForNode(peek, astToPrint);
                                if (stmt != null) {
                                    astToPrint = stmt;
                                }
View Full Code Here

    public void parserChanged(final ChangedParserInfoForObservers info) {
        if (DebugSettings.DEBUG_ANALYSIS_REQUESTS) {
            System.out.println("AnalysisParserObserver: parserChanged");
        }
        final SimpleNode root = (SimpleNode) info.root;
        if (info.file == null) {
            return;
        }
        IFile fileAdapter = null;
        if (info.file instanceof IFile) {
View Full Code Here

                if (sourceModule == null || sourceModule.getAst() == null || lineToUse < 0) {
                    functionName = "None";
                    return functionName;
                }

                SimpleNode ast = sourceModule.getAst();

                functionName = NodeUtils.getContextName(lineToUse, ast);
                if (functionName == null) {
                    functionName = ""; //global context
                }
View Full Code Here

        }

        //ok, it is an import... (can only be a source token)
        SourceToken s = (SourceToken) generator;

        SimpleNode ast = s.getAst();
        if (ast instanceof ImportFrom) {
            ImportFrom i = (ImportFrom) ast;
            //if it is a wild import, it starts on the module name
            if (AbstractVisitor.isWildImport(i)) {
                return i.module.beginLine;
View Full Code Here

        }

        //ok, it is an import... (can only be a source token)
        SourceToken s = (SourceToken) generator;

        SimpleNode ast = s.getAst();
        if (ast instanceof ImportFrom) {
            ImportFrom i = (ImportFrom) ast;
            //if it is a wild import, it starts on the module name
            if (AbstractVisitor.isWildImport(i)) {
                return i.module.beginColumn;
View Full Code Here

        int endCol = -1;
        if (generator.isImport()) {
            //ok, it is an import... (can only be a source token)
            SourceToken s = (SourceToken) generator;

            SimpleNode ast = s.getAst();

            if (ast instanceof ImportFrom) {
                ImportFrom i = (ImportFrom) ast;
                //ok, now, this depends on the name
                NameTok it = getNameForRepresentation(i, shortMessage, true);
View Full Code Here

    @Override
    public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
        AbstractScopeNode<?> scope = info.getScopeAdapter();
        ITextSelection selection = info.getUserSelection();

        SimpleNode node = scope.getASTNode();

        LocalVariablesVisitor visitor = new LocalVariablesVisitor();
        try {
            node.accept(visitor);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        List<Name> variables = visitor.getVariables();
View Full Code Here

    private Assign findAssignment(List<Name> relatedVariables) {
        /* Search for the assignment */
        for (Name variable : relatedVariables) {

            SimpleNode parent = variable.parent;

            if (parent instanceof Assign) {
                Assign assign = (Assign) parent;

                /* The given name has to be one of the targets of this assignment */
 
View Full Code Here

    public boolean beforePerformArrangeImports(PySelection ps, PyEdit edit) {
        if (true) {
            throw new RuntimeException("This class is not working!!!");
        }
        SimpleNode ast = edit.getAST();
        if (ast == null) {
            return true; //we need it to be correctly parsed with an ast to be able to do it...
        }

        EasyASTIteratorVisitor visitor = new EasyASTIteratorVisitor();
        try {
            ast.accept(visitor);
        } catch (Exception e1) {
            Log.log(e1);
            return true; //just go on
        }
        List<ASTEntry> availableImports = visitor.getAsList(new Class[] { ImportFrom.class, Import.class });
View Full Code Here

TOP

Related Classes of org.python.pydev.parser.jython.SimpleNode

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.