public void recursiveTemplateSubstitution(SymbolType st, Map<String, SymbolType> typeParamsMap) { List<SymbolType> bounds = st.getBounds(); if (bounds != null) { for (SymbolType bound : bounds) { recursiveTemplateSubstitution(bound, typeParamsMap); } } else { List<SymbolType> params = st.getParameterizedTypes(); if (params != null) { List<SymbolType> paramsFinal = new LinkedList<SymbolType>(); for (SymbolType param : params) { String tv = param.getTemplateVariable(); if (tv != null) { SymbolType genericTypeDef = typeParamsMap.get(tv); if (genericTypeDef != null) { paramsFinal.add(genericTypeDef); } else { recursiveTemplateSubstitution(param, typeParamsMap); paramsFinal.add(param); } } else { recursiveTemplateSubstitution(param, typeParamsMap); paramsFinal.add(param); } } st.setParameterizedTypes(paramsFinal); } } }
private void processSuperGenerics( SymbolTable table, Symbol<?> symbol, ClassOrInterfaceType type) { if (type != null) { Map<String, SymbolType> typeResolution = new HashMap<String, SymbolType>(); ASTSymbolTypeResolver res = new ASTSymbolTypeResolver(typeResolution, table); SymbolType superType = type.accept(res, null); List<SymbolType> params = superType.getParameterizedTypes(); Map<String, SymbolType> typeMapping = table.getTypeParams(); if (params != null) { Symbol<?> superSymbol = symbol.getInnerScope().findSymbol("super"); Scope innerScope = superSymbol.getInnerScope(); Scope aux = null; if (innerScope != null) { aux = new Scope(superSymbol); } else { aux = new Scope(); } superSymbol.setInnerScope(aux); table.pushScope(aux); Symbol<?> intermediateSuper = new Symbol("super", superSymbol.getType(), superSymbol.getLocation()); if (innerScope != null) { intermediateSuper.setInnerScope(innerScope); } table.pushSymbol(intermediateSuper); // extends a parameterizable type TypeVariable<?>[] tps = superType.getClazz().getTypeParameters(); for (int i = 0; i < tps.length; i++) { table.pushSymbol(tps[i].getName(), ReferenceType.TYPE_PARAM, params.get(i), null); } table.popScope(true); } Set<String> genericLetters = typeMapping.keySet(); if (genericLetters != null) { for (String letter : genericLetters) { if (typeResolution.containsKey(letter)) { table.pushSymbol(letter, ReferenceType.TYPE, typeMapping.get(letter), null); } } } } }