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

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


        //now, on the workspace, we need to find the module definition as well as the imports for it...
        //the local scope should have already determined which is the module to be renamed (unless it
        //is an unresolved import, in which case we'll only make a local refactor)
        if (docOccurrences.size() != 0) {
            ASTEntry entry = docOccurrences.iterator().next();
            Found found = (Found) entry
                    .getAdditionalInfo(ScopeAnalyzerVisitor.FOUND_ADDITIONAL_INFO_IN_AST_ENTRY, null);
            if (found == null) {
                throw new RuntimeException("Expecting decorated entry.");
            }
            if (found.importInfo == null) {
View Full Code Here


     */
    private List<ASTEntry> getLocalOccurrences(String occurencesFor, SimpleNode simpleNode, RefactoringStatus status) {
        List<ASTEntry> ret = new ArrayList<ASTEntry>();

        //get the entry for the function itself
        ASTEntry functionDefEntry = getOriginalFunctionInAst(simpleNode);

        if (functionDefEntry == null) {
            status.addFatalError("Unable to find the original definition for the function definition.");
            return ret;
        }

        if (functionDefEntry.parent != null) {
            //it has some parent

            final SimpleNode parentNode = functionDefEntry.parent.node;
            if (parentNode instanceof ClassDef) {

                //ok, we're in a class, the first thing is to add the reference to the function just gotten
                ret.add(new ASTEntry(functionDefEntry, ((FunctionDef) functionDefEntry.node).name));

                //get the entry for the self.xxx that access that attribute in the class
                SequencialASTIteratorVisitor classVisitor = SequencialASTIteratorVisitor.create(parentNode);
                Iterator<ASTEntry> it = classVisitor.getIterator(Attribute.class);
                while (it.hasNext()) {
                    ASTEntry entry = it.next();
                    List<SimpleNode> parts = NodeUtils.getAttributeParts((Attribute) entry.node);
                    if (!(parts.get(1) instanceof Attribute)) {
                        final String rep0 = NodeUtils.getRepresentationString(parts.get(0));
                        final String rep1 = NodeUtils.getRepresentationString(parts.get(1));
                        if (rep0 != null && rep1 != null && rep0.equals("self") && rep1.equals(occurencesFor)) {
View Full Code Here

     */
    private ASTEntry getOriginalFunctionInAst(SimpleNode simpleNode) {
        if (functionDefEntryCache == null) {
            SequencialASTIteratorVisitor visitor = SequencialASTIteratorVisitor.create(simpleNode);
            Iterator<ASTEntry> it = visitor.getIterator(FunctionDef.class);
            ASTEntry functionDefEntry = null;
            while (it.hasNext()) {
                functionDefEntry = it.next();

                if (functionDefEntry.node.beginLine == this.definition.ast.beginLine
                        && functionDefEntry.node.beginColumn == this.definition.ast.beginColumn) {
View Full Code Here

TOP

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

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.