X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Finspector%2Fjava%2Fstructure%2FFieldDescriptor.java;h=d0a607b2c6134c29b13fb4994216e0c2ec41b0f7;hb=94b2a818903a8ec1579dce828b47076c53f435ab;hp=902d4152f9b5750a4d386c1316cf33b648be278e;hpb=62e7738042b3cdcfb4d0973220eaa9be9754d755;p=javainspect.git diff --git a/src/main/java/eu/svjatoslav/inspector/java/structure/FieldDescriptor.java b/src/main/java/eu/svjatoslav/inspector/java/structure/FieldDescriptor.java index 902d415..d0a607b 100755 --- a/src/main/java/eu/svjatoslav/inspector/java/structure/FieldDescriptor.java +++ b/src/main/java/eu/svjatoslav/inspector/java/structure/FieldDescriptor.java @@ -1,7 +1,7 @@ /* * JavaInspect - Utility to visualize java software * Copyright (C) 2013-2015, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License * or later as published by the Free Software Foundation. @@ -23,26 +23,27 @@ public class FieldDescriptor implements GraphElement { public String name; private ClassDescriptor type; - private ClassDescriptor parentClass; + private final ClassDescriptor parentClass; List typeArguments = new ArrayList(); - public FieldDescriptor(final Field field, final ClassDescriptor parent, - final ClassGraph classGraph) { + public boolean isInherited; + public FieldDescriptor(final ClassDescriptor parent) { parentClass = parent; + } + + public void analyzeField(final Field field) { if (!field.getDeclaringClass().getName() - .equals(parent.classFullyQualifiedName)) - // if field is inherited, do not index it - return; + .equals(parentClass.classFullyQualifiedName)) + isInherited = true; // if (field.getType().isArray()) // System.out.println("field name: " + field.getName()); - parent.nameToFieldMap.put(field.getName(), this); - name = field.getName(); - type = classGraph.addClass(field.getType()); + type = parentClass.getClassGraph().getOrCreateClassDescriptor( + field.getType()); type.registerReference(); final Type genericType = field.getGenericType(); @@ -51,8 +52,8 @@ public class FieldDescriptor implements GraphElement { for (final Type t : pt.getActualTypeArguments()) if (t instanceof Class) { final Class cl = (Class) t; - final ClassDescriptor genericTypeDescriptor = classGraph - .addClass(cl); + final ClassDescriptor genericTypeDescriptor = parentClass + .getClassGraph().getOrCreateClassDescriptor(cl); genericTypeDescriptor.registerReference(); typeArguments.add(genericTypeDescriptor); } @@ -144,6 +145,9 @@ public class FieldDescriptor implements GraphElement { @Override public boolean isVisible() { + if (isInherited) + return false; + if (name.contains("$")) return false;