// Path: com.palantir.typescript/src/com/palantir/typescript/services/language/NavigationBarItem.java
// public final class NavigationBarItem {
// 
//     private final String text;
//     private final ScriptElementKind kind;
//     private final List<ScriptElementKindModifier> kindModifiers;
//     private final List<TextSpan> spans;
//     private final List<NavigationBarItem> childItems;
//     private final int indent;
//     private final boolean bolded;
//     private final boolean grayed;
// 
//     @JsonCreator
//     public NavigationBarItem(
//             @JsonProperty("text") String text,
//             @JsonProperty("kind") ScriptElementKind kind,
//             @JsonProperty("kindModifiers") String kindModifiers,
//             @JsonProperty("spans") List<TextSpan> spans,
//             @JsonProperty("childItems") List<NavigationBarItem> childItems,
//             @JsonProperty("indent") int indent,
//             @JsonProperty("bolded") boolean bolded,
//             @JsonProperty("grayed") boolean grayed) {
//         checkNotNull(text);
//         checkNotNull(kind);
//         checkNotNull(kindModifiers);
//         checkNotNull(spans);
//         checkArgument(indent >= 0);
// 
//         this.text = text;
//         this.kind = kind;
//         this.kindModifiers = ScriptElementKindModifier.parseList(kindModifiers);
//         this.spans = ImmutableList.copyOf(spans);
//         this.childItems = (childItems != null ? ImmutableList.copyOf(childItems) : ImmutableList.<NavigationBarItem> of());
//         this.indent = indent;
//         this.bolded = bolded;
//         this.grayed = grayed;
//     }
// 
//     public String getText() {
//         return this.text;
//     }
// 
//     public ScriptElementKind getKind() {
//         return this.kind;
//     }
// 
//     public List<ScriptElementKindModifier> getKindModifiers() {
//         return this.kindModifiers;
//     }
// 
//     public List<TextSpan> getSpans() {
//         return this.spans;
//     }
// 
//     public List<NavigationBarItem> getChildItems() {
//         return this.childItems;
//     }
// 
//     public int getIndent() {
//         return this.indent;
//     }
// 
//     public boolean getBolded() {
//         return this.bolded;
//     }
// 
//     public boolean getGrayed() {
//         return this.grayed;
//     }
// 
//     @Override
//     public String toString() {
//         return Objects.toStringHelper(this)
//             .add("text", this.text)
//             .add("kind", this.kind)
//             .add("kindModifiers", this.kindModifiers)
//             .add("spans", this.spans)
//             .add("childItems", this.childItems)
//             .add("indent", this.indent)
//             .add("bolded", this.bolded)
//             .add("grayed", this.grayed)
//             .toString();
//     }
// }


import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Tree;
import com.google.common.collect.ImmutableList;
import com.palantir.typescript.services.language.NavigationBarItem;
        for (NavigationBarItem item : this.navigationBarItems) {
            Object parent = getParent(item, childElement);

            if (parent != null) {
                return parent;
            }
        }

        return null;
    }

    @Override
    public boolean hasChildren(Object element) {
        return this.getChildren(element).length > 0;
    }

    @Override
    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        if (newInput instanceof List) {
            this.navigationBarItems = (List<NavigationBarItem>) newInput;
        } else if (newInput == null) {
            this.navigationBarItems = ImmutableList.<NavigationBarItem> of();
        } else {
            throw new RuntimeException("Invalid input for the content provider.");
        }
    }

    private static Object getParent(NavigationBarItem item, Object childElement) {
        for (NavigationBarItem childItem : item.getChildItems()) {
            if (childItem.equals(childElement)) {
// Path: com.palantir.typescript/src/com/palantir/typescript/services/language/NavigationBarItem.java
// public final class NavigationBarItem {
// 
//     private final String text;
//     private final ScriptElementKind kind;
//     private final List<ScriptElementKindModifier> kindModifiers;
//     private final List<TextSpan> spans;
//     private final List<NavigationBarItem> childItems;
//     private final int indent;
//     private final boolean bolded;
//     private final boolean grayed;
// 
//     @JsonCreator
//     public NavigationBarItem(
//             @JsonProperty("text") String text,
//             @JsonProperty("kind") ScriptElementKind kind,
//             @JsonProperty("kindModifiers") String kindModifiers,
//             @JsonProperty("spans") List<TextSpan> spans,
//             @JsonProperty("childItems") List<NavigationBarItem> childItems,
//             @JsonProperty("indent") int indent,
//             @JsonProperty("bolded") boolean bolded,
//             @JsonProperty("grayed") boolean grayed) {
//         checkNotNull(text);
//         checkNotNull(kind);
//         checkNotNull(kindModifiers);
//         checkNotNull(spans);
//         checkArgument(indent >= 0);
// 
//         this.text = text;
//         this.kind = kind;
//         this.kindModifiers = ScriptElementKindModifier.parseList(kindModifiers);
//         this.spans = ImmutableList.copyOf(spans);
//         this.childItems = (childItems != null ? ImmutableList.copyOf(childItems) : ImmutableList.<NavigationBarItem> of());
//         this.indent = indent;
//         this.bolded = bolded;
//         this.grayed = grayed;
//     }
// 
//     public String getText() {
//         return this.text;
//     }
// 
//     public ScriptElementKind getKind() {
//         return this.kind;
//     }
// 
//     public List<ScriptElementKindModifier> getKindModifiers() {
//         return this.kindModifiers;
//     }
// 
//     public List<TextSpan> getSpans() {
//         return this.spans;
//     }
// 
//     public List<NavigationBarItem> getChildItems() {
//         return this.childItems;
//     }
// 
//     public int getIndent() {
//         return this.indent;
//     }
// 
//     public boolean getBolded() {
//         return this.bolded;
//     }
// 
//     public boolean getGrayed() {
//         return this.grayed;
//     }
// 
//     @Override
//     public String toString() {
//         return Objects.toStringHelper(this)
//             .add("text", this.text)
//             .add("kind", this.kind)
//             .add("kindModifiers", this.kindModifiers)
//             .add("spans", this.spans)
//             .add("childItems", this.childItems)
//             .add("indent", this.indent)
//             .add("bolded", this.bolded)
//             .add("grayed", this.grayed)
//             .toString();
//     }
// }


// Path: com.palantir.typescript/src/com/palantir/typescript/text/ContentProvider.java
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Tree;
import com.google.common.collect.ImmutableList;
import com.palantir.typescript.services.language.NavigationBarItem;

        for (NavigationBarItem item : this.navigationBarItems) {
            Object parent = getParent(item, childElement);

            if (parent != null) {
                return parent;
            }
        }

        return null;
    }

    @Override
    public boolean hasChildren(Object element) {
        return this.getChildren(element).length > 0;
    }

    @Override
    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        if (newInput instanceof List) {
            this.navigationBarItems = (List<NavigationBarItem>) newInput;
        } else if (newInput == null) {
            this.navigationBarItems = ImmutableList.<NavigationBarItem> of();
        } else {
            throw new RuntimeException("Invalid input for the content provider.");
        }
    }

    private static Object getParent(NavigationBarItem item, Object childElement) {
        for (NavigationBarItem childItem : item.getChildItems()) {
            if (childItem.equals(childElement)) {
                return item;