definitionToSelectionMap = new HashMap<>(); referenceToSelectionsMap = new HashMap<>(); currentTypeQualifiedName = type.getPackageName() + "." + type.getName(); final StringWriter stringwriter = new StringWriter(); PlainTextOutput plainTextOutput = new PlainTextOutput(stringwriter) {
if (typeDef == null) return false; if (typeDef.isSynthetic()) return false;
private FieldDefinition findFieldInType(TypeDefinition typeDef, String uniqueStr) { String[] linkParts = uniqueStr.split("\\|"); if (linkParts.length != 4) return null; String fieldName = linkParts[3]; if (fieldName.trim().length() <= 0) return null; List<FieldDefinition> declaredFields = typeDef.getDeclaredFields(); if (declaredFields == null) return null; boolean isFound = false; for (FieldDefinition declaredField : declaredFields) { isFound = (declaredField != null && fieldName.equals(declaredField.getName())); if (isFound) { if (declaredField.isSynthetic()) { return null; } else { return declaredField; } } } return null; }
String desc = typeDef.getBriefDescription(); if (desc != null && desc.trim().length() > 0) { readableLink = desc; String constructorName = typeDef.getName(); TypeReference declaringTypeRef = typeRef.getDeclaringType(); if (declaringTypeRef != null) { TypeDefinition declaringTypeDef = declaringTypeRef.resolve(); if (declaringTypeDef != null) { String declaringTypeName = declaringTypeDef.getName(); if (declaringTypeName != null) { constructorName = StringUtilities.removeLeft(constructorName, declaringTypeName);
private TypeDeclaration createTypeCore(final TypeDefinition type) { final TypeDeclaration astType = new TypeDeclaration(); final String packageName = type.getPackageName(); _typeDeclarations.put(type.getInternalName(), new SoftReference<>(astType)); long flags = type.getFlags(); if (type.isInterface() || type.isEnum()) { flags &= Flags.AccessFlags; astType.setName(type.getSimpleName()); astType.putUserData(Keys.TYPE_DEFINITION, type); astType.putUserData(Keys.TYPE_REFERENCE, type); if (type.isEnum()) { astType.setClassType(ClassType.ENUM); else if (type.isAnnotation()) { astType.setClassType(ClassType.ANNOTATION); else if (type.isInterface()) { astType.setClassType(ClassType.INTERFACE); final List<TypeParameterDeclaration> typeParameters = createTypeParameters(type.getGenericParameters()); final TypeReference baseType = type.getBaseType(); if (baseType != null && !type.isEnum() && !BuiltinTypes.Object.equals(baseType)) { astType.addChild(convertType(baseType), Roles.BASE_TYPE);
private static boolean isSwitchMapWrapper(final TypeReference type) { if (type == null) { return false; } final TypeDefinition definition = type instanceof TypeDefinition ? (TypeDefinition) type : type.resolve(); if (definition == null || !definition.isSynthetic() || !definition.isInnerClass()) { return false; } for (final FieldDefinition field : definition.getDeclaredFields()) { if (field.getName().startsWith("$SwitchMap$") && BuiltinTypes.Integer.makeArrayType().equals(field.getFieldType())) { return true; } } return false; } }
@ClassVisitor public void visitClass(TypeDefinition td, ClassContext cc) { if (td.isAnonymous() || td.isSynthetic()) return; String name = td.getSimpleName(); if (Character.isLetter(name.charAt(0)) && !Character.isUpperCase(name.charAt(0)) && name.indexOf('_') == -1) { cc.report("BadNameOfClass", td.isPublic() ? 0 : 15); } if (name.endsWith("Exception") && !Types.isInstance(td, "java/lang/Throwable")) { cc.report("BadNameOfClassException", td.isPublic() ? 0 : 15); } TypeReference superClass = td.getBaseType(); if (superClass != null && superClass.getSimpleName().equals(name)) { cc.report("BadNameOfClassSameAsSuperclass", td.isPublic() ? 0 : 15, Roles.SUPERCLASS.create(superClass)); } for (TypeReference iface : td.getExplicitInterfaces()) { if (iface.getSimpleName().equals(name)) { cc.report("BadNameOfClassSameAsInterface", td.isPublic() ? 0 : 15, Roles.INTERFACE.create(iface)); } } }
@Override protected StringBuilder appendName(final StringBuilder sb, final boolean fullName, final boolean dottedName) { if (fullName && dottedName && isNested() && !isAnonymous() && _simpleName != null) { return getDeclaringType().appendName(sb, true, true).append('.').append(_simpleName); } return super.appendName(sb, fullName, dottedName); }
boolean nested = resolvedType.isNested() || resolvedType.isAnonymous() || resolvedType.isSynthetic(); if (!this.procyonConf.isIncludeNested() && nested) return null;
if(Types.isInstance(td, "com/sun/jna/Callback")) return; for(MethodDefinition md : td.getDeclaredMethods()) { if(md.isPrivate() && !md.isSpecialName() && !Methods.isSerializationMethod(md) if (td.isAnonymous() && !td.isSynthetic() && !td.getSimpleName().contains("$_invokeMethod_") && Types .hasCompleteHierarchy(td)) { for(MethodDefinition md : td.getDeclaredMethods()) { if (!md.isSpecialName() && !md.isPrivate() && !md.isSynthetic() && Methods.findSuperMethod( md) == null) { for(MethodDefinition md : td.getDeclaredMethods()) { if(candidates.isEmpty()) return; if(td.isAnonymous()) { cc.report("UncalledMethodOfAnonymousClass", 0, Roles.METHOD.create(mi)); } else if(called.isEmpty()) {
@Override public void run() { if (uniqueStr == null) return; String[] linkParts = uniqueStr.split("\\|"); if (linkParts.length <= 1) return; String destinationTypeStr = linkParts[1]; try { bar.setVisible(true); getLabel().setText("Navigating: " + destinationTypeStr.replaceAll("/", ".")); TypeReference type = metadataSystem.lookupType(destinationTypeStr); if (type == null) throw new RuntimeException("Cannot lookup type: " + destinationTypeStr); TypeDefinition typeDef = type.resolve(); if (typeDef == null) throw new RuntimeException("Cannot resolve type: " + destinationTypeStr); String tabTitle = typeDef.getName() + ".class"; extractClassToTextPane(typeDef, tabTitle, destinationTypeStr, uniqueStr); getLabel().setText("Complete"); } catch (Exception e) { getLabel().setText("Cannot navigate: " + destinationTypeStr.replaceAll("/", ".")); Luyten.showExceptionDialog("Cannot Navigate!", e); } finally { bar.setVisible(false); } } }).start();
private static boolean isLocalOrAnonymous(final TypeDefinition type) { if (type == null) { return false; } return type.isLocalClass() || type.isAnonymous(); }
public void addTypeDefinition(final TypeDefinition type) { VerifyArgument.notNull(type, "type"); _types.putIfAbsent(type.getInternalName(), type); }
final FieldDefinition getField(final TypeDefinition declaringType, final FieldReference reference) { TypeDefinition type = declaringType; while (type != null) { final FieldDefinition field = getField(type.getDeclaredFields(), reference); if (field != null) { return field; } final TypeReference baseType = type.getBaseType(); if (baseType == null) { return null; } type = resolve(baseType); } return null; }
private MethodDefinition findMethodInType(TypeDefinition typeDef, String uniqueStr) { String[] linkParts = uniqueStr.split("\\|"); if (linkParts.length != 5) return null; String methodName = linkParts[3]; String methodErasedSignature = linkParts[4]; if (methodName.trim().length() <= 0 || methodErasedSignature.trim().length() <= 0) return null; List<MethodDefinition> declaredMethods = typeDef.getDeclaredMethods(); if (declaredMethods == null) return null; boolean isFound = false; for (MethodDefinition declaredMethod : declaredMethods) { isFound = (declaredMethod != null && methodName.equals(declaredMethod.getName())); isFound = (isFound && methodErasedSignature.equals(declaredMethod.getErasedSignature())); if (isFound) { if (declaredMethod.isSynthetic() && !settings.getShowSyntheticMembers()) { return null; } else { return declaredMethod; } } } return null; }
@Override protected void visitType(TypeDefinition td) { TypeReference tr = td.getDeclaringType(); if(tr == null) return; TypeDefinition outer = tr.resolve(); if(outer == null || !outer.isAnonymous()) return; for(MethodDefinition md : td.getDeclaredMethods()) { extractCalls(md, mr -> { mis.add(new MemberInfo(mr)); return true; }); } }
private void writeTypeHeader(final ITextOutput output, final TypeDefinition type) { output.writeAttribute("Minor version"); output.write(": "); output.writeLiteral(type.getCompilerMinorVersion()); output.writeLine(); output.writeAttribute("Major version"); output.write(": "); output.writeLiteral(type.getCompilerMajorVersion()); output.writeLine(); final long flags = type.getFlags(); final List<String> flagStrings = new ArrayList<>(); final EnumSet<Flags.Flag> flagsSet = Flags.asFlagSet( flags, type.isInnerClass() ? Flags.Kind.InnerClass : Flags.Kind.Class ); for (final Flags.Flag flag : flagsSet) { flagStrings.add(flag.name()); } if (!flagStrings.isEmpty()) { output.writeAttribute("Flags"); output.write(": "); for (int i = 0; i < flagStrings.size(); i++) { if (i != 0) { output.write(", "); } output.writeLiteral(flagStrings.get(i)); } output.writeLine(); } }
public static Predicate<Warning> forType(TypeDefinition td) { Predicate<Warning> pred = forSuppressed(getSuppressed(td.getAnnotations())); if(pred == NO_PASS) return pred; for(FieldDefinition fd : td.getDeclaredFields()) { Set<String> suppressed = getSuppressed(fd.getAnnotations()); if(!suppressed.isEmpty()) { for(MethodDefinition md : td.getDeclaredMethods()) { Set<String> suppressed = getSuppressed(md.getAnnotations()); MemberInfo mi = new MemberInfo(md);
@Override protected void visitType(TypeDefinition td) { TypeHierarchy th = getOrCreate(td); th.flags = td.getFlags(); link(th, td.getBaseType()); for (TypeReference id : td.getExplicitInterfaces()) link(th, id); }
private void tryAddDeprecatedAnnotationToType(final TypeDeclaration node) { if (any(node.getAnnotations(), IS_DEPRECATED_ANNOTATION)) { return; } final TypeDefinition type = node.getUserData(Keys.TYPE_DEFINITION); if (type == null || (type.getFlags() & Flags.DEPRECATED) != Flags.DEPRECATED) { return; } if (type.getCompilerMajorVersion() < CompilerTarget.JDK1_5.majorVersion) { return; } addAnnotation(node, type.getResolver(), DEPRECATED_ANNOTATION_NAME); }