Search in sources :

Example 1 with IParsedItem

use of org.python.pydev.shared_ui.outline.IParsedItem in project Pydev by fabioz.

the class ParsedItem method getChildren.

@Override
public IParsedItem[] getChildren() {
    if (children != null) {
        return children;
    }
    if (astChildrenEntries == null) {
        astChildrenEntries = new ASTEntryWithChildren[0];
    }
    ArrayList<ParsedItem> items = new ArrayList<ParsedItem>();
    // only the root can have an error as a child (from there on, the errors don't contain inner errors)
    if (this.parent == null && errorDesc != null && errorDesc.message != null) {
        items.add(new ParsedItem(this, errorDesc));
    }
    for (ASTEntryWithChildren c : astChildrenEntries) {
        items.add(new ParsedItem(this, c, c.getChildren()));
    }
    children = items.toArray(new ParsedItem[items.size()]);
    return children;
}
Also used : BaseParsedItem(org.python.pydev.shared_ui.outline.BaseParsedItem) IParsedItem(org.python.pydev.shared_ui.outline.IParsedItem) ArrayList(java.util.ArrayList) ASTEntryWithChildren(org.python.pydev.parser.visitors.scope.ASTEntryWithChildren)

Example 2 with IParsedItem

use of org.python.pydev.shared_ui.outline.IParsedItem in project Pydev by fabioz.

the class ParsedModel method duplicateRootAddingError.

@Override
protected IParsedItem duplicateRootAddingError(ErrorDescription errorDesc) {
    IParsedItem currRoot = getRoot();
    IParsedItem newRoot;
    if (currRoot != null) {
        newRoot = new ParsedItem(((ParsedItem) currRoot).getAstChildrenEntries(), errorDesc);
        newRoot.updateTo(currRoot);
    } else {
        newRoot = new ParsedItem(new ASTEntryWithChildren[0], errorDesc);
    }
    return newRoot;
}
Also used : IParsedItem(org.python.pydev.shared_ui.outline.IParsedItem) IParsedItem(org.python.pydev.shared_ui.outline.IParsedItem) ASTEntryWithChildren(org.python.pydev.parser.visitors.scope.ASTEntryWithChildren)

Example 3 with IParsedItem

use of org.python.pydev.shared_ui.outline.IParsedItem in project Pydev by fabioz.

the class ParsedItem method updateTo.

@Override
public void updateTo(IParsedItem item) {
    ParsedItem updateToItem = (ParsedItem) item;
    this.astThis = updateToItem.astThis;
    this.astChildrenEntries = updateToItem.astChildrenEntries;
    super.updateTo(item);
}
Also used : BaseParsedItem(org.python.pydev.shared_ui.outline.BaseParsedItem) IParsedItem(org.python.pydev.shared_ui.outline.IParsedItem)

Example 4 with IParsedItem

use of org.python.pydev.shared_ui.outline.IParsedItem in project Pydev by fabioz.

the class ParsedItem method sameNodeType.

@Override
public boolean sameNodeType(IParsedItem newItem) {
    ASTEntryWithChildren astThisOld = this.getAstThis();
    ASTEntryWithChildren astThisNew = ((ParsedItem) newItem).getAstThis();
    if (astThisOld != null && astThisNew != null && astThisOld.node != null && astThisNew.node != null && astThisOld.node.getClass() != astThisNew.node.getClass()) {
        return false;
    }
    // still the same
    return true;
}
Also used : BaseParsedItem(org.python.pydev.shared_ui.outline.BaseParsedItem) IParsedItem(org.python.pydev.shared_ui.outline.IParsedItem) ASTEntryWithChildren(org.python.pydev.parser.visitors.scope.ASTEntryWithChildren)

Example 5 with IParsedItem

use of org.python.pydev.shared_ui.outline.IParsedItem in project Pydev by fabioz.

the class PythonBaseModelProvider method getChildrenFromParsedItem.

/**
 * @param parentElement this is the elements returned
 * @param root this is the parsed item that has children that we want to return
 * @return the children elements (PythonNode) for the passed parsed item
 */
private Object[] getChildrenFromParsedItem(Object parentElement, ParsedItem root, PythonFile pythonFile) {
    IParsedItem[] children = root.getChildren();
    PythonNode[] p = new PythonNode[children.length];
    int i = 0;
    // in this case, we just want to return the roots
    for (IParsedItem e : children) {
        p[i] = new PythonNode(pythonFile, parentElement, (ParsedItem) e);
        i++;
    }
    return p;
}
Also used : IParsedItem(org.python.pydev.shared_ui.outline.IParsedItem) IParsedItem(org.python.pydev.shared_ui.outline.IParsedItem) ParsedItem(org.python.pydev.outline.ParsedItem) PythonNode(org.python.pydev.navigator.elements.PythonNode)

Aggregations

IParsedItem (org.python.pydev.shared_ui.outline.IParsedItem)5 ASTEntryWithChildren (org.python.pydev.parser.visitors.scope.ASTEntryWithChildren)3 BaseParsedItem (org.python.pydev.shared_ui.outline.BaseParsedItem)3 ArrayList (java.util.ArrayList)1 PythonNode (org.python.pydev.navigator.elements.PythonNode)1 ParsedItem (org.python.pydev.outline.ParsedItem)1