X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Finspector%2Fjava%2Fstructure%2FFieldDescriptor.java;h=19bb5857b8392160dcff73c40e004315da364b1e;hb=ffba53aac03e4d107545116ddcfff0c965bd5970;hp=db5a11231182b0ec38f44936e0920ad3090595dd;hpb=ff4200b065c2eb7c8448fa060e7610ab57f6aec1;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 old mode 100644 new mode 100755 index db5a112..19bb585 --- a/src/main/java/eu/svjatoslav/inspector/java/structure/FieldDescriptor.java +++ b/src/main/java/eu/svjatoslav/inspector/java/structure/FieldDescriptor.java @@ -1,10 +1,10 @@ /* * JavaInspect - Utility to visualize java software - * Copyright (C) 2013, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * 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 2 of the GNU General Public License - * as published by the Free Software Foundation. + * modify it under the terms of version 3 of the GNU Lesser General Public License + * or later as published by the Free Software Foundation. */ package eu.svjatoslav.inspector.java.structure; @@ -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 dump) { + public boolean isInherited; + public FieldDescriptor(final ClassDescriptor parent) { parentClass = parent; + } + + public void analyzeField(final Field field) { if (!field.getDeclaringClass().getName() - .equals(parent.fullyQualifiedName)) - // if field is inherited, do not index it - return; + .equals(parentClass.getFullyQualifiedName())) + isInherited = true; // if (field.getType().isArray()) // System.out.println("field name: " + field.getName()); - parent.nameToFieldMap.put(field.getName(), this); - name = field.getName(); - type = dump.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 = dump - .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;