protected void enterTypeDeclaration(ParserRuleContext ctx, int access) { String name = ctx.getToken(JavaParser.Identifier, 0).getText(); JavaParser.TypeContext superType = ctx.getRuleContext(JavaParser.TypeContext.class, 0); String superQualifiedTypeName; if (superType == null) { superQualifiedTypeName = ((access & JavaType.FLAG_INTERFACE) == 0) ? "java/lang/Object" : ""; } else { superQualifiedTypeName = resolveInternalTypeName(superType.classOrInterfaceType().Identifier()); } ParserRuleContext parent = ctx.getParent(); if (parent instanceof JavaParser.TypeDeclarationContext) access += getTypeDeclarationContextAccessFlag(parent); else if (parent instanceof JavaParser.MemberDeclarationContext) access += getMemberDeclarationContextAccessFlag(parent.getParent()); if (currentType == null) { String internalTypeName = packageName.isEmpty() ? name : packageName + "/" + name; String outerName = null; String displayTypeName = name; String displayInnerTypeName = null; currentType = new JavaType( access, internalTypeName, superQualifiedTypeName, outerName, displayTypeName, displayInnerTypeName, displayPackageName, null); types.put(internalTypeName, currentType); rootTypes.add(currentType); nameToInternalTypeName.put(name, internalTypeName); if (mainType == null) { mainType = currentType; } else { // Multi class definitions in the same file String path = entry.getPath(); int index = path.lastIndexOf('/') + 1; if (path.substring(index).startsWith(name + '.')) { // Select the correct root type mainType = currentType; } } } else { String internalTypeName = currentType.getName() + '$' + name; String outerName = currentType.getName(); String displayTypeName = currentType.getDisplayTypeName() + '.' + name; String displayInnerTypeName = name; JavaType subType = new JavaType( access, internalTypeName, superQualifiedTypeName, outerName, displayTypeName, displayInnerTypeName, displayPackageName, currentType); currentType.getInnerTypes().add(subType); currentType = subType; types.put(internalTypeName, currentType); nameToInternalTypeName.put(name, internalTypeName); } }
public Type getType(String typeName) { return types.get(typeName); }