TypeInfo (@NotNull LighterAST tree, @NotNull LighterASTNode element, StubElement<?> parentStub) { int arrayCount = 0; LighterASTNode typeElement = null; if (element.getTokenType() == JavaElementType.ENUM_CONSTANT) { return ((PsiClassStubImpl<?>)parentStub).getQualifiedNameTypeInfo(); } for (final LighterASTNode child : tree.getChildren(element)) { IElementType type = child.getTokenType(); if (type == JavaElementType.TYPE) { typeElement = child; } else if (type == JavaTokenType.LBRACKET) { arrayCount++; // C-style array } } if (typeElement == null && element.getTokenType() == JavaElementType.FIELD) { LighterASTNode parent = tree.getParent(element); assert parent != null : element; List<LighterASTNode> fields = LightTreeUtil.getChildrenOfType(tree, parent, JavaElementType.FIELD); int idx = fields.indexOf(element); for (int i = idx - 1; i >= 0 && typeElement == null; i--) { // int i, j typeElement = LightTreeUtil.firstChildOfType(tree, fields.get(i), JavaElementType.TYPE); } } assert typeElement != null : element + " in " + parentStub; TypeInfo typeInfo = fromTypeElement(tree, typeElement); for (int i = 0; i < arrayCount; i++) { typeInfo = typeInfo.arrayOf(); } byte[] prefix = new byte[arrayCount]; Arrays.fill(prefix, TypeAnnotationContainer.Collector.ARRAY_ELEMENT); TypeAnnotationContainer.Collector collector = new TypeAnnotationContainer.Collector(typeInfo); collectAnnotations(typeInfo, collector, tree, typeElement, prefix); collector.install(); return typeInfo; }