Package org.python.pydev.parser.jython

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


        if (found != null && found.defined && found.token instanceof SourceToken) {
            nameToken = (SourceToken) found.token;
            String rep = nameToken.getRepresentation();

            ArrayList<IDefinition> definition = new ArrayList<IDefinition>();
            SimpleNode ast = nameToken.getAst();
            try {
                PyRefactoringFindDefinition.findActualDefinition(null, this.current, rep, definition, ast.beginLine,
                        ast.beginColumn, this.nature, this.completionCache);
            } catch (Exception e) {
                Log.log(e);
View Full Code Here


    private final Map<ClassDef, SimpleNode> defToConsideredInit = new HashMap<ClassDef, SimpleNode>();

    /*default*/void checkNameFound(Call callNode, SourceToken sourceToken) throws Exception {
        FunctionDef functionDefinitionReferenced;
        boolean callingBoundMethod = false;
        SimpleNode ast = sourceToken.getAst();
        if (ast instanceof FunctionDef) {
            functionDefinitionReferenced = (FunctionDef) ast;
            analyzeCallAndFunctionMatch(callNode, functionDefinitionReferenced, sourceToken, callingBoundMethod);

        } else if (ast instanceof ClassDef) {
            ClassDef classDef = (ClassDef) ast;
            SimpleNode initNode = defToConsideredInit.get(classDef);
            callingBoundMethod = true;
            if (initNode == null) {
                String className = ((NameTok) classDef.name).id;

                Definition foundDef = sourceToken.getDefinition();
                IModule mod = this.current;
                if (foundDef != null) {
                    mod = foundDef.module;
                }
                SimpleNode n = NodeUtils.getNodeFromPath(classDef, "__init__");
                if (n instanceof FunctionDef) {
                    initNode = n;

                } else {
                    IDefinition[] definition = mod.findDefinition(CompletionStateFactory.getEmptyCompletionState(
View Full Code Here

    }

    public void addSpecialTokenToLastOpened(Object o) throws ParseException {
        o = convertStringToSpecialStr(o);
        if (o != null) {
            SimpleNode lastOpened = grammar.getJJTree().getLastOpened();
            if (o instanceof ISpecialStr) {
                lastSpecial = (ISpecialStr) o;
                lastNodeWithSpecial = lastOpened;
            }

            lastOpened.getSpecialsBefore().add(o);

        }
    }
View Full Code Here

        Tuple<SimpleNode, Throwable> returnVar = new Tuple<SimpleNode, Throwable>(null, null);
        IGrammar grammar = null;
        try {
            grammar = createGrammar(info.generateTree, info.grammarVersion, charArray);
            SimpleNode newRoot = grammar.file_input(); // parses the file
            returnVar.o1 = newRoot;

            //only notify successful parses
            if (successfulParseListeners.size() > 0) {
                Tuple3<SimpleNode, Throwable, ParserInfo> param = new Tuple3<SimpleNode, Throwable, ParserInfo>(
View Full Code Here

     * Adds a special token to the current token that's in the top of the stack (the peeked token)
     * @return the peeked node.
     */
    @SuppressWarnings("rawtypes")
    public SimpleNode addToPeek(Object t, boolean after, Class class_) throws ParseException {
        SimpleNode peeked = (SimpleNode) grammar.getJJTree().peekNode();
        addToPeek(peeked, t, after, class_);
        return peeked;
    }
View Full Code Here

     *
     * @param n the node that should have its scope closed.
     * @throws ParseException
     */
    public void jjtreeCloseNodeScope(Node n) throws ParseException {
        SimpleNode peeked = grammar.getJJTree().peekNode();
        List<Object> specialTokens = grammar.getTokenSourceSpecialTokensList();
        boolean after = true;
        if (n instanceof SimpleNode) {
            if (specialTokens.size() > 0) {
                if (this.prev == null) {
View Full Code Here

            this.prev = (SimpleNode) peeked;
        }
    }

    private SimpleNode findTokenToAdd(Token next) {
        SimpleNode curr = (SimpleNode) grammar.getJJTree().peekNode();
        if (curr != this.prev) {
            //let's see which one is better suited
            if (this.prev.beginLine == next.beginLine) {
                return this.prev;
            }
View Full Code Here

     */
    protected boolean isVirtual(FunctionDef node) {
        if (node.body != null) {
            int len = node.body.length;
            for (int i = 0; i < len; i++) {
                SimpleNode n = node.body[i];
                if (n instanceof Raise) {
                    continue;
                }
                if (n instanceof Expr) {
                    if (((Expr) n).value instanceof Str) {
View Full Code Here

            openAction.run(itemPointer);
        }
    }

    public static ItemPointer getItemPointer(File file, String fileContents, String testPath) {
        SimpleNode testNode = null;
        if (fileContents != null) {
            SimpleNode node = FastDefinitionsParser.parse(fileContents, "");
            if (testPath != null && testPath.length() > 0) {
                testNode = NodeUtils.getNodeFromPath(node, testPath);
            }
        }
View Full Code Here

        } else {
            throw new RuntimeException("Don't know how to handle: " + doc + " -- " + doc.getClass());
        }

        SimpleNode node = FastDefinitionsParser.parse(charArray, key.file.getName(), len);
        if (node == null) {
            return null;
        }

        return addAstInfo(node, key, generateDelta);
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.