RefTypeInfo (@NotNull LighterAST tree, @NotNull LighterASTNode ref) { RefTypeInfo info = null; for (LighterASTNode child : tree.getChildren(ref)) { IElementType tokenType = child.getTokenType(); if (tokenType == JavaElementType.JAVA_CODE_REFERENCE) { info = fromCodeReference(tree, child); } else if (tokenType == JavaTokenType.IDENTIFIER) { String text = ((LighterASTTokenNode)child).getText().toString(); info = new RefTypeInfo(text, info); } else if (tokenType == JavaElementType.REFERENCE_PARAMETER_LIST) { if (info == null) { throw new IllegalArgumentException("Malformed type: " + LightTreeUtil.toFilteredString(tree, ref, null)); } List<TypeInfo> components = new ArrayList<>(); for (LighterASTNode component : tree.getChildren(child)) { if (component.getTokenType() == JavaElementType.TYPE) { components.add(fromTypeElement(tree, component)); } } info = info.withComponents(components); } } return info; }